comparison epro.py @ 5:982eeffe9d95

Convert booleans to boolean. Sqlite doesn't do it and stores them as ints instead
author Daniel O'Connor <darius@dons.net.au>
date Wed, 25 Sep 2019 21:37:28 +0930
parents 787d9c8fdec6
children 2f7ee650e6fb
comparison
equal deleted inserted replaced
4:787d9c8fdec6 5:982eeffe9d95
154 MSGNAME = "Monitor Status" 154 MSGNAME = "Monitor Status"
155 LEN = 3 155 LEN = 3
156 156
157 def __init__(self, dstadr, srcadr, devid, msgtype, data): 157 def __init__(self, dstadr, srcadr, devid, msgtype, data):
158 super(MonitorStatus, self).__init__(dstadr, srcadr, devid, msgtype, data) 158 super(MonitorStatus, self).__init__(dstadr, srcadr, devid, msgtype, data)
159 self.autosyncvolt = data[0] & 0x10 159 self.autosyncvolt = bool(data[0] & 0x10)
160 self.autosyncamp = data[0] & 0x08 160 self.autosyncamp = bool(data[0] & 0x08)
161 self.autosyncchrg = data[0] & 0x04 161 self.autosyncchrg = bool(data[0] & 0x04)
162 self.e501compat = data[0] & 0x02 162 self.e501compat = bool(data[0] & 0x02)
163 self.alarmtst = data[0] & 0x01 163 self.alarmtst = bool(data[0] & 0x01)
164 self.backlight = data[1] & 0x40 164 self.backlight = bool(data[1] & 0x40)
165 self.disptst = data[1] & 0x20 165 self.disptst = bool(data[1] & 0x20)
166 self.tempsense = data[1] & 0x10 # Seems to be inverted from data sheet 166 self.tempsense = bool(data[1] & 0x10) # Seems to be inverted from data sheet
167 self.auxhv = data[1] & 0x08 167 self.auxhv = bool(data[1] & 0x08)
168 self.auxlv = data[1] & 0x04 168 self.auxlv = bool(data[1] & 0x04)
169 self.lock = data[1] & 0x02 169 self.lock = bool(data[1] & 0x02)
170 self.mainhv = data[1] & 0x01 170 self.mainhv = bool(data[1] & 0x01)
171 self.mainlv = data[2] & 0x40 171 self.mainlv = bool(data[2] & 0x40)
172 self.lowbatalarm = data[2] & 0x20 172 self.lowbatalarm = bool(data[2] & 0x20)
173 self.batflat = data[2] & 0x10 173 self.batflat = bool(data[2] & 0x10)
174 self.batfull = data[2] & 0x08 174 self.batfull = bool(data[2] & 0x08)
175 self.charged = data[2] & 0x04 175 self.charged = bool(data[2] & 0x04)
176 self.nosync = data[2] & 0x02 176 self.nosync = bool(data[2] & 0x02)
177 self.monreset = data[2] & 0x01 177 self.monreset = bool(data[2] & 0x01)
178 178
179 def __repr__(self): 179 def __repr__(self):
180 s = super(MonitorStatus, self).__repr__() 180 s = super(MonitorStatus, self).__repr__()
181 stats = ( ( "ASV", self.autosyncvolt ), ( "ASA", self.autosyncamp ), ( "ASC" , self.autosyncchrg ), 181 stats = ( ( "ASV", self.autosyncvolt ), ( "ASA", self.autosyncamp ), ( "ASC" , self.autosyncchrg ),
182 ( "E501", self.e501compat ), ( "Alarm test", self.alarmtst ), ( "Light", self.backlight ), 182 ( "E501", self.e501compat ), ( "Alarm test", self.alarmtst ), ( "Light", self.backlight ),