WSF
WsfTrackStateController Class Reference

#include <WsfTrackStateController.hpp>

Collaboration diagram for WsfTrackStateController:

Classes

class  TrackStateMachine

Public Member Functions

 WsfTrackStateController ()
 WsfTrackStateController (WsfScriptContext &aContext)
 WsfTrackStateController (const WsfTrackStateController &aSrc, WsfScriptContext &aContext)
virtual ~WsfTrackStateController ()
WsfPlatformGetPlatform () const
 Get the platform to which the controller is attached.
WsfProcessorGetProcessor () const
 Get the processor to which the controller is attached.

Callbacks from the state machine (not part of the public interface).

WsfPlatformmPlatformPtr
WsfProcessormProcessorPtr
WsfTimeDelayQueuemThinkerPtr
WsfScriptContextmContextPtr
UtScript * mOnTrackDropScriptPtr
TrackStateMachinemStateMachinePtr
WsfTrackManagermTrackManagerPtr
UtCallbackHolder mCallbacks
WsfLocalTrackListmTrackListPtr
UtMappedList< WsfLocalTrackStatus, WsfTrackIdmTrackStatusList
std::map< WsfStringId, WsfRandomVariablemTimeToEvalByName
std::vector< WsfRandomVariablemTimeToEvalByIndex
 The time it takes to evaluate a state by state index.
std::map< WsfStringId, WsfRandomVariablemEvalIntervalByName
std::vector< WsfRandomVariablemEvalIntervalByIndex
 Evaluation interval by state index.
std::vector< int > mTracksInState
 The number of tracks in a state, indexed by state index.
bool mEvaluateCandidateTracks
bool mShowStateTransitions
bool mClearSignalOnStateExit
bool mIsTurnedOn
double mEvaluationInterval
double mTransitionTime
double mEvaluationSimTime
WsfTrackId mEvaluationTrackId
WsfLocalTrackmEvaluationTrackPtr
UtScriptDatamSignalVarPtr
UtScriptDatamStatusVarPtr
UtScriptDatamTrackVarPtr
virtual void EnterState (int aStateIndex)
virtual void ExitState (int aStateIndex)
virtual double EvaluationComplete (double aSimTime, const WsfTrackId &aLocalTrackId, unsigned int aEvaluationEpoch)
virtual void RequestEvaluation (double aSimTime, const WsfTrackId &aLocalTrackId, unsigned int aEvaluationEpoch)
void PreConstruct ()
void DeleteTrack (double aSimTime, const WsfTrackId &aLocalTrackId)
void DiscoverTrack (double aSimTime, const WsfLocalTrack *aTrackPtr)
bool EvaluateTrack (double aSimTime, WsfLocalTrackStatus *aStatusPtr)
void SubmitRequest (double aSimTime, WsfLocalTrackStatus *aStatusPtr)
void CandidateTrackPromoted (double aSimTime, const WsfLocalTrack *aLocalTrackPtr)
 Handle 'candidate track promotion' events (A callback from WsfTrackManager).
void LocalTrackInitiated (double aSimTime, const WsfLocalTrack *aLocalTrackPtr, const WsfTrack *aRawTrackPtr)
 Handle 'local track initiation' events (A callback from WsfTrackManager).
void LocalTrackDropped (double aSimTime, const WsfLocalTrack *aLocalTrackPtr)
 Handle 'local track dropped' events (A callback from WsfTrackManager).
void TrackManagerChanged (double aSimTime, WsfTrackManager *aNewManagerPtr)

Common framework methods.

virtual bool Initialize (double aSimTime, WsfProcessor *aProcessorPtr, WsfTimeDelayQueue *aThinkerPtr, WsfTrackManager *aTrackManagerPtr)
virtual bool ProcessInput (const WsfScenario &aScenario, UtInput &aInput)
virtual bool ProcessMessage (double aSimTime, const WsfMessage &aMessage)
bool IsTurnedOn () const
virtual void TurnOff (double aSimTime)
 The processor to which we're attached has been turned off.
virtual void TurnOn (double aSimTime)
 The processor to which we're attached has been turned on.
void ConnectCallbacks ()
void SetEvaluationInterval (double aEvaluationInterval)
void SetTransitionTime (double aTransitionTime)
virtual void EnterState (double aSimTime, const WsfTrackId &aTrackId, WsfStringId aNewStateName)
virtual void TracksInState (WsfStringId aStateName, std::vector< WsfLocalTrack * > &aTrackList)
virtual int TracksInState (WsfStringId aStateName)
virtual WsfStringId StateOfTrack (const WsfTrackId &aLocalTrackId)
WsfSimulationGetSimulation () const

