AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
gitpath.hh
Go to the documentation of this file.
1#ifndef _DRAMA2_GITPATH_INC
2#define _DRAMA2_GITPATH_INC
3
22/*
23 * History:
24 17-Mar-2015 - TJF - Original version
25 30-Sep-2016 - TJF - Many changes before now.
26 Improve comments.
27 Add ignoreInitParam argument to GetVerInfo().
28 Add GetVerInfo() method.
29 20-Nov-2017 - TJF Add GetSimulation() method.
30 21-May-2018 - TJF - Add RemoteNetStart() method to Path class, allows
31 a sub-class to start the remote network.
32 28-Oct-2020 - TJF - Support the idea of the controlled task itself being
33 a control task. The main difference is that they
34 are sent RESET RECOVER commands when other tasks may
35 not be. Add _isControlTask member and
36 SetIsAControlTask() method.
37
38 * The above ID is for Doxygen, this one has the format ACMM is looking for.
39 * "@(#) $Id$"
40 */
41
42#include "drama.hh"
43#include "Git.h"
44
45namespace drama {
49 namespace git {
50
51
52
55 enum ResetEnum {
56 Soft=0,
57 Full,
58 Hard,
59 Recover,
60 Invalid
61 };
62 /* Used to relate reset enum string values to the enum value */
63 class ResetEnumLookup : public drama::gitarg::EnumLookupClass {
64 public:
65 unsigned int GetMaxValue() const override final {
66 return (int)(Invalid)-1;
67 }
68 const char ** GetStringArray() const override final {
69 static const char *table[] = { "SOFT", "FULL", "HARD",
70 "RECOVER", 0 };
71 return table;
72 }
73 };
85 class ResetType : public drama::gitarg::Enum<ResetEnumLookup, ResetEnum>{
86 using drama::gitarg::Enum<ResetEnumLookup, ResetEnum>::Enum;
87
88 public:
89 };
90
120 class Path : public drama::Path {
121
122 protected:
123 /*
124 * History says that sub-classes might need these. Really the
125 * functionality should be revamped an appropriate access methods
126 * provided.
127 */
128 ResetType _resetMode=ResetEnum::Full;
129 bool _pollDont=false;
130 bool _pollCanceling=false;
131 unsigned _pollMaxAttempts=5;
132 std::string _simLevel="NONE";
133 std::string _simArg;
134 float _simTimeBase=1;
135 bool _simSent = false;
137 bool _havePath=false;
138 bool _failed=false;
140 bool _amExiting=false;
142 bool _resetting=false;
143 bool _firstTime=true;
145 bool _initialised=false;
149 bool _isControlTask=false;
155 std::string _verDate;
156 std::string _verNum;
157 std::string _taskDescr;
158 std::string _devType;
184 const std::string &simLevel,
185 float timeBase,
186 const std::string &simArg);
187
197
217 bool ignoreInitParam/* = false*/);
218
219
228 ResetType & mode);
229
230
231
238 virtual void SendExit(thread::TMessHandler *action);
239
240
241
242 public:
261 Path(std::weak_ptr<drama::Task> theTask,
262 const std::string &name,
263 const std::string &host = "",
264 const std::string &file = "");
286 virtual void SetSimulation(const std::string &value,
287 const float timeBase=1.0,
288 const std::string &simArg="");
289
290
304 virtual void GetSimulation(bool *beenSet,
305 std::string *value,
306 float *timeBase=nullptr,
307 std::string *simArg=nullptr) const;
308
309
320 }
325 ResetEnum GetResetMode() const {
326 return _resetMode;
327 }
328
364 bool ignoreInitParam = false);
365
384 virtual void Poll(thread::TMessHandler *action);
385
392 void SetPollMaxAttempts(unsigned int n) {
394 }
395
396
408 virtual void PollCancel(thread::TMessHandler *action);
409
418 virtual void Exit(thread::TMessHandler *action);
427 virtual void Report(thread::TMessHandler *action);
428
431 virtual ~Path() { }
432
439 virtual void SetFailed() {
440//fprintf(stderr,"#### SetFailed invoked\n");
441 _failed = true;
442 }
443
462 virtual void GetVerInfo(std::string *verNum,
463 std::string *verDate=nullptr,
464 std::string *taskDescr=nullptr,
465 std::string *devType=nullptr) const ;
467
489 virtual bool RemoteNetStart(const std::string &node,
491
492
493
505 void SetIsAControlTask() {
506 _isControlTask = true;
507 }
508
509
510
511 }; // class Path
512
513 } // namespace git
514
515} // namespace drama
517#endif
Path()
Construct a null object.
Definition path.hh:996
A Class which provides access to DRAMA's message sending facilities.
Definition path.hh:689
virtual void SendInitialise(thread::TMessHandler *action)
Send the INTIIALISE action to the task.
virtual void DoGetPath(thread::TMessHandler *action)
Get the path to the task, loading if needed.
bool _havePath
Set true when we have the path.
Definition gitpath.hh:164
bool _pollDont
If true, don't poll
Definition gitpath.hh:156
ResetType _resetMode
The mode for the next reset.
Definition gitpath.hh:155
virtual void SendSimLevel(thread::TMessHandler *action, const std::string &simLevel, float timeBase, const std::string &simArg)
Send the SIMULATE_LEVEL action to the task.
Path(std::weak_ptr< drama::Task > theTask, const std::string &name, const std::string &host="", const std::string &file="")
Construct a drama::git::Path object.
virtual void SetFailed()
Set the task to failed state.
Definition gitpath.hh:466
virtual void SendExit(thread::TMessHandler *action)
Send the EXIT action to the task.
std::string _simLevel
Simulate level
Definition gitpath.hh:159
virtual void Initialise(thread::TMessHandler *action, bool ignoreInitParam=false)
Perform the complete initialisation sequence for a GIT task.
bool _initialised
If task is found running, will have the value of the INITIALISED parameter.
Definition gitpath.hh:172
bool _simSent
Has simulation value been sent?
Definition gitpath.hh:162
bool _amExiting
Set true when the EXIT message is sent.
Definition gitpath.hh:167
virtual void SendReset(thread::TMessHandler *action, ResetType &mode)
Send the RESET action to the task.
float _simTimeBase
Timebase for simulation
Definition gitpath.hh:161
void SetPollMaxAttempts(unsigned int n)
Set the maximum number of poll restarts.
Definition gitpath.hh:419
std::string _taskDescr
From ENQ_DEV_DESCR parameter.
Definition gitpath.hh:184
virtual void GetVerInfo(thread::TMessHandler *action, bool ignoreInitParam)
Get the tasks version information.
virtual ~Path()
Destructor.
Definition gitpath.hh:458
bool _firstTime
Set true for first init attempt.
Definition gitpath.hh:170
bool _resetting
Set true if we are resetting.
Definition gitpath.hh:169
bool _failed
Task has failed in some way and should be reset on Initiailse()
Definition gitpath.hh:165
void SetResetMode(ResetEnum mode)
Set the reset mode.
Definition gitpath.hh:345
ResetEnum GetResetMode() const
Return the reset mode.
Definition gitpath.hh:352
bool _pollCanceling
Polling is being canceled.
Definition gitpath.hh:157
unsigned _pollMaxAttempts
Maximum attempts at polling.
Definition gitpath.hh:158
virtual void Report(thread::TMessHandler *action)
Dump details using MsgOut.
std::string _simArg
Extra simulation level argument.
Definition gitpath.hh:160
virtual void GetVerInfo(std::string *verNum, std::string *verDate=nullptr, std::string *taskDescr=nullptr, std::string *devType=nullptr) const
Return the task version and device info values.
std::string _verDate
From ENQ_VER_DATE parameter.
Definition gitpath.hh:182
virtual void Exit(thread::TMessHandler *action)
Cause a GIT task to exit.
virtual void GetSimulation(bool *beenSet, std::string *value, float *timeBase=nullptr, std::string *simArg=nullptr) const
Get simulation details.
bool _isControlTask
True if this task is itself a control task, which will result in a RESET RECOVER being sent in cases ...
Definition gitpath.hh:176
virtual void PollCancel(thread::TMessHandler *action)
Cancel POLLing in the GIT task
virtual void Poll(thread::TMessHandler *action)
Send POLL to the GIT task
std::string _devType
From ENQ_DEV_TYPE parameter.
Definition gitpath.hh:185
virtual void SetSimulation(const std::string &value, const float timeBase=1.0, const std::string &simArg="")
Set simulation and timebase
virtual bool RemoteNetStart(const std::string &node, thread::TMessHandler *action)
Start the DRAMA networking on a remote machine.
std::string _verNum
From ENQ_VER_NUM parameter.
Definition gitpath.hh:183
void SetIsAControlTask()
Tell git::Path that this task is a control task.
Definition gitpath.hh:532
A path object for communicating with DRAMA GIT tasks.
Definition gitpath.hh:147
A type used to represent the current reset mode.
Definition gitpath.hh:112
An interface for the lookup class template arguments to drama::gitarg::Enum.
Definition gitarg.hh:186
Enum()
Default contructor for the object.
Definition gitarg.hh:274
A class which reads Enumerated values from a SDS argument structures.
Definition gitarg.hh:245
This interface class must be implemented by classes which have threads waiting for messages.
Definition thread.hh:308
DRAMA 2 main include file.
ResetEnum
This enum contains the possible reset types.
Definition gitpath.hh:82
@ Full
A full reset, but don't necessarily power cycle H/W.
Definition gitpath.hh:84
@ Recover
Only reset if last operation failed.
Definition gitpath.hh:86
@ Invalid
Used by gitarg::Enum to indicate an invalid mode.
Definition gitpath.hh:87
@ Hard
A full reset with power cycling of hardware.
Definition gitpath.hh:85
@ Soft
A soft reset - tidy up software rather then hardware.
Definition gitpath.hh:83
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
@ Exit
Loaded task exited message received.
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93