12#ifndef WSFBEHAVIORTREENODE_HPP
13#define WSFBEHAVIORTREENODE_HPP
20#include "wsf_export.h"
70 static void Reset() { mNextUniqueId = 0; }
72 bool PreconditionsMet();
73 double PreconditionValue();
87 bool Execute(
double aSimTime,
88 bool aSkipCheck =
false);
92 void SetFailureReason(
const std::string& aReason,
bool aSendEvent =
false);
97 void SetExecutedLastRun(
bool aVal);
98 void SetExecutedLastRunRecursive(
bool aVal);
99 void SetExecutedLastRun(
bool aVal,
const std::string& aReason);
100 void SetExecutedLastRunRecursive(
bool aVal,
const std::string& aReason);
108 bool TryRunLast(
double aSimTime);
109 bool ShouldRunNext(
double aSimTime);
112 unsigned int Id()
const {
return mId; }
114 void LogNodeStructure(
double aSimTime,
bool aRecurse);
118 void SetFilePath(
const std::string& aPath);
119 void SetFileInfo(
const std::string& aPath, time_t aModTime);
122 void FindLastExecuted(std::vector<WsfBehaviorTreeNode*>& aLastExecuted);
125 UtScriptContext* GetScriptAccessibleContext()
const override;
128 virtual bool ProcessMessage(
double aSimTime,
const WsfMessage& aMessage);
162 static unsigned int mNextUniqueId;
170 LoadResult
LoadType(UtInput& aInput)
override;
177 bool aRegisterPlatformVariable =
true,
178 bool aRegisterProcessorVariable =
true);
194 UtScript* mOnInitScriptPtr;
195 UtScript* mExecuteScriptPtr;
202 UtScriptContext*
GetContext(
void* aObjectPtr)
override;
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
bool RegisterExternVariable(const std::string &aVariableType, const std::string &aVariableName)
Definition WsfBehaviorTreeNode.cpp:928
void SetTree(WsfBehaviorTree *aTreePtr) override
Definition WsfBehaviorTreeNode.cpp:922
bool Initialize(double aSimTime, WsfScriptContext *aParentContextPtr) override
Definition WsfBehaviorTreeNode.cpp:864
void RegisterInput(UtInput &aInput) override
Definition WsfBehaviorTreeNode.cpp:852
WsfBehaviorTreeLeafNode & operator=(const WsfBehaviorTreeLeafNode &aRhs)=delete
bool LocalExecute(double aSimTime) override
Definition WsfBehaviorTreeNode.cpp:896
~WsfBehaviorTreeLeafNode() override=default
WsfBehaviorTreeLeafNode(WsfScenario &aScenario, bool aRegisterPlatformVariable=true, bool aRegisterProcessorVariable=true)
Definition WsfBehaviorTreeNode.cpp:762
LoadResult LoadType(UtInput &aInput) override
Definition WsfBehaviorTreeNode.cpp:58
WsfBehaviorTreeNodeTypes(WsfScenario &aScenario)
Definition WsfBehaviorTreeNode.cpp:45
Definition WsfBehaviorTreeNode.hpp:38
std::string mFullPathFileName
Definition WsfBehaviorTreeNode.hpp:145
bool mTurnedOn
Definition WsfBehaviorTreeNode.hpp:133
void TurnOff()
Definition WsfBehaviorTreeNode.hpp:90
friend class WsfBehaviorTreeLeafNode
Definition WsfBehaviorTreeNode.hpp:39
UtScript * mNewExecuteScriptPtr
Definition WsfBehaviorTreeNode.hpp:139
RunType
Definition WsfBehaviorTreeNode.hpp:48
@ ForTime
Definition WsfBehaviorTreeNode.hpp:50
@ Repeat
Definition WsfBehaviorTreeNode.hpp:49
@ UntilDone
Definition WsfBehaviorTreeNode.hpp:51
std::vector< WsfBehaviorTreeNode * > & Children()
Definition WsfBehaviorTreeNode.hpp:76
UtScript * mNewFailScriptPtr
Definition WsfBehaviorTreeNode.hpp:140
int mRepeats
Definition WsfBehaviorTreeNode.hpp:148
friend class WsfBehaviorTreeSequenceNode
Definition WsfBehaviorTreeNode.hpp:40
WsfBehaviorTreeNode * Parent()
Definition WsfBehaviorTreeNode.hpp:80
const WsfScenario & mScenario
Definition WsfBehaviorTreeNode.hpp:131
WsfBehaviorTreeNode * mParentPtr
Definition WsfBehaviorTreeNode.hpp:135
std::vector< WsfBehaviorTreeNode * > mChildren
Definition WsfBehaviorTreeNode.hpp:136
int mRepeatsLeft
Definition WsfBehaviorTreeNode.hpp:151
void SetParent(WsfBehaviorTreeNode *aNodePtr)
Definition WsfBehaviorTreeNode.hpp:79
static void Reset()
Definition WsfBehaviorTreeNode.hpp:70
int ChildCount() const
Definition WsfBehaviorTreeNode.hpp:77
WsfBehaviorTree * mParentTreePtr
Definition WsfBehaviorTreeNode.hpp:134
UtScript * mPreconditionScriptPtr
Definition WsfBehaviorTreeNode.hpp:138
WsfScriptMessageHandler * mMessageHandlerPtr
Definition WsfBehaviorTreeNode.hpp:158
SelectType
Definition WsfBehaviorTreeNode.hpp:55
@ Continous
Definition WsfBehaviorTreeNode.hpp:56
@ Finite
Definition WsfBehaviorTreeNode.hpp:57
const WsfScenario & GetScenario() const
Definition WsfBehaviorTreeNode.hpp:126
WsfBehaviorTreeNode(const WsfScenario &aScenario)
Definition WsfBehaviorTreeNode.cpp:101
unsigned int mId
Definition WsfBehaviorTreeNode.hpp:144
RunType mRunType
Definition WsfBehaviorTreeNode.hpp:147
bool mLastExecute
Definition WsfBehaviorTreeNode.hpp:143
double mRunDuration
Definition WsfBehaviorTreeNode.hpp:149
WsfBehaviorTreeNode & operator=(const WsfBehaviorTreeNode &)=delete
friend class WsfBehaviorTreePrioritySelectorNode
Definition WsfBehaviorTreeNode.hpp:43
void TurnOn()
Definition WsfBehaviorTreeNode.hpp:89
WsfScriptStateMachine * mFiniteStateMachinePtr
Definition WsfBehaviorTreeNode.hpp:156
bool mDebug
Definition WsfBehaviorTreeNode.hpp:159
WsfScriptContext & GetScriptContext()
Definition WsfBehaviorTreeNode.hpp:85
int mStateIndex
Definition WsfBehaviorTreeNode.hpp:157
static unsigned int GetUniqueNodeId(void)
Definition WsfBehaviorTreeNode.hpp:69
time_t mFileLastModTime
Definition WsfBehaviorTreeNode.hpp:146
friend class WsfBehaviorTreeWeightedRandomNode
Definition WsfBehaviorTreeNode.hpp:44
SelectType mSelectType
Definition WsfBehaviorTreeNode.hpp:153
std::string mFailureReason
Definition WsfBehaviorTreeNode.hpp:141
WsfObject * Clone() const override=0
friend class WsfBehaviorTreeParallelNode
Definition WsfBehaviorTreeNode.hpp:42
WsfScriptContext * mContextPtr
Definition WsfBehaviorTreeNode.hpp:137
WsfBehaviorTreeNode * mLastNodeSelectedPtr
Definition WsfBehaviorTreeNode.hpp:150
friend class WsfBehaviorTreeSelectorNode
Definition WsfBehaviorTreeNode.hpp:41
bool ExecutedLastRun()
Definition WsfBehaviorTreeNode.hpp:95
bool mInitialized
Definition WsfBehaviorTreeNode.hpp:132
double mRunStartTime
Definition WsfBehaviorTreeNode.hpp:152
double mFailureTime
Definition WsfBehaviorTreeNode.hpp:142
std::string FilePath() const
Definition WsfBehaviorTreeNode.hpp:116
std::string FailureReason() const
Definition WsfBehaviorTreeNode.hpp:93
time_t FileLastModTime() const
Definition WsfBehaviorTreeNode.hpp:117
virtual bool LocalExecute(double aSimTime)=0
int mSelectCount
Definition WsfBehaviorTreeNode.hpp:155
int mSelectLimit
Definition WsfBehaviorTreeNode.hpp:154
unsigned int Id() const
Definition WsfBehaviorTreeNode.hpp:112
virtual void RegisterInput(UtInput &aInput)
Definition WsfBehaviorTreeNode.hpp:67
WsfBehaviorTreeParallelNode(const WsfScenario &aScenario)
Definition WsfBehaviorTreeNode.cpp:1031
bool LocalExecute(double aSimTime) override
Definition WsfBehaviorTreeNode.cpp:1045
WsfBehaviorTreePrioritySelectorNode(WsfScenario &aScenario)
Definition WsfBehaviorTreeNode.cpp:1064
bool LocalExecute(double aSimTime) override
Definition WsfBehaviorTreeNode.cpp:1079
WsfBehaviorTreeSelectorNode(WsfScenario &aScenario)
Definition WsfBehaviorTreeNode.cpp:986
bool LocalExecute(double aSimTime) override
Definition WsfBehaviorTreeNode.cpp:1000
bool LocalExecute(double aSimTime) override
Definition WsfBehaviorTreeNode.cpp:956
WsfBehaviorTreeSequenceNode(WsfScenario &aScenario)
Definition WsfBehaviorTreeNode.cpp:941
WsfBehaviorTreeWeightedRandomNode(WsfScenario &aScenario)
Definition WsfBehaviorTreeNode.cpp:1144
bool LocalExecute(double aSimTime) override
Definition WsfBehaviorTreeNode.cpp:1159
Definition WsfBehaviorTree.hpp:31
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
WsfObjectTypeList(WsfScenario &aScenario, unsigned int aFlags, const std::string &aBlockName)
Definition WsfObjectTypeList.hpp:76
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
virtual WsfObject * Clone() const =0
virtual bool ProcessInput(UtInput &aInput)
Definition WsfObject.cpp:140
const char * GetScriptClassName() const override
Definition WsfObject.cpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
UT_DECLARE_SCRIPT_METHOD(Executed)
UT_DECLARE_SCRIPT_METHOD(TurnOn)
UT_DECLARE_SCRIPT_METHOD(ChildEntry)
WsfScriptBehaviorTreeNodeClass(const std::string &aClassName, UtScriptTypes *aScriptTypesPtr)
Definition WsfBehaviorTreeNode.cpp:691
UtScriptContext * GetContext(void *aObjectPtr) override
Definition WsfBehaviorTreeNode.cpp:705
UT_DECLARE_SCRIPT_METHOD(Id)
UT_DECLARE_SCRIPT_METHOD(Parent)
UT_DECLARE_SCRIPT_METHOD(TurnOff)
UT_DECLARE_SCRIPT_METHOD(Failure)
UT_DECLARE_SCRIPT_METHOD(ChildCount)
Definition WsfScriptContext.hpp:71
Definition WsfScriptMessageHandler.hpp:42
WsfScriptObjectClass(const std::string &aClassName, UtScriptTypes *aTypesPtr)
Definition WsfScriptObjectClass.cpp:24
Definition WsfScriptProcessor.hpp:43
Definition WsfScriptStateMachine.hpp:47
The main controller for a simulation.
Definition WsfSimulation.hpp:109