Browse Source

update

master
zhaohe 1 year ago
parent
commit
ce82cd5cc9
  1. 8
      components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  2. 3
      components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  3. 9
      components/zcancmder/zcan_protocol_parser.cpp
  4. 4
      components/zcancmder/zcan_protocol_parser.hpp

8
components/step_motor_ctrl_module/step_motor_ctrl_module.cpp

@ -285,20 +285,20 @@ int32_t StepMotorCtrlModule::exec_move_to_io_task(int32_t ioindex, int32_t direc
vTaskDelay(1); vTaskDelay(1);
} }
// 等待电机停止
// 绛夊緟鐢垫満鍋滄�
while (!m_stepM1->isStoped() && !m_thread.getExitFlag()) { while (!m_stepM1->isStoped() && !m_thread.getExitFlag()) {
m_stepM1->stop(); m_stepM1->stop();
vTaskDelay(100); vTaskDelay(100);
} }
// 失败返回
// 澶辫触杩斿洖
if (!xreach_io) { if (!xreach_io) {
ZLOGE(TAG, "x reach io failed"); ZLOGE(TAG, "x reach io failed");
return err::kxymotor_not_found_x_zero_point; return err::kxymotor_not_found_x_zero_point;
} }
} }
// 如果设备已经在零点,则反向移动一定距离远离零点
// 濡傛灉璁惧�宸茬粡鍦ㄩ浂鐐癸紝鍒欏弽鍚戠Щ鍔ㄤ竴瀹氳窛绂昏繙绂婚浂鐐�
if (gpio->getState()) { if (gpio->getState()) {
ZLOGI(TAG, "---------STEP2-------- find edge"); ZLOGI(TAG, "---------STEP2-------- find edge");
_rotate(-direction * lookPointVelocity, lookPointDec, lookPointDec); _rotate(-direction * lookPointVelocity, lookPointDec, lookPointDec);
@ -313,7 +313,7 @@ int32_t StepMotorCtrlModule::exec_move_to_io_task(int32_t ioindex, int32_t direc
vTaskDelay(1); vTaskDelay(1);
} }
while (!m_stepM1->isStoped() && !m_thread.getExitFlag()) { // 等待电机停止
while (!m_stepM1->isStoped() && !m_thread.getExitFlag()) { // 绛夊緟鐢垫満鍋滄�
m_stepM1->stop(); m_stepM1->stop();
vTaskDelay(100); vTaskDelay(100);
} }

3
components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

@ -59,7 +59,10 @@ class StepMotorCtrlModule : public ZIModule, public ZIStepMotor {
*id = m_id; *id = m_id;
return 0; return 0;
} }
virtual int32_t module_xxx_reg(int32_t param_id, bool read, int32_t& val); virtual int32_t module_xxx_reg(int32_t param_id, bool read, int32_t& val);
virtual int32_t module_stop() override { return step_motor_stop(0); }
virtual int32_t module_active_cfg() override { return step_motor_active_cfg(); }
/*********************************************************************************************************************** /***********************************************************************************************************************
* ZIStepMotor * * ZIStepMotor *
***********************************************************************************************************************/ ***********************************************************************************************************************/

9
components/zcancmder/zcan_protocol_parser.cpp

@ -156,6 +156,15 @@ int32_t ZCanProtocolParser::module_clear_error(cmdcontxt_t* cxt) {
return module->module_clear_error(); return module->module_clear_error();
} }
int32_t ZCanProtocolParser::module_stop(cmdcontxt_t* cxt) {
CHECK_AND_GET_MODULE(0);
return module->module_stop();
}
int32_t ZCanProtocolParser::module_active_cfg(cmdcontxt_t* cxt) {
CHECK_AND_GET_MODULE(0);
return module->module_active_cfg();
}
#undef MODULE_CLASS #undef MODULE_CLASS
/*********************************************************************************************************************** /***********************************************************************************************************************

4
components/zcancmder/zcan_protocol_parser.hpp

@ -52,6 +52,10 @@ class ZCanProtocolParser : public IZCanReceiverListener {
static int32_t module_get_reg(cmdcontxt_t* cxt); static int32_t module_get_reg(cmdcontxt_t* cxt);
static int32_t module_get_error(cmdcontxt_t* cxt); static int32_t module_get_error(cmdcontxt_t* cxt);
static int32_t module_clear_error(cmdcontxt_t* cxt); static int32_t module_clear_error(cmdcontxt_t* cxt);
static int32_t module_stop(cmdcontxt_t* cxt);
static int32_t module_active_cfg(cmdcontxt_t* cxt);
static int32_t step_motor_enable(cmdcontxt_t* cxt); static int32_t step_motor_enable(cmdcontxt_t* cxt);
static int32_t step_motor_stop(cmdcontxt_t* cxt); static int32_t step_motor_stop(cmdcontxt_t* cxt);

Loading…
Cancel
Save