WsfSimulation

WsfSimulation

Static Methods

static int PlatformCount()

Return the number of active platforms in the simulation.

static WsfPlatform PlatformEntry(int aEntry)

Return the WsfPlatform object at the given entry in the list of active platforms, if aEntry is in the range [0, PlatformCount()). Otherwise a null reference will be returned.

Note

This is not the same as the platform’s index which can be used to retrieve a platform with FindPlatform, and which is constant for a given platform. PlatformEntry will therefore always return a valid WsfPlatform if aEntry is within the necessary range.

The following example can be used to loop over all the active platforms in a simulation:

for (int i = 0; i < WsfSimulation.PlatformCount(); i = i + 1)
{
   WsfPlatform p = WsfSimulation.PlatformEntry(i);
   ...
}
static WsfPlatform FindPlatform(string aPlatformName)
static WsfPlatform FindPlatform(int aPlatformIndex)

Return the platform with the specified name or index.

Note

The return value will be invalid if the specified platform does not exist. Use IsValid() method on the return value to ensure it is valid before performing any operations on it.

static WsfPlatform AddPlatform(WsfPlatform aPlatform, string aName)

Adds an instance of the supplied platform template (created by WsfSimulation.CreatePlatform below) to the simulation. The name to be assigned to the platform instance is specified by the ‘aName’ parameter. If the name is specified as a null string (“”) or “<default>”, a unique name will be generated and assigned.

The return value is a reference to the platform instance in the simulation, and is a COPY of the platform template supplied by the input argument.

Note

The return value will be a null reference if the platform could not be added to the simulation. IsValid() can be used on the return value to ensure to determine if the operation was successful.

Example:

WsfPlatform p = WsfSimulation.CreatePlatform("TARGET");
p.ProcessInput("side red");
p.ProcessInput("position 40n 89.5w heading 45 deg");
WsfPlatform pa = WsfSimulation.AddPlatform(p, "");    // Use a generated name
if (! pa.IsValid()) writeln("***** ERROR T=", TIME_NOW, " Could not add platform of type ", p.Type());
static WsfPlatform CreatePlatform(string aPlatformType)

Creates a platform template of the specified type. The return value is a reference to the created template which can subsequently be populated with the desired values and added to the simulation using WsfSimulation.AddPlatform above.

Note

The return value will be a null reference if the platform template could note be created. IsValid() can be used on the return value to ensure to determine if the operation was successful.

static void DeletePlatform(string aPlatformName)
static void DeletePlatform(int aPlatformIndex)

Remove the platform with the specified name or index from the simulation.

static string PlatformName(int aPlatformIndex)

Return the name of the platform given the index.

Note

The platform may not be active in the simulation.

static string PlatformType(int aPlatformIndex)

Return the type of the platform given the index.

Note

The platform may not be active in the simulation.

static int RandomSeed()

Returns the current simulation random seed.

static int RunNumber()

Returns the current simulation run number.

static Atmosphere GetAtmosphere()

Returns the current simulation Atmosphere object. This is a different object from the object created via Atmosphere.Construct().

static double EndTime()

Returns the scheduled end-time of the simulation, in seconds.

static void SetEndTime(double aEndTime)

Sets the scheduled end-time of the simulation, in seconds, to the greater of aEndTime and the current simulation time.

static void Terminate()

Terminates the simulation at the current time.

static bool IsRealtime()

Flag to check if the current simulation mode is realtime.

static double ClockRate()

Gets the current simulation clock_rate. This only has effect in realtime mode.

static void SetClockRate(double aClockRate)

Changes the simulation clock_rate. This only has effect in realtime mode.

static bool ScriptExists(string aScript)

Returns ‘true’ if a global script with the given name exists.

static Object Execute(string aScript)
static Object Execute(string aScript, Array<Object> aArgs)

Execute a global script with the given name and optional argument list. Returns the return value of the executed script.

Example:

int count = (int)WsfSimulation.Execute("SensorCount", {"airliner"} );
static bool ExecuteAtTime(double aSimTime, string aScript)
static bool ExecuteAtTime(double aSimTime, string aScript, Array<Object> aArgs)

