Ignore:
Timestamp:
04/28/12 12:25:48 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the weight help tab

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/fsuipc.py

    r97 r117  
    531531        self._handler.requestRead([(0x3bfc, "d")], self._handleZFW, extra = callback)
    532532
     533    def requestWeights(self, callback):
     534        """Request the following weights: DOW, ZFW, payload.
     535
     536        These values will be passed to the callback function in this order, as
     537        separate arguments."""       
     538        self._handler.requestRead([(0x13fc, "d")], self._handlePayloadCount,
     539                                  extra = callback)
     540
    533541    def requestTime(self, callback):
    534542        """Request the time from the simulator."""
     
    737745        """Callback for a time retrieval request."""
    738746        callback(Simulator._getTimestamp(data))
     747
     748    def _handlePayloadCount(self, data, callback):
     749        """Callback for the payload count retrieval request."""
     750        payloadCount = data[0]
     751        data = [(0x3bfc, "d"), (0x30c0, "f")]
     752        for i in range(0, payloadCount):
     753            data.append((0x1400 + i*48, "f"))
     754       
     755        self._handler.requestRead(data, self._handleWeights,
     756                                  extra = callback)
     757
     758    def _handleWeights(self, data, callback):
     759        """Callback for the weights retrieval request."""
     760        zfw = data[0] * const.LBSTOKG / 256.0
     761        grossWeight = data[1] * const.LBSTOKG
     762        payload = sum(data[2:]) * const.LBSTOKG
     763        dow = zfw - payload
     764        callback(dow, payload, zfw, grossWeight)
    739765                                                 
    740766#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.