-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved aircraft type data to external files.
- Loading branch information
1 parent
1888e23
commit fc9e0bc
Showing
4 changed files
with
141 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,74 @@ | ||
import json | ||
|
||
class aircrafttype: | ||
|
||
def __init__(self, name): | ||
self._name = name | ||
# TODO: Look for the file using a relative path. | ||
filename = "/content/src/airpower/aircrafttypes/%s.json" % name | ||
# TODO: Handle errors. | ||
self._data = json.load(open(filename, "r", encoding="utf-8")) | ||
assert name == self._data["name"] | ||
|
||
def power(self, configuration, setting): | ||
if not setting in self._data["powertable"][configuration]: | ||
return None | ||
else: | ||
return self._data["powertable"][configuration][setting] | ||
|
||
def powerchart(self, configuration): | ||
if self._name == "F-80C": | ||
return { | ||
"CL" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5, }, | ||
"1/2" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5, }, | ||
"DT" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5, }, | ||
"FUEL": { "IDLE": 0.0, "NOR": 0.5, "MIL": 1.0, } | ||
}[configuration] | ||
elif self._name == "F-84E": | ||
return { | ||
"CL" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5, }, | ||
"1/2" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 0.5, "SPBR": 0.5, }, | ||
"DT" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 0.5, "SPBR": 1.0, }, | ||
"FUEL": { "IDLE": 0.0, "NOR": 0.5, "MIL": 1.0, } | ||
}[configuration] | ||
def SPBR(self, configuration): | ||
return self._data["powertable"][configuration]["SPBR"] | ||
|
||
def turndragchart(self, configuration): | ||
if self._name == "F-80C": | ||
return { | ||
"CL" : { "TT": 0.0, "HT": 1.0, "BT": 1.0, }, | ||
"1/2": { "TT": 0.0, "HT": 1.0, "BT": 1.0, }, | ||
"DT" : { "TT": 0.0, "HT": 1.0, "BT": 2.0, }, | ||
}[configuration] | ||
elif self._name == "F-84E": | ||
return { | ||
"CL" : { "TT": 0.0, "HT": 1.0, "BT": 2.0, }, | ||
"1/2": { "TT": 1.0, "HT": 2.0, "BT": 2.0, }, | ||
"DT" : { "TT": 1.0, "HT": 2.0, "BT": 2.0, }, | ||
}[configuration] | ||
def fuelrate(self, setting): | ||
if not setting in self._data["powertable"]["FUEL"]: | ||
return None | ||
else: | ||
return self._data["powertable"]["FUEL"][setting] | ||
|
||
def turndrag(self, configuration, turnrate): | ||
if not turnrate in self._data["turndragtable"][configuration]: | ||
return None | ||
else: | ||
return self._data["turndragtable"][configuration][turnrate] | ||
|
||
def minspeed(self, configuration, altitudeband): | ||
if altitudeband == "UH": | ||
altitudeband = "EH" | ||
if self._name == "F-80C": | ||
return { | ||
"CL" : { "LO": 1.5, "ML": 1.5, "MH": 2.0, "HI": 2.0, "VH": 2.5, "EH": 0.0, }, | ||
"1/2": { "LO": 1.5, "ML": 2.0, "MH": 2.0, "HI": 2.5, "VH": 2.5, "EH": 0.0, }, | ||
"DT" : { "LO": 2.0, "ML": 2.0, "MH": 2.5, "HI": 2.5, "VH": 0.0, "EH": 0.0, }, | ||
}[configuration][altitudeband] | ||
elif self._name == "F-84E": | ||
return { | ||
"CL" : { "LO": 1.5, "ML": 1.5, "MH": 2.0, "HI": 2.5, "VH": 2.5, "EH": 0.0, }, | ||
"1/2": { "LO": 1.5, "ML": 2.0, "MH": 2.0, "HI": 2.5, "VH": 2.5, "EH": 0.0, }, | ||
"DT" : { "LO": 2.0, "ML": 2.0, "MH": 2.5, "HI": 0.0, "VH": 0.0, "EH": 0.0, }, | ||
}[configuration][altitudeband] | ||
if not altitudeband in self._data["minspeedtable"][configuration]: | ||
return None | ||
else: | ||
return self._data["minspeedtable"][configuration][altitudeband] | ||
|
||
def maxspeed(self, configuration, altitudeband): | ||
if altitudeband == "UH": | ||
altitudeband = "EH" | ||
if self._name == "F-80C": | ||
return { | ||
"CL" : { "LO": 5.5, "ML": 5.5, "MH": 5.0, "HI": 4.5, "VH": 4.0, "EH": 0.0, }, | ||
"1/2": { "LO": 5.5, "ML": 5.0, "MH": 4.5, "HI": 4.5, "VH": 4.0, "EH": 0.0, }, | ||
"DT" : { "LO": 5.0, "ML": 4.5, "MH": 4.5, "HI": 4.0, "VH": 0.0, "EH": 0.0, }, | ||
}[configuration][altitudeband] | ||
elif self._name == "F-84E": | ||
return { | ||
"CL" : { "LO": 6.0, "ML": 6.0, "MH": 5.5, "HI": 5.5, "VH": 5.5, "EH": 0.0, }, | ||
"1/2": { "LO": 5.5, "ML": 5.5, "MH": 5.5, "HI": 5.0, "VH": 5.0, "EH": 0.0, }, | ||
"DT" : { "LO": 5.5, "ML": 5.0, "MH": 5.5, "HI": 0.0, "VH": 0.0, "EH": 0.0, }, | ||
}[configuration][altitudeband] | ||
return self._data["maxspeedtable"][configuration][altitudeband] | ||
|
||
def cruisespeed(self): | ||
if self._name == "F-80C": | ||
return 4.0 | ||
elif self._name == "F-84E": | ||
return 4.5 | ||
return self._data["cruisespeed"] | ||
|
||
def climbspeed(self): | ||
if self._name == "F-80C": | ||
return 3.0 | ||
elif self._name == "F-84E": | ||
return 3.5 | ||
return self._data["climbspeed"] | ||
|
||
def divespeed(self, altitudeband): | ||
if altitudeband == "UH": | ||
altitudeband = "EH" | ||
if self._name == "F-80C": | ||
return { "LO": 6.5, "ML": 6.5, "MH": 6.5, "HI": 6.5, "VH": 6.0, "EH": 0.0, }[altitudeband] | ||
elif self._name == "F-84E": | ||
return { "LO": 7.0, "ML": 7.0, "MH": 6.5, "HI": 6.5, "VH": 6.0, "EH": 0.0, }[altitudeband] | ||
if not altitudeband in self._data["divespeedtable"]: | ||
return None | ||
else: | ||
return self._data["divespeedtable"][altitudeband] | ||
|
||
def ceiling(self, configuration): | ||
if self._name == "F-80C": | ||
return { "CL": 45, "1/2": 40, "DT": 35, }[configuration] | ||
elif self._name == "F-84E": | ||
return { "CL": 41, "1/2": 36, "DT": 30, }[configuration] | ||
return self._data["ceilingtable"][configuration] | ||
|
||
def rollhfp(self): | ||
return self._data["maneuvertable"]["LR/DR"]["HFP"] | ||
|
||
def rolldrag(self, rolltype): | ||
assert rolltype in [ "VR", "LR", "DR" ] | ||
if rolltype != "VR": | ||
rolltype == "LR/DR" | ||
return self._data["maneuvertable"][rolltype]["DP"] | ||
|
||
def hasproperty(self, p): | ||
if self._name == "F-80C": | ||
return p in ["HTD"] | ||
elif self._name == "F-84E": | ||
return p in ["HTD"] | ||
return p in self._data["properties"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "F-80C", | ||
"origin": "TSOH", | ||
"powertable": { | ||
"CL" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 }, | ||
"1/2" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 }, | ||
"DT" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 }, | ||
"FUEL": { "IDLE": 0.0, "NOR": 0.5, "MIL": 1.0 } | ||
}, | ||
"maneuvertable": { | ||
"LR/DR": { "HFP": 1.0, "DP": 1.5 }, | ||
"VR": { "DP": 0.5 } | ||
}, | ||
"turndragtable": { | ||
"CL" : { "TT": 0.0, "HT": 1.0, "BT": 1.0 }, | ||
"1/2": { "TT": 0.0, "HT": 1.0, "BT": 1.0 }, | ||
"DT" : { "TT": 0.0, "HT": 1.0, "BT": 2.0 } | ||
}, | ||
"minspeedtable": { | ||
"CL" : { "LO": 1.5, "ML": 1.5, "MH": 2.0, "HI": 2.0, "VH": 2.5, "EH": 0.0 }, | ||
"1/2": { "LO": 1.5, "ML": 2.0, "MH": 2.0, "HI": 2.5, "VH": 2.5, "EH": 0.0 }, | ||
"DT" : { "LO": 2.0, "ML": 2.0, "MH": 2.5, "HI": 2.5, "VH": 0.0, "EH": 0.0 } | ||
}, | ||
"maxspeedtable": { | ||
"CL" : { "LO": 5.5, "ML": 5.5, "MH": 5.0, "HI": 4.5, "VH": 4.0, "EH": 0.0 }, | ||
"1/2": { "LO": 5.5, "ML": 5.0, "MH": 4.5, "HI": 4.5, "VH": 4.0, "EH": 0.0 }, | ||
"DT" : { "LO": 5.0, "ML": 4.5, "MH": 4.5, "HI": 4.0, "VH": 0.0, "EH": 0.0 } | ||
}, | ||
"cruisespeed": 4.0, | ||
"climbspeed": 3.0, | ||
"divespeedtable": { "LO": 6.5, "ML": 6.5, "MH": 6.5, "HI": 6.5, "VH": 6.0, "EH": 0.0 }, | ||
"ceilingtable": { "CL": 45, "1/2": 40, "DT": 35 }, | ||
"properties": [ "HTD" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "F-84E", | ||
"origin": "TSOH", | ||
"powertable": { | ||
"CL" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 }, | ||
"1/2" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 0.5, "SPBR": 0.5 }, | ||
"DT" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 0.5, "SPBR": 1.0 }, | ||
"FUEL": { "IDLE": 0.0, "NOR": 0.5, "MIL": 1.0 } | ||
}, | ||
"maneuvertable": { | ||
"LR/DR": { "HFP": 1.0, "DP": 1.5 }, | ||
"VR": { "DP": 0.5 } | ||
}, | ||
"turndragtable": { | ||
"CL" : { "TT": 0.0, "HT": 1.0, "BT": 2.0 }, | ||
"1/2": { "TT": 1.0, "HT": 2.0, "BT": 2.0 }, | ||
"DT" : { "TT": 1.0, "HT": 2.0, "BT": 2.0 } | ||
}, | ||
"minspeedtable": { | ||
"CL" : { "LO": 1.5, "ML": 1.5, "MH": 2.0, "HI": 2.5, "VH": 2.5, "EH": 0.0 }, | ||
"1/2": { "LO": 1.5, "ML": 2.0, "MH": 2.0, "HI": 2.5, "VH": 2.5, "EH": 0.0 }, | ||
"DT" : { "LO": 2.0, "ML": 2.0, "MH": 2.5, "HI": 0.0, "VH": 0.0, "EH": 0.0 } | ||
}, | ||
"maxspeedtable": { | ||
"CL" : { "LO": 6.0, "ML": 6.0, "MH": 5.5, "HI": 5.5, "VH": 5.5, "EH": 0.0 }, | ||
"1/2": { "LO": 5.5, "ML": 5.5, "MH": 5.5, "HI": 5.0, "VH": 5.0, "EH": 0.0 }, | ||
"DT" : { "LO": 5.5, "ML": 5.0, "MH": 5.5, "HI": 0.0, "VH": 0.0, "EH": 0.0 } | ||
}, | ||
"cruisespeed": 4.5, | ||
"climbspeed": 3.5, | ||
"divespeedtable": { "LO": 7.0, "ML": 7.0, "MH": 6.5, "HI": 6.5, "VH": 6.0, "EH": 0.0 }, | ||
"ceilingtable": { "CL": 41, "1/2": 36, "DT": 30 }, | ||
"properties": [ "HTD" ] | ||
} |