WSF
WsfMessageProcessor Class Reference

A processor that implements time-delays and message routing. More...

#include <WsfMessageProcessor.hpp>

Inheritance diagram for WsfMessageProcessor:
Collaboration diagram for WsfMessageProcessor:

Classes

class  Action
class  Selector
class  Process
class  DelayRequest
 A unit of work within a time delay queue. More...

Public Member Functions

 WsfMessageProcessor (WsfScenario &aScenario)
WsfMessageProcessoroperator= (const WsfMessageProcessor &)=delete
 ~WsfMessageProcessor () override
Public Member Functions inherited from WsfScriptProcessor
 WsfScriptProcessor (const WsfScenario &aScenario)
 WsfScriptProcessor (const WsfScenario &aScenario, WsfStringId aPartClass, const std::string &aPartVarName)
 ~WsfScriptProcessor () override
WsfProcessorClone () const override
bool Initialize (double aSimTime) override
bool Initialize2 (double aSimTime) override
bool ProcessInput (UtInput &aInput) override
void Update (double aSimTime) override
bool ProcessMessage (double aSimTime, const WsfMessage &aMessage) override
void SendMessage (double aSimTime, const WsfMessage &aMessage) override
virtual void ExecuteOnMessageCreate (double aSimTime, WsfMessage &aMessage)
virtual bool ExecuteScript (double aSimTime, const std::string &aScriptName)
virtual bool ExecuteScript (double aSimTime, WsfStringId aScriptName, UtScriptData &aScriptRetVal, const UtScriptDataList &aScriptArgs=UtScriptDataList())
void ExecuteScriptAtTime (double aTime, WsfStringId aScriptName, const UtScriptDataList &aScriptArgs)
virtual void SuppressMessage (bool aSuppressMessage)
WsfScriptMessageHandlerGetMessageHandler ()
WsfScriptContextGetScriptContext ()
UtScriptContext * GetScriptAccessibleContext () const override
void SetPlatform (WsfPlatform *aPlatformPtr) override
const WsfBehaviorTreeBehaviorTree () const
WsfAdvancedBehaviorTreeAdvancedBehaviorTree () const
virtual const WsfScriptStateMachineGetStateMachine () const
wsf::ExternalLinksGetExternalLinks ()
std::string State ()
std::string StateAll ()
void SetState (std::string &stateName)
void SetStateAll (std::string &stateNameAll)
Public Member Functions inherited from WsfProcessor
 WsfProcessor (const WsfScenario &aScenario)
 ~WsfProcessor () override=default
ComponentListGetComponents ()
const ComponentListGetComponents () const
virtual void ProcessCallback (double aSimTime, const WsfCallback &aCallback)
WsfComponentCloneComponent () const override
const int * GetComponentRoles () const override
void * QueryInterface (int aRole) override
int GetComponentInitializationOrder () const override
const char * GetScriptClassName () const override
bool PreInitialize (double aSimTime) override
void PreInput () override
void TurnOff (double aSimTime) override
void TurnOn (double aSimTime) override
void SetNonOperational (double aSimTime) override
void SetOperational (double aSimTime) override
void PartBroken (double aSimTime) override
double GetUpdateInterval () const override
void SetUpdateInterval (double aUpdateInterval) override
Public Member Functions inherited from WsfPlatformPart
 WsfPlatformPart (const WsfScenario &aScenario, int aPartType)
WsfPlatformPartoperator= (const WsfPlatformPart &aRhs)=delete
 ~WsfPlatformPart () override
bool DebugEnabled () const
 Returns 'true' if debugging is enabled for this instance.
void SetDebugEnabled (bool aDebugEnabled)
unsigned int GetDebugMask ()
bool IsExternallyControlled () const
virtual void SetExternallyControlled (double aSimTime, bool aIsExternallyControlled)
int GetPartType () const
const char * GetScriptClassName () const override
WsfSimulationGetSimulation () const
const WsfScenarioGetScenario () const
WsfStringId GetComponentName () const override
void ComponentParentChanged (WsfPlatform *aPlatformPtr) override
WsfPlatformGetPlatform () const
virtual void PlatformAdded (double aSimTime, WsfPlatform *aPlatformPtr)
virtual void PlatformDeleted (WsfPlatform *aPlatformPtr)
double GetLastStatusChangeTime () const
void SetLastStatusChangeTime (double aSimTime)
 Allows a system to set the time at which the device was initialized.
bool CanBeMadeOperational () const
 Returns an indication that this system can be made operational.
bool CanBeMadeNonOperational () const
 Returns an indication that this system can be made non-operational.
bool CanBeTurnedOn () const
 Returns an indication that this system can be turned on.
bool CanBeTurnedOff () const
 Returns an indication that this system can be turned off.
bool IsTurnedOn () const
bool InitiallyTurnedOn () const
 Is the system to be turned 'on' when added to the simulation?
void SetInitiallyTurnedOn (bool aInitiallyTurnedOn)
 Sets if the system is turned on when added to the simulation.
virtual void Restore (double aSimTime)
bool IsOperational () const
bool SetOperational (double aSimTime, bool aMakeOperational)
double GetDamageFactor () const
bool SetDamageFactor (double aSimTime, double aDamageFactor)
bool IsCritical () const
void SetCritical (bool aValue)
virtual void OnPlatformBrokenEvent (double aSimTime)
 Owning platform has issued a broken event.
bool IsBroken () const
WsfInternalLinksGetInternalLinks ()
 Return the internal links for this part.
virtual bool HasInternalLinks () const
 Does this platform part have a communication link to other platform parts?
virtual void SendMessageTo (double aSimTime, const WsfMessage &aMessage, WsfStringId aRecipientId)
void SendMessageToProcessor (double aSimTime, const WsfMessage &aMessage, WsfStringId aRecipientId)
virtual void SendQueuedMessages (double aSimTime)
const WsfCategoryListGetCategories () const
 Get the categories to which this part belongs.
void AddCategory (WsfStringId aCategoryId)
 Adds the provided category to the platform part's category list.
bool IsCategoryMember (WsfStringId aCategoryId) const
const WsfGroupListGetGroups () const
 Get the groups to which this platform part belongs.
void JoinGroup (WsfGroup *aGroupPtr)
 Join the given group.
void LeaveGroup (WsfGroup *aGroupPtr)
 Leave the given group.
bool IsGroupMember (WsfStringId aGroupId)
unsigned int GetUpdateEventEpoch () const
void IncrementUpdateEventEpoch ()
bool UpdateEventActive () const
 Is an 'Update' event active?
void SetUpdateEventActive (bool aUpdateEventActive)
 Indicate if the 'Update' event is active.
Public Member Functions inherited from WsfObject
 WsfObject ()
 This is the constructor for the WsfObject class.
 ~WsfObject () override
 This is the destructor for the WsfObject class.
const char * GetScriptClassName () const override
const std::string & GetType () const
WsfStringId GetTypeId () const
 Get the string ID of the 'type' of the object.
void SetType (WsfStringId aType)
const std::string & GetBaseType () const
WsfStringId GetBaseTypeId () const
const TypeListGetTypeList () const
bool IsA_TypeOf (WsfStringId aType) const
WsfObjectoperator= (const WsfObject &aRhs)
 Assignment operator.
template<typename T>
void Serialize (T &aBuff)
 For XIO (de)serialization.
const std::string & GetName () const
WsfStringId GetNameId () const
void SetName (WsfStringId aName)
Public Member Functions inherited from WsfComponentT< WsfPlatform >
 WsfComponentT ()
 WsfComponentT (const WsfComponentT &) noexcept
WsfComponentToperator= (const WsfComponentT &) noexcept
 ~WsfComponentT () override=default
ParentTypeGetComponentParent () const
void SetComponentParent (ParentType *aParentPtr)
Public Member Functions inherited from WsfComponent
virtual ~WsfComponent ()=default
template<typename T>
bool QueryInterfaceT (T *&aRolePtr)
bool ComponentHasRole (int aRole)
 Returns true if the component has the specified role.
Public Member Functions inherited from WsfUniqueId
 WsfUniqueId ()
 Construtor initializes the unique identifier to 0.
 WsfUniqueId (const WsfUniqueId &)
 Copy constructor initializes the unique identifier to 0.
WsfUniqueIdoperator= (const WsfUniqueId &)
unsigned int GetUniqueId () const
 Get the unique identifier assigned to this object.
template<typename T>
void Serialize (T &aBuff)
 For XIO (de)serialization.
Public Member Functions inherited from WsfAuxDataEnabled
 WsfAuxDataEnabled ()=default
 WsfAuxDataEnabled (const WsfAuxDataEnabled &aSrc)=default
WsfAuxDataEnabledoperator= (const WsfAuxDataEnabled &aRhs)
 WsfAuxDataEnabled (WsfAuxDataEnabled &&)=default
WsfAuxDataEnabledoperator= (WsfAuxDataEnabled &&)=default
virtual ~WsfAuxDataEnabled () noexcept
void SetAuxData (const WsfAttributeContainer &aAuxData)
void DeleteAuxData ()
 Delete the aux data container from the object.
void MergeAuxData (const WsfAuxDataEnabled &aSrc)
 Merge the object's aux data with aux data from an existing object.
void UpdateAuxData (const WsfAuxDataEnabled &aSrc)
 Update the object's aux data with aux data from an existing object.
bool HasAuxData () const
 Returns true if this object has aux data.
bool ProcessInput (UtInput &aInput)
template<typename T>
void Serialize (T &aBuff)
 (De)serialization for XIO
WsfAttributeContainerGetAuxData ()
const WsfAttributeContainerGetAuxData () const noexcept
const WsfAttributeContainerGetAuxDataConst () const noexcept

Framework Methods

class Action
class Selector
class Process
class DelayRequest
WsfProcessorClone () const override
bool Initialize (double aSimTime) override
bool ProcessInput (UtInput &aInput) override
bool ProcessMessage (double aSimTime, const WsfMessage &aMessage) override
bool ReceiveMessage (double aSimTime, const WsfMessage &aMessage) override
void SendMessage (double aSimTime, const WsfMessage &aMessage) override
void TurnOff (double aSimTime) override
void TurnOn (double aSimTime) override
void Update (double aSimTime) override
bool ProcessAction (double aSimTime, const WsfMessage &aMessage)
 Execute custom actions (scripts) based on the message type.
 WsfMessageProcessor (const WsfMessageProcessor &aSrc)
 Copy constructor (for Clone()).

Additional Inherited Members

using ComponentList = WsfComponentListT<WsfProcessorComponent>
Public Types inherited from WsfPlatformPart
enum  { cLEVEL_ONE_DEBUG = 0x00000001 , cLEVEL_TWO_DEBUG = 0x00000002 }
using InternalMessageQueue = std::queue<WsfMessage*>
using RecipientMessageQueue = std::queue<std::pair<WsfPlatformPart*, WsfMessage*>>
Public Types inherited from WsfObject
typedef std::vector< WsfStringIdTypeList
 The list of types returned by GetTypeList.
Public Types inherited from WsfComponentT< WsfPlatform >
typedef WsfPlatform ParentType
 This is needed to support the WsfComponentList template.
Static Public Attributes inherited from WsfAuxDataEnabled
static UtCallbackListN< void(const WsfAuxDataEnabled *)> AuxDataAccessed
static UtCallbackListN< void(const WsfAuxDataEnabled *)> AuxDataDestroyed
Protected Member Functions inherited from WsfScriptProcessor
 WsfScriptProcessor (const WsfScriptProcessor &aSrc)
 WsfProcessor (const WsfProcessor &aSrc)
 Copy constructor (for Clone()).
WsfProcessoroperator= (const WsfProcessor &aRhs)=delete
 WsfPlatformPart (const WsfPlatformPart &aSrc)
 Copy constructor (for Clone()).
 WsfObject (const WsfObject &aSrc)
 Copy constructor (for Clone()).
