master: [#9] parse event in master to route it fwd
This commit is contained in:
parent
39a297c8a8
commit
2240d6ce09
@ -12,36 +12,74 @@ Master::Master(ThreadCommon::QueueManager* qm) : _qm(qm)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Master::taskFunction() {
|
void Master::HandleEventType(Event* e, Event::EventType type)
|
||||||
Event data(Event::Null, 0);
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Event::Null:
|
||||||
|
break;
|
||||||
|
case Event::Rotary:
|
||||||
|
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, e, 0);
|
||||||
|
DebugRotaryEvent(e->getDataOf(Event::Rotary));
|
||||||
|
break;
|
||||||
|
case Event::InternalTemp:
|
||||||
|
// TODO remove (deprecated)
|
||||||
|
break;
|
||||||
|
case Event::ExternalTemp:
|
||||||
|
//TODO comes from sensors, goes to relay & manager
|
||||||
|
break;
|
||||||
|
case Event::SetPoint:
|
||||||
|
//TODO comes from manager, goes to relay
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Master::DebugRotaryEvent(EventRawData e_data)
|
||||||
|
{
|
||||||
bool LedState = true;
|
bool LedState = true;
|
||||||
for (;;) {
|
switch(e_data)
|
||||||
if(!_qm->receive<Event>(ThreadCommon::QueueManager::master_event_all, &data, 10000))
|
|
||||||
data.setDataOf(Event::Rotary, ThreadCommon::RotaryAction::Idle);
|
|
||||||
switch(data.getDataOf(Event::Rotary))
|
|
||||||
{
|
{
|
||||||
case ThreadCommon::RotaryAction::Right:
|
case ThreadCommon::RotaryAction::Right:
|
||||||
Board_LED_Set(ThreadCommon::RotaryAction::Right, LedState);
|
Board_LED_Set(ThreadCommon::RotaryAction::Right, LedState);
|
||||||
printf("Right\r\n");
|
printf("Right\r\n");
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, &data, 0);
|
|
||||||
break;
|
break;
|
||||||
case ThreadCommon::RotaryAction::Left:
|
case ThreadCommon::RotaryAction::Left:
|
||||||
Board_LED_Set(ThreadCommon::RotaryAction::Left, LedState);
|
Board_LED_Set(ThreadCommon::RotaryAction::Left, LedState);
|
||||||
printf("Left\r\n");
|
printf("Left\r\n");
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, &data, 0);
|
|
||||||
break;
|
break;
|
||||||
case ThreadCommon::RotaryAction::Press:
|
case ThreadCommon::RotaryAction::Press:
|
||||||
Board_LED_Set(ThreadCommon::RotaryAction::Press, LedState);
|
Board_LED_Set(ThreadCommon::RotaryAction::Press, LedState);
|
||||||
printf("Press\r\n");
|
printf("Press\r\n");
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, &data, 0);
|
|
||||||
break;
|
break;
|
||||||
case ThreadCommon::RotaryAction::Idle:
|
case ThreadCommon::RotaryAction::Idle:
|
||||||
//Board_LED_Set(ThreadCommon::RotaryAction::Right, LedState);
|
//Board_LED_Set(ThreadCommon::RotaryAction::Right, LedState);
|
||||||
printf("Idle\r\n");
|
printf("Idle\r\n");
|
||||||
_qm->send<Event>(ThreadCommon::QueueManager::manager_event_master, &data, 0);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LedState = !LedState;
|
LedState = !LedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Master::taskFunction() {
|
||||||
|
Event data(Event::Null, 0);
|
||||||
|
for (;;) {
|
||||||
|
if(!_qm->receive<Event>(ThreadCommon::QueueManager::master_event_all, &data, 10000))
|
||||||
|
data.setDataOf(Event::Rotary, ThreadCommon::RotaryAction::Idle);
|
||||||
|
|
||||||
|
for(Event::EventType i :
|
||||||
|
{Event::Null,
|
||||||
|
Event::Rotary,
|
||||||
|
Event::InternalTemp,
|
||||||
|
Event::ExternalTemp,
|
||||||
|
Event::SetPoint})
|
||||||
|
{
|
||||||
|
if (data.getDataOf(i) != ERROR_RETURN)
|
||||||
|
{
|
||||||
|
HandleEventType(&data, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
Event* message;
|
Event* message;
|
||||||
ThreadCommon::QueueManager* _qm;
|
ThreadCommon::QueueManager* _qm;
|
||||||
|
void HandleEventType(Event* e, Event::EventType type);
|
||||||
|
void DebugRotaryEvent(EventRawData data);
|
||||||
};
|
};
|
||||||
|
|
||||||
void thread_master(void* pvParams);
|
void thread_master(void* pvParams);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user