AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
drama::git::Path Class Reference

Detailed Description

A path object for communicating with DRAMA GIT tasks.

This class is a sub-class of drama::Path, which is used to communicate with tasks that obey the DRAMA GIT Specification. Methods are provided to Initalise GIT tasks (including loading and reset of * tasks), Poll tasks and to shut them down.

A set of GIT tasks can be easily run via these objects, with much of the detail hidden.

Additionally, tasks which are not really GIT tasks can be controlled by a sub-class overriding various implementation methods (e.g. DoGeth(), SendSimLevel(), SendInitialise(), GetVerInfo(), SendReset() and SendExit()). This should allow a control task to run a set of tasks in a consistent manner

Sub-classes can then implement additional methods for the particular type of task being controlled.

See also
Example gitpathtest.cpp
Author
Tony Farrell, AAO $Revision$ $Date$ $Id$
Examples
gitpathtest.cpp.

#include "gitpath.hh"

Inheritance diagram for drama::git::Path:
drama::Path

Public Member Functions

 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 ~Path ()
 Destructor.
 
virtual bool Active () const
 Indicate if a task is active.
 
virtual bool Busy () const
 Returns true if we can't send a message because path is busy.
 
virtual void ClearState ()
 Clear the task state.
 
void Control (thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a control message to a task and blocks the current thread until the reply is received.
 
bool ControlWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a control message to a task and block the current thread until the reply is received or a timeout has occurred.
 
virtual void Delete (int force)
 Delete the task.
 
virtual void Died ()
 Note that a task has died.
 
virtual void Exit (thread::TMessHandler *action)
 Cause a GIT task to exit.
 
const std::string & GetArgument () const
 Fetch the load argument.
 
virtual DitsPathType GetDitsPath (bool nothrow=false)
 Return the underlying DITS path object.
 
const std::string & GetHost () const
 Fetch the task host name.
 
void GetParam (thread::TMessHandler *action, const std::initializer_list< std::string > names, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a get parameter message to a task and blocks the current thread until it completes.
 
void GetParam (thread::TMessHandler *action, const std::string &name, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a get parameter message to a task and blocks the current thread until it completes.
 
bool GetParamWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::initializer_list< std::string > names, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a get parameter message to a task and blocks the current thread until it completes.
 
bool GetParamWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a get parameter message to a task and blocks the current thread until it completes.
 
void GetPath (thread::TMessHandler *action, thread::TransEvtProcessor *const eventProcessor=&_getPathEventProcessor)
 Get a path to a the task.
 
virtual void GetPathImmed ()
 Get a path to a task if DITS already has it.
 
bool GetPathLoaded () const
 Indicate if a the task was loaded.
 
bool GetPathWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, thread::TransEvtProcessor *const eventProcessor=&_getPathEventProcessor)
 Get a path to a the task.
 
ResetEnum GetResetMode () const
 Return the reset mode.
 
virtual void GetSimulation (bool *beenSet, std::string *value, float *timeBase=nullptr, std::string *simArg=nullptr) const
 Get simulation details.
 
virtual std::shared_ptr< TaskGetTask () const
 Get a reference to the DRAMA task we are part of.
 
const std::string GetTaskName () const
 Fetch the task name.
 
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.
 
virtual bool Initial () const
 Return true if a GetPath operation is required.
 
virtual void Initialise (thread::TMessHandler *action, bool ignoreInitParam=false)
 Perform the complete initialisation sequence for a GIT task.
 
virtual bool IsDead () const
 Return true if a previously active task has disconnected.
 
void Kick (thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a kick message to a task and blocks the current thread until the reply is received.
 
void KickBulk (thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a kick message, with bulk data argument, to a task and blocks the current thread until the reply is received.
 
void KickBulk (thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a kick message, with SDS bulk data argument, to a task and blocks the current thread until the reply is received.
 
bool KickBulkWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a kick message to a task and block the current thread until the reply is received or a timeout has occurred.
 
bool KickBulkWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a kick message to a task and block the current thread until the reply is received or a timeout has occurred.
 
bool KickWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a kick message to a task and block the current thread until the reply is received or a timeout has occurred.
 
virtual void LogLoad (const bool Flag=true)
 Load use MsgOut() a lines indicating the load operations.
 
virtual void LosePath ()
 Lose the path and then set as if the task has died.
 
void MonitorCancel (thread::TMessHandler *action, int monId, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Send a Monitor Cancel message to a task and block until it is complete.
 
void MonitorForward (thread::TMessHandler *action, const sds::Id &argIn, MessageEventHandler *const eventProcessor=&_simpleMonEventProcessor)
 Send a Monitor Forward message to a task and block until it is complete.
 
template<typename ContainerType >
void MonitorForward (thread::TMessHandler *taction, const std::string &task, const std::string action, const ContainerType &pars, MessageEventHandler *const eventProcessor=&_simpleMonEventProcessor)
 Send a Monitor Forward message to a task and block until it is complete.
 
void MonitorForward (thread::TMessHandler *taction, const std::string &task, const std::string action, std::initializer_list< std::string > pars, MessageEventHandler *const eventProcessor=&_simpleMonEventProcessor)
 Send a Monitor Forward message to a task and block until it is complete.
 
void MonitorStart (thread::TMessHandler *action, const sds::Id &argIn, MessageEventHandler *const eventProcessor)
 Send a Monitor Start message to a task and block until is it is complete.
 
void Obey (thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends an obey message to a task and blocks the current thread until the action is complete.
 
void ObeyBulk (thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends an obey message to a task, with bulk data argument, and blocks the current thread until the action is complete.
 
void ObeyBulk (thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends an obey message to a task, with SDS bulk data argument, and blocks the current thread until the action is complete.
 
bool ObeyBulkWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends an obey message to a task, with a bulk data argument, and blocks the current thread until the action is complete or a timeout has occurred.
 
bool ObeyBulkWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends an obey message to a task, with a SDS bulk data argument, and blocks the current thread until the action is complete or a timeout has occurred.
 
bool ObeyWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends an obey message to a task and blocks the current thread until the action is complete or a timeout has occurred.
 
virtual void Poll (thread::TMessHandler *action)
 Send POLL to the GIT task

 
virtual void PollCancel (thread::TMessHandler *action)
 Cancel POLLing in the GIT task

 
virtual bool RemoteNetStart (const std::string &node, thread::TMessHandler *action)
 Start the DRAMA networking on a remote machine.
 
virtual void Report (thread::TMessHandler *action)
 Dump details using MsgOut.
 
void Report (thread::TMessHandler *action) const
 Dump details using MsgOut().
 
virtual void SetArgument (const std::string &LoadArg, bool const Append=false)
 Set the load time argument string.
 
virtual void SetBuffers (const Buffers &buffs)
 Set the DRAMA path buffers.
 
virtual void SetFailed ()
 Set the task to failed state.
 
virtual void SetFile (const std::string &File)
 Set the executable file name.
 
virtual void SetFlowControl ()
 Set the FLOW control flag.
 
virtual void SetHost (const std::string &Host)
 Set the task host name.
 
void SetIsAControlTask ()
 Tell git::Path that this task is a control task.
 
virtual void SetName (const std::string &TaskName)
 Set the task name.
 
virtual void SetNames (const bool Flag=true)
 Insist that symbols known to IMP_Master be known to the task.
 
void SetParam (thread::TMessHandler *action, const std::string &name, const sds::Id &argIn, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a set parameter message to a task and blocks the current thread until it completes.
 
bool SetParamWaitUntil (std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
 Sends a set parameter message to a task and blocks the current thread until it completes or a timeout has occurred.
 
void SetPollMaxAttempts (unsigned int n)
 Set the maximum number of poll restarts.
 
virtual void SetPriority (const int Priority, const bool Absolute=false)
 Set the load time priority for a task when loaded.
 
virtual void SetProcess (const std::string &ProcessName)
 Set the process names.
 
virtual void SetProg (const bool Flag=true)
 Interpert file name as a program name.
 
void SetResetMode (ResetEnum mode)
 Set the reset mode.
 
virtual void SetSimulation (const std::string &value, const float timeBase=1.0, const std::string &simArg="")
 Set simulation and timebase

 
virtual void SetStackSize (unsigned bytes)
 Set the stack size for the load.
 
virtual void SetSymbols (const bool Flag=true)
 Interpert file name as a symbol (VMS Target only)
 

Static Public Member Functions

static std::chrono::steady_clock::time_point DeltaToTimePoint (int secs)
 Given a number of seconds, return a time point that number of seconds into the future.
 
static void HandleDisconnected (const char *task, DitsPathType path, StatusType *status)
 Handle task disconnection.
 
static drama::sds::Id SpawnKickArg (DitsTransIdType tid)
 Create an SDS argument structure for kicking a Spawned transaction.
 
static void SpawnKickArgUpdate (drama::sds::Id *arg, DitsTransIdType tid)
 update an SDS argument structure for kicking a Spawned transaction
 

Protected Member Functions

virtual void Disconnected ()
 Invoked when the task we are talking to disappears.
 
virtual void DoGetPath (thread::TMessHandler *action)
 Get the path to the task, loading if needed.
 
virtual void GetVerInfo (thread::TMessHandler *action, bool ignoreInitParam)
 Get the tasks version information.
 
virtual void SendExit (thread::TMessHandler *action)
 Send the EXIT action to the task.
 
virtual void SendInitialise (thread::TMessHandler *action)
 Send the INTIIALISE action to the task.
 
virtual void SendReset (thread::TMessHandler *action, ResetType &mode)
 Send the RESET action to the task.
 
virtual void SendSimLevel (thread::TMessHandler *action, const std::string &simLevel, float timeBase, const std::string &simArg)
 Send the SIMULATE_LEVEL action to the task.
 

Protected Attributes

bool _amExiting =false
 Set true when the EXIT message is sent.
 
std::string _devType
 From ENQ_DEV_TYPE parameter.
 
bool _failed =false
 Task has failed in some way and should be reset on Initiailse()
 
bool _firstTime =true
 Set true for first init attempt.
 
bool _havePath =false
 Set true when we have the path.
 
bool _initialised =false
 If task is found running, will have the value of the INITIALISED parameter.
 
bool _isControlTask =false
 True if this task is itself a control task, which will result in a RESET RECOVER being sent in cases it might otherwise not be (e.g.
 
bool _pollCanceling =false
 Polling is being canceled.
 
bool _pollDont =false
 If true, don't poll

 
unsigned _pollMaxAttempts =5
 Maximum attempts at polling.
 
ResetType _resetMode =ResetEnum::Full
 The mode for the next reset.
 
bool _resetting =false
 Set true if we are resetting.
 
std::string _simArg
 Extra simulation level argument.
 
std::string _simLevel ="NONE"
 Simulate level

 
bool _simSent = false
 Has simulation value been sent?
 
float _simTimeBase =1
 Timebase for simulation

 
std::string _taskDescr
 From ENQ_DEV_DESCR parameter.
 
std::string _verDate
 From ENQ_VER_DATE parameter.
 
std::string _verNum
 From ENQ_VER_NUM parameter.
 

The documentation for this class was generated from the following file: