relay: [#9] create Event parser

This commit is contained in:
Vasily Davydov 2023-05-13 00:24:31 +03:00
parent 1d9e53dc20
commit 07a6937077
2 changed files with 29 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include "Event.h" #include "Event.h"
#include "Log.h" #include "Log.h"
// TODO Remove en pins
RelayDevice::RelayDevice(uint8_t en_pin, RelayDevice::RelayDevice(uint8_t en_pin,
uint8_t en_port, uint8_t en_port,
uint8_t pha_pin, uint8_t pha_pin,
@ -42,9 +43,33 @@ void Relay::taskFunction()
for(;;) for(;;)
{ {
_qm->receive<Event>(ThreadCommon::QueueManager::relay_event_master, &data, portMAX_DELAY); _qm->receive<Event>(ThreadCommon::QueueManager::relay_event_master, &data, portMAX_DELAY);
parseEvent(&data);
} }
} }
void Relay::parseEvent(Event* d)
{
for (uint8_t i = Event::ExternalTemp; i <= Event::SetPoint; i++)
{
EventRawData rd = data.getDataOf(i);
if(rd == ERROR_RETURN)
{
continue;
}
switch(i /* EventType */)
{
case Event::ExternalTemp:
ext_temp = rd;
break;
case Event::SetPoint:
setpoint = rd;
default:
assert(0);
}
}
}
void thread_relay(void * pvParams) void thread_relay(void * pvParams)
{ {
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams); ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);

View File

@ -10,6 +10,7 @@
#include "ThreadCommon.h" #include "ThreadCommon.h"
#include "DigitalIoPin.h" #include "DigitalIoPin.h"
#include "Counter.h"
class RelayDevice { class RelayDevice {
public: public:
@ -33,6 +34,9 @@ private:
ThreadCommon::QueueManager* _qm; ThreadCommon::QueueManager* _qm;
RelayDevice relays [2] = {{0, 23, 0, 24, 0}, RelayDevice relays [2] = {{0, 23, 0, 24, 0},
{0, 25, 0, 26, 1}}; {0, 25, 0, 26, 1}};
void parseEvent(Event * d);
int8_t setpoint, ext_temp;
}; };
void thread_relay(void * pvParams); void thread_relay(void * pvParams);