39template <
class FlightPhases,
class SimulatorData,
class ActuatorData>
42 using PhasesCallback =
44 ActuatorData>::PhasesCallback;
56 HIL(HILTransceiver<FlightPhases, SimulatorData, ActuatorData>*
58 HILPhasesManager<FlightPhases, SimulatorData, ActuatorData>*
60 std::function<ActuatorData()> updateActuatorData,
int simulationPeriod)
64 updateActuatorData(updateActuatorData),
65 simulationPeriod(simulationPeriod)
72 [[nodiscard]]
bool start()
override
78 LOG_ERR(logger,
"hilTransceiver started with errors");
84 LOG_ERR(logger,
"hilPhasesManager started with errors");
90 LOG_ERR(logger,
"hil started with errors");
102 LOG_INFO(logger,
"HIL framework stopped");
107 LOG_INFO(logger,
"Waiting for simulation to start...");
109 miosix::Thread::sleep(1);
113 const PhasesCallback& func)
132 HILPhasesManager<FlightPhases, SimulatorData, ActuatorData>*
138 uint64_t ts = miosix::getTime();
141 ts +=
msToNs(simulationPeriod);
143 miosix::Thread::nanoSleepUntil(ts);
149 std::function<ActuatorData()> updateActuatorData;
150 int simulationPeriod;
#define LOG_INFO(logger,...)
#define LOG_ERR(logger,...)
bool shouldStop()
Tells whether or not the ActiveObject should stop its execution.
virtual void stop()
Signals the runner thread to terminate and joins the thread.
virtual bool start()
Start the thread associated with this active object.
Single interface to the hardware-in-the-loop framework.
const SimulatorData * getSensorData() const
int getSimulationPeriod() const
HIL(HILTransceiver< FlightPhases, SimulatorData, ActuatorData > *hilTransceiver, HILPhasesManager< FlightPhases, SimulatorData, ActuatorData > *hilPhasesManager, std::function< ActuatorData()> updateActuatorData, int simulationPeriod)
Constructor of the HIL framework.
HILPhasesManager< FlightPhases, SimulatorData, ActuatorData > * hilPhasesManager
void stop()
Signals the runner thread to terminate and joins the thread.
bool start() override
Start the needed hardware-in-the-loop components.
int64_t getTimestampSimulatorData() const
void registerToFlightPhase(const FlightPhases &flag, const PhasesCallback &func)
HILTransceiver< FlightPhases, SimulatorData, ActuatorData > * hilTransceiver
void waitStartSimulation()
Singleton object that manages all the phases of the simulation. After his instantiation we need to se...
static PrintLogger getLogger(const string &name)
This file includes all the types the logdecoder script will decode.
constexpr long long msToNs(long long ms)
Convert milliseconds to nanoseconds.