Detailed Description

A processor for directing a set of local tracks through a state machine.

This processor takes a collection of local tracks (as maintained by WsfTrackManager or some equivalent), associates a 'state' with each track, and in response to calls to Update() and ProcessMessage(), will invoke the state machine to potentially update the 'state' of the tracks.

The states of the state machine may be used to represent anything that is of consequence to the user. The transition rules in the state machine may allocate resources, issue commands, etc., that will cause to state of the local track to change.

Constructor & Destructor Documentation

◆ WsfTrackStateController() [1/3]

◆ WsfTrackStateController() [2/3]

WsfTrackStateController::WsfTrackStateController ( WsfScriptContext & aContext)

◆ WsfTrackStateController() [3/3]

◆ ~WsfTrackStateController()

WsfTrackStateController::~WsfTrackStateController ( )
virtual

References mStateMachinePtr.

Member Function Documentation

◆ CandidateTrackPromoted()

void WsfTrackStateController::CandidateTrackPromoted ( double aSimTime,
const WsfLocalTrack * aLocalTrackPtr )
protected

Handle 'candidate track promotion' events (A callback from WsfTrackManager).

References DiscoverTrack(), and mEvaluateCandidateTracks.

Referenced by ConnectCallbacks().

◆ ConnectCallbacks()

void WsfTrackStateController::ConnectCallbacks ( )

◆ DeleteTrack()

void WsfTrackStateController::DeleteTrack ( double aSimTime,
const WsfTrackId & aLocalTrackId )
protected

Drop a local track (status). A local track has been dropped, so delete the associated local track status.

Parameters
aSimTimeThe current simulation time.
aLocalTrackIdThe track ID of the local track (status) to be dropped.

Formerly, whenever a track is dropped DeleteTrack() would also delete the associated TrackStatus entry. The problem is that external methods invoked by EvaluateTrack() or EnterState() process MAY cause a track (and the associated TrackStatus entry) to be deleted, thus invalidating the local pointer these routines have to the TrackStatus entry! This event simply serves as a way to delay the deletion of the TrackStatus until a more opportune time.

References WsfSimulation::AddEvent(), GetSimulation(), WsfLocalTrackStatus::GetStateIndex(), WsfLocalTrackStatus::GetTargetName(), mPlatformPtr, mProcessorPtr, mShowStateTransitions, mStateMachinePtr, mTracksInState, mTrackStatusList, WsfTrack::SetTargetName(), WsfTrack::SetTrackId(), WsfObserver::StateEntry(), and WsfObserver::StateExit().

Referenced by EvaluateTrack(), and RequestEvaluation().

◆ DiscoverTrack()

void WsfTrackStateController::DiscoverTrack ( double aSimTime,
const WsfLocalTrack * aTrackPtr )
protected

Discover a local track. We have been informed of the existence of a new track (by either the track manager or by turning on the processor and searching the track list). Schedule the initial evaluation of the track.

Parameters
aSimTimeThe current simulation time.
aTrackPtrThe pointer to the track that has been discovered.

References WsfSimulation::AddEvent(), GetSimulation(), WsfTrack::GetTargetName(), WsfTrack::GetTrackId(), mPlatformPtr, mProcessorPtr, mShowStateTransitions, mStateMachinePtr, mTracksInState, and mTrackStatusList.

Referenced by CandidateTrackPromoted(), LocalTrackInitiated(), and TurnOn().

◆ EnterState() [1/2]

void WsfTrackStateController::EnterState ( double aSimTime,
const WsfTrackId & aLocalTrackId,
WsfStringId aNewStateName )
virtual

Enter a state directly without evaluating the transition rules for the current state. This method exits the current state, enters the requested state and schedules an immediate evaluation of the rules for the new state.

Parameters
aSimTimeThe current simulation time.
aLocalTrackIdThe local track ID of the track.
aNewStateNameThe name (string ID) of the desired state.
Note
This method does nothing if the track no longer exists or the state is invalid. If the selected state is the same as the current state then it simply schedules a re-evaluation (it does not exit and re-enter).

References WsfSimulation::AddEvent(), GetSimulation(), WsfLocalTrackStatus::GetStateIndex(), mEvaluationSimTime, mEvaluationTrackPtr, mStateMachinePtr, mStatusVarPtr, mTrackListPtr, mTracksInState, mTrackStatusList, mTrackVarPtr, WsfLocalTrackStatus::SetState(), WsfLocalTrackStatus::SetTransitionPending(), trackPtr, WsfLocalTrackStatus::TransitionPending(), WsfLocalTrackStatus::UpdateEvaluationEpoch(), and WsfLocalTrackStatus::UpdateTargetName().

◆ EnterState() [2/2]

void WsfTrackStateController::EnterState ( int aStateIndex)
virtual

The following is invoked from the state machine to indicate that we are entering a new state.

Parameters
aStateIndexThe state that we are entering.

References WsfSimulation::GetPlatformByIndex(), GetSimulation(), mEvaluationSimTime, mEvaluationTrackPtr, mPlatformPtr, mProcessorPtr, mShowStateTransitions, mStateMachinePtr, platformPtr, and WsfObserver::StateEntry().

◆ EvaluateTrack()

bool WsfTrackStateController::EvaluateTrack ( double aSimTime,
WsfLocalTrackStatus * aStatusPtr )
protected

Evaluate the status of a single local track. Only the current state will be evaluated. It is the responsibility of the caller to recall this routine if they want to perform as many transitions as possible.

Parameters
aSimTimeThe current simulation time.
aStatusPtrThe pointer to the local track status to be evaluated.
Returns
'true' if evaluated or 'false' if the corresponding local track does not exist.

References DeleteTrack(), WsfLocalTrackStatus::GetLocalTrackId(), GetSimulation(), WsfLocalTrackStatus::GetStateIndex(), mEvaluateCandidateTracks, mEvaluationInterval, mEvaluationSimTime, mEvaluationTrackPtr, mPlatformPtr, mProcessorPtr, mStateMachinePtr, mStatusVarPtr, mTrackListPtr, mTrackManagerPtr, mTracksInState, mTrackVarPtr, mTransitionTime, WsfLocalTrackStatus::SetState(), WsfLocalTrackStatus::SetTransitionPending(), trackPtr, WsfLocalTrackStatus::TransitionPending(), and WsfLocalTrackStatus::UpdateTargetName().

Referenced by EvaluationComplete(), and ProcessMessage().

◆ EvaluationComplete()

double WsfTrackStateController::EvaluationComplete ( double aSimTime,
const WsfTrackId & aLocalTrackId,
unsigned int aEvaluationEpoch )
virtual

This is called indirectly from the request queue to indicate that the evaluation has been completed.

This is called when the 'evaluation time' (i.e.: the logical time that it takes to perform an evaluation) has elapsed. It is at this point we actually invoke the physical code to complete the evaluation (i.e.: the physical code is executed on the 'falling edge' of the evaluation time).

Parameters
aSimTimeThe current simulation time.
aLocalTrackIdThe ID of the local track that is being evaluated.
aEvaluationEpochThe epoch used for check for obsolete evaluations.
Returns
If less than zero then the request is complete. If greater than or equal to zero then it is the additional time that is required to complete the request.

References WsfSimulation::AddEvent(), EvaluateTrack(), WsfLocalTrackStatus::EvaluationEpoch(), GetSimulation(), WsfLocalTrackStatus::GetStateIndex(), mClearSignalOnStateExit, mEvalIntervalByIndex, mEvaluationInterval, mSignalVarPtr, mTimeToEvalByIndex, mTrackStatusList, mTransitionTime, and WsfLocalTrackStatus::TransitionPending().

◆ ExitState()

void WsfTrackStateController::ExitState ( int aStateIndex)
virtual

The following is invoked from the state machine to indicate that we are exiting the current state.

Parameters
aStateIndexThe state that we are leaving.

When processing a SIGNAL message, we must clear the SIGNAL variable when the state is exited.

References WsfSimulation::GetPlatformByIndex(), GetSimulation(), mClearSignalOnStateExit, mEvaluationSimTime, mEvaluationTrackPtr, mPlatformPtr, mProcessorPtr, mShowStateTransitions, mSignalVarPtr, mStateMachinePtr, platformPtr, and WsfObserver::StateExit().

◆ GetPlatform()

WsfPlatform * WsfTrackStateController::GetPlatform ( ) const
inline

Get the platform to which the controller is attached.

References mPlatformPtr.

◆ GetProcessor()

WsfProcessor * WsfTrackStateController::GetProcessor ( ) const
inline

Get the processor to which the controller is attached.

References mProcessorPtr.

◆ GetSimulation()

WsfSimulation * WsfTrackStateController::GetSimulation ( ) const

◆ Initialize()

◆ IsTurnedOn()

bool WsfTrackStateController::IsTurnedOn ( ) const
inline

