From f20a0f5affb28e0f4ae6c6dddfea7c54b493fe54 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 16 Nov 2023 20:35:50 +0800 Subject: [PATCH] update --- api/zi_motor.hpp | 1 + cmdid.hpp | 9 +++++---- protocol_proxy.cpp | 4 +++- protocol_proxy.hpp | 2 ++ zmodule_device_manager.cpp | 2 ++ zmodule_device_manager.hpp | 3 +++ zmodule_device_script_cmder_paser.cpp | 4 +++- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/api/zi_motor.hpp b/api/zi_motor.hpp index 3bc7f7f..c7d59b5 100644 --- a/api/zi_motor.hpp +++ b/api/zi_motor.hpp @@ -38,6 +38,7 @@ class ZIMotor { virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; // virtual int32_t motor_set_shaft(); diff --git a/cmdid.hpp b/cmdid.hpp index 93f3e40..e38a1b9 100644 --- a/cmdid.hpp +++ b/cmdid.hpp @@ -85,10 +85,11 @@ typedef enum { kmotor_move_to_torque = CMDID(2, 15), // para:{4,4,4}, ack:{} kmotor_calculated_pos_by_move_to_zero = CMDID(2, 16), // para:{}, ack:{} - kmotor_easy_rotate = CMDID(2, 17), // para:{4}, ack:{} - kmotor_easy_move_by = CMDID(2, 18), // para:{4}, ack:{} - kmotor_easy_move_to = CMDID(2, 19), // para:{4}, ack:{} - kmotor_easy_move_to_zero = CMDID(2, 20), // para:{1}, ack:{} + kmotor_easy_rotate = CMDID(2, 17), // para:{4}, ack:{} + kmotor_easy_move_by = CMDID(2, 18), // para:{4}, ack:{} + kmotor_easy_move_to = CMDID(2, 19), // para:{4}, ack:{} + kmotor_easy_move_to_zero = CMDID(2, 20), // para:{1}, ack:{} + kmotor_easy_set_current_pos = CMDID(2, 21), // para:{4}, ack:{} #if 0 virtual ~ZIXYMotor() {} diff --git a/protocol_proxy.cpp b/protocol_proxy.cpp index dfd4c67..d711037 100644 --- a/protocol_proxy.cpp +++ b/protocol_proxy.cpp @@ -139,6 +139,8 @@ int32_t ZIProtocolProxy::module_enable(int32_t para0) { PROXY_IMPL_10(kmodule_en virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; + #endif int32_t ZIProtocolProxy::motor_enable(int32_t para0) { PROXY_IMPL_10(kmotor_enable, OVERTIME); } @@ -167,7 +169,7 @@ int32_t ZIProtocolProxy::motor_easy_rotate(int32_t para0) { PROXY_IMPL_10(kmotor int32_t ZIProtocolProxy::motor_easy_move_by(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_by, OVERTIME); } int32_t ZIProtocolProxy::motor_easy_move_to(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_to, OVERTIME); } int32_t ZIProtocolProxy::motor_easy_move_to_zero(int32_t para0) { PROXY_IMPL_10(kmotor_easy_move_to_zero, OVERTIME); } - +int32_t ZIProtocolProxy::motor_easy_set_current_pos(int32_t para0) { PROXY_IMPL_10(kmotor_easy_set_current_pos, OVERTIME); } /******************************************************************************* * ZIXYMotor * *******************************************************************************/ diff --git a/protocol_proxy.hpp b/protocol_proxy.hpp index c5d6dcf..551bc66 100644 --- a/protocol_proxy.hpp +++ b/protocol_proxy.hpp @@ -90,6 +90,7 @@ class ZIProtocolProxy : public ZIMotor, // virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; #endif @@ -119,6 +120,7 @@ class ZIProtocolProxy : public ZIMotor, // virtual int32_t motor_easy_move_by(int32_t distance) override; virtual int32_t motor_easy_move_to(int32_t position) override; virtual int32_t motor_easy_move_to_zero(int32_t direction) override; + virtual int32_t motor_easy_set_current_pos(int32_t pos) override; /******************************************************************************* * ZIXYMotor * diff --git a/zmodule_device_manager.cpp b/zmodule_device_manager.cpp index 9e254b7..36eabeb 100644 --- a/zmodule_device_manager.cpp +++ b/zmodule_device_manager.cpp @@ -93,6 +93,7 @@ int32_t ZModuleDeviceManager::module_start(uint16_t id) { PROXY_IMPL(ZIModule, m virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); + virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; #endif int32_t ZModuleDeviceManager::motor_enable(uint16_t id, int32_t enable) { PROXY_IMPL(ZIMotor, motor_enable, enable); } @@ -115,6 +116,7 @@ int32_t ZModuleDeviceManager::motor_easy_rotate(uint16_t id, int32_t direction) int32_t ZModuleDeviceManager::motor_easy_move_by(uint16_t id, int32_t distance) { PROXY_IMPL(ZIMotor, motor_easy_move_by, distance); } int32_t ZModuleDeviceManager::motor_easy_move_to(uint16_t id, int32_t position) { PROXY_IMPL(ZIMotor, motor_easy_move_to, position); } int32_t ZModuleDeviceManager::motor_easy_move_to_zero(uint16_t id, int32_t direction) { PROXY_IMPL(ZIMotor, motor_easy_move_to_zero, direction); } +int32_t ZModuleDeviceManager::motor_easy_set_current_pos(uint16_t id, int32_t pos) { PROXY_IMPL(ZIMotor, motor_easy_set_current_pos, pos); } /******************************************************************************* * ZIXYMotor * *******************************************************************************/ diff --git a/zmodule_device_manager.hpp b/zmodule_device_manager.hpp index 49609d1..eedca7a 100644 --- a/zmodule_device_manager.hpp +++ b/zmodule_device_manager.hpp @@ -135,6 +135,8 @@ class ZModuleDeviceManager { virtual int32_t motor_easy_move_by(int32_t distance) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to(int32_t position) { return err::koperation_not_support; }; virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; + #endif virtual int32_t motor_enable(uint16_t id, int32_t enable); @@ -158,6 +160,7 @@ class ZModuleDeviceManager { virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); + virtual int32_t motor_easy_set_current_pos(uint16_t id, int32_t pos); /******************************************************************************* * ZIXYMotor * diff --git a/zmodule_device_script_cmder_paser.cpp b/zmodule_device_script_cmder_paser.cpp index faae359..6287f39 100644 --- a/zmodule_device_script_cmder_paser.cpp +++ b/zmodule_device_script_cmder_paser.cpp @@ -155,7 +155,8 @@ void ZModuleDeviceScriptCmderPaser::regfn() { virtual int32_t motor_easy_rotate(uint16_t id, int32_t direction); virtual int32_t motor_easy_move_by(uint16_t id, int32_t distance); virtual int32_t motor_easy_move_to(uint16_t id, int32_t position); - virtual int32_t motor_easy_move_to_zero(uint16_t id, int32_t direction); + virtual int32_t motor_easy_move_to_zero(int32_t direction) { return err::koperation_not_support; }; + virtual int32_t motor_easy_set_current_pos(int32_t pos) { return err::koperation_not_support; }; #endif PROCESS_PACKET_20(motor_enable, "(mid, enable)"); @@ -184,6 +185,7 @@ void ZModuleDeviceScriptCmderPaser::regfn() { PROCESS_PACKET_20(motor_easy_move_by, "(mid, distance)"); PROCESS_PACKET_20(motor_easy_move_to, "(mid, position)"); PROCESS_PACKET_20(motor_easy_move_to_zero, "(mid, direction)"); + PROCESS_PACKET_20(motor_easy_set_current_pos, "(mid, pos)"); #if 0 virtual ~ZIXYMotor() {}