Execute a global script at the given future simulation time with the given name and optional argument list. Return value indicates whether the supplied script exists in the global context.

static void SetStartDate(int aYear, int aMonth, int aDay)

Set the start date for the simulation.

Note

The methods SetStartDate, SetStart SetStartTime, and SetStartEpoch are special use methods and must be called before the initialization of any platforms that depend on the start date and time.

static void SetStartTime(int aHour, int aMinute, int aSecond)

Set the start time for the simulation.

Note

The methods SetStartDate, SetStart SetStartTime, and SetStartEpoch are special use methods and must be called before the initialization of any platforms that depend on the start date and time.

static void SetStartEpoch(double aEpoch)

Set the start epoch-value for the simulation.

Note

The methods SetStartDate, SetStart SetStartTime, and SetStartEpoch are special use methods and must be called before the initialization of any platforms that depend on the start date and time.

static string ExpandPathVariables(string aString)

Returns the input string after path variable substitution. See define_path_variable.

Example:

string CASE = WsfSimulation.ExpandPathVariables("$(CASE)"); # use to retrieve define_path_variable CASE MyCaseString
static Array<string> MainInputFiles()

Returns the list of top-level scenario files. These are the same files given to mission on the command line.

static string ClassificationString()

Returns the classification string of the scenario. See classification command for more details.

static Color ClassificationColor()

Returns the color {R, G, B} associated with the classification level of the scenario. See classification_levels command for more details.

static string Name()

Returns the name set by the simulation_name command. If no name was set, returns an empty string.

Cyber Methods

bool CyberAttack(WsfPlatform aTarget, string aAttackType)
bool CyberAttack(WsfPlatform aTarget, string aAttackType, WsfCyberAttackParameters aParameters)

A special use case to launch a cyber attack. Typically, cyber attacks are initiated from the platform scope against a target platform. However, not all cyber attacks fit this definition, such as in the case of embedded cyber. The AFSIM cyber framework considers such attacks as self-inflicted, as in the attacking platform is the same as the victim. This method allows self-targeting cyber attacks for use cases such as embedded cyber, from the global scope. The target platform ‘aTarget’ is also the attacker in this method, and uses the attack type ‘aAttackType’. ‘aAttackType’ must be a valid cyber_attack type.

The version of this method using WsfCyberAttackParameters allows for the passage of user defined parameters, in cases where effects associated with the attack can utilize or require such data.

Returns true if the command was successful or false if one of the arguments was incorrect.

Note

Be mindful that the attacker is also the victim in this call, especially in terms of defining cyber_protect for this platform. Any default cyber protection will also apply to any attack called in this way.

int CyberEngagementScanDelayStatus(string aAttackType, WsfPlatform aAttacker, WsfPlatform aTarget)
int CyberEngagementAttackDelayStatus(string aAttackType, WsfPlatform aAttacker, WsfPlatform aTarget)

Queries for truth regarding the delay of the scan or attack engagement specified by the parameters provided. The integer return value indicates the current delay in the cyber engagement progression in the following manner:

Return Value

Delay Type

0

Scan Delay

1

Attack Delay

2

Attack Detection Delay

3

Attack Recovery Delay

4

Unused in Core

5

None

As indicated above, a return value of none is the result of an engagement that is not active or ongoing, has no delays, or could not be found matching the user supplied parameters.

bool CyberScanCancel(string aAttackType, WsfPlatform aAttacker, WsfPlatform aTarget)
bool CyberAttackCancel(string aAttackType, WsfPlatform aAttacker, WsfPlatform aTarget)

Ends a scan or attack engagement, specified by the parameters provided, immediately during the current delay phase. The effect on the cyber engagement progression depends on the delay phase in which the engagement is canceled.

  • An attack or scan canceled during their initial delay will prevent the attack or scan and any subsequent actions.

  • An attack canceled during a detection delay will prevent subsequent detection and recovery by the target.

  • An attack canceled during attack recovery delay will not recover.

This method returns true if the engagement was successfully found and canceled. It will return false if the engagement could not be found with the provided parameters, or if the engagement is not active.