Lists

Top  Previous  Next

Lists are a container for one or more FreeFlyer objects of the same type. The following examples show how to create, edit, and view output for various types of Lists. Keep in mind that only a selection of the possible types of Object List is shown here.

 

For information on collections of objects of different types, see the Structs page.

 

Note: The Save, Restore, Get, and Put commands cannot be used with Lists.

 

There are a variety of Sample Mission Plans (included with your FreeFlyer installation) that demonstrate various applications of this topic. Continue to the FreeFlyer Scripting Samples page to view descriptions and images of these examples.

 

 

Creating a List


Lists of objects can only be created in FreeFlyer script - they can't be created in the Object Browser. Angle brackets are used to specify the type of object List you are creating. The syntax for creating a List is:

 

List<Object Type> ListName;

 

To create Lists, use the following examples as a guide:

 

List<Array> MultiDimArray;

List<GroundStation> DSN;

List<ImpulsiveBurn> ApogeeManeuvers;

List<ReportInterface> OutputProducts;

List<Spacecraft> GPS;

List<Viewpoint> OrbitViews;

 

 

Setting the Length of a List


When you first create a List, it will be empty. To begin editing a List, start by setting its "Count", or length. This specifies how many elements the List will contain.

 

// Set the length of Object Lists

MultiDimArray.Count = 10;

DSN.Count = 3;

ApogeeManeuvers.Count = 4;

OutputProducts.Count = 2;

GPS.Count = 6;

OrbitViews.Count = 3;

 

Note that a List's count can also be set during its initial creation, as shown below:

 

List<Array> MultiDimArray[10];

List<GroundStation> DSN[3];

List<ImpulsiveBurn> ApogeeManeuvers[4];

List<ReportInterface> OutputProducts[2];

List<Spacecraft> GPS[6];

List<Viewpoint> OrbitViews[3];

 

The number of elements in a List can be increased or decreased at any time by changing the value of the List.Count. You can also use the List.Clear() method to reset the List back to empty. To remove individual elements from a List, use the List.RemoveAt() method, as shown below:

 

// Decrease the number of elements in a List:

ApogeeManeuvers.Count = 3;

 

// Remove the first element from a List:

ApogeeManeuvers.RemoveAt(0);

 

// Remove all elements from a List:

ApogeeManeuvers.Clear();

 

Note: When you remove elements from a List, the removed objects will continue to exist in memory if there were any other references to those objects. The object will be removed from the List, but the object will only be cleared completely from memory if the List was the only thing that held a reference to that object. References can be created in various ways, such as by the using reference assignment operator (:=), or by displaying the object in output views (e.g. the View command). References are also held when you use methods with state - you can call the ResetMethodStates() method on the object before clearing it from the List to remove those references. References are also held when you use the Save command; those references can be released by calling Object.ClearSavedStates().

 

 

Editing a List


Once the Count is set, you can edit the properties of the individual List elements. You can do this individually for each element, or use a For loop to set properties for all elements at once.

 

// Edit one element at a time

DSN[0].Latitude  = -35;

DSN[0].Longitude = 149;

DSN[1].Latitude  = 40;

DSN[1].Longitude = 355;

DSN[2].Latitude  = 35;

DSN[2].Longitude = 243;

 

// Edit all elements at once using a For loop

Variable i;

For i = 0 to GPS.Count-1;

 

     GPS[i].A = 26560;

     GPS[i].E = 0;

     GPS[i].RAAN = 60*i;

 

     Report GPS[i].A, GPS[i].E, GPS[i].RAAN;

End;

 

By including the indexing variable "i" in the expression for RAAN (Right Ascension of the Ascending Node), the GPS example above produces the following values:

 

GPS[i].A

GPS[i].E

GPS[i].RAAN

26560.000000000

0.000000000

 0.000000000

26560.000000000

0.000000000

60.000000000

26560.000000000

0.000000000

120.000000000

26560.000000000

0.000000000

180.000000000

26560.000000000

0.000000000

240.000000000

26560.000000000

0.000000000

300.000000000

 

You can also use reference assignment (the := operator) to configure an object contained within a List to refer to another object that you created separately. This will cause any references to that List element to refer to the specified object. The example below demonstrates using reference assignment with a GroundStation contained in a List:

 

GroundStation Madrid;

 

// Add another element to the DSN List<GroundStation>

DSN.Count++;

 

// Any references to DSN[3] will now point to the Madrid GroundStation object

DSN[3] := Madrid;

 

 

Setting the Propagator and Propagating and Maneuvering Lists of Spacecraft


When working with Lists of Spacecraft, please see the following sections of the Formations article:

 

Setting the Propagator for elements of a List of Spacecraft or Formation

Propagating and Maneuvering elements of a List of Spacecraft or Formation

 

 

Output and Visualization


Since Lists can only be created and edited in FreeFlyer Script, any visualization commands or objects must be configured in script as well. The following example shows how to create simple 2D and 3D views of a List of GroundStations and a List of Spacecraft using the View and Map commands:

 

While (GPS[0].ElapsedTime < TIMESPAN(1 days));

     View GPS, DSN;

     Map GPS, DSN;

     Step GPS;

End;

 

You can also add a List of viewable objects into a ViewWindow using the ViewWindow.AddObject() method:

 

ViewWindow vw();

 

vw.AddObject(GPS); // List<Spacecraft>

vw.AddObject(DSN); // List<GroundStation>

 

3D View showing a 3-element List of GroundStations and a 6-element List of Spacecraft

3D View showing a 3-element List of GroundStations and a 6-element List of Spacecraft

 

See Also


List<Object> Properties and Methods

Formation Properties and Methods

Structs page