![]() |
MAK RTIspy API Documentation for HLA 1.3
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2006 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: simpleTimeTimeManagedEntity.h,v $ $Revision: 1.3 $ $State: Exp $ 00007 *******************************************************************************/ 00008 #ifndef _TIMEMANAGEDOBJECTDEFINITION_ 00009 #define _TIMEMANAGEDOBJECTDEFINITION_ 00010 // A simple object that dictates the behavior of an advancing entity. 00011 #ifdef DtIFSPEC1516 00012 #include "simpleTimeAttribute1516.h" 00013 #include "simpleTimeInteraction1516.h" 00014 #elif defined(DtIFSPEC1516E) 00015 #include "simpleTimeAttribute1516e.h" 00016 #include "simpleTimeInteraction1516e.h" 00017 #else 00018 #ifdef DtIFSPEC13DLC 00019 #include "simpleTimeAttribute13dlc.h" 00020 #include "simpleTimeInteraction13dlc.h" 00021 #else 00022 #include "simpleTimeAttribute13.h" 00023 #include "simpleTimeInteraction13.h" 00024 #endif 00025 #endif 00026 #include <queue> 00027 00028 class timeManagedEntity 00029 { 00030 public: 00031 enum entity_state{ Alive = 0, 00032 FiredUpon = 1, 00033 Damaged = 2, 00034 Dead = 3 }; 00035 enum active_state{ Initial = 0, 00036 Firing = 1, 00037 SendDetonate = 3, 00038 Idle = 5}; 00039 00040 // constructor and destructor for timeManagedEntity 00041 timeManagedEntity(); 00042 ~timeManagedEntity(); 00043 00044 00045 // Peek at our queue's of attributes and Interaction to see if there 00046 // is an event waiting to be processed. 00047 bool attrUpdateWaiting(); 00048 bool interactionWaiting(); 00049 00050 // retreive an event from one of the event queue's 00051 attributeUpdateEvent* getNextAttrUpdateEvent(); 00052 interactionEvent* getNextInteractionEvent(); 00053 00054 // add an event to our event queue. 00055 void addAttrUpdateEvent(attributeUpdateEvent*); 00056 void addInteractionEvent(interactionEvent*); 00057 00058 // access this timeManagedEntity's state. 00059 bool shouldFire(); 00060 bool shouldDetonate(); 00061 bool isFiredUpon(); 00062 bool isDetonated(); 00063 00064 // Change this timeManagedEntity's state. 00065 void setPhaseLine(int phaseLine); 00066 void incPosition(); 00067 void firePressed(); 00068 void reset(); 00069 00070 // Sets myState to the correct Value. 00071 void tick(); 00072 00073 private: 00074 void sendFire(); 00075 void sendDetonate(); 00076 void processEvents(); 00077 00078 private: 00079 00080 bool myFirePressed; 00081 unsigned int myPosition; 00082 unsigned int myVelocity; 00083 00084 // myPhaseLine acts as a boundary for this federate. When the position of the timeManagedEntity is past 00085 // the myPhaseLine, the timeManagedEntity will start firing on other federates. 00086 unsigned int myPhaseLine; 00087 entity_state myPhysicalState; 00088 active_state myState; 00089 std::queue< attributeUpdateEvent* > myAttrUpdateQueue; 00090 std::queue< interactionEvent* > myInteractionQueue; 00091 }; 00092 00093 00094 #endif