![]() |
VR-Forces 5.0.3 Developer's Guide
|
This class is a two-way interface between the script language and its parent controller. There are functions that either the parent controller will call on the script interface (such as tick() ) and there will be functions the script interface will call on the parent controller to inform the parent of status updates and for data access.

Classes | |
| class | DtScriptFunctionReference |
| struct | PostSetDataCallbackLessThan |
Public Types | |
| typedef boost::shared_ptr < DtScriptFunctionReference > | DtScriptFunctionReferencePtr |
| typedef std::pair < DtGenericMessageType, DtScriptFunctionReferencePtr > | DtPostCallbackEntry |
| typedef std::set < DtPostCallbackEntry, PostSetDataCallbackLessThan > | DtPostSetDataCallbackSet |
| typedef std::vector < DtSimMessage * > | DtSetDataMessageVector |
| typedef std::map < DtPostCallbackEntry, bool > | DtPostCallbackEntryPendingChanges |
Public Member Functions | |
| virtual | ~DtScriptInterface () |
| virtual bool | invokeInit ()=0 |
| virtual void | invokeSuspend ()=0 |
| virtual bool | invokeResume ()=0 |
| virtual void | invokeTick ()=0 |
| virtual bool | loadScript (bool reload=false)=0 |
| virtual void | invokeCheckInit ()=0 |
| virtual bool | invokeCheck ()=0 |
| virtual void | invokeShutdown ()=0 |
| virtual void | invokeUpdateDisplayGraph ()=0 |
| virtual void | invokeDisable ()=0 |
| virtual DtString | type () const =0 |
| virtual void | setTaskId (int taskId) |
| virtual int | taskId () const |
| virtual void | setScriptId (const DtString &scriptId) |
| virtual const DtGenericMessageType & | scriptId () const |
| virtual void | setSystemName (const DtString &system) |
| virtual const DtString & | systemName () const |
| virtual void | setScriptPath (const DtFilename &scriptPath) |
| virtual const DtFilename & | scriptPath () const |
| virtual void | setEntity (DtLocalObject *entity) |
| virtual DtLocalObject * | entity () const |
| virtual void | init () |
| virtual void | setTaskVariables (const DtRwVariableBindings &variables) |
| virtual const DtRwVariableBindings & | taskVariables () const |
| virtual bool | updateTaskVariables () |
| virtual DtReaderWriter * | saveState ()=0 |
| virtual bool | loadState (const DtReaderWriter *savedState)=0 |
| virtual void | processClearForReuse () |
| virtual void | setTaskStarting (bool v) |
| virtual bool | taskStarting () const |
| virtual bool | isGraphCapable () const |
| virtual void | setIsGraphCapable (bool isCapable=true) |
| virtual bool | shouldGenerateGraphOutput () const |
| virtual void | setShouldGenerateGraphOutput (const bool doGenerate, const DtUUID &sender) |
| virtual void | processGraphCommands (const std::string &dotFileName) |
| virtual void | setController (DtScriptTaskControllerInterface *controller) |
| virtual DtScriptTaskControllerInterface * | controller () |
| virtual void | processEntityDestroyed () |
| virtual void | invokePostSetDataCallback (DtScriptFunctionReferencePtr functionReference, DtSetDataRequestMessage *setDatRequest)=0 |
| virtual double | getTerrainAltitude (const double lat, const double lon, bool &dataAvailable, std::string &surface) const |
| virtual double | getTerrainAltitudeBelow (const DtLocation3D &point, bool &available, std::string &surfaceString) const |
| virtual double | getGroundAltitude (const double lat, const double lon, bool &isWater, bool &dataAvailable) |
| virtual void | chordIntersectionDebug (const DtLocation3D &startLoc, const DtLocation3D &endLoc) |
| virtual bool | doesChordHitTerrain (const DtLocation3D &pt1, const DtLocation3D &pt2, bool &dataAvailable) const |
| bool | chordIntersectsTerrain (const DtLocation3D &pt1, const DtLocation3D &pt2, bool &dataAvailable, DtLocation3D &intersection) const |
| virtual DtLocation3D | findClosestPointInNavigationArea (const DtLocation3D &point, bool &error) const |
| virtual DtLocation3D | findClosestPointInNavigationAreaInRadius (const DtLocation3D &point, const double radius, bool &error) const |
| virtual DtLocation3D | findClosestPointInNavigationAreaInRadiusAndVertLimit (const DtLocation3D &point, const double radius, const double verticalLimit, bool &error) const |
| bool | findFarthestPositionAlongHeading (const DtLocation3D &point, const double heading, const double maxDistance, DtLocation3D &stopPoint, double &distanceReached) const |
| virtual DtLocation3D | findClosestPointToRoad (const DtLocation3D &point, double searchRadius, bool &dataAvailable, bool &success, DtLocation3D &endA, DtLocation3D &endB, double &offsetToOutsideLane) const |
| virtual std::list< std::string > | getDynamicTerrainFeatureChangeTypes (const DtLocation3D &location, double radius, bool &dataVailable) |
| virtual std::list< DtLocation3D > | getDynamicTerrainFeatureLocationsForChangeType (const std::string &changeType, const DtLocation3D &location, double radius, bool &dataVailable) |
| virtual std::list< std::string > | getDynamicTerrainFeatureValuesForChangeType (const std::string &changeType, const DtLocation3D &location, double radius, bool &dataVailable) |
| virtual void | changeDynamicTerrain (const std::string &changeType, const std::string &changeValue, const DtLocation3D &location, double radius) |
| bool | forcesHostile (std::string force1, std::string force2) |
| std::list< std::string > | entityTypesForEquipment (const std::string &equipmentType) |
| virtual double | gaussian () |
| virtual void | setGraphCapable () |
| virtual void | setTaskResuming (bool v) |
| virtual bool | taskResuming () const |
| virtual void | setIsBackgroundProces (bool isBgProc) |
| virtual bool | isBackgroundProcess () const |
| virtual void | setIsSet (bool isSet) |
| virtual bool | isSet () const |
Protected Member Functions | |
| DtScriptInterface (DtSimulationServices *) | |
| DtScriptInterface (const DtScriptInterface &other) | |
| DtScriptInterface & | operator= (const DtScriptInterface &other) |
| virtual void | scriptTaskComplete (bool success) |
| virtual void | scriptTaskError () |
| virtual bool | scriptText (DtString &text) |
| virtual bool | scriptPath (DtString &path) |
| virtual const DtReaderWriter * | getTaskParam (const DtString ¶mName) |
| virtual bool | getParamMetaDataType (const DtString ¶mName, DtString &typeName) |
| typedef boost::shared_ptr<DtScriptFunctionReference> DtScriptInterface::DtScriptFunctionReferencePtr |
Shared ptr to DtScriptFunctionReference.
| typedef std::pair<DtGenericMessageType, DtScriptFunctionReferencePtr> DtScriptInterface::DtPostCallbackEntry |
Matches a set data request type with a DtScriptFunctionReferencePtr.
| typedef std::set<DtPostCallbackEntry, PostSetDataCallbackLessThan> DtScriptInterface::DtPostSetDataCallbackSet |
| typedef std::vector<DtSimMessage*> DtScriptInterface::DtSetDataMessageVector |
| typedef std::map<DtPostCallbackEntry, bool> DtScriptInterface::DtPostCallbackEntryPendingChanges |
|
protected |
Call the DtScriptInterfaceHandler::createScriptInterface() function to create one.
|
protected |
|
virtual |
|
protected |
|
pure virtual |
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
This will be called by the parent to invoke the script tick.
Implemented in DtLuaScriptInterfaceImpl.
This will be called by the parent to let the interface know when to load the script.
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Called when graphs are enabled to get an immediate graph output.
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Only called for reactive tasks which can be enabled but not active. When the task is completely disabled, this should be invoked.
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Script engine type.
Implemented in DtLuaScriptInterfaceImpl.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Derived class inits may do things, so init should always be called.
Reimplemented in DtLuaScriptInterfaceImpl.
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
|
pure virtual |
Called when the scenario is saved. The stateState pointer may not be valid, in which case something went wrong with saving.
Implemented in DtLuaScriptInterfaceImpl.
|
pure virtual |
Called when the scenario is loaded. The load state pointer may not be valid, which does not indicate that the scenario loaded incorrectly, but that the data for this particular script interface was either corrupt or did not exist.
Implemented in DtLuaScriptInterfaceImpl.
|
virtual |
This function should be overridden by the inheritor to clear out any task specific variables. This version should probably be called last if you override it rather than first to take care of things before these things get cleared. Note: This function should only be used when a script interface is being reused between different controllers/vrfObjects (to keep from having to delete and recreate the script interface).
Reimplemented in DtLuaScriptInterfaceImpl.
|
virtual |
|
virtual |
|
virtual |
Flag indicating if the task is resuming from a suspended state.
|
virtual |
Flag indicating if the task is resuming from a suspended state.
|
virtual |
Flag indicating if this task is a background process.
|
virtual |
Flag indicating if this task is a background process.
|
virtual |
Flag indicating if this a set process.
|
virtual |
Flag indicating if this a set process.
|
virtual |
Check whether this script is capable of generating graphs. This is normally called by the scriptMultiTaskController to respond to a graph-capable request from the GUI.
|
virtual |
Set whether this script is capable of generating graphs. This is normally called by setGraphCapable (below)
|
virtual |
Return value indicates that the script should generate graphical output of the script. This function can be called by a script.
|
virtual |
Sets the flag indicating that a script should (or shouldn't) generate graph output. If the flag is changed from false to true by this call, the script callback updateGraphDisplay() is called.
|
virtual |
Runs the dot program on the given file to generate svg graph output, and sends an object message to the GUI with the svg file name. Used (only) by the behavior engine, when generating graphs.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Can be overridden to perform some processing when the entity is destroyed.
Reimplemented in DtLuaScriptInterfaceImpl.
| double DtScriptInterface::scriptGetExerciseTime | ( | ) |
Returns wind speed in meters/second.
| int DtScriptInterface::scriptGetApplicationId | ( | ) |
Returns wind speed in meters/second.
| double DtScriptInterface::scriptGetSimulationTime | ( | ) |
Returns wind speed in meters/second.
| double DtScriptInterface::scriptGetTimeMultiplier | ( | ) |
Returns wind speed in meters/second.
| double DtScriptInterface::scriptGetTimeOfDay | ( | ) |
Returns wind speed in meters/second.
| double DtScriptInterface::scriptGetDateAndTimeOfDay | ( | ) |
Returns wind speed in meters/second.
| double DtScriptInterface::scriptGetWindSpeed | ( | ) |
Returns wind speed in meters/second.
| double DtScriptInterface::scriptGetWindDirection | ( | ) |
Returns wind direction in radians.
| double DtScriptInterface::scriptGetMagneticDeclination | ( | const DtLocation3D & | location | ) |
Returns magnetic declination in radians.
| DtScriptVrfObject DtScriptInterface::scriptGetVrfObjectByName | ( | const std::string | name | ) |
Returns wind speed in meters/second.
| DtScriptVrfObject DtScriptInterface::scriptGetVrfObjectByUUID | ( | const std::string | name | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printError | ( | const std::string | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printErrorToChannel | ( | const std::string | channel, |
| const std::string | message | ||
| ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printErrorTranslatableStream | ( | const DtTranslatableStream & | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printWarn | ( | const std::string | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printWarnToChannel | ( | const std::string | channel, |
| const std::string | message | ||
| ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printWarnTranslatableStream | ( | const DtTranslatableStream & | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printInfo | ( | const std::string | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printInfoToChannel | ( | const std::string | channel, |
| const std::string | message | ||
| ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printInfoTranslatableStream | ( | const DtTranslatableStream & | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printVerbose | ( | const std::string | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printVerboseToChannel | ( | const std::string | channel, |
| const std::string | message | ||
| ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printVerboseTranslatableStream | ( | const DtTranslatableStream & | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printDebug | ( | const std::string | message | ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printDebugToChannel | ( | const std::string | channel, |
| const std::string | message | ||
| ) |
Returns wind speed in meters/second.
| void DtScriptInterface::printDebugTranslatableStream | ( | const DtTranslatableStream & | message | ) |
Returns wind speed in meters/second.
| bool DtScriptInterface::entityTypeMatches | ( | const std::string & | , |
| const std::string & | |||
| ) |
Returns wind speed in meters/second.
| void DtScriptInterface::setTickPeriod | ( | double | ) |
Tick management. Will store information in PSR of controller only.
| void DtScriptInterface::setTickWhilePaused | ( | bool | ) |
Enables or disables ticking when simulation is paused.
| void DtScriptInterface::setRespondToNewSensorContacts | ( | bool | ) |
Set tick on new sensor contact. Will cause a script to set its next tick time to current sim time when new sensor information is available - either a new sensor contact or a contact reaching a higher CID level.
|
virtual |
Adds a callback to be invoked after the specified type of set data request is executed.
|
virtual |
Remove a callback invoked after the specified type of set data request is executed.
|
virtual |
Clear all post-set data request callbacks. This will remove set data request callbacks that would be invoked this tick.
|
static |
Callback registered to the set data manager. This callback will clone the DtSimMessage and add a post tick entry to the sim manager to invoke any lua callback functions registered for the specific set data request type.
|
virtual |
Returns wind speed in meters/second.
|
static |
Invokes any post-set data request callbacks for set data requests executed this tick. Removes itself as a post-tick entry on the DtSimManager, so it is only invoked when there is work to do.
|
virtual |
Invokes any post-set data request callbacks for set data requests executed this tick. Removes itself as a post-tick entry on the DtSimManager, so it is only invoked when there is work to do.
|
pure virtual |
Implement to invoke the function referenced by functionReference. setDatRequest contains the information to be set. If a script interface implementation will not make use of post-set data request callbacks, this can be a no-op.
Implemented in DtLuaScriptInterfaceImpl.
|
virtual |
Gets the terrain height at the given location. This function always makes a non-blocking call to the terrain interface (see documentation for DtTerrainInterface), even if dataAvailable is null; if dataAvailable is not null, then it is filled in with the result from the terrainInterface call indicating whether the altitude data is valid.
Note that in the Lua interface, dataAvailable and surface are pure_out_values, meaning that the arguments are not included in the function call, but are provided as additional return values of the function. E.g. use: height, valid, surfaceType = getTerrainAltitude(lat, lon)
|
virtual |
Same as getTerrainAltitude, but gets the terrain below the input point, not the highest terrain at the xy of the input point.
|
virtual |
Gets the height of the ground at the given location. If this point on the terrain is ground, then the value will be the same as that returned by getTerrainAltitude. However, if the terrain is water, then this function will return the altitude of the sea floor instead of the altitude of the water surface. This function always makes a non-blocking call to the terrain interface (see documentation for DtTerrainInterface), even if dataAvailable is null; if dataAvailable is not null, then it is filled in with the result from the terrainInterface call indicating whether the altitude data is valid.
Note that in the Lua interface, dataAvailable and surface are pure_out_values, meaning that the arguments are not included in the function call, but are provided as additional return values of the function.
|
virtual |
Script function for debugging chord-terrain intersections.
|
virtual |
Determines if the chord formed by (point1, point2) intersects the terrain. The ground surface and features are considered. Returns a boolean indicating whether the LOS is blocked, and provides a flag indicating if the result is valid (the terrain data was available). This function always makes a non-blocking call to the terrain interface (see documentation for DtTerrainInterface), even if dataAvailable passed in is null. The intersectionTime parameter is a number in [0,1] indicating where along the line segment the intersection occurred.
| bool DtScriptInterface::chordIntersectsTerrain | ( | const DtLocation3D & | pt1, |
| const DtLocation3D & | pt2, | ||
| bool & | dataAvailable, | ||
| DtLocation3D & | intersection | ||
| ) | const |
Like chordIntersectsTerrain() Returns boolean if terrain is blocked. On return, if dataAvailable is true, the terrain data was available (paged in). If dataAvailable is false, the terrain wasn't paged in yet and the result is inconclusive. If dataAvailable is true, then intersection will contain the location where terrain obstructs the chord from pt1 to pt2.
|
virtual |
These functions wrap the navArea findInsidePositionFromOutsidePosition. They find the nearest point on the nav area (that the point is in) that is also on the nav mesh, vs in an obstacle. Radius is the horizontal distance to search within, and vertLimit is the distance up and down to search within. @(.
|
virtual |
|
virtual |
| bool DtScriptInterface::findFarthestPositionAlongHeading | ( | const DtLocation3D & | point, |
| const double | heading, | ||
| const double | maxDistance, | ||
| DtLocation3D & | stopPoint, | ||
| double & | distanceReached | ||
| ) | const |
Wraps findFarthestPositionAlongHeading for nav area. However, it returns the distanceReached (computes it) instead of just a boolean maxDistanceReached.
|
virtual |
|
virtual |
Returns a list of the dynamic terrain feature change types in the specified area.
|
virtual |
Returns a list of the locations of dynamic terrain features with the given change type in the specified area.
|
virtual |
Returns a list of the possible values for the given change type for dynamic terrain features in the specified area.
|
virtual |
Causes the given change at the specified area of the terrain.
| bool DtScriptInterface::forcesHostile | ( | std::string | force1, |
| std::string | force2 | ||
| ) |
| std::list<std::string> DtScriptInterface::entityTypesForEquipment | ( | const std::string & | equipmentType | ) |
Looks in the vrfParameterDb for types that have a Primary-Equipment parameter property matching the given equipment type, and returns them in a list. The entity type is given in its string representation, e.g. "1:1:222:3:1:0:0".
|
virtual |
Returns a number drawn from a standard Gaussian distribution.
|
virtual |
Tells VRF (this script interface) that the script can generate a graph for display by the entity info panel on the GUI.
|
protectedvirtual |
This function is meant to be called by the script itself or the script object to tell the parent that the script task is complete. This call will mark this object for deletion.
|
protectedvirtual |
Returns the script text as a string and a bool on whether the text is valid or not.
Returns the path to this script.
|
protectedvirtual |
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Indicates that a new task is starting, and should be initialized on the next tick.
|
protected |
|
protected |
|
protected |
|
protected |
Callbacks registered from the scripting language. Registration/unregistration is done using vrf:addPostSetDataCallback and vrf:removePostSetDataCallback.
|
protected |
Stores copies of set data request messages that callbacks have been registered for. These are deleted after they are used in processPostTick.
|
protected |
If a post set data callback is added or removed while invoking callbacks add to this map instead of inserting or removing immediately. The map is DtPostCallbackEntry, bool where true == insert and false == remove.
|
protected |
If a set data request is executed while invoking callbacks, add it to this vector instead of mySetDataMessages. Messages will be moved from this to mySetDataMessages once we're done invoking callbacks. These copied messages will be processed the next time callbacks are invoked by default, the next simulation tick).
|
protected |
Set to true when invoking post set data callbacks.
|
protected |
Indicates the the script being run by this interface can generate graphs for processing and display in the entity info panel. This flag is set by the script itself using a vrf:setGraphCapable() call.
|
protected |
Indicates that this script should generate graphical output. This flag is made available to scripts through the vrf:generateGraphOutput() function, which calls doGenerateGraphOutput in this class. When the script calls that and it is true, the script generates a dot description in a file and calls vrf:processGraphCommands(). The script can do this test and generate repeatedly.
|
protected |
Keep track of who sends the graph requests, and send messages back to them.
|
protected |
Indicates that the dot program could not be found (and a message to that effect was printed).