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"
|
||||
Loading…
Reference in new issue