0c4544c1e1
ConfigStore for storing and retrieving config settings (needs XML import/export) Header display with 4 different header fields (all configurable) Publisher for ADC and FMS.
110 lines
3.4 KiB
Text
110 lines
3.4 KiB
Text
# Copyright (C) 2018 Stuart Buchanan
|
|
# FG1000 Configuration store
|
|
#
|
|
# This only stores configuration with pre-defined values
|
|
#
|
|
|
|
var ConfigStore = {
|
|
|
|
configValues : {
|
|
"DisplayUnitsNavAngle": ["MAGNETIC", "TRUE"] ,
|
|
"DisplayUnitsDistanceAndSpeed": ["NAUTICAL", "METRIC"] ,
|
|
"DisplayUnitsAltitude": ["FEET", "METERS"] ,
|
|
"DisplayUnitsTemperature": ["CELCIUS", "FAHRENHEIT"] ,
|
|
|
|
"BaroTransitionAlert": ["ON", "OFF"] ,
|
|
"BaroTransitionAltitude": ["6000", "18000"] ,
|
|
|
|
"AirspaceAlertBuffer": ["100", "200", "300", "400", "500", "750", "1000"] ,
|
|
"AirspaceAlertClassB": ["OFF", "ON"] ,
|
|
"AirspaceAlertClassC": ["OFF", "ON"] ,
|
|
"AirspaceAlertClassD": ["OFF", "ON"] ,
|
|
"AirspaceAlertRestricted": ["OFF", "ON"] ,
|
|
"AirspaceAlertMOA": ["OFF", "ON"] ,
|
|
"AirspaceAlertOther": ["OFF", "ON"] ,
|
|
|
|
"ArrivalAlert": ["OFF", "ON"] ,
|
|
"ArrivalDistance": ["0.0", "1.0", "2.0", "3.0", "4.0", "6.0", "8.0", "10.0"] ,
|
|
"AudioAlertVoice": ["MALE", "FEMALE"] ,
|
|
|
|
"PageNavigationChangeOnFirstClick": ["OFF", "ON"] ,
|
|
"PageNavigationTimeout" : [0.5, 1.0, 2.0, 3.0] ,
|
|
|
|
|
|
# MFD Header Fields
|
|
#
|
|
# Bearing (BRG)
|
|
# Crosstrack Error (XTK)
|
|
# Distance (DIS)
|
|
# Desired Track (DTK)
|
|
# Endurance (END)
|
|
# En Route Safe Altitude (ESA)
|
|
# Estimated Time of Arrival (ETA)
|
|
# Estimated Time En Route (ETE)
|
|
# Fuel Over Destination (FOD)
|
|
# Fuel On Board (FOB)
|
|
# Ground Speed (GS)
|
|
# Minimum Safe Altitude (MSA)
|
|
# True Air Speed (TAS)
|
|
# Track Angle Error (TKE)
|
|
# Track (TRK)
|
|
# Vertical Speed Required (VSR)
|
|
|
|
"MFDHeader1": ["BRG", "XTK", "DIS", "DTK", "END", "ESA", "ETA", "ETE", "FOD", "FOB", "GS", "MSA", "TAS", "TKE", "TRK", "VSR"] ,
|
|
"MFDHeader2": ["BRG", "XTK", "DIS", "DTK", "END", "ESA", "ETA", "ETE", "FOD", "FOB", "GS", "MSA", "TAS", "TKE", "TRK", "VSR"] ,
|
|
"MFDHeader3": ["BRG", "XTK", "DIS", "DTK", "END", "ESA", "ETA", "ETE", "FOD", "FOB", "GS", "MSA", "TAS", "TKE", "TRK", "VSR"] ,
|
|
"MFDHeader4": ["BRG", "XTK", "DIS", "DTK", "END", "ESA", "ETA", "ETE", "FOD", "FOB", "GS", "MSA", "TAS", "TKE", "TRK", "VSR"] ,
|
|
},
|
|
|
|
new : func()
|
|
{
|
|
var obj ={
|
|
parents : [ ConfigStore ],
|
|
_values : {},
|
|
};
|
|
|
|
foreach (var i; keys(ConfigStore.configValues)) {
|
|
var values = ConfigStore.configValues[i];
|
|
obj.set(i, values[0]);
|
|
}
|
|
|
|
# Special case defaults
|
|
obj.set("MFDHeader1", "GS");
|
|
obj.set("MFDHeader2", "DIS");
|
|
obj.set("MFDHeader3", "ETE");
|
|
# ESA should be the default, but it's not implemented right now, so use FOD
|
|
#obj.set("MFDHeader4", "ESA");
|
|
obj.set("MFDHeader4", "FOD");
|
|
|
|
return obj;
|
|
},
|
|
|
|
set : func(name, value) {
|
|
# Validate name is something we know.
|
|
assert(contains(ConfigStore.configValues, name), "ConfigStore does not contain name " ~ name);
|
|
|
|
if (size(ConfigStore.configValues[name]) == 0) {
|
|
# If not valid values, then anything goes.
|
|
me._values[name] = value;
|
|
} else {
|
|
# Validate the value is part of the set of acceptable values
|
|
var found = 0;
|
|
foreach(var val; ConfigStore.configValues[name]) {
|
|
if (value == val) {
|
|
found =1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
assert(found == 1,
|
|
"Invalid value for " ~ name ~ ": " ~ value ~
|
|
"(Should be one of " ~ string.join(", ", ConfigStore.configValues[name]) ~ ")");
|
|
|
|
me._values[name] = value;
|
|
}
|
|
},
|
|
|
|
get : func(name) {
|
|
return me._values[name];
|
|
},
|
|
};
|