Skip to content
Snippets Groups Projects
Commit f864110f authored by Dónal Murray's avatar Dónal Murray
Browse files

Remove unused structs and rename clashing unset values

parent 4ad4cc69
No related merge requests found
...@@ -41,10 +41,10 @@ ...@@ -41,10 +41,10 @@
// enum of all transfer types // enum of all transfer types
enum PRIORITY : uint8_t { enum PRIORITY : uint8_t {
DATA = PACKET_DATA, DATA_ADDR = PACKET_DATA,
CMD = PACKET_CMD, CMD_ADDR = PACKET_CMD,
ALARM = PACKET_ALARM, ALARM_ADDR = PACKET_ALARM,
UNSET = 0x00 UNSET_ADDR = 0x00
}; };
// payload consists of type and information // payload consists of type and information
...@@ -52,7 +52,7 @@ enum PRIORITY : uint8_t { ...@@ -52,7 +52,7 @@ enum PRIORITY : uint8_t {
// information is set as information in the protocol // information is set as information in the protocol
class Payload { class Payload {
public: public:
Payload(PRIORITY type = PRIORITY::UNSET) {_type = type; } Payload(PRIORITY type = PRIORITY::UNSET_ADDR) {_type = type; }
Payload(const Payload &other) { Payload(const Payload &other) {
_type = other._type; _type = other._type;
_size = other._size; _size = other._size;
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
} }
~Payload() { unset(); } ~Payload() { unset(); }
void unset() { memset( _buffer, 0, PAYLOAD_MAX_SIZE_BUFFER); _type = PRIORITY::UNSET; _size = 0;} void unset() { memset( _buffer, 0, PAYLOAD_MAX_SIZE_BUFFER); _type = PRIORITY::UNSET_ADDR; _size = 0;}
void setType(PRIORITY type) { _type = type; } void setType(PRIORITY type) { _type = type; }
PRIORITY getType() {return _type; } PRIORITY getType() {return _type; }
......
...@@ -137,7 +137,7 @@ void CommsControl::receiver() { ...@@ -137,7 +137,7 @@ void CommsControl::receiver() {
bool CommsControl::writePayload(Payload &pl) { bool CommsControl::writePayload(Payload &pl) {
PRIORITY payload_type = pl.getType(); PRIORITY payload_type = pl.getType();
if (payload_type != PRIORITY::UNSET) { if (payload_type != PRIORITY::UNSET_ADDR) {
// create comms format using payload, the type is deduced from the payload itself // create comms format using payload, the type is deduced from the payload itself
CommsFormat comms = CommsFormat(pl); CommsFormat comms = CommsFormat(pl);
...@@ -282,11 +282,11 @@ PRIORITY CommsControl::getInfoType(uint8_t &address) { ...@@ -282,11 +282,11 @@ PRIORITY CommsControl::getInfoType(uint8_t &address) {
// get link to queue according to packet format // get link to queue according to packet format
RingBuf<CommsFormat, COMMS_MAX_SIZE_RB_SENDING> *CommsControl::getQueue(PRIORITY &type) { RingBuf<CommsFormat, COMMS_MAX_SIZE_RB_SENDING> *CommsControl::getQueue(PRIORITY &type) {
switch (type) { switch (type) {
case PRIORITY::ALARM: case PRIORITY::ALARM_ADDR:
return &_ring_buff_alarm; return &_ring_buff_alarm;
case PRIORITY::CMD: case PRIORITY::CMD_ADDR:
return &_ring_buff_cmd; return &_ring_buff_cmd;
case PRIORITY::DATA: case PRIORITY::DATA_ADDR:
return &_ring_buff_data; return &_ring_buff_data;
default: default:
return nullptr; return nullptr;
......
...@@ -8,13 +8,13 @@ CommsFormat::CommsFormat(uint8_t info_size, uint8_t address, uint16_t control) { ...@@ -8,13 +8,13 @@ CommsFormat::CommsFormat(uint8_t info_size, uint8_t address, uint16_t control) {
CommsFormat::CommsFormat(Payload &pl) { CommsFormat::CommsFormat(Payload &pl) {
uint8_t address; uint8_t address;
switch (pl.getType()) { switch (pl.getType()) {
case PRIORITY::ALARM: case PRIORITY::ALARM_ADDR:
address = PACKET_ALARM; address = PACKET_ALARM;
break; break;
case PRIORITY::CMD: case PRIORITY::CMD_ADDR:
address = PACKET_CMD; address = PACKET_CMD;
break; break;
case PRIORITY::DATA: case PRIORITY::DATA_ADDR:
address = PACKET_DATA; address = PACKET_DATA;
break; break;
default: default:
......
...@@ -25,7 +25,7 @@ void UILoop::receiveCommands() ...@@ -25,7 +25,7 @@ void UILoop::receiveCommands()
// check any received payload // check any received payload
if(_comms->readPayload(_plReceive)) { if(_comms->readPayload(_plReceive)) {
if (_plReceive.getType() == PRIORITY::CMD) { if (_plReceive.getType() == PRIORITY::CMD_ADDR) {
// apply received cmd to ui loop // apply received cmd to ui loop
cmd_format cmd; cmd_format cmd;
_plReceive.getPayload(reinterpret_cast<void*>(&cmd)); _plReceive.getPayload(reinterpret_cast<void*>(&cmd));
...@@ -33,7 +33,7 @@ void UILoop::receiveCommands() ...@@ -33,7 +33,7 @@ void UILoop::receiveCommands()
} }
// unset received type not to read it again // unset received type not to read it again
_plReceive.setType(PRIORITY::UNSET); _plReceive.setType(PRIORITY::UNSET_ADDR);
} }
} }
...@@ -56,7 +56,7 @@ void UILoop::reportFastReadings() ...@@ -56,7 +56,7 @@ void UILoop::reportFastReadings()
_fast_data.pressure_o2_regulated = readings_avgs.pressure_o2_regulated; _fast_data.pressure_o2_regulated = readings_avgs.pressure_o2_regulated;
_fast_data.pressure_diff_patient = readings_avgs.pressure_diff_patient; _fast_data.pressure_diff_patient = readings_avgs.pressure_diff_patient;
_plSend.setPayload(PRIORITY::DATA, reinterpret_cast<void *>(&_fast_data), sizeof(_fast_data)); _plSend.setPayload(PRIORITY::DATA_ADDR, reinterpret_cast<void *>(&_fast_data), sizeof(_fast_data));
_comms->writePayload(_plSend); _comms->writePayload(_plSend);
_fast_report_time = tnow; _fast_report_time = tnow;
} }
...@@ -107,7 +107,7 @@ void UILoop::reportReadbackValues() ...@@ -107,7 +107,7 @@ void UILoop::reportReadbackValues()
// _readback_data.peep = _breathing_loop->peep(); // _readback_data.peep = _breathing_loop->peep();
_readback_data.inhale_exhale_ratio = _breathing_loop->getIERatio(); _readback_data.inhale_exhale_ratio = _breathing_loop->getIERatio();
_plSend.setPayload(PRIORITY::DATA, reinterpret_cast<void *>(&_readback_data), sizeof(_readback_data)); _plSend.setPayload(PRIORITY::DATA_ADDR, reinterpret_cast<void *>(&_readback_data), sizeof(_readback_data));
_comms->writePayload(_plSend); _comms->writePayload(_plSend);
_readback_report_time = tnow; _readback_report_time = tnow;
} }
...@@ -121,7 +121,7 @@ void UILoop::reportCycleReadings() ...@@ -121,7 +121,7 @@ void UILoop::reportCycleReadings()
_cycle_data.timestamp = tnow; _cycle_data.timestamp = tnow;
_plSend.setPayload(PRIORITY::DATA, reinterpret_cast<void *>(&_cycle_data), sizeof(_cycle_data)); _plSend.setPayload(PRIORITY::DATA_ADDR, reinterpret_cast<void *>(&_cycle_data), sizeof(_cycle_data));
_comms->writePayload(_plSend); _comms->writePayload(_plSend);
_cycle_report_time = tnow; _cycle_report_time = tnow;
} }
......
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
const float MAX_VALVE_FRAC_OPEN = 0.68; const float MAX_VALVE_FRAC_OPEN = 0.68;
// input params // input params
enum PAYLOAD_TYPE : uint8_t { enum PAYLOAD_TYPE : uint8_t {
UNSET = 0, UNSET = 0,
DATA = 1, DATA = 1,
READBACK = 2, READBACK = 2,
CYCLE = 3, CYCLE = 3,
THRESHOLDS = 4, THRESHOLDS = 4,
CMD = 5, CMD = 5,
ALARM = 6 ALARM = 6
}; };
enum CMD_TYPE : uint8_t { enum CMD_TYPE : uint8_t {
...@@ -135,13 +135,6 @@ struct alarm_format { ...@@ -135,13 +135,6 @@ struct alarm_format {
}; };
#pragma pack() #pragma pack()
enum DATA_TYPE: uint8_t {
FAST = 1,
READBACK = 2,
CYCLE = 3,
THRESHOLDS = 4
};
// struct for all data sent // struct for all data sent
#pragma pack(1) #pragma pack(1)
struct fast_data_format { struct fast_data_format {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment