Skip to content

Commit

Permalink
can calculate end to end timing for one chain
Browse files Browse the repository at this point in the history
  • Loading branch information
vovatrykoz committed Nov 13, 2024
1 parent 67b142d commit 8565043
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ add_executable(
)

target_compile_features(runner PUBLIC cxx_std_17)
target_link_libraries(runner task)
target_link_libraries(runner analysis task mathFramework timedPath)

include(FetchContent)
FetchContent_Declare(
Expand Down
2 changes: 1 addition & 1 deletion source/Analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ std::set<TimedPath> analysis::removeUnreachablePaths(

for(const auto& path : pathSet) {
if(mathframework::pathReach(path.asVector())) {
output.emplace(path);
output.insert(path);
}
}

Expand Down
59 changes: 55 additions & 4 deletions source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,63 @@
#include <Task.h>
#include <Analysis.h>

#include <iostream>
#include <limits>
#include <optional>

int readInt(const std::string& message);
TaskInstance readTaskInstance();

int main(void) {
Task task(10, 5, 1);
std::string taskChainName;
int numOfTasks;

std::cout << "Enter task chain name: ";
std::cin >> taskChainName;

TimedPath timedPath;

std::cout << "Created a task with period " << task.period << " and wcet "
<< task.wcet << std::endl;
numOfTasks = readInt("How many tasks should be in the chain: ");

for (int i = 0; i < numOfTasks; i++) {
std::cout << "Reading Task " << i + 1 << std::endl;
TaskInstance taskInstance = readTaskInstance();
timedPath.appendTaskInstance(taskInstance);
std::cout << std::endl;
}

std::cout << "End to end timing: " << timedPath.endToEndDelay() << std::endl;

return 0;
}
}

int readInt(const std::string& message) {
int output;
bool validInput = false;

do {
std::cout << message;
std::cin >> output;

if (std::cin.fail()) {
std::cout << std::endl
<< "The input was not an integer, please try again"
<< std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
} else {
validInput = true;
}
} while (!validInput);

return output;
}

TaskInstance readTaskInstance() {
int period = readInt("Enter task period: ");
int wcet = readInt("Enter worst case execution time for the task: ");
int priority = readInt("Enter task priority: ");
int activationTime = readInt("Enter task activation time or offset: ");

return TaskInstance(Task(period, wcet, priority), activationTime);
}

0 comments on commit 8565043

Please sign in to comment.