Added new task for testing

This commit is contained in:
dario
2023-11-21 19:47:41 +01:00
committed by carlwachter
parent 5217945c03
commit a70dc00f4c
9 changed files with 84 additions and 8 deletions

View File

@@ -13,6 +13,7 @@
#include <sta/tacos/statemachine.hpp>
#include <tasks/dummy.hpp>
#include <tasks/toggle.hpp>
#include <tasks/disturb.hpp>
#include <gpio.h>
#include <sta/devices/stm32/gpio_pin.hpp>
@@ -35,7 +36,9 @@ namespace sta
// The dummy task runs for state 0.
Manager::instance()->registerThread(std::make_shared<demo::DummyTask>("State 0"), {0});
Manager::instance()->registerThread(std::make_shared<demo::DummyTask>("State 1"), {1});
Manager::instance()->registerThread(std::make_shared<demo::DummyTask>("State 2 - FAIL"), {2});
Manager::instance()->registerThread(std::make_shared<demo::Toggle>(), {0, 1});
Manager::instance()->registerThread(std::make_shared<demo::DisturbTask>(), {0, 1});
}
} // namespace tacos
} // namespace sta

35
App/Src/tasks/disturb.cpp Normal file
View File

@@ -0,0 +1,35 @@
/*
* disturb.cpp
*
* Created on: Nov 20, 2023
* Author: Dario
*/
#include <tasks/disturb.hpp>
#include <sta/tacos/statemachine.hpp>
#include <sta/debug/debug.hpp>
namespace demo
{
DisturbTask::DisturbTask()
: sta::tacos::TacosThread("Disturb", osPriorityNormal)
{
}
void DisturbTask::init()
{
}
void DisturbTask::func()
{
STA_DEBUG_PRINTLN(this->getName());
sta::tacos::Statemachine::instance()->stateChangeEvent.wait(sta::tacos::EventFlags::ALL, osWaitForever);
uint16_t currentState = sta::tacos::Statemachine::instance()->getCurrentState();
sta::tacos::Statemachine::instance()->requestTimedStateTransition(currentState, 2, 4000, 0);
}
} // namespace demo

View File

@@ -19,8 +19,6 @@ namespace demo
}
DummyTask::~DummyTask(){}
void DummyTask::init()
{

View File

@@ -26,8 +26,23 @@ namespace demo
{
osDelay(5000);
// Have we been requested to terminate while waiting?
if (!isRunning())
return;
// Do some important stuff...
uint16_t state = sta::tacos::Statemachine::instance()->getCurrentState();
uint16_t next = 1 - state;
uint16_t next;
if (state != 2)
{
next = 1 - state;
}
else
{
next = 0;
}
STA_DEBUG_PRINTLN("Toggle!");
sta::tacos::Statemachine::instance()->requestStateTransition(state, next, 0);