References mIsTurnedOn.

◆ LocalTrackDropped()

void WsfTrackStateController::LocalTrackDropped ( double aSimTime,
const WsfLocalTrack * aLocalTrackPtr )
protected

◆ LocalTrackInitiated()

void WsfTrackStateController::LocalTrackInitiated ( double aSimTime,
const WsfLocalTrack * aLocalTrackPtr,
const WsfTrack * aRawTrackPtr )
protected

Handle 'local track initiation' events (A callback from WsfTrackManager).

References DiscoverTrack(), WsfTrack::IsCandidate(), and mEvaluateCandidateTracks.

Referenced by ConnectCallbacks().

◆ PreConstruct()

◆ ProcessInput()

◆ ProcessMessage()

◆ RequestEvaluation()

void WsfTrackStateController::RequestEvaluation ( double aSimTime,
const WsfTrackId & aLocalTrackId,
unsigned int aEvaluationEpoch )
virtual

Request that an evaluation be performed on the specified local track. This is called from the RequestEvaluationEvent to start the process of evaluating a track. An evaluation request is formed and passed to the request queue where it will be assigned a 'thinker'. If the local track status has been dropped then the request will be ignored.

Parameters
aSimTimeThe current simulation time.
aLocalTrackIdThe ID of the local track to be evaluated.
aEvaluationEpochThe evaluation epoch used for detecting obsolete events.

References DeleteTrack(), WsfLocalTrackStatus::EvaluationEpoch(), mTrackStatusList, and SubmitRequest().

◆ SetEvaluationInterval()

void WsfTrackStateController::SetEvaluationInterval ( double aEvaluationInterval)
inline

Dynamically redefine the evaluation interval to be used for scheduling the next evaluation.

Note
This is provided to be called by user scripts during the current evaluation.

References mEvaluationInterval.

◆ SetTransitionTime()

void WsfTrackStateController::SetTransitionTime ( double aTransitionTime)
inline

Dynamically specify the transition delay to be applied when transitioning to a new state.

Note
This is provided to be called by user scripts during the current evaluation.

References mTransitionTime.

◆ StateOfTrack()

WsfStringId WsfTrackStateController::StateOfTrack ( const WsfTrackId & aLocalTrackId)
virtual

Returns the state name (ID) of a given track.

Parameters
aLocalTrackIdThe track ID of the local track to be evaluated.
Returns
The state name (ID) in which the track is currently in.

References WsfLocalTrackStatus::GetStateName(), and mTrackStatusList.

◆ SubmitRequest()

void WsfTrackStateController::SubmitRequest ( double aSimTime,
WsfLocalTrackStatus * aStatusPtr )
protected

Assign a server (thinker) to process the evaluation for the specified track.

Parameters
aSimTimeThe current simulation time.
aStatusPtrThe pointer to the track status to be evaluated.

References WsfLocalTrackStatus::GetStateIndex(), mThinkerPtr, mTimeToEvalByIndex, and WsfLocalTrackStatus::TransitionPending().

Referenced by RequestEvaluation().

◆ TrackManagerChanged()

void WsfTrackStateController::TrackManagerChanged ( double aSimTime,
WsfTrackManager * aNewManagerPtr )
protected

References mTrackListPtr, and mTrackManagerPtr.

Referenced by ConnectCallbacks().

◆ TracksInState() [1/2]

int WsfTrackStateController::TracksInState ( WsfStringId aStateName)
virtual

Return the count of tracks in the specified state name (ID).

Parameters
aStateNameThe name (ID) of the state of interest.

References mStateMachinePtr, and mTracksInState.

◆ TracksInState() [2/2]

void WsfTrackStateController::TracksInState ( WsfStringId aStateName,
std::vector< WsfLocalTrack * > & aTrackList )
virtual

Return the tracks that are in the specified state name (ID).

Parameters
aStateNameThe name (ID) of the state of interest.
aTrackListThe tracks in the state of interest.

References WsfLocalTrackStatus::GetLocalTrackId(), WsfLocalTrackStatus::GetStateIndex(), mStateMachinePtr, mTrackListPtr, mTracksInState, mTrackStatusList, and trackPtr.

◆ TurnOff()

void WsfTrackStateController::TurnOff ( double aSimTime)
virtual

The processor to which we're attached has been turned off.

References mCallbacks, mIsTurnedOn, and mTrackStatusList.

◆ TurnOn()

void WsfTrackStateController::TurnOn ( double aSimTime)
virtual

The processor to which we're attached has been turned on.

