|
|
@ -353,6 +353,31 @@ std::vector<uint8_t> handle_write_regsiter(uint16_t cmdId, uint16_t slaveId, uin |
|
|
|
ZLOGI(TAG, "SET LASER POWER ADDRESS %d", power); |
|
|
|
break; |
|
|
|
} |
|
|
|
case TMEP_CONTROL_NOZZLE_SET_TEMP_ADDRESS: { |
|
|
|
const int32_t i_temp = value; |
|
|
|
const double temp = abs(i_temp) * 0.1; |
|
|
|
AppHardware::ins()->temp_control_nozzle.setTemp(temp); |
|
|
|
ZLOGI(TAG, "SET NOZZLE TEMP %f", temp); |
|
|
|
break; |
|
|
|
} |
|
|
|
case TMEP_CONTROL_NOZZLE_CLOSE_TEMP_ADDRESS: { |
|
|
|
AppHardware::ins()->temp_control_nozzle.close(); |
|
|
|
ZLOGI(TAG, "CLOSE NOZZLE TEMP"); |
|
|
|
break; |
|
|
|
} |
|
|
|
case TMEP_CONTROL_SLIDE_SET_TEMP_ADDRESS: { |
|
|
|
const int32_t i_temp = value; |
|
|
|
const double temp = abs(i_temp) * 0.1; |
|
|
|
AppHardware::ins()->temp_control_slide.setTemp(temp); |
|
|
|
ZLOGI(TAG, "SET SLIDE TEMP %f", temp); |
|
|
|
break; |
|
|
|
} |
|
|
|
case TMEP_CONTROL_SLIDE_CLOSE_TEMP_ADDRESS: { |
|
|
|
AppHardware::ins()->temp_control_slide.close(); |
|
|
|
ZLOGI(TAG, "CLOSE SLIDE TEMP"); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
default: { |
|
|
|
break; |
|
|
@ -467,7 +492,8 @@ std::vector<uint8_t> handle_read_coils(uint16_t cmdId, uint16_t slaveId, uint16_ |
|
|
|
if(count != 4) { |
|
|
|
break; |
|
|
|
} |
|
|
|
const bool isE_Stop = ExtiKeyManager::ins()->isPinTriggered(E_STOP_PIN); |
|
|
|
// const bool isE_Stop = ExtiKeyManager::ins()->isPinTriggered(E_STOP_PIN);
|
|
|
|
const bool isE_Stop = false; |
|
|
|
const bool isPause = ExtiKeyManager::ins()->isPinTriggered(SYSTEM_POWER_PIN); |
|
|
|
const uint8_t twvStatus = AppHardware::ins()->three_way_valve.getMode(); |
|
|
|
bool pumpIsNormal = AppHardware::ins()->pump_controller.isNoraml(); |
|
|
@ -528,7 +554,8 @@ std::vector<uint8_t> handle_read_coils(uint16_t cmdId, uint16_t slaveId, uint16_ |
|
|
|
break; |
|
|
|
} |
|
|
|
bool coils[count] = {0}; |
|
|
|
coils[0] = ExtiKeyManager::ins()->isPinTriggered(E_STOP_PIN); |
|
|
|
// coils[0] = ExtiKeyManager::ins()->isPinTriggered(E_STOP_PIN);
|
|
|
|
coils[0] = false; |
|
|
|
coils[1] = AppHardware::ins()->isLaunched(); |
|
|
|
|
|
|
|
coils[2] = !MotorManager::ins()->motors[0].isMoveFinished(); |
|
|
@ -603,7 +630,7 @@ std::vector<uint8_t> handle_read_registers(uint16_t cmdId, uint16_t slaveId, uin |
|
|
|
} |
|
|
|
|
|
|
|
bool is_flip = ELCMotorHelper::isFlip(motor_index); |
|
|
|
int32_t motor_pos = MotorManager::ins()->motors[motor_index].getEncoderPosition(); |
|
|
|
int32_t motor_pos = MotorManager::ins()->motors[motor_index].getPosition(); |
|
|
|
#if defined TEST
|
|
|
|
motor_pos = (400 + motor_index) * 1000; |
|
|
|
#else
|
|
|
@ -637,13 +664,33 @@ std::vector<uint8_t> handle_read_registers(uint16_t cmdId, uint16_t slaveId, uin |
|
|
|
ZLOGI(TAG, "READ MOTOR [%d] RT_SPEED_READ_ADDRESS", motor_index); |
|
|
|
break; |
|
|
|
} |
|
|
|
case TMEP_CONTROL_NOZZLE_READ_TEMP_ADDRESS: { |
|
|
|
if(count != 1) { |
|
|
|
break; |
|
|
|
} |
|
|
|
const double d_temp = AppHardware::ins()->temp_control_nozzle.getCurrentTemp(); |
|
|
|
const int16_t i_temp = int16_t(d_temp * 10); |
|
|
|
data[0] = i_temp; |
|
|
|
ack_msg = ModbusRtuProtocolFactory::createReadHoldingRegistersResponse(cmdId, slaveId, address, count, data); |
|
|
|
break; |
|
|
|
} |
|
|
|
case TMEP_CONTROL_SLIDE_READ_TEMP_ADDRESS: { |
|
|
|
if(count != 1) { |
|
|
|
break; |
|
|
|
} |
|
|
|
const double d_temp = AppHardware::ins()->temp_control_slide.getCurrentTemp(); |
|
|
|
const int16_t i_temp = int16_t(d_temp * 10); |
|
|
|
data[0] = i_temp; |
|
|
|
ack_msg = ModbusRtuProtocolFactory::createReadHoldingRegistersResponse(cmdId, slaveId, address, count, data); |
|
|
|
break; |
|
|
|
} |
|
|
|
case MOTOR_XYZ_ADDRESS: { |
|
|
|
if(count != 6) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
for(int motor_index = 0; motor_index < 3; motor_index++) { |
|
|
|
const int32_t motor_pos = MotorManager::ins()->motors[motor_index].getEncoderPosition(); |
|
|
|
const int32_t motor_pos = MotorManager::ins()->motors[motor_index].getPosition(); |
|
|
|
intToShortArray(motor_pos, data + 2 * motor_index); |
|
|
|
} |
|
|
|
ack_msg = ModbusRtuProtocolFactory::createReadHoldingRegistersResponse(cmdId, slaveId, address, count, data); |
|
|
@ -655,7 +702,7 @@ std::vector<uint8_t> handle_read_registers(uint16_t cmdId, uint16_t slaveId, uin |
|
|
|
} |
|
|
|
|
|
|
|
for(int motor_index = 0; motor_index < 3; motor_index++) { |
|
|
|
int32_t motor_pos = MotorManager::ins()->motors[motor_index].getEncoderPosition(); |
|
|
|
int32_t motor_pos = MotorManager::ins()->motors[motor_index].getPosition(); |
|
|
|
intToShortArray(motor_pos, data + 4 * motor_index); |
|
|
|
|
|
|
|
int32_t motor_speed = MotorManager::ins()->motors[motor_index].getRTSpeed(); |
|
|
|