4 changed files with 269 additions and 1 deletions
-
2components/pipette_module/pipette_ctrl_module.cpp
-
185components/pipette_module/pipette_ctrl_module_v2.cpp
-
81components/pipette_module/pipette_ctrl_module_v2.hpp
-
2components/zprotocols/zcancmder_v2
@ -0,0 +1,185 @@ |
|||||
|
#include "pipette_ctrl_module_v2.hpp"
|
||||
|
|
||||
|
using namespace iflytop; |
||||
|
|
||||
|
#define TAG "PipetteModule"
|
||||
|
|
||||
|
#define DO(infostr, ACTION) \
|
||||
|
{ \ |
||||
|
int exec_ret = ACTION; \ |
||||
|
if (exec_ret != 0) { \ |
||||
|
ZLOGE(TAG, "do " infostr "(line:%d) fail, ret = %d", __LINE__, exec_ret); \ |
||||
|
m_lastexec_status.set_exec_status(exec_ret); \ |
||||
|
return; \ |
||||
|
} \ |
||||
|
ZLOGI(TAG, "do " infostr " complete"); \ |
||||
|
} |
||||
|
|
||||
|
void PipetteModule::initialize(int32_t id, config_t *config, hardward_config_t *hardwaredcfg) { //
|
||||
|
ZASSERT(config != nullptr); |
||||
|
ZASSERT(hardwaredcfg != nullptr); |
||||
|
m_id = id; |
||||
|
m_config = *config; |
||||
|
m_smtp2.initialize(hardwaredcfg->uart, hardwaredcfg->hdma_rx, hardwaredcfg->hdma_tx); |
||||
|
} |
||||
|
|
||||
|
int32_t PipetteModule::getid(int32_t *id) { |
||||
|
*id = m_id; |
||||
|
return 0; |
||||
|
} |
||||
|
/*******************************************************************************
|
||||
|
* Module * |
||||
|
*******************************************************************************/ |
||||
|
|
||||
|
int32_t PipetteModule::module_enable(int32_t enable) { return err::koperation_not_support; } |
||||
|
|
||||
|
int32_t PipetteModule::module_stop() { |
||||
|
ZLOGI(TAG, "pipette_ctrl_stop"); |
||||
|
m_thread.stop(); |
||||
|
return 0; |
||||
|
} |
||||
|
int32_t PipetteModule::module_break() { |
||||
|
ZLOGI(TAG, "pipette_ctrl_break"); |
||||
|
m_thread.stop(); |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
int32_t PipetteModule::module_clear_error() { return err::koperation_not_support; } |
||||
|
|
||||
|
#define ACTION_NULL ;
|
||||
|
#define REG(param_id, readaction, writeacton) \
|
||||
|
case param_id: { \ |
||||
|
if (read) { \ |
||||
|
readaction; \ |
||||
|
} else { \ |
||||
|
writeacton; \ |
||||
|
} \ |
||||
|
} |
||||
|
|
||||
|
int32_t PipetteModule::module_process_reg_read_and_write(int32_t param_id, bool read, int32_t &val) { |
||||
|
switch (param_id) { |
||||
|
REG(kreg_module_version, /* */ val = 0, ACTION_NULL); |
||||
|
REG(kreg_module_type, /* */ val = 0, ACTION_NULL); |
||||
|
REG(kreg_module_status, /* */ val = read_status(), ACTION_NULL); |
||||
|
REG(kreg_module_errorcode, /* */ val = read_error_status(), ACTION_NULL); |
||||
|
REG(kreg_module_initflag, /* */ val = module_get_inited_flag(), ACTION_NULL); |
||||
|
REG(kreg_module_enableflag, /* */ val = 1, ACTION_NULL); |
||||
|
REG(kreg_module_errorbitflag0, /* */ val = 0, ACTION_NULL); |
||||
|
REG(kreg_module_errorbitflag1, /* */ val = 0, ACTION_NULL); |
||||
|
REG(kreg_module_input_state, /* */ val = read_input_status(), ACTION_NULL); |
||||
|
REG(kreg_module_last_cmd_exec_status, /**/ val = m_lastexec_status.exec_status, ACTION_NULL); |
||||
|
REG(kreg_module_last_cmd_exec_val0, /* */ val = m_lastexec_status.exec_val[0], ACTION_NULL); |
||||
|
REG(kreg_module_last_cmd_exec_val1, /* */ val = m_lastexec_status.exec_val[1], ACTION_NULL); |
||||
|
REG(kreg_module_last_cmd_exec_val2, /* */ val = m_lastexec_status.exec_val[2], ACTION_NULL); |
||||
|
REG(kreg_module_last_cmd_exec_val3, /* */ val = m_lastexec_status.exec_val[3], ACTION_NULL); |
||||
|
REG(kreg_module_last_cmd_exec_val4, /* */ val = m_lastexec_status.exec_val[4], ACTION_NULL); |
||||
|
REG(kreg_module_last_cmd_exec_val5, /* */ val = m_lastexec_status.exec_val[5], ACTION_NULL); |
||||
|
REG(kreg_pipette_pos_ul, /* */ val = read_pos_ul(), ACTION_NULL); |
||||
|
REG(kreg_pipette_capactitance_val, /* */ val = read_capactitance(), ACTION_NULL); |
||||
|
REG(kreg_pipette_tip_state, /* */ val = read_tip_state(), ACTION_NULL); |
||||
|
REG(kreg_pipette_limit_ul, /* */ val = read_ul_limit(), write_ul_limit(val)); |
||||
|
|
||||
|
default: |
||||
|
return err::kmodule_not_find_config_index; |
||||
|
break; |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
int32_t PipetteModule::module_set_reg(int32_t param_id, int32_t param_value) { |
||||
|
switch (param_id) { |
||||
|
default: |
||||
|
return err::kmodule_not_find_config_index; |
||||
|
} |
||||
|
return 0; |
||||
|
} |
||||
|
int32_t PipetteModule::module_get_reg(int32_t param_id, int32_t *param_value) { return err::koperation_not_support; } |
||||
|
|
||||
|
int32_t PipetteModule::module_readio(int32_t *io) { return err::koperation_not_support; } |
||||
|
|
||||
|
int32_t PipetteModule::module_factory_reset() { return err::koperation_not_support; } |
||||
|
int32_t PipetteModule::module_flush_cfg() { return err::koperation_not_support; } |
||||
|
int32_t PipetteModule::module_active_cfg() { return err::koperation_not_support; } |
||||
|
|
||||
|
int32_t PipetteModule::read_error_status() { |
||||
|
bool isbusy = false; |
||||
|
err::error_t errorcode = err::ksucc; |
||||
|
int32_t retecode = m_smtp2.getState(isbusy, errorcode); |
||||
|
if (retecode != 0) { |
||||
|
return retecode; |
||||
|
} |
||||
|
if (errorcode != err::ksucc && errorcode != err::kSMTP2_NoError) { |
||||
|
return errorcode; |
||||
|
} |
||||
|
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
int32_t PipetteModule::read_status() { |
||||
|
if (read_error_status() != 0) { |
||||
|
m_thread.stop(); |
||||
|
return 3; |
||||
|
} |
||||
|
|
||||
|
if (m_thread.isworking()) { |
||||
|
return 1; |
||||
|
} else { |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*******************************************************************************
|
||||
|
* pipette_ctrl * |
||||
|
*******************************************************************************/ |
||||
|
|
||||
|
int32_t PipetteModule::pipette_ctrl_init_device() { |
||||
|
ZLOGI(TAG, "pipette_ctrl_init_device"); |
||||
|
if (!m_smtp2.isOnline()) return err::kdevice_offline; |
||||
|
m_thread.stop(); |
||||
|
m_thread.start([this]() { |
||||
|
DO("init_device_block", m_smtp2.init_device_block()); |
||||
|
m_lastexec_status.set_exec_status(0); |
||||
|
}); |
||||
|
return 0; |
||||
|
}; |
||||
|
int32_t PipetteModule::pipette_ctrl_put_tip() { |
||||
|
ZLOGI(TAG, "pipette_ctrl_put_tip"); |
||||
|
if (!m_smtp2.isOnline()) return err::kdevice_offline; |
||||
|
m_thread.stop(); |
||||
|
m_thread.start([this]() { |
||||
|
DO("put_tip_block", m_smtp2.put_tip_block()); |
||||
|
m_lastexec_status.set_exec_status(0); |
||||
|
}); |
||||
|
return 0; |
||||
|
}; |
||||
|
int32_t PipetteModule::pipette_ctrl_move_to_ul(int32_t ul) { |
||||
|
ZLOGI(TAG, "pipette_ctrl_move_to_ul %d", ul); |
||||
|
if (ul > m_config.limit_ul) { |
||||
|
return err::kparam_out_of_range; |
||||
|
} |
||||
|
|
||||
|
if (!m_smtp2.isOnline()) return err::kdevice_offline; |
||||
|
m_thread.stop(); |
||||
|
m_thread.start([this, ul]() { |
||||
|
DO("move_to_ul_block", m_smtp2.move_to_ul_block(ul)); |
||||
|
m_lastexec_status.set_exec_status(0); |
||||
|
}); |
||||
|
return 0; |
||||
|
}; |
||||
|
|
||||
|
int32_t PipetteModule::read_input_status() { //
|
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
int32_t PipetteModule::read_pos_ul() { return m_smtp2.read_pos_ul(); } |
||||
|
int32_t PipetteModule::read_capactitance() { |
||||
|
int32_t val = 0; |
||||
|
m_smtp2.read_capacitance_val(val); |
||||
|
return val; |
||||
|
} |
||||
|
|
||||
|
int32_t PipetteModule::read_tip_state() { |
||||
|
bool tipstate = false; |
||||
|
m_smtp2.read_tip_state(tipstate); |
||||
|
return tipstate; |
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
#pragma once
|
||||
|
//
|
||||
|
#include "sdk/os/zos.hpp"
|
||||
|
#include "sdk\components\sensors\smtp2\smtp2.hpp"
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\api\api.hpp"
|
||||
|
// #include "StepMotorCtrlModule"
|
||||
|
|
||||
|
/**
|
||||
|
* @brief |
||||
|
* |
||||
|
* ²Î¿¼:https://iflytop1.feishu.cn/wiki/LTilwSyJwi6fJUkiIhzc2oRqnTb ¶ÔÉ豸½øÐгõʼ»¯
|
||||
|
* |
||||
|
*/ |
||||
|
namespace iflytop { |
||||
|
|
||||
|
class PipetteModule : public ZIModule, public ZIPipetteCtrlModule { |
||||
|
public: |
||||
|
typedef struct { |
||||
|
UART_HandleTypeDef *uart; |
||||
|
DMA_HandleTypeDef *hdma_rx; |
||||
|
DMA_HandleTypeDef *hdma_tx; |
||||
|
} hardward_config_t; |
||||
|
|
||||
|
typedef struct { |
||||
|
int32_t limit_ul; |
||||
|
} config_t; |
||||
|
|
||||
|
private: |
||||
|
SMTP2 m_smtp2; |
||||
|
ZThread m_thread; |
||||
|
|
||||
|
int32_t m_id = 0; |
||||
|
ModuleCMDExecStatus m_lastexec_status; |
||||
|
|
||||
|
config_t m_config; |
||||
|
|
||||
|
public: |
||||
|
void initialize(int32_t id, config_t* config, hardward_config_t *cfg); |
||||
|
|
||||
|
virtual int32_t getid(int32_t *id); |
||||
|
|
||||
|
/*******************************************************************************
|
||||
|
* Module * |
||||
|
*******************************************************************************/ |
||||
|
|
||||
|
virtual int32_t module_enable(int32_t enable); |
||||
|
|
||||
|
virtual int32_t module_stop(); |
||||
|
virtual int32_t module_break(); |
||||
|
|
||||
|
virtual int32_t module_clear_error(); |
||||
|
|
||||
|
virtual int32_t module_set_reg(int32_t param_id, int32_t param_value); |
||||
|
virtual int32_t module_get_reg(int32_t param_id, int32_t *param_value); |
||||
|
|
||||
|
virtual int32_t module_readio(int32_t *io); |
||||
|
|
||||
|
virtual int32_t module_factory_reset(); |
||||
|
virtual int32_t module_flush_cfg(); |
||||
|
virtual int32_t module_active_cfg(); |
||||
|
|
||||
|
/*******************************************************************************
|
||||
|
* pipette_ctrl * |
||||
|
*******************************************************************************/ |
||||
|
|
||||
|
virtual int32_t pipette_ctrl_init_device(); |
||||
|
virtual int32_t pipette_ctrl_put_tip(); |
||||
|
virtual int32_t pipette_ctrl_move_to_ul(int32_t ul); |
||||
|
|
||||
|
private: |
||||
|
int32_t module_process_reg_read_and_write(int32_t param_id, bool read, int32_t ¶m_value); |
||||
|
int32_t read_status(); |
||||
|
int32_t read_error_status(); |
||||
|
int32_t read_input_status(); |
||||
|
int32_t read_pos_ul(); |
||||
|
int32_t read_capactitance(); |
||||
|
int32_t read_tip_state(); |
||||
|
int32_t read_ul_limit(); |
||||
|
void write_ul_limit(int32_t ul_limit); |
||||
|
}; |
||||
|
} // namespace iflytop
|
@ -1 +1 @@ |
|||||
Subproject commit 0f9409ebe63d00be964d5573cb34dc79b94de24f |
|
||||
|
Subproject commit ced01b81ca88792a9278c139be63faed5ef8efb1 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue