Working manager & statemachine tasks; timers still bugged; statemachine init bugged

This commit is contained in:
dario
2023-09-27 00:07:23 +02:00
parent 5bf6cca3b1
commit 817db58a0e
10 changed files with 83 additions and 31 deletions

View File

@@ -7,6 +7,7 @@
#include <sta/tacos/manager.hpp>
#include <sta/tacos/statemachine.hpp>
#include <sta/debug/debug.hpp>
namespace sta
@@ -69,11 +70,20 @@ namespace sta
void Manager::init()
{
STA_DEBUG_PRINTLN("INITIALIZING MANAGER!");
startThreads(Statemachine::instance()->getCurrentState());
}
void Manager::func()
{
if (true)
{
// STA_DEBUG_PRINTLN("LOOPY LOOP IN MANAGER TASK");
osDelay(1000);
}
// Wait for either the termination request or the state change flag.
uint32_t flags = osEventFlagsWait(getInstance(), STA_RTOS_THREAD_FLAG_TERMINATE, osFlagsWaitAny, osWaitForever);

View File

@@ -69,7 +69,7 @@ namespace sta
{
onManagerInit();
Statemachine::instance()->start();
Manager::instance()->start();
}
} // namespace tacos

View File

@@ -7,23 +7,43 @@
#include <sta/tacos/statemachine.hpp>
#include <sta/debug/debug.hpp>
namespace sta
{
namespace tacos
{
Statemachine::Statemachine(){}
Statemachine::Statemachine()
: currentState_{STA_TACOS_INITIAL_STATE}, lockoutTimer_{[](void *){}, NULL}, failsafeTimer_{[](void *){}, NULL}
{
STA_ASSERT(STA_TACOS_INITIAL_STATE < STA_TACOS_NUM_STATES);
}
void Statemachine::init()
{
STA_DEBUG_PRINTLN("INITIALIZING STATEMACHINE");
/*
lockoutTimer_.setCallback([](void *) { STA_DEBUG_PRINTLN("Lockout timer triggered!"); }, NULL);
lockoutTimer_.start(1000);
failsafeTimer_.setCallback([](void *) { STA_DEBUG_PRINTLN("Failsafe timer triggered!"); }, NULL);
failsafeTimer_.start(2000);
*/
}
void Statemachine::func()
{
// STA_DEBUG_PRINTLN("LOOPY LOOP IN STATEMACHINE");
STA_DEBUG_PRINT("Failsafe timer is running: ");
STA_DEBUG_PRINTLN(failsafeTimer_.isRunning());
osDelay(1000);
}
uint16_t Statemachine::getCurrentState()
uint16_t Statemachine::getCurrentState() const
{
return currentState_;
}

View File

@@ -19,11 +19,14 @@ namespace sta
{
TacosThread::TacosThread(const char* name, osPriority_t prio)
: RtosThread(RtosHandle<osThreadId_t>(Handle::Deferred(&instance_))),
instance_{ NULL },
attribs_{ .name = name, .priority = prio }
{}
TacosThread::TacosThread()
: RtosThread(RtosHandle<osThreadId_t>(Handle::Deferred(&instance_)))
: RtosThread(RtosHandle<osThreadId_t>(Handle::Deferred(&instance_))),
instance_{ NULL },
attribs_{ }
{}
void TacosThread::entry_point(void* arg)
@@ -85,6 +88,7 @@ namespace sta
}
void TacosThread::init(){}
void TacosThread::func(){}
TacosThread::~TacosThread(){}