update HandlePumpTimeControl
This commit is contained in:
parent
318b57b2bf
commit
f6453f4811
19
protocol.c
19
protocol.c
@ -1395,8 +1395,14 @@ void initCTLSystem(void)
|
|||||||
systemStatus.ds = &deviceStatus; // 赋值地址而不是内容
|
systemStatus.ds = &deviceStatus; // 赋值地址而不是内容
|
||||||
systemStatus.ds->initStatus = INIT_IN_PROGRESS;
|
systemStatus.ds->initStatus = INIT_IN_PROGRESS;
|
||||||
systemStatus.rst = 0;
|
systemStatus.rst = 0;
|
||||||
|
//更新参数
|
||||||
|
for (size_t index = 0; index < 2; index++)
|
||||||
|
{
|
||||||
|
//更新参数
|
||||||
|
systemStatus.pumpsSpeed[index] = transSpeedPercentToSpeed(index, systemStatus.ds->pumps.speedPercent[index]);
|
||||||
|
}
|
||||||
InitValve();
|
InitValve();
|
||||||
// InitPump();
|
InitPump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1561,13 +1567,15 @@ static uint8_t HandlePumpTimeControl(uint8_t *Buff, uint8_t len) {
|
|||||||
}
|
}
|
||||||
uint16_t time = (Buff[index*3+1]<<8) | Buff[index*3+2];
|
uint16_t time = (Buff[index*3+1]<<8) | Buff[index*3+2];
|
||||||
if(time == 0) {
|
if(time == 0) {
|
||||||
// 方向控制办法待确定
|
StopPump(index);
|
||||||
SetPumpJogSpeed(index,-1*dp.pump[index].fullSpeed*dp.pump[index].speedPercent);
|
// The jogging direction is set by the last DI command.
|
||||||
|
SetPumpStepTarget(index,direction);
|
||||||
StartPumpJog(index);
|
StartPumpJog(index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 使用步数方式更靠谱,通过时间和速度计算步数,结束时不用发送停止命令
|
// 使用步数方式更靠谱,通过时间和速度计算步数,结束时不用发送停止命令
|
||||||
int32_t step = direction*time*dp.pump[index].fullSpeed*dp.pump[index].speedPercent/100;
|
int32_t step = direction*time*systemStatus.pumpsSpeed[index];
|
||||||
|
StopPump(index);//stop first
|
||||||
SetPumpStepTarget(index, step);
|
SetPumpStepTarget(index, step);
|
||||||
StartPumpRelativeMove(index);
|
StartPumpRelativeMove(index);
|
||||||
|
|
||||||
@ -1621,7 +1629,8 @@ static uint8_t HandlePumpSpeedControl(uint8_t *Buff, uint8_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新参数
|
//更新参数
|
||||||
systemStatus.ds->pumps.speed[index] = speedPercent;
|
systemStatus.pumpsSpeed[index] = speed;
|
||||||
|
systemStatus.ds->pumps.speedPercent[index] = speedPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ACK_OK;
|
return ACK_OK;
|
||||||
|
@ -238,7 +238,7 @@ static const uint8_t statusInfo[16][60]={
|
|||||||
#define RTU_PUMP_CMD_JA 0x002E // Jog加速度
|
#define RTU_PUMP_CMD_JA 0x002E // Jog加速度
|
||||||
#define RTU_PUMP_CMD_JL 0x002F // Jog减速度
|
#define RTU_PUMP_CMD_JL 0x002F // Jog减速度
|
||||||
#define RTU_PUMP_CMD_JS 0x0030 // Jog速度
|
#define RTU_PUMP_CMD_JS 0x0030 // Jog速度
|
||||||
|
// The jogging direction is set by the last DI command.
|
||||||
|
|
||||||
|
|
||||||
/* 备注:
|
/* 备注:
|
||||||
@ -385,7 +385,7 @@ typedef struct {
|
|||||||
// 泵结构体
|
// 泵结构体
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t status[2]; // 泵运行状态 (停止/顺时针/逆时针)
|
uint8_t status[2]; // 泵运行状态 (停止/顺时针/逆时针)
|
||||||
uint8_t speed[2]; // 泵速度百分比 (0-100),设置值
|
uint8_t speedPercent[2]; // 泵速度百分比 (0-100),设置值
|
||||||
} PumpStatus_t;
|
} PumpStatus_t;
|
||||||
|
|
||||||
// 设备状态结构体,用于上报HOST
|
// 设备状态结构体,用于上报HOST
|
||||||
@ -406,8 +406,8 @@ typedef struct
|
|||||||
DeviceStatus_t *ds;
|
DeviceStatus_t *ds;
|
||||||
int32_t valvesSpeed[2];//实时速度
|
int32_t valvesSpeed[2];//实时速度
|
||||||
uint8_t valvesSpeedPercent[2];//实时速度百分比
|
uint8_t valvesSpeedPercent[2];//实时速度百分比
|
||||||
uint32_t valvesPos[2];//实时位置
|
uint32_t valvesPos[2];//实时位置,实时角度已有,在DeviceStatus_t
|
||||||
uint32_t pumpsSpeed[2];//实时速度
|
uint32_t pumpsSpeed[2];//设定速度
|
||||||
uint8_t pumpsSpeedPercent[2];//实时速度百分比
|
uint8_t pumpsSpeedPercent[2];//实时速度百分比
|
||||||
uint32_t pumpsPos[2];//实时位置
|
uint32_t pumpsPos[2];//实时位置
|
||||||
uint8_t isValveMovingBackToOrigin[2];//阀门是否在回归原点
|
uint8_t isValveMovingBackToOrigin[2];//阀门是否在回归原点
|
||||||
|
Loading…
Reference in New Issue
Block a user