5 changed files with 133 additions and 6 deletions
-
46components/zcancmder/zimodule_impl_v2.cpp
-
86components/zcancmder/zimodule_impl_v2.hpp
-
2components/zprotocols/zcancmder_v2/api/reg_index.hpp
-
3components/zprotocols/zcancmder_v2/api/zi_module.hpp
-
2components/zprotocols/zcancmder_v2/protocol_parser.cpp
@ -0,0 +1,46 @@ |
|||||
|
#include "zimodule_impl_v2.hpp"
|
||||
|
|
||||
|
#include <stdint.h>
|
||||
|
|
||||
|
#include <functional>
|
||||
|
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\api\reg_index.hpp"
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\api\zi_module.hpp"
|
||||
|
|
||||
|
using namespace iflytop; |
||||
|
|
||||
|
ZIModuleImplV2::ZIModuleImplV2(int32_t id) { m_id = id; } |
||||
|
|
||||
|
int32_t ZIModuleImplV2::getid(int32_t *id) { |
||||
|
*id = m_id; |
||||
|
return 0; |
||||
|
} |
||||
|
int32_t ZIModuleImplV2::getid() { return m_id; } |
||||
|
int32_t ZIModuleImplV2::module_ping() { return 0; } |
||||
|
int32_t ZIModuleImplV2::module_get_status(int32_t *status) { return module_get_reg(kreg_module_status, status); } |
||||
|
int32_t ZIModuleImplV2::module_get_error(int32_t *iserror) { return module_get_reg(kreg_module_errorcode, iserror); } |
||||
|
int32_t ZIModuleImplV2::module_clear_error() { return module_set_reg(kreg_module_errorcode, 0); } |
||||
|
int32_t ZIModuleImplV2::module_enable(int32_t enable) { return module_set_reg(kreg_module_enableflag, enable); } |
||||
|
// int32_t ZIModuleImplV2::module_readio(int32_t *io) { return module_get_reg(kreg_module_input_state, io); }
|
||||
|
// int32_t ZIModuleImplV2::module_writeio(int32_t idindex, int32_t io) { return module_set_reg(kreg_module_output_state, io); }
|
||||
|
int32_t ZIModuleImplV2::module_factory_reset() { return 0; } |
||||
|
int32_t ZIModuleImplV2::module_flush_cfg() { return 0; } |
||||
|
int32_t ZIModuleImplV2::module_active_cfg() { return 0; } |
||||
|
|
||||
|
int32_t ZIModuleImplV2::module_set_reg(int32_t param_id, int32_t param_value) { |
||||
|
int32_t retVal = 0; |
||||
|
// if (m_reg_change_listener) {
|
||||
|
// m_reg_change_listener(param_id, param_value);
|
||||
|
// }
|
||||
|
return 0; |
||||
|
} |
||||
|
int32_t ZIModuleImplV2::module_get_reg(int32_t param_id, int32_t *param_value) { |
||||
|
|
||||
|
} |
||||
|
int32_t ZIModuleImplV2::module_get_regbit(int32_t param_id, int32_t bitoffset, int32_t *param_value) {} |
||||
|
int32_t ZIModuleImplV2::module_set_regbit(int32_t param_id, int32_t bitoffset, int32_t bitval) {} |
||||
|
|
||||
|
void ZIModuleImplV2::_regRegChangeListener(reg_change_listener_t onregchange) { //
|
||||
|
m_reg_change_listener = onregchange; |
||||
|
} |
||||
|
void ZIModuleImplV2::_allocRegTable(int32_t regNum) {} |
@ -0,0 +1,86 @@ |
|||||
|
#pragma once
|
||||
|
#include <stdint.h>
|
||||
|
|
||||
|
#include <functional>
|
||||
|
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\api\zi_module.hpp"
|
||||
|
|
||||
|
namespace iflytop { |
||||
|
using namespace std; |
||||
|
|
||||
|
class ZIModuleImplV2 : public ZIModule { |
||||
|
public: |
||||
|
private: |
||||
|
/*******************************************************************************
|
||||
|
* 结构定义 * |
||||
|
*******************************************************************************/ |
||||
|
typedef struct { |
||||
|
int32_t index; |
||||
|
int32_t value; |
||||
|
// limit
|
||||
|
bool enablelimit; |
||||
|
int32_t minval; |
||||
|
int32_t maxval; |
||||
|
} reg_iterm_t; |
||||
|
|
||||
|
typedef enum { |
||||
|
kon_reg_write, |
||||
|
kon_reg_read, |
||||
|
} reg_change_event_t; |
||||
|
|
||||
|
typedef function<int32_t(reg_change_event_t event, int32_t index, int32_t ®val)> reg_change_listener_t; |
||||
|
|
||||
|
private: |
||||
|
/*******************************************************************************
|
||||
|
* 成员变量 * |
||||
|
*******************************************************************************/ |
||||
|
int32_t m_id = 0; |
||||
|
reg_iterm_t *m_regtable = NULL; |
||||
|
int32_t m_regNum = 0; |
||||
|
|
||||
|
reg_iterm_t *m_internal_regtable = NULL; |
||||
|
int32_t m_internal_regNum = 0; |
||||
|
|
||||
|
reg_change_listener_t m_reg_change_listener; |
||||
|
|
||||
|
public: |
||||
|
virtual ~ZIModuleImplV2() {} |
||||
|
|
||||
|
ZIModuleImplV2(int32_t id); |
||||
|
|
||||
|
/*******************************************************************************
|
||||
|
* ZIModuleImpl * |
||||
|
*******************************************************************************/ |
||||
|
|
||||
|
virtual int32_t getid(int32_t *id) override final; |
||||
|
virtual int32_t getid() override final; |
||||
|
virtual int32_t module_ping() override final; |
||||
|
|
||||
|
virtual int32_t module_get_status(int32_t *status) override final; |
||||
|
virtual int32_t module_get_error(int32_t *iserror) override final; |
||||
|
virtual int32_t module_clear_error() override final; |
||||
|
virtual int32_t module_enable(int32_t enable) override final; |
||||
|
virtual int32_t module_set_reg(int32_t param_id, int32_t param_value) override final; |
||||
|
virtual int32_t module_set_regbit(int32_t param_id, int32_t bitoffset, int32_t bitval) final; |
||||
|
virtual int32_t module_get_reg(int32_t param_id, int32_t *param_value) final; |
||||
|
virtual int32_t module_get_regbit(int32_t param_id, int32_t bitoffset, int32_t *param_value) final; |
||||
|
|
||||
|
virtual int32_t module_factory_reset() override final; |
||||
|
virtual int32_t module_flush_cfg() override final; |
||||
|
virtual int32_t module_active_cfg() override final; |
||||
|
|
||||
|
// virtual int32_t module_stop() = 0;
|
||||
|
// virtual int32_t module_break() = 0;
|
||||
|
// virtual int32_t module_start() = 0;
|
||||
|
// virtual int32_t module_read_raw(int32_t index, uint8_t *data, int32_t *len) override final;
|
||||
|
|
||||
|
/*******************************************************************************
|
||||
|
* 工具方法 * |
||||
|
*******************************************************************************/ |
||||
|
|
||||
|
void _regRegChangeListener(reg_change_listener_t onregchange); |
||||
|
void _allocRegTable(int32_t regNum); |
||||
|
|
||||
|
public: |
||||
|
}; |
||||
|
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue