main
MichaelK 3 days ago
parent 28a2b34b28
commit 95afe546b7

@ -1,50 +0,0 @@
import sys
from time import sleep, time
from source.IdiBus4DC import Module4DC
from source.IdiBusSerialLine import IdiBusSerialLine
class Executioner():
def __init__(self, name):
self.name = name
self.port = ""
self.address = 0
self.speed = 0
def execute(self, command, args):
pass
# Must return string with all data in csv format. without \n or \r
def get_log_string(self):
pass
class Exec4DC(Executioner):
def __init__(self, ):
super().__init__("Module4DC")
def execute(self, command, args):
module = Module4DC(addr=self.address, line=IdiBusSerialLine(port=self.port, baudrate=self.speed))
if command == "set-data":
module.set_channel_data(args[0], args[1], args[2])
elif command == "set-state":
module.set_channel_state(args[0], args[1])
else:
print("Unknown command: " + command)
def get_log_string(self):
module = Module4DC(addr=self.address, line=IdiBusSerialLine(port=self.port, baudrate=self.speed))
str = ""
for i in range(4):
data = module.set_channel_data(i)
if data == None:
return None
else:
str += f"{data["voltage"]},{data["current"]},"
class ExecSystem(Executioner):
def __init__(self):
super().__init__("Module4DC")
def execute(self, command, args):
if command == "sleep":
sleep(args[0])
elif command == "exit":
sys.exit(0)
else:
print("Unknown command: " + command)
def get_log_string(self):
return "System is ok. :P"

@ -12,7 +12,7 @@ class IdiBusModule():
raise TypeError("Line is not an IdiBusSerialLine") raise TypeError("Line is not an IdiBusSerialLine")
self.line = line self.line = line
def startLongOp(self): def startLongOp(self):
self.line.timeout = 3 self.line.timeout = 1
def endLongOp(self): def endLongOp(self):
self.line.timeout = self.line.defaultTimeout self.line.timeout = self.line.defaultTimeout
def c_Init(self): def c_Init(self):

@ -71,7 +71,7 @@ class IdiBusSMESParser(IdiBusMES):
unpacked = struct.unpack(format_string, self.getData()) unpacked = struct.unpack(format_string, self.getData())
return unpacked return unpacked
except struct.error as e: except struct.error as e:
print(f"Parse error: {e}") print(f"Parse error: {e}. got len {len(self.getData())}")
return None return None
except UnicodeDecodeError as e: except UnicodeDecodeError as e:
print(f"Parse error: {e}") print(f"Parse error: {e}")

Loading…
Cancel
Save