11#include <dpsim/RealTimeSimulation.h>
13#include <spdlog/fmt/chrono.h>
18RealTimeSimulation::RealTimeSimulation(String name,
CommandLineArgs &args)
21RealTimeSimulation::RealTimeSimulation(String name, Logger::Level logLevel)
29 run(Timer::StartClock::now() + startIn);
39 SPDLOG_LOGGER_INFO(
mLog,
"Opening interfaces.");
48 "Starting simulation at {:%Y-%m-%d %H:%M:%S} (delta_T = {} seconds)",
49 startAt, startAt - Timer::StartClock::now());
51 mTimer.setStartTime(startAt);
60 if (mTimer.ticks() == 1)
61 SPDLOG_LOGGER_INFO(
mLog,
"Simulation started.");
64 SPDLOG_LOGGER_INFO(
mLog,
"Simulation finished.");
The Simulation holds a SystemTopology and a Solver.
void sync() const
Synchronize simulation with remotes by exchanging intial state over interfaces.
virtual Real step()
Solve system A * x = z for x and current time.
const CPS::Attribute< Real >::Ptr mTimeStep
Simulation timestep.
void initialize()
Create solver instances etc.
const CPS::Attribute< Real >::Ptr mFinalTime
Final time of the simulation.
std::shared_ptr< Scheduler > mScheduler
Scheduler used for task scheduling.
std::vector< Interface::Ptr > mInterfaces
Vector of Interfaces.
Simulation(String name, CommandLineArgs &args)
Creates simulation with name and CommandLineArgs.
Real mTime
Time variable that is incremented at every step.
void run()
Run simulation until total time is elapsed.
DataLoggerInterface::List mLoggers
The data loggers.
CPS::Logger::Log mLog
Simulation logger.
void stop()
Stop real-time timer.
void sleep()
Suspend thread execution until next tick.