11 #include <dpsim/RealTimeSimulation.h>
15 using namespace DPsim;
17 RealTimeSimulation::RealTimeSimulation(String name,
CommandLineArgs &args)
20 RealTimeSimulation::RealTimeSimulation(String name, Logger::Level logLevel)
28 run(Timer::StartClock::now() + startIn);
35 SPDLOG_LOGGER_INFO(
mLog,
"Opening interfaces.");
42 auto now_time = std::chrono::system_clock::to_time_t(startAt);
43 SPDLOG_LOGGER_INFO(
mLog,
"Starting simulation at {} (delta_T = {} seconds)",
44 std::put_time(std::localtime(&now_time),
"%F %T"),
45 std::chrono::duration_cast<std::chrono::seconds>(
46 startAt - Timer::StartClock::now())
49 mTimer.setStartTime(startAt);
58 if (mTimer.ticks() == 1)
59 SPDLOG_LOGGER_INFO(
mLog,
"Simulation started.");
62 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.
DataLogger::List mLoggers
The data loggers.
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.
Real mTime
Time variable that is incremented at every step.
void run()
Run simulation until total time is elapsed.
CPS::Logger::Log mLog
Simulation logger.
void stop()
Stop real-time timer.
void sleep()
Suspend thread execution until next tick.