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);
38 SPDLOG_LOGGER_INFO(
mLog,
"Opening interfaces.");
45 auto now_time = std::chrono::system_clock::to_time_t(startAt);
46 SPDLOG_LOGGER_INFO(
mLog,
"Starting simulation at {} (delta_T = {} seconds)",
47 std::put_time(std::localtime(&now_time),
"%F %T"),
48 std::chrono::duration_cast<std::chrono::seconds>(
49 startAt - Timer::StartClock::now())
52 mTimer.setStartTime(startAt);
61 if (mTimer.ticks() == 1)
62 SPDLOG_LOGGER_INFO(
mLog,
"Simulation started.");
65 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.
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.