Fix switch bank callback and temperature/humidity data
This commit is contained in:
10
boatdata.py
10
boatdata.py
@@ -1,4 +1,4 @@
|
|||||||
'''
|
"""
|
||||||
!!! Dies ist noch im Ideen-Stadium
|
!!! Dies ist noch im Ideen-Stadium
|
||||||
WIP TBD
|
WIP TBD
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ xdrRoll
|
|||||||
xdrPitch
|
xdrPitch
|
||||||
xdrYaw
|
xdrYaw
|
||||||
|
|
||||||
'''
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
@@ -379,7 +379,11 @@ class SwitchBank():
|
|||||||
def setCallback(self, index, cb_function):
|
def setCallback(self, index, cb_function):
|
||||||
if index < 1 or index > 28:
|
if index < 1 or index > 28:
|
||||||
raise IndexError("Switch index out of range")
|
raise IndexError("Switch index out of range")
|
||||||
self.callback[index] = cb_function
|
self.callback[index-1] = cb_function
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
out = f"Switch bank instance #{self.instance}"
|
||||||
|
return out
|
||||||
|
|
||||||
class Tank():
|
class Tank():
|
||||||
"""
|
"""
|
||||||
|
|||||||
34
parser.py
34
parser.py
@@ -168,7 +168,7 @@ def parse_127501(buf):
|
|||||||
val = val >> 2
|
val = val >> 2
|
||||||
ix += 1
|
ix += 1
|
||||||
|
|
||||||
def parse_127502(buf):
|
def parse_127502(buf, boatdata):
|
||||||
# Switch bank control
|
# Switch bank control
|
||||||
# 7 byte for switches every switch takes 2 bits
|
# 7 byte for switches every switch takes 2 bits
|
||||||
# 0 = Off, 1=On, 2=reserved and 3=no action
|
# 0 = Off, 1=On, 2=reserved and 3=no action
|
||||||
@@ -313,14 +313,43 @@ def parse_129540(buf, boatdata):
|
|||||||
status = buf[s+14] & 0x0f
|
status = buf[s+14] & 0x0f
|
||||||
boatdata.updateSatellite(prn, elevation, azimuth, snr, rres, status)
|
boatdata.updateSatellite(prn, elevation, azimuth, snr, rres, status)
|
||||||
|
|
||||||
|
def parse_130311(buf, boatdata):
|
||||||
|
# Environmental parameters
|
||||||
|
# sid = buf[0]
|
||||||
|
src_temp = buf[1] # lookup "temperature" (0 .. 15)
|
||||||
|
src_hum = buf[2] # lookup "humidity" (0 .. 1)
|
||||||
|
val_temp = (buf[3] * 256 + buf[2]) * 0.01 # Kelvin
|
||||||
|
val_hum = (buf[5] * 256 + buf[4]) * 0.004 # Percent
|
||||||
|
val_press = (buf[7] * 256 + buf[6]) * 100 # Pa
|
||||||
|
boatdata.setValue("xdrTemp", val_temp)
|
||||||
|
boatdata.setValue("xdrHum", val_hum)
|
||||||
|
boatdata.setValue("xdrPress", val_press)
|
||||||
|
|
||||||
def parse_130312(buf, boatdata):
|
def parse_130312(buf, boatdata):
|
||||||
# Temperature
|
# Temperature
|
||||||
|
# sid = buf[0]
|
||||||
|
instance = buf[1]
|
||||||
src = buf[2] # lookup "temperature" (0 .. 15)
|
src = buf[2] # lookup "temperature" (0 .. 15)
|
||||||
val = (buf[4] * 256 + buf[3]) * 0.01 # Kelvin
|
val = (buf[4] * 256 + buf[3]) * 0.01 # Kelvin
|
||||||
if instance == 0 and src == 1:
|
if instance == 0 and src == 1:
|
||||||
boatdata.setValue("xdrTemp", val)
|
boatdata.setValue("xdrTemp", val)
|
||||||
elif instance in boatdata.temp:
|
elif instance in boatdata.temp:
|
||||||
boatdata.temp[instance].value = val
|
boatdata.temp[instance].value = val
|
||||||
|
#ignored
|
||||||
|
#setval = (buf[6] * 256 + buf[5]) * 0.01
|
||||||
|
|
||||||
|
def parse_130313(buf, boatdata):
|
||||||
|
# Humidity
|
||||||
|
# sid = buf[0]
|
||||||
|
instance = buf[1]
|
||||||
|
src = buf[2] # lookup "humidity" (0 .. 1)
|
||||||
|
val = (buf[4] * 256 + buf[3]) * 0.004 # Percent
|
||||||
|
if instance == 0 and src == 1:
|
||||||
|
boatdata.setValue("xdrHum", val)
|
||||||
|
elif instance in boatdata.hum:
|
||||||
|
boatdata.hum[instance].value = val
|
||||||
|
#ignored
|
||||||
|
#setval = (buf[6] * 256 + buf[5]) * 0.004
|
||||||
|
|
||||||
def parse_130314(buf, boatdata):
|
def parse_130314(buf, boatdata):
|
||||||
# Pressure
|
# Pressure
|
||||||
@@ -343,9 +372,10 @@ def parse_130316(buf, boatdata):
|
|||||||
src = buf[2] # lookup "temperature" (0 .. 15)
|
src = buf[2] # lookup "temperature" (0 .. 15)
|
||||||
val = ((buf[5] << 16) | (buf[4] << 8) | buf[3]) * 0.001
|
val = ((buf[5] << 16) | (buf[4] << 8) | buf[3]) * 0.001
|
||||||
# TODO save in global temp data
|
# TODO save in global temp data
|
||||||
# Konflikt mit 130312?
|
|
||||||
#if instance == 0 and src == 2:
|
#if instance == 0 and src == 2:
|
||||||
# boatdata.setValue("xdrTemp", val)
|
# boatdata.setValue("xdrTemp", val)
|
||||||
# save in engine data
|
# save in engine data
|
||||||
if src == 14 and instance in boatdata.engine:
|
if src == 14 and instance in boatdata.engine:
|
||||||
boatdata.engine[instance].exhaust_temp = val
|
boatdata.engine[instance].exhaust_temp = val
|
||||||
|
#ignored
|
||||||
|
#setval = (buf[7] * 256 + buf[6]) * 0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user