4 changed files with 101 additions and 2 deletions
-
2components/pipette_module/pipette_ctrl_module_v2.cpp
-
2components/sensors/smtp2/smtp2.cpp
-
66components/zcancmder/protocol_event_bus_sender.cpp
-
33components/zcancmder/protocol_event_bus_sender.hpp
@ -0,0 +1,66 @@ |
|||
#include "protocol_event_bus_sender.hpp"
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
void ProtocolEventBusSender::initialize(IZCanReceiver* zcanreceiver) { |
|||
m_zcanreceiver = zcanreceiver; |
|||
lock_.init(); |
|||
} |
|||
|
|||
|
|||
void ProtocolEventBusSender::push_reg_state_change_event(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval) { |
|||
zlock_guard l(lock_); |
|||
|
|||
zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; |
|||
int32_t* data = (int32_t*)cmd_header->data; |
|||
cmd_header->subModuleid = moduleid; |
|||
cmd_header->cmdMainId = zcr::kevent_bus_reg_change_report >> 8; |
|||
cmd_header->subModuleid = zcr::kevent_bus_reg_change_report & 0xff; |
|||
|
|||
data[0] = regindex; |
|||
data[1] = oldval; |
|||
data[2] = toval; |
|||
m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 3); |
|||
} |
|||
|
|||
void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t data0) { |
|||
zlock_guard l(lock_); |
|||
|
|||
zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; |
|||
int32_t* data = (int32_t*)cmd_header->data; |
|||
cmd_header->subModuleid = moduleid; |
|||
cmd_header->cmdMainId = cmdindex >> 8; |
|||
cmd_header->subModuleid = cmdindex & 0xff; |
|||
|
|||
data[0] = data0; |
|||
m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 1); |
|||
} |
|||
void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1) { |
|||
zlock_guard l(lock_); |
|||
|
|||
zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; |
|||
int32_t* data = (int32_t*)cmd_header->data; |
|||
cmd_header->subModuleid = moduleid; |
|||
cmd_header->cmdMainId = cmdindex >> 8; |
|||
cmd_header->subModuleid = cmdindex & 0xff; |
|||
|
|||
data[0] = data0; |
|||
data[1] = data1; |
|||
m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 1); |
|||
} |
|||
void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1, int32_t data2) { |
|||
zlock_guard l(lock_); |
|||
|
|||
zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; |
|||
int32_t* data = (int32_t*)cmd_header->data; |
|||
cmd_header->subModuleid = moduleid; |
|||
cmd_header->cmdMainId = cmdindex >> 8; |
|||
cmd_header->subModuleid = cmdindex & 0xff; |
|||
|
|||
data[0] = data0; |
|||
data[1] = data1; |
|||
data[2] = data2; |
|||
m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 1); |
|||
} |
|||
|
|||
} // namespace iflytop
|
@ -0,0 +1,33 @@ |
|||
#pragma once
|
|||
|
|||
#include "a8000_protocol\protocol.hpp"
|
|||
#include "basic.hpp"
|
|||
#include "sdk/os/zos.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
class ProtocolEventBusSender { |
|||
IZCanReceiver* m_zcanreceiver = nullptr; |
|||
zmutex lock_; |
|||
|
|||
uint8_t txbuf[128]; |
|||
|
|||
public: |
|||
static ProtocolEventBusSender* inst() { |
|||
static ProtocolEventBusSender instance; |
|||
return &instance; |
|||
} |
|||
|
|||
void initialize(IZCanReceiver* zcanreceiver); |
|||
|
|||
void push_reg_state_change_event(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval); |
|||
|
|||
void report(int32_t moduleid, int32_t cmdindex, int32_t data0); |
|||
void report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1); |
|||
void report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1, int32_t data2); |
|||
|
|||
private: |
|||
void _report(int32_t moduleid, int32_t cmdindex, int32_t ndata, int32_t* data); |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue