24.2.3 The Global Command

 

Declaration of objects as Global is specified in the Mission Control Sequence and in Function Control Sequences using the Global command, which has syntax described in Table 24.?.

----------------------------------------------

Table 24.?: Global Command  (I don’t know how to do this table so it matches the existing ones *****)

 

ScriptSyntax:

Global ObjectName …

 

ObjectName Default: “”. Options: [ String]: The ObjectName option allows the user to specify the name(s) of the objects to be declared Global.  Names must be separated by blanks.  There is no limit to the number of items that can be declared Global on one line

 

Script Examples

 

% Declare a Spacecraft to be Global

Global Sat1;

% Declare 3 Variables to be Gobal

Global v1 v2 v3;

% Declare 4 Arrays to be Global

Global a1 arr1 array1 myArray1

% Declare objects of different types to be Global

Global Sat2 Burn3 v12

----------------------------------------------

 

Each Global command declares one or more objects to be Global.  Note that Coordinate Systems, Propagators, and Functions are automatically created as Global Objects.  Inclusion of an object of one of these types in a Global statement is not necessary, though this will not generate an error.

 

 

Parsing of The Global Command

 

Parsing of a Global Command is handled one of two ways depending on where it is encountered.   See Chapter 16 (“Script Reading and Writing”) for more information on how scripts are parsed in GMAT.

 

Object Mode

 

When the Global command is included in the main script, and the parsing is in object property mode, encountering a Global command results in the Interpreter toggling to Command Mode, with the Global command set as the first command in the Mission Control Sequence.

 

Command Mode

 

When the parsing of the main script is in command mode, or the Global command is found during parsing of a Gmat Function (which happens during control sequence initialization via a call to the Moderator::InterpretGmatFunction()), a Global command object is created.  The requested object name(s) are stored inside the Global command instance.  The Global command checks for name uniqueness at this point and displays a warning message to the user if there is a duplicate name.

 

 

Global Command Initialization

 

On initialization, each command in a sequence is given: 1) a pointer to the Solar System, 2) a pointer to the transient force vector, 3) a pointer to an object map that becomes the command’s Local Object Store (for commands in the main sequence, the Sandbox Object Map is passed in, so that configured objects can be found if needed; for a command in a Function Control Sequence, the Function Object Store is passed in); and 4) a pointer to the Global Object Store, which contains all objects that have already been declared to be Global, or are automatically Global.

 

No other action is taken by the Global command at initialization.

 

 

Global Command Execution

 

On execution, the Global command needs to insert its Global objects into the Global Object Store (GOS) it was passed on initialization, so that the objects may be used in the main sequence or in other functions.  It must also check its Local Object Store for the object, as the object is not allowed to be in both stores.  Its Local Object Store (LOS) is a pointer to either the Sandbox Object Store for Global commands in the main sequence, or to the Function Object Store for Global commands in function sequences.

 

The Global command follows the following procedure for each object in its list:

 

  1. check to see if the object is in the LOS
  2. if it is found in the LOS
    1. check the GOS for an object with the same name
    2. if it is not found in the GOS, remove the object from the LOS and put it into the GOS
    3. if it is found in the GOS, throw an exception, reporting that an object was found in the GOS with the same name as the one being added; this terminates the run
  3. if it is not in the LOS,
    1. check to see if it is in the GOS
    2. if it is not in the GOS or it is in the GOS but its pointer is NULL, throw an exception stating that the object was not created; this also terminates the run

 

Care must be taken to ensure that objects are included in only one object store, either the Local Object Store or the Global Object Store.

 

 

Global Command Attributes and Methods

 

The class design for the Global command is shown in Figure 24.?

 

Class Attributes

 

Each Global command instance contains the following data elements:

 

  • StringArray objNames: the names of the objects requested to be declared Global

 

Methods

 

The public methods implemented in the Global command are itemized here:

 

  • void SetStringParameter(const std::string &str): sets the names for the objects to be declared Global
  • StringArray GetStringArrayParameter(): to return the names of the objects
  • bool Initialize(): Performs initialization of the Global command
  • bool Execute(): Executes the Global command