Protected Member Functions inherited from WsfUniqueId
void AssignUniqueId (WsfSimulation *aSimulationPtr)
Protected Attributes inherited from WsfScriptProcessor
WsfScriptContextmContextPtr
 Pointer to the script context.
WsfScriptMessageHandlermMessageHandlerPtr
 Pointer to the 'on_message' handler.
UtScript * mOnMessageCreateScriptPtr
 Pointer to the 'on_message_create' script.
UtScriptClass * mMessageClassPtr
wsf::ExternalLinks mExternalLinks
 The external recipients.
WsfBehaviorTreemBehaviorTreePtr
ut::CloneablePtr< WsfAdvancedBehaviorTreemAdvancedBehaviorTreePtr
std::unique_ptr< WsfScriptStateMachinemStateMachinePtr
int mStateIndex
bool mSuppressMessage

Detailed Description

A processor that implements time-delays and message routing.

Constructor & Destructor Documentation

◆ WsfMessageProcessor() [1/2]

◆ ~WsfMessageProcessor()

WsfMessageProcessor::~WsfMessageProcessor ( )
override

◆ WsfMessageProcessor() [2/2]

WsfMessageProcessor::WsfMessageProcessor ( const WsfMessageProcessor & aSrc)
protected

Member Function Documentation

◆ Clone()

WsfProcessor * WsfMessageProcessor::Clone ( ) const
overridevirtual

Create a clone of this object.

Returns
A pointer to the new copy.

Implements WsfProcessor.

References WsfMessageProcessor(), and WsfProcessor::WsfProcessor().

Referenced by WsfMessageProcessor::DelayRequest::DelayRequest().

◆ Initialize()

bool WsfMessageProcessor::Initialize ( double aSimTime)
overridevirtual

Perform phase 1 initialization. This is called by WsfPlatform::Initialize() during phase 1 initialization of the platform. The component should complete validation of input data that could not be done by ProcessInput, as well as any other functions to prepare for simulation use (subject to the next paragraph).

The order in which components are initialized is defined by GetComponentInitializationOrder. In general a component implementation of this method should not be dependent on the state of another component, i.e.: it should not assume that the other components Initialize() method has been called. If such a dependency exists one should use Initialize2() if possible, or specify a value GetComponentInitializationOrder to force things to initialize in a particular order.

Parameters
aSimTimeThe current simulation time.
Returns
true if successful or false if unsuccessful (bad input data, etc.)
Note
This method should NOT add any other components to the platform. This MUST be done in PreInitialize().

Reimplemented from WsfComponent.

References WsfPlatformPart::GetPlatform(), WsfScriptProcessor::Initialize(), WsfScriptProcessor::mContextPtr, and ok.

Referenced by WsfImageProcessor::Initialize().

◆ operator=()

WsfMessageProcessor & WsfMessageProcessor::operator= ( const WsfMessageProcessor & )
delete

◆ ProcessAction()

bool WsfMessageProcessor::ProcessAction ( double aSimTime,
const WsfMessage & aMessage )

Execute custom actions (scripts) based on the message type.

References WsfScriptProcessor::mContextPtr, and WsfMessageProcessor::Action::mScriptPtr.

Referenced by operator=(), WsfImageProcessor::ProcessMessage(), and ProcessMessage().

◆ ProcessInput()

bool WsfMessageProcessor::ProcessInput ( UtInput & aInput)
overridevirtual

Process input from a generic source.

Examine the current input command. If it is NOT one of the commands recognized by this class then it simply returns 'false'. If it is one of the commands recognized by this class then it processes the command and returns 'true'.

Parameters
aInputa reference to a UtInput object.
Returns
'true' if the command was one recognized by the class or 'false' if not.
Exceptions
UtInput::ExceptionBase(or an object derived from it) if the command was recognized but contains some sort of error.
Note
If a derived class does not recognize the command (i.e.: the return value is false) then it should call the base class ProcessInput method. This chain should continue until either the command is recognized or the top-level base class is encountered.

