Changeset 336:2fa4d33cd52b
- Timestamp:
- 11/13/12 18:42:21 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/pyuipc_sim.py
r334 r336 315 315 316 316 self.xpdrC = False 317 318 self.apMaster = False 319 self.apHeadingHold = False 320 self.apHeading = 124 321 self.apAltitudeHold = False 322 self.apAltitude = 7000 317 323 318 324 def read(self, offset, type): … … 390 396 elif offset==0x0628: # Replay 391 397 return 1 if self.replay else 0 398 elif offset==0x07bc: # AP Master switch 399 return 1 if self.apMaster else 0 400 elif offset==0x07c8: # AP heading hold 401 return 1 if self.apHeadingHold else 0 402 elif offset==0x07cc: # AP heading 403 return int(self.apHeading * 65536.0 / 360.0) 404 elif offset==0x07d0: # AP altitude hold 405 return 1 if self.apAltitudeHold else 0 406 elif offset==0x07d4: # AP altitude 407 return int(self.apAltitude * const.FEETTOMETRES * 65536.0) 392 408 elif offset==0x088c: # Engine #1 throttle 393 409 return self._getThrottle(self.ENGINE_1) … … 634 650 elif offset==0x0628: # Replay 635 651 self.replay = value!=0 652 elif offset==0x07bc: # AP Master switch 653 self.apMaster = value!=0 654 elif offset==0x07c8: # AP heading hold 655 self.apHeadingHold = value!=0 656 elif offset==0x07cc: # AP heading 657 self.apHeading = value * 360.0 / 65536.0 658 elif offset==0x07d0: # AP altitude hold 659 self.apAltitudeHold = value!=0 660 elif offset==0x07d4: # AP altitude 661 self.apAltitude = value / const.FEETTOMETRES / 65536.0 636 662 elif offset==0x088c: # Engine #1 throttle 637 663 self._setThrottle(self.ENGINE_1, value) … … 1057 1083 def pyuipc2degree(value): 1058 1084 """Convert the given PyUIPC value into a degree.""" 1059 return val ie * 360.0 / 65536.0 / 65536.01085 return value * 360.0 / 65536.0 / 65536.0 1060 1086 1061 1087 @staticmethod … … 1088 1114 """Convert the given PyUIPC value into a throttle value.""" 1089 1115 return value * 100.0 / 16384.0 1116 1117 @staticmethod 1118 def heading2pyuipc(heading): 1119 """Convert the given heading (as a string) into a PyUIPC value.""" 1120 return int(float(heading) * 65536.0 / 360.0) 1121 1122 @staticmethod 1123 def pyuipc2heading(value): 1124 """Convert the given PyUIPC value into a heading.""" 1125 return value * 360.0 / 65536.0 1126 1127 @staticmethod 1128 def altitude2pyuipc(altitude): 1129 """Convert the given altitude (as a string) into a PyUIPC value.""" 1130 return int(float(altitude) * const.FEETTOMETRES * 65536.0) 1131 1132 @staticmethod 1133 def pyuipc2altitude(value): 1134 """Convert the given PyUIPC value into an altitude.""" 1135 return value / const.FEETTOMETRES / 65536.0 1090 1136 1091 1137 def __init__(self): … … 1381 1427 lambda word: int(word)) 1382 1428 1429 self._valueHandlers["apMaster"] = ([(0x07bc, "u")], 1430 CLI.bool2str, CLI.str2bool) 1431 self._valueHandlers["apHeadingHold"] = ([(0x07c8, "u")], 1432 CLI.bool2str, CLI.str2bool) 1433 self._valueHandlers["apHeading"] = ([(0x07cc, "H")], 1434 CLI.pyuipc2heading, 1435 CLI.heading2pyuipc) 1436 self._valueHandlers["apAltitudeHold"] = ([(0x07d0, "u")], 1437 CLI.bool2str, CLI.str2bool) 1438 self._valueHandlers["apAltitude"] = ([(0x07d4, "H")], 1439 CLI.pyuipc2altitude, 1440 CLI.altitude2pyuipc) 1441 1383 1442 def default(self, line): 1384 1443 """Handle unhandle commands."""
Note:
See TracChangeset
for help on using the changeset viewer.