OBP60v/appdata.py

50 lines
1.5 KiB
Python

"""
Generische Applikationsdaten
"""
import os
from tracker import Tracker
class AppData():
def __init__(self):
self.shutdown = False # Globaler Ausschalter
self.track = Tracker('NONE')
self.frontend = None
# Für u.a. Header-Indikatoren
# TODO
self.status = {
'AP': False, # Accesspoint
'WIFI': False, # Wireless Client
'TCP': False, # TCP Network
'N2K': False, # NMEA2000
'183': False, # NMEA0183
'USB': False, # USB Datenverbindung
'GPS': False, # GPS-Fix und -daten
'TRK': False # Tracker
}
def setFrontend(self, frontend):
self.frontend = frontend # Referenz zur GUI
def refreshStatus(self):
self.status['AP'] = False
self.status['TCP'] = False
self.status['WIFI'] = False
for intf in os.listdir('/sys/class/net'):
statefile = os.path.join('/sys/class/net', interface, 'operstate')
wififile = os.path.join('/sys/class/net', interface, 'wireless')
if os.path.exists(statefile):
with open(statefile) as fh:
state = f.read().strip()
if state == 'up':
if os.path.exists(wififile):
self.status['WIFI'] = True
else:
self.status['TCP'] = True
self.status['TRK'] = self.track.is_active()