relay: [#9] init task

This commit is contained in:
Vasily Davydov
2023-05-12 23:25:07 +03:00
parent 2f58aad006
commit 2a42371458
4 changed files with 65 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
#include "Log.h"
#include "ThreadCommon.h"
#include "Rotary.h"
#include "Relay.h"
#include "Manager.h"
#include "Logging.h"
#include "UserInterface.h"
@@ -108,6 +109,9 @@ void thread_master(void* pvParams) {
manager->qm->createQueue(20,
sizeof(UserInterface::InterfaceWithData),
ThreadCommon::QueueManager::ui_event_manager);
manager->qm->createQueue(10,
sizeof(Event),
ThreadCommon::QueueManager::relay_event_master);
LOG_INFO("Master created queues");
@@ -121,6 +125,9 @@ void thread_master(void* pvParams) {
manager->tm->createTask(thread_user_interface, "user_interface",
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager));
manager->tm->createTask(thread_relay, "relay",
configMINIMAL_STACK_SIZE * 10,tskIDLE_PRIORITY + 1UL,
static_cast<void*>(manager));
LOG_INFO("Master created tasks");
m.taskFunction();
}

View File

@@ -0,0 +1,33 @@
/*
* Relay.cpp
*
* Created on: 12 May 2023
* Author: tylen
*/
#include "Relay.h"
#include "Event.h"
#include "Log.h"
Relay::Relay(ThreadCommon::QueueManager* qm): _qm(qm) {
LOG_DEBUG("Creating Relay");
}
Relay::~Relay() {
LOG_ERROR("Deleting Relay");
}
void Relay::taskFunction()
{
Event data(Event::Null, 0);
for(;;)
{
_qm->receive<Event>(ThreadCommon::QueueManager::relay_event_master, &data, portMAX_DELAY);
}
}
void thread_relay(void * pvParams)
{
ThreadCommon::CommonManagers * manager = static_cast<ThreadCommon::CommonManagers*>(pvParams);
Relay r(manager->qm);
}

View File

@@ -0,0 +1,24 @@
/*
* Relay.h
*
* Created on: 12 May 2023
* Author: tylen
*/
#ifndef THREADS_RELAY_RELAY_H_
#define THREADS_RELAY_RELAY_H_
#include "ThreadCommon.h"
class Relay {
public:
Relay(ThreadCommon::QueueManager* qm);
virtual ~Relay();
void taskFunction();
private:
ThreadCommon::QueueManager* _qm;
};
void thread_relay(void * pvParams);
#endif /* THREADS_RELAY_RELAY_H_ */