Changeset 336:2fa4d33cd52b


Ignore:
Timestamp:
11/13/12 18:42:21 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

#138: added support for the AP-related offsets in the simulator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/pyuipc_sim.py

    r334 r336  
    315315
    316316        self.xpdrC = False
     317
     318        self.apMaster = False
     319        self.apHeadingHold = False
     320        self.apHeading = 124
     321        self.apAltitudeHold = False
     322        self.apAltitude = 7000
    317323
    318324    def read(self, offset, type):
     
    390396        elif offset==0x0628:       # Replay
    391397            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)
    392408        elif offset==0x088c:       # Engine #1 throttle
    393409            return self._getThrottle(self.ENGINE_1)
     
    634650        elif offset==0x0628:       # Replay
    635651            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
    636662        elif offset==0x088c:       # Engine #1 throttle
    637663            self._setThrottle(self.ENGINE_1, value)
     
    10571083    def pyuipc2degree(value):
    10581084        """Convert the given PyUIPC value into a degree."""
    1059         return valie * 360.0 / 65536.0 / 65536.0
     1085        return value * 360.0 / 65536.0 / 65536.0
    10601086
    10611087    @staticmethod
     
    10881114        """Convert the given PyUIPC value into a throttle value."""
    10891115        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
    10901136
    10911137    def __init__(self):
     
    13811427                                        lambda word: int(word))
    13821428
     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
    13831442    def default(self, line):
    13841443        """Handle unhandle commands."""
Note: See TracChangeset for help on using the changeset viewer.