Scripting Multiple Representations
You must address certain attributes as pairings or groupings in order to assure proper use. Below are descriptions and code samples for two main pairings: Facility.Position and Satellite.OrbitState. Also below are examples using the nonspecific type LINKTOOBJ, which is a pointer to a group of objects.
Facility.Position
Facility.Position is a multiple representation object. You must apply changes to the entire scope at once to ensure the proper coordinate transformation. To do that, first get position elements in one of the available representations: ToCartesian(), ToGeodetic(), ToGeocentric(), ToCylindrical(), and ToSpherical(). Then modify individual elements of the temp variable and assign them back as a group.
COM
set pos = scen.TrackingSystem(0).Facility(0).Position.ToGeodetic()
pos.Lat.Set 10, "deg"
pos.Lon.Set 20, "deg"
pos.Alt.Set 100, "m"
scen.TrackingSystem(0).Facility(0).Position.Assign pos
var pos = scen.TrackingSystem(0).Facility(0).Position.ToGeodetic();
pos.Lat.Set(10, "deg");
pos.Lon.Set(20, "deg");
pos.Alt.Set(100, "m");
scen.TrackingSystem(0).Facility(0).Position.Assign(pos);
my $pos = $scen->TrackingSystem(0)->Facility(0)->Position->ToGeodetic();
$pos->Lat->Set(10, "deg");
$pos->Lon->Set(20, "deg");
$pos->Alt->Set(100, "m");
$scen->TrackingSystem(0)->Facility(0)->Position->Assign($pos);
pos = scen.TrackingSystem(0).Facility(0).Position.ToGeodetic()
pos.Lat.Set(10, "deg")
pos.Lon.Set(20, "deg")
pos.Alt.Set(100, "m")
scen.TrackingSystem(0).Facility(0).Position.Assign(pos)
pos = scen.invoke('TrackingSystem').invoke('Item', 0).invoke('Facility').invoke('Item', 0).invoke('Position').invoke('ToGeodetic');
pos.invoke('Lat').invoke('Set', 10, 'deg');
pos.invoke('Lon').invoke('Set', 20, 'deg');
pos.invoke('Alt').invoke('Set', 100, 'm');
scen.invoke('TrackingSystem').invoke('Item', 0).invoke('Facility').invoke('Item', 0).invoke('Position').invoke('Assign', pos);
Cross-Platform API
def print_geodetic_pos(p):
print(f'Lat : {p.Lat.GetIn("deg")} deg, Lon: {p.Lon.GetIn("deg")} deg, Alt: {p.Alt.GetIn("m")} m')
pos = facility.Position.ToGeodetic()
print_geodetic_pos(pos)
pos.Lat.Set(10, 'deg')
pos.Lon.Set(20, 'deg')
pos.Alt.Set(100, 'm')
facility.Position.Assign(pos)
pos = facility.Position.ToGeodetic()
print_geodetic_pos(pos)
pos = facility.Position.ToGeodetic();
printGeodeticPos(pos);
pos.Lat.Set(10, 'deg');
pos.Lon.Set(20, 'deg');
pos.Alt.Set(100, 'm');
facility.Position.Assign(pos);
pos = facility.Position.ToGeodetic();
printGeodeticPos(pos);
const auto pos = facility("Position")("ToGeodetic").InvokeAttrProxy();
PrintGeodeticPos(pos);
pos("Lat")("Set").Invoke(10, "deg");
pos("Lon")("Set").Invoke(20, "deg");
pos("Alt")("Set").Invoke(100, "m");
facility("Position")("Assign").Invoke(pos);
const auto updatedPos = facility("Position")("ToGeodetic").InvokeAttrProxy();
PrintGeodeticPos(updatedPos);
AttrProxy pos = facility.get("Position.ToGeodetic").invokeAttr();
printGeodeticPos(pos);
pos.get("Lat.Set").invoke(10, "deg");
pos.get("Lon.Set").invoke(20, "deg");
pos.get("Alt.Set").invoke(100, "m");
facility.get("Position.Assign").invoke(pos);
pos = facility.get("Position.ToGeodetic").invokeAttr();
printGeodeticPos(pos);
Satellite.OrbitState
For Satellite.OrbitState, you must change the individual members defining the orbit state vector in a temp variable and then assign them back as a group.
COM
set kep = scen.Satellite(0).OrbitState.ToKeplerian()' Raise altitude by 10 km
newSize = kep.SemiMajorAxis.GetIn("km")
kep.SemiMajorAxis.Set newSize + 10, "km"
' Set the rest of the orbital elements
kep.Epoch.Set "1 Jul 2009 00:00:00", "UTCG"
kep.Eccentricity = 0.00123
kep.TrueArgOfLatitude.Set "33.3", "deg"
kep.Inclination.Set "67.8", "deg"
kep.RAAN.Set "321.123", "deg"
kep.ArgOfPerigee.Set "3.141592654", "rad"
scen.Satellite(0).OrbitState.Assign kep
var kep = scen.Satellite(0).OrbitState.ToKeplerian();
// Raise altitude by 10 km
var newSize = kep.SemiMajorAxis.GetIn("km");
kep.SemiMajorAxis.Set(newSize + 10, "km");
// Set the rest of the orbital elements
kep.Epoch.Set("1 Jul 2009 00:00:00", "UTCG");
kep.Eccentricity = 0.00123;
kep.TrueArgOfLatitude.Set("33.3", "deg");
kep.Inclination.Set("67.8", "deg");
kep.RAAN.Set("321.123", "deg");
kep.ArgOfPerigee.Set("3.141592654", "rad");
scen.Satellite(0).OrbitState.Assign(kep);
my $kep = $scen->Satellite(0)->OrbitState->ToKeplerian();# Raise altitude by 10 km
my $newSize = $kep->SemiMajorAxis->GetIn("km")->{Value};
$kep->SemiMajorAxis->Set($newSize + 10, "km");
# Set the rest of the orbital elements
$kep->Epoch->Set("1 Jul 2009 00:00:00", "UTCG");
$kep->Eccentricity->{Value} = 0.00123;
$kep->TrueArgOfLatitude->Set(33.3, "deg");
$kep->Inclination->Set(67.8, "deg");
$kep->RAAN->Set(321.123, "deg");
$kep->ArgOfPerigee->Set(3.141592654, "rad");
$scen->Satellite(0)->OrbitState->Assign($kep);
kep = scen.Satellite(0).OrbitState.ToKeplerian()
# Raise altitude by 10 km
newSize = kep.SemiMajorAxis.GetIn("km")
kep.SemiMajorAxis.Set(int(newSize) + 10, "km") #newSize must be casted to an integer to be able to add 10
# Set the rest of the orbital elements
kep.Epoch.Set("1 Jul 2009 00:00:00", "UTCG")
kep.Eccentricity = 0.00123
kep.TrueArgOfLatitude.Set("33.3", "deg")
kep.Inclination.Set("67.8", "deg")
kep.RAAN.Set("321.123", "deg")
kep.ArgOfPerigee.Set("3.141592654", "rad")
scen.Satellite(0).OrbitState.Assign(kep)
kep = scen.invoke('Satellite').invoke('Item', 0).invoke('OrbitState').invoke('ToKeplerian');
% Raise altitude by 10 km
newSize = kep.invoke('SemiMajorAxis').invoke('GetIn', 'km').invoke('Value');
kep.invoke('SemiMajorAxis').invoke('Set', newSize + 10, 'km');
% Set the rest of the orbital elements
kep.invoke('Epoch').invoke('Set', '1 Jul 2009 00:00:00', 'UTCG');
kep.set('Eccentricity', 0.00123);
kep.invoke('TrueArgOfLatitude').invoke('Set', '33.3', 'deg');
kep.invoke('Inclination').invoke('Set', '67.8', 'deg');
kep.invoke('RAAN').invoke('Set', '321.123', 'deg');
kep.invoke('ArgOfPerigee').invoke('Set', '3.141592654', 'rad');
scen.invoke('Satellite').invoke('Item', 0).invoke('OrbitState').invoke('Assign', kep);
Cross-Platform API
def print_keplerian_orbit_state(orbit_state):
print(f'Epoch : {orbit_state.Epoch.Format("UTCG")} UTCG, Eccentricity: {orbit_state.Eccentricity.eval()}, '
f'TrueArgOfLatitude: {orbit_state.TrueArgOfLatitude.GetIn("deg")} deg, '
f'Inclination: {orbit_state.Inclination.GetIn("deg")} deg, '
f'RAAN: {orbit_state.RAAN.GetIn("deg")} deg, ArgOfPerigee: {orbit_state.ArgOfPerigee.GetIn("rad")} rad')
kep = satellite.OrbitState.ToKeplerian()
print_keplerian_orbit_state(kep)
# Raise altitude by 10 km
newSize = kep.SemiMajorAxis.GetIn('km')
kep.SemiMajorAxis.Set(newSize + 10, 'km')
# Set the rest of the orbital elements
kep.Epoch.Set('1 Jul 2009 00:00:00', 'UTCG')
kep.Eccentricity = 0.00123
kep.TrueArgOfLatitude.Set('33.3', 'deg')
kep.Inclination.Set('67.8', 'deg')
kep.RAAN.Set('321.123', 'deg')
kep.ArgOfPerigee.Set('3.141592654', 'rad')
kep = satellite.OrbitState.Assign(kep)
print_keplerian_orbit_state(satellite.OrbitState.ToKeplerian())
kep = satellite.OrbitState.ToKeplerian();
printKeplerianOrbitState(kep);
% Raise altitude by 10 km
newSize = kep.SemiMajorAxis.GetIn("km");
kep.SemiMajorAxis.Set(newSize + 10, "km");
% Set the rest of the orbital elements
kep.Epoch.Set("1 Jul 2009 00:00:00", "UTCG");
kep.Eccentricity = 0.00123;
kep.TrueArgOfLatitude.Set("33.3", "deg");
kep.Inclination.Set("67.8", "deg");
kep.RAAN.Set("321.123", "deg");
kep.ArgOfPerigee.Set("3.141592654", "rad");
kep = satellite.OrbitState.Assign(kep);
printKeplerianOrbitState(satellite.OrbitState.ToKeplerian());
const agi::odtk::AttrProxy kep = satellite("OrbitState")("ToKeplerian").InvokeAttrProxy();
PrintKeplerianOrbitState(kep);
// Raise altitude by 10 km
const auto newSize = kep("SemiMajorAxis")("GetIn").InvokeDouble("km");
kep("SemiMajorAxis")("Set").Invoke(newSize + 10, "km");
// Set the rest of the orbital elements
kep("Epoch")("Set").Invoke("1 Jul 2009 00:00:00", "UTCG");
kep("Eccentricity").Assign(0.00123);
kep("TrueArgOfLatitude")("Set").Invoke("33.3", "deg");
kep("Inclination")("Set").Invoke("67.8", "deg");
kep("RAAN")("Set").Invoke("321.123", "deg");
kep("ArgOfPerigee")("Set").Invoke("3.141592654", "rad");
satellite("OrbitState")("Assign").Invoke(kep);
PrintKeplerianOrbitState(satellite("OrbitState")("ToKeplerian").InvokeAttrProxy());
AttrProxy kep = satellite.get("OrbitState.ToKeplerian").InvokeAttr();
printKeplerianOrbitState(kep);
// Raise altitude by 10 km
double newSize = kep.get("SemiMajorAxis.GetIn").invokeDouble("km");
kep.get("SemiMajorAxis.Set").invoke(newSize + 10, "km");
// Set the rest of the orbital elements
kep.get("Epoch.Set").invoke("1 Jul 2009 00:00:00", "UTCG");
kep.get("Eccentricity").assign(0.00123);
kep.get("TrueArgOfLatitude.Set").invoke("33.3", "deg");
kep.get("Inclination.Set").invoke("67.8", "deg");
kep.get("RAAN.Set").invoke("321.123", "deg");
kep.get("ArgOfPerigee.Set").invoke("3.141592654", "rad");
kep = satellite.get("OrbitState.Assign").invokeAttr(kep);
printKeplerianOrbitState(satellite.get("OrbitState.ToKeplerian").invokeAttr());
Type LINKTOOBJ with "not specified" choice
The LINKTOOBJ type is a pointer to a specific group of objects that sometimes can offer a "not specified" choice. Examples are the GNSSReceiver.DefaultAntenna, Transponder.DefaultAntenna, and Facility.ReferenceEmitter attributes.
COM
set gpsr = scen.Satellite(0).GNSSReceiver(0)for each cc in gpsr.DefaultAntenna.Choices
if varType(cc) = vbString then
msgbox cc
else
msgbox cc.name
end if
next
gpsr.DefaultAntenna = "not specified"
msgbox "Antenna 1:" & gpsr.DefaultAntenna.ID
gpsr.DefaultAntenna = gpsr.Antenna(0)
msgbox "Antenna 2:" & gpsr.DefaultAntenna.ID
gpsr = scen.Satellite(0).GNSSReceiver(0)
for cc in gpsr.DefaultAntenna.Choices:
if type(cc) == str:
print(cc)
else:
print(cc.name)
gpsr.DefaultAntenna = "not specified"
print("Antenna 1:" + str(gpsr.DefaultAntenna.ID))
gpsr.DefaultAntenna = gpsr.Antenna(0)
print("Antenna 2:" + str(gpsr.DefaultAntenna.ID))
Cross-Platform API
gpsr = odtk.application.createObj(satellite, 'GNSSReceiver', 'GNSSReceiver1')
antenna = odtk.application.createObj(gpsr, 'Antenna', 'Antenna1')
for choice in gpsr.DefaultAntenna.Choices:
choiceVal = choice.eval()
if type(choiceVal) == str:
print(choiceVal)
else:
print(choiceVal.name.eval())
gpsr.DefaultAntenna = 'not specified'
print("Antenna 1: " + str(gpsr.DefaultAntenna.ID.eval()))
gpsr.DefaultAntenna = gpsr.Antenna[0]
print("Antenna 2: " + str(gpsr.DefaultAntenna.ID.eval()))
gpsr = odtk.application.createObj(satellite, "GNSSReceiver", 'GNSSReceiver1');
antenna = odtk.application.createObj(gpsr, "Antenna", "Antenna1");
for i = 0: gpsr.DefaultAntenna.Choices.Count-1
choice = gpsr.DefaultAntenna.Choices{i};
if isa(choice, 'string')
fprintf("%s\n", choice);
else
fprintf("%s\n", choice.name);
end
end
gpsr.DefaultAntenna = "not specified";
fprintf("Antenna 1: %s\n", gpsr.DefaultAntenna.ID);
gpsr.DefaultAntenna = gpsr.Antenna{0};
fprintf("Antenna 2: %s\n", gpsr.DefaultAntenna.ID);
const agi::odtk::AttrProxy gpsr = odtk("application")("createObj").InvokeAttrProxy(satellite, "GNSSReceiver", "GNSSReceiver1");
const agi::odtk::AttrProxy antenna = odtk("application")("createObj").InvokeAttrProxy(gpsr, "Antenna", "Antenna1");
for (int i = 0; i < gpsr("DefaultAntenna")("Choices")("Count").AsInt(); i++)
{
// Invoke 'GetValue' to get a Variant since we don't know the type of choice (either string or AttrProxy)
const auto choice = gpsr("DefaultAntenna")("Choices")[i].GetValue();
// Use the 'holds' helper method to check for the type
if (agi::odtk::holds<std::string(choice))
{
// Use the 'as' helper method to convert the Variant
std::cout << agi::odtk::as<std::string>(choice) << "\n";
}
else
{
// Use the 'as' helper method to convert the Variant, then get then name
std::cout << agi::odtk::as<agi::odtk::AttrProxy>(choice)("name").AsString() << "\n";
}
}
gpsr("DefaultAntenna").Assign("not specified");
std::cout << "Antenna 1: " << gpsr("DefaultAntenna")("ID").AsString() << "\n";
gpsr("DefaultAntenna").Assign(gpsr("Antenna")[0]);
std::cout << "Antenna 2: " << gpsr("DefaultAntenna")("ID").AsString() << "\n";
AttrProxy gpsr = odtk.get("application.createObj").InvokeAttr(satellite, "GNSSReceiver", "GNSSReceiver1");
odtk.get("application.createObj").invoke(gpsr, "Antenna", "Antenna1");
choices = gpsr.get("DefaultAntenna.Choices").asIterProxy();
while (choices.hasNext()) {
AttrProxy choice = choices.next();
if (choice.asObject().getClass().equals(String.class)) {
System.out.println(choice.asObject());
} else {
System.out.println(choice.get("name").asString());
}
}
gpsr.get("DefaultAntenna").assign("not specified");
System.out.println("Antenna 1: " + gpsr.get("DefaultAntenna.ID ").asString());
gpsr.get("DefaultAntenna").assign(gpsr.get("Antenna[0]"));
System.out.println("Antenna 2: " + gpsr.get("DefaultAntenna.ID ").asString());