ADD [WIP] Static scheduling with event

This commit is contained in:
2024-11-17 23:09:00 +01:00
parent 6f7ee84ea0
commit b4d5f8028d
12 changed files with 783 additions and 17 deletions

View File

@ -25,6 +25,7 @@
#include <chrono>
#include "static_scheduling/bike_system.hpp"
#include "static_scheduling_with_event/bike_system.hpp"
#include "greentea-client/test_env.h"
#include "mbed.h"
@ -105,6 +106,39 @@ static void test_bike_system_event_queue() {
}
}
// test_bike_system_with_event handler function
static void test_bike_system_with_event() {
// create the BikeSystem instance
static_scheduling_with_event::BikeSystem bikeSystem;
// run the bike system in a separate thread
Thread thread;
thread.start(callback(&bikeSystem, &static_scheduling_with_event::BikeSystem::start));
// let the bike system run for 20 secs
ThisThread::sleep_for(20s);
// stop the bike system
bikeSystem.stop();
// check whether scheduling was correct
// Order is kGearTaskIndex, kSpeedTaskIndex, kTemperatureTaskIndex,
// kResetTaskIndex, kDisplayTask1Index, kDisplayTask2Index
// When we use event handling, we do not check the computation time
constexpr std::chrono::microseconds taskPeriods[] = {
800000us, 400000us, 1600000us, 800000us, 1600000us, 1600000us};
// allow for 2 msecs offset (with EventQueue)
uint64_t deltaUs = 2000;
for (uint8_t taskIndex = 0; taskIndex < advembsof::TaskLogger::kNbrOfTasks;
taskIndex++) {
TEST_ASSERT_UINT64_WITHIN(
deltaUs,
taskPeriods[taskIndex].count(),
bikeSystem.getTaskLogger().getPeriod(taskIndex).count());
}
}
static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test or the
// name of our Python file)
@ -117,6 +151,7 @@ static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
static Case cases[] = {
Case("test bike system", test_bike_system),
Case("test bike system with event queue", test_bike_system_event_queue)
Case("test bike system with event handling", test_bike_system_with_event),
};
static Specification specification(greentea_setup, cases);