|
|
@ -9,15 +9,15 @@ using namespace iflytop; |
|
|
|
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); \ |
|
|
|
_module_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); |
|
|
|
ZASSERT(config != nullptr); |
|
|
|
ZASSERT(hardwaredcfg != nullptr); |
|
|
|
m_id = id; |
|
|
|
m_config = *config; |
|
|
|
m_smtp2.initialize(hardwaredcfg->uart, hardwaredcfg->hdma_rx, hardwaredcfg->hdma_tx); |
|
|
@ -44,41 +44,18 @@ int32_t PipetteModule::module_break() { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModule::module_clear_error() { return err::koperation_not_support; } |
|
|
|
int32_t PipetteModule::module_readio(int32_t *io) { return 0; } |
|
|
|
int32_t PipetteModule::module_factory_reset() { return 0; } |
|
|
|
int32_t PipetteModule::module_flush_cfg() { return 0; } |
|
|
|
int32_t PipetteModule::module_active_cfg() { return 0; } |
|
|
|
|
|
|
|
#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) { |
|
|
|
int32_t PipetteModule::module_xxx_reg(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)); |
|
|
|
|
|
|
|
MODULE_COMMON_PROCESS_REG_CB(); |
|
|
|
PROCESS_REG(kreg_pipette_pos_ul, /* */ read_pos_ul(&val), ACTION_NONE); |
|
|
|
PROCESS_REG(kreg_pipette_capactitance_val, /* */ read_capactitance(&val), ACTION_NONE); |
|
|
|
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; |
|
|
|
break; |
|
|
@ -86,48 +63,24 @@ int32_t PipetteModule::module_process_reg_read_and_write(int32_t param_id, bool |
|
|
|
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::module_get_status(int32_t *status) { |
|
|
|
int32_t ecode = 0; |
|
|
|
ecode = _read_error_status(); |
|
|
|
|
|
|
|
int32_t PipetteModule::read_status() { |
|
|
|
if (read_error_status() != 0) { |
|
|
|
if (ecode != 0) { |
|
|
|
m_com_reg.module_errorcode = ecode; |
|
|
|
*status = 3; |
|
|
|
m_thread.stop(); |
|
|
|
return 3; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
if (m_thread.isworking()) { |
|
|
|
return 1; |
|
|
|
*status = 1; |
|
|
|
} else { |
|
|
|
return 0; |
|
|
|
*status = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
}; |
|
|
|
/*******************************************************************************
|
|
|
|
* pipette_ctrl * |
|
|
|
*******************************************************************************/ |
|
|
@ -138,7 +91,7 @@ int32_t PipetteModule::pipette_ctrl_init_device() { |
|
|
|
m_thread.stop(); |
|
|
|
m_thread.start([this]() { |
|
|
|
DO("init_device_block", m_smtp2.init_device_block()); |
|
|
|
m_lastexec_status.set_exec_status(0); |
|
|
|
_module_set_exec_status(0); |
|
|
|
}); |
|
|
|
return 0; |
|
|
|
}; |
|
|
@ -148,7 +101,7 @@ int32_t PipetteModule::pipette_ctrl_put_tip() { |
|
|
|
m_thread.stop(); |
|
|
|
m_thread.start([this]() { |
|
|
|
DO("put_tip_block", m_smtp2.put_tip_block()); |
|
|
|
m_lastexec_status.set_exec_status(0); |
|
|
|
_module_set_exec_status(0); |
|
|
|
}); |
|
|
|
return 0; |
|
|
|
}; |
|
|
@ -162,24 +115,32 @@ int32_t PipetteModule::pipette_ctrl_move_to_ul(int32_t ul) { |
|
|
|
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); |
|
|
|
_module_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; |
|
|
|
/*******************************************************************************
|
|
|
|
* PRIVATE * |
|
|
|
*******************************************************************************/ |
|
|
|
int32_t PipetteModule::read_pos_ul(int32_t *val) { return m_smtp2.read_pos_ul(*val); } |
|
|
|
int32_t PipetteModule::read_capactitance(int32_t *val) { return m_smtp2.read_capacitance_val(*val); } |
|
|
|
int32_t PipetteModule::read_tip_state(int32_t *val) { |
|
|
|
bool tipstate = false; |
|
|
|
int32_t ecode = m_smtp2.read_tip_state(tipstate); |
|
|
|
*val = tipstate ? 1 : 0; |
|
|
|
return ecode; |
|
|
|
} |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PipetteModule::read_tip_state() { |
|
|
|
bool tipstate = false; |
|
|
|
m_smtp2.read_tip_state(tipstate); |
|
|
|
return tipstate; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |