mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-09-29 02:57:33 +00:00
Added new task for testing
This commit is contained in:
@@ -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
35
App/Src/tasks/disturb.cpp
Normal 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
|
||||
|
@@ -19,8 +19,6 @@ namespace demo
|
||||
|
||||
}
|
||||
|
||||
DummyTask::~DummyTask(){}
|
||||
|
||||
void DummyTask::init()
|
||||
{
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user