Пример #1
0
 def getData(self):
     data = self.data
     log.info("READ totals today:\n%s" % lib.hexdump(data))
     totals = {
         'today': lib.BangInt(data[0:2]) / 10.0,
         'yesterday': lib.BangInt(data[2:4]) / 10.0
     }
     return totals
Пример #2
0
    def getData(self):
        data = self.data
        log.info("READ pump settings:\n%s" % lib.hexdump(data))

        auto_off_duration_hrs = data[0]
        alarm = self.alarm(data[1])
        audio_bolus_enable = data[2] == 1
        audio_bolus_size = 0
        if audio_bolus_enable:
            audio_bolus_size = data[3] / 10.0
        variable_bolus_enable = data[4] == 1
        #MM23 is different
        maxBolus = data[5] / 10.0
        # MM512 and up
        maxBasal = lib.BangInt(data[6:8]) / 40
        timeformat = data[8]
        insulinConcentration = {0: 100, 1: 50}[data[9]]
        patterns_enabled = data[10] == 1
        selected_pattern = data[11]
        rf_enable = data[12] == 1
        block_enable = data[13] == 1
        """
    # MM12
    insulin_action_type = data[17] == 0 and 'Fast' or 'Regular'
    """
        #MM15
        insulin_action_type = data[17]
        low_reservoir_warn_type = data[18]
        low_reservoir_warn_point = data[19]
        keypad_lock_status = data[20]

        return locals()
Пример #3
0
    def readStatus(self):
        result = self.link.sendComLink2Command(3)
        commStatus = result[0]  # 0 indicates success
        assert commStatus == 0
        status = result[2]
        lb, hb = result[3], result[4]
        bytesAvailable = lib.BangInt((lb, hb))
        self.status = status

        if (status & 0x1) > 0:
            return bytesAvailable
        return 0
Пример #4
0
 def getData(self):
     data = self.data
     bd = bytearray(data)
     volt = lib.BangInt((bd[1], bd[2]))
     indicator = bd[0]
     battery = {
         'status': {
             0: 'normal',
             1: 'low'
         }[indicator],
         'voltage': volt / 100.0
     }
     return battery
Пример #5
0
    def readDeviceDataIO(self):
        results = self.readData()
        lb, hb = results[5] & 0x7F, results[6]
        self.eod = (results[5] & 0x80) > 0
        resLength = lib.BangInt((lb, hb))
        log.info('XXX resLength: %s' % resLength)
        #assert resLength < 64, ("cmd low byte count:\n%s" % lib.hexdump(results))

        data = results[13:13 + resLength]
        assert len(data) == resLength
        crc = results[-1]
        # crc check
        log.info('readDeviceDataIO:msgCRC:%r:expectedCRC:%r:data:%r' %
                 (crc, CRC8(data), data))
        assert crc == CRC8(data)
        return data
Пример #6
0
    def readStatus(self):
        result = []

        def fetch_status():
            res = self.link.sendComLink2Command(3)
            #status = res and res[0] # 0 indicates success
            log.info("res: %r" % res)
            if res and res[0] == 0:  # 0 indicates success
                return res
            #if status == 0:
            #result = res
            #return True
            return False

        #if not retry(fetch_status) or len(result) == 0:
        result = retry(fetch_status)
        if not result:
            raise RFFailed("rf read header indicates failure")
        """
    """
        #result         = self.link.sendComLink2Command(3)

        commStatus = result[0]  # 0 indicates success

        status = result[2]
        lb, hb = result[3], result[4]

        stat = StickStatusStruct(status)
        header = result[0:3]
        test = [StickStatusStruct(s) for s in header]
        log.info(test)
        log.info("HEADER:\n%s" % lib.hexdump(header))
        if 0 != commStatus:
            raise DeviceCommsError('\n'.join([
                "rf read header indicates failure",
                "%s" % lib.hexdump(header)
            ]))
        assert commStatus == 0, ("command status not 0: %s:%s" %
                                 (commStatus, stat))
        bytesAvailable = lib.BangInt((lb, hb))
        self.status = status

        if (status & 0x1) > 0:
            return bytesAvailable
        return 0
Пример #7
0
def ls_int(B):
    B.reverse()
    return lib.BangInt(B)
Пример #8
0
 def getData(self):
     data = self.data
     rate = lib.BangInt(data[2:4]) / 40.0
     duration = lib.BangInt(data[4:6])
     log.info("READ temporary basal:\n%s" % lib.hexdump(data))
     return {'rate': rate, 'duration': duration}
Пример #9
0
 def getData(self):
     data = self.data
     log.info("READ remaining insulin:\n%s" % lib.hexdump(data))
     return lib.BangInt(data[0:2]) / 10.0
Пример #10
0
 def rfByteCount(self, count):
     return lib.BangInt(count)