Mercurial > atc
changeset 23:b2ed1770081f
Load the plane specs at start up from files
committer: Jeff <jeffpc@batlh.(none)> 1121707415 -0400
author | Jeff <jeffpc@batlh.(none)> |
---|---|
date | Mon, 18 Jul 2005 17:23:35 -0400 |
parents | a6f6d5d822be |
children | aa7332d16d82 |
files | atc_config.py atc_plane_specs.py planes/B747.info planes/PA28.info |
diffstat | 4 files changed, 76 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/atc_config.py Mon Jul 18 16:40:59 2005 -0400 +++ b/atc_config.py Mon Jul 18 17:23:35 2005 -0400 @@ -4,4 +4,7 @@ # 1 (default) = realistic # 2 = very detailed -plane_label = 1 \ No newline at end of file +plane_label = 1 + +# relative location of the plane specs directory +plane_spec_dir = "planes"
--- a/atc_plane_specs.py Mon Jul 18 16:40:59 2005 -0400 +++ b/atc_plane_specs.py Mon Jul 18 17:23:35 2005 -0400 @@ -20,17 +20,61 @@ # * @(#) %M% %I% %E% %U% # */ +import os +import sys +import atc_config + # all measurements in meters/sec or meters -plane_SPECS = ({"fullname": "Piper PA28-140 Cherokee", - "name": "PA28", - "heavy": False, - "stall_speed": 16.667, - "climb_normal": 2.54, - "max_altitude": 6500.0}, - - {"fullname": "Boeing 747-400", - "name": "B747", - "heavy": True, - "stall_speed": 66.878, - "climb_normal": 10.16, - "max_altitude": 13000.0}) +plane_SPECS = [] + +plane_dir = os.listdir(atc_config.plane_spec_dir) + +for f in plane_dir: + plane = {"fullname": str(None), + "name": str(None), + "heavy": False, + "jet": False, + "stall_speed": 0.0, + "climb_normal": 0.0, + "max_altitude": 0.0} + + fd = open(atc_config.plane_spec_dir + "/" + f, 'r') + s = fd.read() + fd.close() + + s = s.split("\n") + for line in s: + if (line.__len__()==0): + continue + + cmd = line[:line.find(' ')-1] + param = line[line.find(' ')+1:] + + if cmd=="FullName": + plane["fullname"] = param + elif cmd=="Name": + plane["name"] = param + elif cmd=="Heavy": + if (param.upper() == "YES"): + plane["heavy"] = True + else: + plane["heavy"] = False + elif cmd=="Jet": + if (param.upper() == "YES"): + plane["jet"] = True + else: + plane["jet"] = False + elif cmd=="StallSpeed": + plane["stall_speed"] = float(param) + elif cmd=="ClimbNormal": + plane["climb_normal"] = float(param) + elif cmd=="MaxAltitude": + plane["max_altitude"] = float(param) + else: + print "Error parsing " + f + ": Unknown statement" + sys.exit(1) + + plane_SPECS.append(plane) + print "Parsed and added " + plane["fullname"] + " aka. " + plane["name"] + +print "Added " + str(plane_SPECS.__len__()) + " plane types"