References ConnectCallbacks(), DiscoverTrack(), mIsTurnedOn, and mTrackListPtr.

Member Data Documentation

◆ mCallbacks

UtCallbackHolder WsfTrackStateController::mCallbacks
protected

Referenced by ConnectCallbacks(), and TurnOff().

◆ mClearSignalOnStateExit

bool WsfTrackStateController::mClearSignalOnStateExit
protected

◆ mContextPtr

◆ mEvalIntervalByIndex

std::vector<WsfRandomVariable> WsfTrackStateController::mEvalIntervalByIndex
protected

Evaluation interval by state index.

Referenced by EvaluationComplete(), Initialize(), and ProcessMessage().

◆ mEvalIntervalByName

std::map<WsfStringId, WsfRandomVariable> WsfTrackStateController::mEvalIntervalByName
protected

Evaluation interval by state name. This is only used during input processing and is invalid after initialization.

Referenced by Initialize(), ProcessInput(), and WsfTrackStateController().

◆ mEvaluateCandidateTracks

bool WsfTrackStateController::mEvaluateCandidateTracks
protected

◆ mEvaluationInterval

double WsfTrackStateController::mEvaluationInterval
protected

The dynamically-defined evaluation interval. If greater than zero, this value overrides the evaluation_interval for the current state. It is set to -1 prior to performing state evaluation. The user may call SetEvaluationInterval() during evaluation to update the value.

Referenced by EvaluateTrack(), EvaluationComplete(), PreConstruct(), ProcessMessage(), and SetEvaluationInterval().

◆ mEvaluationSimTime

double WsfTrackStateController::mEvaluationSimTime
protected

The following are used only to propagate data from the evaluator to the state machine enter/exit state callbacks.

Referenced by EnterState(), EnterState(), EvaluateTrack(), ExitState(), and PreConstruct().

◆ mEvaluationTrackId

WsfTrackId WsfTrackStateController::mEvaluationTrackId
protected

◆ mEvaluationTrackPtr

WsfLocalTrack* WsfTrackStateController::mEvaluationTrackPtr
protected

◆ mIsTurnedOn

bool WsfTrackStateController::mIsTurnedOn
protected

◆ mOnTrackDropScriptPtr

UtScript* WsfTrackStateController::mOnTrackDropScriptPtr
protected

◆ mPlatformPtr

◆ mProcessorPtr

◆ mShowStateTransitions

bool WsfTrackStateController::mShowStateTransitions
protected

◆ mSignalVarPtr

UtScriptData* WsfTrackStateController::mSignalVarPtr
protected

◆ mStateMachinePtr

◆ mStatusVarPtr

UtScriptData* WsfTrackStateController::mStatusVarPtr
protected

◆ mThinkerPtr

WsfTimeDelayQueue* WsfTrackStateController::mThinkerPtr
protected

◆ mTimeToEvalByIndex

std::vector<WsfRandomVariable> WsfTrackStateController::mTimeToEvalByIndex
protected

The time it takes to evaluate a state by state index.

Referenced by EvaluationComplete(), Initialize(), SubmitRequest(), and WsfTrackStateController().

◆ mTimeToEvalByName

std::map<WsfStringId, WsfRandomVariable> WsfTrackStateController::mTimeToEvalByName
protected

The time it takes to evaluate a state by state name. This is only used during input processing and is invalid after initialization.

Referenced by Initialize(), ProcessInput(), and WsfTrackStateController().

◆ mTrackListPtr

WsfLocalTrackList* WsfTrackStateController::mTrackListPtr
protected

◆ mTrackManagerPtr

WsfTrackManager* WsfTrackStateController::mTrackManagerPtr
protected

◆ mTracksInState

std::vector<int> WsfTrackStateController::mTracksInState
protected

The number of tracks in a state, indexed by state index.

Referenced by DeleteTrack(), DiscoverTrack(), EnterState(), EvaluateTrack(), Initialize(), TracksInState(), and TracksInState().

◆ mTrackStatusList

◆ mTrackVarPtr

UtScriptData* WsfTrackStateController::mTrackVarPtr
protected

◆ mTransitionTime

double WsfTrackStateController::mTransitionTime
protected

The dynamically-defined transition delay. If greater than zero, this value defines the time that must elapsed between exiting the current state and entering the next state. It is set to -1 prior to performing state evaluation. The user may call SetTransitionTime() during evaluation to update the value.

Referenced by EvaluateTrack(), EvaluationComplete(), PreConstruct(), ProcessMessage(), and SetTransitionTime().


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