|
WSF
|
#include <WsfTrackStateController.hpp>

Classes | |
| class | TrackStateMachine |
Public Member Functions | |
| WsfTrackStateController () | |
| WsfTrackStateController (WsfScriptContext &aContext) | |
| WsfTrackStateController (const WsfTrackStateController &aSrc, WsfScriptContext &aContext) | |
| virtual | ~WsfTrackStateController () |
| WsfPlatform * | GetPlatform () const |
| Get the platform to which the controller is attached. | |
| WsfProcessor * | GetProcessor () const |
| Get the processor to which the controller is attached. | |
Callbacks from the state machine (not part of the public interface). | |
| WsfPlatform * | mPlatformPtr |
| WsfProcessor * | mProcessorPtr |
| WsfTimeDelayQueue * | mThinkerPtr |
| WsfScriptContext * | mContextPtr |
| UtScript * | mOnTrackDropScriptPtr |
| TrackStateMachine * | mStateMachinePtr |
| WsfTrackManager * | mTrackManagerPtr |
| UtCallbackHolder | mCallbacks |
| WsfLocalTrackList * | mTrackListPtr |
| UtMappedList< WsfLocalTrackStatus, WsfTrackId > | mTrackStatusList |
| std::map< WsfStringId, WsfRandomVariable > | mTimeToEvalByName |
| std::vector< WsfRandomVariable > | mTimeToEvalByIndex |
| The time it takes to evaluate a state by state index. | |
| std::map< WsfStringId, WsfRandomVariable > | mEvalIntervalByName |
| std::vector< WsfRandomVariable > | mEvalIntervalByIndex |
| 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 |
| WsfLocalTrack * | mEvaluationTrackPtr |
| UtScriptData * | mSignalVarPtr |
| UtScriptData * | mStatusVarPtr |
| UtScriptData * | mTrackVarPtr |
| 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) |
| WsfSimulation * | GetSimulation () const |
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.
| WsfTrackStateController::WsfTrackStateController | ( | ) |
| WsfTrackStateController::WsfTrackStateController | ( | WsfScriptContext & | aContext | ) |
References mContextPtr, mStateMachinePtr, and PreConstruct().
| WsfTrackStateController::WsfTrackStateController | ( | const WsfTrackStateController & | aSrc, |
| WsfScriptContext & | aContext ) |
|
virtual |
References mStateMachinePtr.
|
protected |
Handle 'candidate track promotion' events (A callback from WsfTrackManager).
References DiscoverTrack(), and mEvaluateCandidateTracks.
Referenced by ConnectCallbacks().
| void WsfTrackStateController::ConnectCallbacks | ( | ) |
References CandidateTrackPromoted(), LocalTrackDropped(), LocalTrackInitiated(), mCallbacks, mIsTurnedOn, mTrackManagerPtr, and TrackManagerChanged().
Referenced by TurnOn().
|
protected |
Drop a local track (status). A local track has been dropped, so delete the associated local track status.
| aSimTime | The current simulation time. |
| aLocalTrackId | The 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().
|
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.
| aSimTime | The current simulation time. |
| aTrackPtr | The 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().
|
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.
| aSimTime | The current simulation time. |
| aLocalTrackId | The local track ID of the track. |
| aNewStateName | The name (string ID) of the desired state. |
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().
|
virtual |
The following is invoked from the state machine to indicate that we are entering a new state.
| aStateIndex | The state that we are entering. |
References WsfSimulation::GetPlatformByIndex(), GetSimulation(), mEvaluationSimTime, mEvaluationTrackPtr, mPlatformPtr, mProcessorPtr, mShowStateTransitions, mStateMachinePtr, platformPtr, and WsfObserver::StateEntry().
|
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.
| aSimTime | The current simulation time. |
| aStatusPtr | The pointer to the local track status to be evaluated. |
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().
|
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).
| aSimTime | The current simulation time. |
| aLocalTrackId | The ID of the local track that is being evaluated. |
| aEvaluationEpoch | The epoch used for check for obsolete evaluations. |
References WsfSimulation::AddEvent(), EvaluateTrack(), WsfLocalTrackStatus::EvaluationEpoch(), GetSimulation(), WsfLocalTrackStatus::GetStateIndex(), mClearSignalOnStateExit, mEvalIntervalByIndex, mEvaluationInterval, mSignalVarPtr, mTimeToEvalByIndex, mTrackStatusList, mTransitionTime, and WsfLocalTrackStatus::TransitionPending().
|
virtual |
The following is invoked from the state machine to indicate that we are exiting the current state.
| aStateIndex | The 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().
|
inline |
Get the platform to which the controller is attached.
References mPlatformPtr.
|
inline |
Get the processor to which the controller is attached.
References mProcessorPtr.
| WsfSimulation * WsfTrackStateController::GetSimulation | ( | ) | const |
References mPlatformPtr.
Referenced by DeleteTrack(), DiscoverTrack(), EnterState(), EnterState(), EvaluateTrack(), EvaluationComplete(), ExitState(), Initialize(), and ProcessMessage().
|
virtual |
References WsfRandomVariable::cPOSITIVE, GetSimulation(), mContextPtr, mEvalIntervalByIndex, mEvalIntervalByName, mOnTrackDropScriptPtr, mPlatformPtr, mProcessorPtr, mSignalVarPtr, mStateMachinePtr, mStatusVarPtr, mThinkerPtr, mTimeToEvalByIndex, mTimeToEvalByName, mTrackListPtr, mTrackManagerPtr, mTracksInState, mTrackVarPtr, and ok.
|
inline |
References mIsTurnedOn.
|
protected |
Handle 'local track dropped' events (A callback from WsfTrackManager).
References WsfTrack::GetTargetName(), WsfTrack::GetTrackId(), mContextPtr, mOnTrackDropScriptPtr, mPlatformPtr, mProcessorPtr, mShowStateTransitions, mTrackStatusList, and mTrackVarPtr.
Referenced by ConnectCallbacks().
|
protected |
Handle 'local track initiation' events (A callback from WsfTrackManager).
References DiscoverTrack(), WsfTrack::IsCandidate(), and mEvaluateCandidateTracks.
Referenced by ConnectCallbacks().
|
protected |
References mClearSignalOnStateExit, mContextPtr, mEvaluateCandidateTracks, mEvaluationInterval, mEvaluationSimTime, mEvaluationTrackPtr, mIsTurnedOn, mOnTrackDropScriptPtr, mPlatformPtr, mProcessorPtr, mShowStateTransitions, mSignalVarPtr, mStateMachinePtr, mStatusVarPtr, mThinkerPtr, mTrackListPtr, mTrackManagerPtr, mTrackVarPtr, and mTransitionTime.
Referenced by WsfTrackStateController(), WsfTrackStateController(), and WsfTrackStateController().
|
virtual |
|
virtual |
References WsfSimulation::AddEvent(), EvaluateTrack(), WsfStatusMessage::GetRequestId(), GetSimulation(), WsfLocalTrackStatus::GetStateIndex(), WsfStatusMessage::GetStatus(), WsfStatusMessage::GetStatusId(), WsfMessage::GetType(), WsfStatusMessage::GetTypeId(), mClearSignalOnStateExit, mEvalIntervalByIndex, mEvaluationInterval, mSignalVarPtr, mTrackStatusList, mTransitionTime, and WsfLocalTrackStatus::UpdateEvaluationEpoch().
|
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.
| aSimTime | The current simulation time. |
| aLocalTrackId | The ID of the local track to be evaluated. |
| aEvaluationEpoch | The evaluation epoch used for detecting obsolete events. |
References DeleteTrack(), WsfLocalTrackStatus::EvaluationEpoch(), mTrackStatusList, and SubmitRequest().
|
inline |
Dynamically redefine the evaluation interval to be used for scheduling the next evaluation.
References mEvaluationInterval.
|
inline |
Dynamically specify the transition delay to be applied when transitioning to a new state.
References mTransitionTime.
|
virtual |
Returns the state name (ID) of a given track.
| aLocalTrackId | The track ID of the local track to be evaluated. |
References WsfLocalTrackStatus::GetStateName(), and mTrackStatusList.
|
protected |
Assign a server (thinker) to process the evaluation for the specified track.
| aSimTime | The current simulation time. |
| aStatusPtr | The pointer to the track status to be evaluated. |
References WsfLocalTrackStatus::GetStateIndex(), mThinkerPtr, mTimeToEvalByIndex, and WsfLocalTrackStatus::TransitionPending().
Referenced by RequestEvaluation().
|
protected |
References mTrackListPtr, and mTrackManagerPtr.
Referenced by ConnectCallbacks().
|
virtual |
Return the count of tracks in the specified state name (ID).
| aStateName | The name (ID) of the state of interest. |
References mStateMachinePtr, and mTracksInState.
|
virtual |
Return the tracks that are in the specified state name (ID).
| aStateName | The name (ID) of the state of interest. |
| aTrackList | The tracks in the state of interest. |
References WsfLocalTrackStatus::GetLocalTrackId(), WsfLocalTrackStatus::GetStateIndex(), mStateMachinePtr, mTrackListPtr, mTracksInState, mTrackStatusList, and trackPtr.
|
virtual |
The processor to which we're attached has been turned off.
References mCallbacks, mIsTurnedOn, and mTrackStatusList.
|
virtual |
The processor to which we're attached has been turned on.
References ConnectCallbacks(), DiscoverTrack(), mIsTurnedOn, and mTrackListPtr.
|
protected |
Referenced by ConnectCallbacks(), and TurnOff().
|
protected |
Referenced by EvaluationComplete(), ExitState(), PreConstruct(), and ProcessMessage().
|
protected |
Referenced by Initialize(), LocalTrackDropped(), PreConstruct(), ProcessInput(), WsfTrackStateController(), and WsfTrackStateController().
|
protected |
Evaluation interval by state index.
Referenced by EvaluationComplete(), Initialize(), and ProcessMessage().
|
protected |
Evaluation interval by state name. This is only used during input processing and is invalid after initialization.
Referenced by Initialize(), ProcessInput(), and WsfTrackStateController().
|
protected |
Referenced by CandidateTrackPromoted(), EvaluateTrack(), LocalTrackInitiated(), PreConstruct(), ProcessInput(), and WsfTrackStateController().
|
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().
|
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().
|
protected |
|
protected |
Referenced by EnterState(), EnterState(), EvaluateTrack(), ExitState(), and PreConstruct().
|
protected |
Referenced by ConnectCallbacks(), IsTurnedOn(), PreConstruct(), TurnOff(), and TurnOn().
|
protected |
Referenced by Initialize(), LocalTrackDropped(), and PreConstruct().
|
protected |
Referenced by DeleteTrack(), DiscoverTrack(), EnterState(), EvaluateTrack(), ExitState(), GetPlatform(), GetSimulation(), Initialize(), LocalTrackDropped(), and PreConstruct().
|
protected |
Referenced by DeleteTrack(), DiscoverTrack(), EnterState(), EvaluateTrack(), ExitState(), GetProcessor(), Initialize(), LocalTrackDropped(), and PreConstruct().
|
protected |
Referenced by DeleteTrack(), DiscoverTrack(), EnterState(), ExitState(), LocalTrackDropped(), PreConstruct(), ProcessInput(), and WsfTrackStateController().
|
protected |
Referenced by EvaluationComplete(), ExitState(), Initialize(), PreConstruct(), and ProcessMessage().
|
protected |
|
protected |
Referenced by EnterState(), EvaluateTrack(), Initialize(), and PreConstruct().
|
protected |
Referenced by Initialize(), PreConstruct(), and SubmitRequest().
|
protected |
The time it takes to evaluate a state by state index.
Referenced by EvaluationComplete(), Initialize(), SubmitRequest(), and WsfTrackStateController().
|
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().
|
protected |
Referenced by EnterState(), EvaluateTrack(), Initialize(), PreConstruct(), TrackManagerChanged(), TracksInState(), and TurnOn().
|
protected |
Referenced by ConnectCallbacks(), EvaluateTrack(), Initialize(), PreConstruct(), and TrackManagerChanged().
|
protected |
The number of tracks in a state, indexed by state index.
Referenced by DeleteTrack(), DiscoverTrack(), EnterState(), EvaluateTrack(), Initialize(), TracksInState(), and TracksInState().
|
protected |
|
protected |
Referenced by EnterState(), EvaluateTrack(), Initialize(), LocalTrackDropped(), and PreConstruct().
|
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().