Browse Source

update

master
zhaohe 1 year ago
parent
commit
8691aaccb1
  1. 2
      components/pipette_module/pipette_ctrl_module_v2.cpp
  2. 2
      components/sensors/smtp2/smtp2.cpp
  3. 66
      components/zcancmder/protocol_event_bus_sender.cpp
  4. 33
      components/zcancmder/protocol_event_bus_sender.hpp

2
components/pipette_module/pipette_ctrl_module_v2.cpp

@ -1,5 +1,5 @@
#include "pipette_ctrl_module_v2.hpp"
#include "sdk\components\zcancmder\protocol_event_bus_sender.hpp"
using namespace iflytop;
#define TAG "PipetteModule"

2
components/sensors/smtp2/smtp2.cpp

@ -435,7 +435,7 @@ int32_t SMTP2::doaction_block(function<int32_t()> action) {
// int32_t state = getState();
osDelay(100);
bool isbusy;
bool isbusy = false;
err::error_t error;
int32_t ecode = getState(isbusy, error);

66
components/zcancmder/protocol_event_bus_sender.cpp

@ -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

33
components/zcancmder/protocol_event_bus_sender.hpp

@ -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
Loading…
Cancel
Save