From f204e7c9f2418a9859ef30dd019356ace745b15c Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 8 Jun 2024 15:40:51 +0800 Subject: [PATCH] update --- components/hardware/adc/z_simple_adc.cpp | 2 +- .../mini_servo_motor_ctrl_module.cpp | 2 +- .../pipette_module/pipette_ctrl_module_v2.cpp | 4 +-- components/sensors/m3078/m3078_code_scaner.cpp | 2 +- .../step_motor_ctrl_module.cpp | 2 +- .../water_cooling_temperature_control_module.cpp | 5 ++-- .../xy_robot_ctrl_module/xy_robot_ctrl_module.cpp | 2 +- components/zcancmder/zcan_board_module.cpp | 30 ++++++++++---------- components/zcancmder/zcan_protocol_parser.cpp | 33 ++++++++++++++++++---- components/zcancmder/zcan_protocol_parser.hpp | 4 +++ 10 files changed, 56 insertions(+), 30 deletions(-) diff --git a/components/hardware/adc/z_simple_adc.cpp b/components/hardware/adc/z_simple_adc.cpp index 611f0f5..4c5f9b4 100644 --- a/components/hardware/adc/z_simple_adc.cpp +++ b/components/hardware/adc/z_simple_adc.cpp @@ -29,7 +29,7 @@ int32_t ZADC::get_adc_value(int32_t& adcval) { sConfig.Rank = 1; sConfig.SamplingTime = m_samplingTime; /* 采样时间 */ if (HAL_ADC_ConfigChannel(m_hadc1, &sConfig) != HAL_OK) { - return err::kmicro_adcRecvFail; + return -1; } HAL_ADC_Start(m_hadc1); HAL_ADC_PollForConversion(m_hadc1, HAL_MAX_DELAY); diff --git a/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp b/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp index fd9745e..38249d5 100644 --- a/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp +++ b/components/mini_servo_motor/mini_servo_motor_ctrl_module.cpp @@ -42,7 +42,7 @@ int32_t MiniServoCtrlModule::module_xxx_reg(int32_t param_id, bool read, int32_t PROCESS_REG(kreg_mini_servo_limit_torque, REG_GET(m_cfg.limit_torque), REG_SET(m_cfg.limit_torque)); PROCESS_REG(kreg_mini_servo_protective_torque, REG_GET(m_cfg.protective_torque), REG_SET(m_cfg.protective_torque)); default: - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; break; } return 0; diff --git a/components/pipette_module/pipette_ctrl_module_v2.cpp b/components/pipette_module/pipette_ctrl_module_v2.cpp index 3b29231..88e21ab 100644 --- a/components/pipette_module/pipette_ctrl_module_v2.cpp +++ b/components/pipette_module/pipette_ctrl_module_v2.cpp @@ -31,7 +31,7 @@ int32_t PipetteModule::getid(int32_t *id) { * Module * *******************************************************************************/ -int32_t PipetteModule::module_enable(int32_t enable) { return err::koperation_not_support; } +int32_t PipetteModule::module_enable(int32_t enable) { return err::kcmd_not_support; } int32_t PipetteModule::module_stop() { ZLOGI(TAG, "pipette_ctrl_stop"); @@ -54,7 +54,7 @@ int32_t PipetteModule::module_xxx_reg(int32_t param_id, bool read, int32_t &val) PROCESS_REG(kreg_pipette_tip_state, /* */ read_tip_state(&val), ACTION_NONE); PROCESS_REG(kreg_pipette_limit_ul, /* */ REG_GET(m_config.limit_ul), REG_SET(m_config.limit_ul)); default: - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; break; } return 0; diff --git a/components/sensors/m3078/m3078_code_scaner.cpp b/components/sensors/m3078/m3078_code_scaner.cpp index 328c3c9..9e7826c 100644 --- a/components/sensors/m3078/m3078_code_scaner.cpp +++ b/components/sensors/m3078/m3078_code_scaner.cpp @@ -98,7 +98,7 @@ int32_t M3078CodeScanner::module_xxx_reg(int32_t param_id, bool read, int32_t& v switch (param_id) { MODULE_COMMON_PROCESS_REG_CB(); default: - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; break; } return 0; diff --git a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp index b8fb62e..802cde9 100644 --- a/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp +++ b/components/step_motor_ctrl_module/step_motor_ctrl_module.cpp @@ -93,7 +93,7 @@ int32_t StepMotorCtrlModule::pri_module_xxx_reg(int32_t param_id, bool read, int PROCESS_REG(kreg_step_motor_tzerowait, REG_GET(m_cfg.motor_tzerowait), REG_SET(m_cfg.motor_tzerowait)); default: - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; break; } return 0; diff --git a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp index 333dc85..35bb285 100644 --- a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp +++ b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp @@ -98,7 +98,7 @@ int32_t WaterCoolingTemperatureControlModule::module_xxx_reg(int32_t param_id, b PROCESS_REG(kreg_sensor_temperature3, REG_GET(getTemperatureSensorVal(3) * 100), ACTION_NONE); default: - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; break; } return 0; @@ -202,7 +202,8 @@ int32_t WaterCoolingTemperatureControlModule::checkdevice() { BIT(module_errorbitflag0, 2), // BIT(module_errorbitflag0, 3)); m_pelter_ctrl->dumpErrorInfo(); - creg.module_errorcode = err::khwardware_error; + //TODO 设置错误码 + // creg.module_errorcode = err::khwardware_error; return 1; } return 0; diff --git a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp index fd820a4..cf6bcab 100644 --- a/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp +++ b/components/xy_robot_ctrl_module/xy_robot_ctrl_module.cpp @@ -681,7 +681,7 @@ int32_t XYRobotCtrlModule::module_xxx_reg(int32_t param_id, bool read, int32_t& PROCESS_REG(kreg_xyrobot_io_state0, module_readio(&val), ACTION_NONE); default: - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; break; } return 0; diff --git a/components/zcancmder/zcan_board_module.cpp b/components/zcancmder/zcan_board_module.cpp index fc5f83c..53b1bf2 100644 --- a/components/zcancmder/zcan_board_module.cpp +++ b/components/zcancmder/zcan_board_module.cpp @@ -47,7 +47,7 @@ int32_t ZCanBoardModule::module_xxx_reg(int32_t param_id, bool read, int32_t &va PROCESS_REG(kreg_module_version, /* */ REG_GET(0x0001), ACTION_NONE); PROCESS_REG(kreg_module_type, /* */ REG_GET(0), ACTION_NONE); default: - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; break; } return 0; @@ -82,68 +82,68 @@ int32_t ZCanBoardModule::readoutput() { int32_t ZCanBoardModule::readTemperature(int32_t sensorId, int32_t &temperature_val) { if (sensorId < 0 || sensorId >= ZARRAY_SIZE(m_cfg.temperature_sensor)) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } if (m_cfg.temperature_sensor[sensorId] == nullptr) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } return m_cfg.temperature_sensor[sensorId]->getTemperature(temperature_val); } int32_t ZCanBoardModule::setPwmState(int32_t pwmId, int32_t state) { if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } if (m_cfg.pwmctrl[pwmId] == nullptr) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } return m_cfg.pwmctrl[pwmId]->pwm_set_state(state); } int32_t ZCanBoardModule::getPwmState(int32_t pwmId, int32_t &state) { if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } if (m_cfg.pwmctrl[pwmId] == nullptr) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } return m_cfg.pwmctrl[pwmId]->pwm_get_state(state); } int32_t ZCanBoardModule::readPwmDuty(int32_t pwmId, int32_t &duty) { if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } if (m_cfg.pwmctrl[pwmId] == nullptr) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } return m_cfg.pwmctrl[pwmId]->get_pwm_duty(duty); } int32_t ZCanBoardModule::setPwmDuty(int32_t pwmId, int32_t duty) { if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } if (m_cfg.pwmctrl[pwmId] == nullptr) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } return m_cfg.pwmctrl[pwmId]->set_pwm_duty(duty); } int32_t ZCanBoardModule::readPwmFreq(int32_t pwmId, int32_t &freq) { if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } if (m_cfg.pwmctrl[pwmId] == nullptr) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } return m_cfg.pwmctrl[pwmId]->get_pwm_freq(freq); } int32_t ZCanBoardModule::setPwmFreq(int32_t pwmId, int32_t freq) { if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } if (m_cfg.pwmctrl[pwmId] == nullptr) { - return err::kmodule_not_find_config_index; + return err::kmodule_not_find_reg; } return m_cfg.pwmctrl[pwmId]->set_pwm_freq(freq); } \ No newline at end of file diff --git a/components/zcancmder/zcan_protocol_parser.cpp b/components/zcancmder/zcan_protocol_parser.cpp index c43b7cf..20d7459 100644 --- a/components/zcancmder/zcan_protocol_parser.cpp +++ b/components/zcancmder/zcan_protocol_parser.cpp @@ -64,11 +64,14 @@ void ZCanProtocolParser::initialize(IZCanReceiver* cancmder) { REGFN(code_scaner_get_result_length); REGFN(code_scaner_read_scaner_result); - REGFN(pipette_ctrl_init_device); REGFN(pipette_ctrl_put_tip); REGFN(pipette_ctrl_move_to_ul); + REGFN(water_cooling_temp_start_hearting); + REGFN(water_cooling_temp_stop_hearting); + + REGFN(fan_controler_set_speed); #if 0 REGFN(xymotor_enable); REGFN(xymotor_move_by); @@ -129,7 +132,7 @@ void ZCanProtocolParser::_onRceivePacket(ZIModule* module, zcr_cmd_header_t* rxc cmdfn_t* fn = findcmdfn(cmdid); if (!fn) { - m_cancmder->sendErrorAck(rxcmd, err::koperation_not_support); + m_cancmder->sendErrorAck(rxcmd, err::kcmd_not_support); return; } cmdcontxt_t cxt = {0}; @@ -153,14 +156,14 @@ void ZCanProtocolParser::_onRceivePacket(ZIModule* module, zcr_cmd_header_t* rxc return; } -#define CHECK_AND_GET_MODULE(paraNum) \ - auto* module = dynamic_cast(cxt->module); \ - if (module == nullptr) return err::koperation_not_support; \ +#define CHECK_AND_GET_MODULE(paraNum) \ + auto* module = dynamic_cast(cxt->module); \ + if (module == nullptr) return err::kcmd_not_support; \ if (paraNum >= 0 && paraNum != cxt->paramlen / 4) return err::kcmd_param_num_error; #define GET_MODULE(paraNum) \ auto* module = dynamic_cast(cxt->module); \ - if (module == nullptr) return err::koperation_not_support; + if (module == nullptr) return err::kcmd_not_support; #define MODULE_CLASS ZIModule int32_t ZCanProtocolParser::module_ping(cmdcontxt_t* cxt) { @@ -446,6 +449,24 @@ int32_t ZCanProtocolParser::pipette_ctrl_move_to_ul(cmdcontxt_t* cxt) { #undef MODULE_CLASS +#define MODULE_CLASS ZI_WaterCoolingTemperatureControler +int32_t ZCanProtocolParser::water_cooling_temp_start_hearting(cmdcontxt_t* cxt) { + CHECK_AND_GET_MODULE(1); + return module->water_cooling_temp_start_hearting(cxt->params[0]); +} +int32_t ZCanProtocolParser::water_cooling_temp_stop_hearting(cmdcontxt_t* cxt) { + CHECK_AND_GET_MODULE(0); + return module->water_cooling_temp_stop_hearting(); +} +#undef MODULE_CLASS + +#define MODULE_CLASS ZIFanControler +int32_t ZCanProtocolParser::fan_controler_set_speed(cmdcontxt_t* cxt) { + CHECK_AND_GET_MODULE(1); + return module->fan_controler_set_speed(cxt->params[0]); +} +#undef MODULE_CLASS + #if 0 #define MODULE_CLASS ZIXYMotor diff --git a/components/zcancmder/zcan_protocol_parser.hpp b/components/zcancmder/zcan_protocol_parser.hpp index 70fe13f..0c910c9 100644 --- a/components/zcancmder/zcan_protocol_parser.hpp +++ b/components/zcancmder/zcan_protocol_parser.hpp @@ -101,6 +101,10 @@ class ZCanProtocolParser : public IZCanReceiverListener { static int32_t pipette_ctrl_put_tip(cmdcontxt_t* cxt); static int32_t pipette_ctrl_move_to_ul(cmdcontxt_t* cxt); + static int32_t water_cooling_temp_start_hearting(cmdcontxt_t* cxt); + static int32_t water_cooling_temp_stop_hearting(cmdcontxt_t* cxt); + + static int32_t fan_controler_set_speed(cmdcontxt_t* cxt); #if 0 static int32_t xymotor_enable(cmdcontxt_t* cxt); static int32_t xymotor_move_by(cmdcontxt_t* cxt);