def getRawDataFromValue(self, value): """ Converts value to raw data """ if (value == None): return None r = 0 for idx in range(8): varname = 'ibutton_connected_' + str(idx + 1) bits.bitSetValue(r, idx, value[varname] \ if varname in value else 0) return super(Tag213, self).getRawDataFromValue(r)
def getRawDataFromValue(self, value): """ Converts value to raw data """ if (value == None): return None r = 0 for idx in range(16): varname = 'din' + str(idx) bits.bitSetValue(r, idx, value[varname] \ if varname in value else 0) return super(Tag70, self).getRawDataFromValue(r)
def getRawDataFromValue(self, value): """ Converts value to raw data """ if (value == None): return None r = 0 r = self.bitSet(r, 0, value, 'moving') r = self.bitSet(r, 1, value, 'critical_angle') r = self.bitSet(r, 3, value, 'gsm_no_sim_card') r = self.bitSet(r, 4, value, 'geofence_presence') r = self.bitSet(r, 5, value, 'int_battery_low_level') r = self.bitSet(r, 6, value, 'sat_antenna_connected') r = self.bitSet(r, 7, value, 'bad_bus_voltage') r = self.bitSet(r, 8, value, 'bad_ext_voltage') r = self.bitSet(r, 9, value, 'acc') r = self.bitSet(r, 10, value, 'critical_vibration') r = self.bitSet(r, 11, value, 'sat_glonass_enabled') r = self.bitSet(r, 12, value, 'gsm_signal_quality') if 'gsm_signal_quality' in value: r = bits.bitSetValue(r, 12, value['gsm_signal_quality'] % 2) r = bits.bitSetValue(r, 13, value['gsm_signal_quality'] >> 1) r = self.bitSet(r, 14, value, 'armed') r = self.bitSet(r, 15, value, 'sos') return super(Tag64, self).getRawDataFromValue(r)
def bitSet(cls, result, offset, value, varname): """ Set bit value for number """ return bits.bitSetValue(result, offset, value[varname] \ if varname in value else 0)