DPsim
SequentialScheduler.h
1 /* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2  * EONERC, RWTH Aachen University
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7  *********************************************************************************/
8 
9 #pragma once
10 
11 #include <dpsim/Scheduler.h>
12 
13 #include <chrono>
14 #include <typeinfo>
15 #include <unordered_map>
16 #include <vector>
17 
18 namespace DPsim {
20 public:
21  SequentialScheduler(String outMeasurementFile = String(),
22  CPS::Logger::Level logLevel = CPS::Logger::Level::info)
23  : Scheduler(logLevel), mOutMeasurementFile(outMeasurementFile) {}
24 
25  void createSchedule(const CPS::Task::List &tasks, const Edges &inEdges,
26  const Edges &outEdges);
27  void step(Real time, Int timeStepCount);
28  void stop();
29 
30 private:
31  CPS::Task::List mSchedule;
32 
33  std::unordered_map<size_t, std::vector<std::chrono::nanoseconds>>
34  mMeasurements;
35  std::vector<std::chrono::nanoseconds> mStepMeasurements;
36  CPS::String mOutMeasurementFile;
37 };
38 } // namespace DPsim
std::unordered_map< CPS::Task::Ptr, std::deque< CPS::Task::Ptr > > Edges
Definition: Scheduler.h:31
void stop()
Called on simulation stop to reliably clean up e.g. running helper threads.
void step(Real time, Int timeStepCount)
Performs a single simulation step.
void createSchedule(const CPS::Task::List &tasks, const Edges &inEdges, const Edges &outEdges)
Creates the schedule for the given dependency graph.