FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
CProgress.h
1#include <fhsim/FhSimMgr.h>
2#include <fhsim/NFhSim.h>
3#include <fhsim/simobject/SimObject.h>
4#include <chrono>
5#include <string>
6
51class CProgress : public SimObject
52{
53 public:
54 CProgress(const std::string& name, ISimObjectCreator* const creator);
56 ~CProgress() override;
57 void OdeFcn(const double t, const double* const x, double* const xdot) const override;
58 void AcceptedStep(const double t, const double* const x) override;
59 void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator);
60#ifdef FH_VISUALIZATION
61 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator)
62 { }
63 virtual void RenderUpdate(const double T, const double* const X) { }
64#endif
65 protected:
67 std::string FormatProgress(double t) const;
69 void Write(const std::string& progress);
70
72 std::string m_output_name;
74 double m_end_time;
76 std::string m_last_written;
78 std::string m_latest;
80 std::chrono::steady_clock::time_point m_last_write_time;
82 std::chrono::steady_clock::duration m_min_write_interval = std::chrono::milliseconds(500);
83};
Definition CProgress.h:52
std::string FormatProgress(double t) const
The progress text for accepted time t: the percentage of the end time, or 0.00 when it is infinite.
std::chrono::steady_clock::duration m_min_write_interval
Definition CProgress.h:82
double m_end_time
Definition CProgress.h:74
std::chrono::steady_clock::time_point m_last_write_time
Definition CProgress.h:80
void Write(const std::string &progress)
Replaces the file's content with progress.
std::string m_output_name
Definition CProgress.h:72
~CProgress() override
Writes the last accepted step's progress if the file does not hold it yet.
std::string m_last_written
Definition CProgress.h:76
std::string m_latest
Definition CProgress.h:78