Reimplemented from WsfObject.

References WsfMessageProcessor::Process::mSelectorList, Process, WsfMessageProcessor::Process::ProcessInput(), and WsfScriptProcessor::ProcessInput().

Referenced by WsfImageProcessor::ProcessInput().

◆ ProcessMessage()

bool WsfMessageProcessor::ProcessMessage ( double aSimTime,
const WsfMessage & aMessage )
overridevirtual

Process a received message.

Parameters
aSimTimeThe current simulation time.
aMessageThe message that is being sent.
Returns
'true' if the message was processed or 'false' if not.
Note
A message is first received by ReceiveMessage which then calls ProcessMessage to process the message. A derived class ReceiveMessage method may choose to delay the message before calling ProcessMessage or may choose to ignore the message altogether.

Reimplemented from WsfPlatformPart.

References WsfPlatformPart::DebugEnabled(), WsfObject::GetName(), WsfPlatformPart::GetPlatform(), WsfMessage::GetSerialNumber(), WsfMessage::GetSubType(), WsfMessage::GetType(), WsfScriptProcessor::mMessageHandlerPtr, WsfScriptProcessor::mSuppressMessage, ProcessAction(), and SendMessage().

Referenced by ReceiveMessage().

◆ ReceiveMessage()

bool WsfMessageProcessor::ReceiveMessage ( double aSimTime,
const WsfMessage & aMessage )
overridevirtual

Receive a message from another platform part (system). The default implementation simply calls ProcessMessage to process the received message.

Parameters
aSimTimeThe current simulation time.
aMessageThe message that is being sent.
Returns
'true' if the message was received or 'false' if not.
Note
A message is first received by ReceiveMessage which then calls ProcessMessage to process the message. A derived class ReceiveMessage method may choose to delay the message before calling ProcessMessage or may choose to ignore the message altogether.

Reimplemented from WsfPlatformPart.

References WsfPlatformPart::DebugEnabled(), WsfRandomVariable::Draw(), WsfObject::GetName(), WsfPlatformPart::GetPlatform(), WsfMessage::GetSerialNumber(), WsfMessage::GetSubType(), WsfMessage::GetType(), WsfMessageProcessor::Action::mDelayTime, WsfMessageProcessor::Action::mIgnoreMessage, and ProcessMessage().

Referenced by WsfImageProcessor::ReceiveMessage().

◆ SendMessage()

void WsfMessageProcessor::SendMessage ( double aSimTime,
const WsfMessage & aMessage )
overridevirtual

Send a message to platform parts (systems) with whom we are linked.

Parameters
aSimTimeThe current simulation time.
aMessageThe message that is being sent.

Reimplemented from WsfPlatformPart.

References WsfPlatformPart::GetInternalLinks(), WsfScriptProcessor::mExternalLinks, and WsfScriptProcessor::SendMessage().

Referenced by ProcessMessage().

◆ TurnOff()

void WsfMessageProcessor::TurnOff ( double aSimTime)
overridevirtual

Turn off the platform part (system).

Parameters
aSimTimeThe current simulation time.

Reimplemented from WsfPlatformPart.

References WsfProcessor::TurnOff().

Referenced by WsfImageProcessor::TurnOff().

◆ TurnOn()

void WsfMessageProcessor::TurnOn ( double aSimTime)
overridevirtual

Turn on the platform part (system).

Parameters
aSimTimeThe current simulation time.

Reimplemented from WsfPlatformPart.

References WsfProcessor::TurnOn().

◆ Update()

void WsfMessageProcessor::Update ( double aSimTime)
overridevirtual

Update the state of an platform part. Updates the platform part to reflect the state at the specified simulation time.

Parameters
aSimTimeThe current simulation time.

Reimplemented from WsfPlatformPart.

References WsfScriptProcessor::Update().

◆ Action

friend class Action
friend

◆ DelayRequest

friend class DelayRequest
friend

References WsfMessageProcessor().

◆ Process

friend class Process
friend

Referenced by ProcessInput().

◆ Selector

friend class Selector
friend

The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved