Skip to content

Commit

Permalink
V1.18.18
Browse files Browse the repository at this point in the history
  • Loading branch information
jgyates committed Nov 2, 2023
1 parent c473889 commit 9191608
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 122 deletions.
4 changes: 2 additions & 2 deletions data/controller/Evolution_Liquid_Cooled.json
Original file line number Diff line number Diff line change
Expand Up @@ -1240,11 +1240,11 @@
"comment": "The 'command_sequence can be one or more commands",
"command_sequence" : [
{
"comment": "the value written to 'reg' is supplied by the user. 'input_title' is required. 'length' (number of mobus bytes to write) is 2 by default,but must be a multiple of 2",
"comment": "the value written to 'reg' is supplied by the user. 'input_title' is required. 'length' (number of modbus bytes to write) is 2 by default,but must be a multiple of 2",
"comment2": "'bounds_reg' is optional but allows the user interface to bounds check the data before sending it to genmon",
"comment3": "'tooltip' is optional but allows the user interface to display more information regarding the input.",
"reg": "023e",
"input_title": "Exercise Duration",
"input_title": "Minutes",
"type": "int",
"length": 2,
"bounds_regex":"^([1][2-9])|([2-5][0-9])|([6][0])$",
Expand Down
22 changes: 12 additions & 10 deletions genmonlib/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ def SetCommandButton(self, CommandString):
CommandSetList = json.loads(EntryString)
# validate object
if not isinstance(CommandSetList, list) and not (len(CommandSetList) == 0):
self.LogError("Invalid button object in SetCommandButton")
return "Error: Invalid button object"
# Execute Command
return self.ExecuteRemoteCommand(CommandSetList)
Expand All @@ -852,7 +853,7 @@ def SetCommandButton(self, CommandString):
return "Error: Invalid input for SetCommandButton (2), see error log."
else:
self.LogError("Error in SetCommandButton: invalid input: " + str(CommandString))
return "Error: Invalid input for SetButton (3)."
return "Error: Invalid input for SetCommandButton (3)."
return "OK"
except Exception as e1:
self.LogErrorLine("Error in SetCommandButton: " + str(e1))
Expand All @@ -879,7 +880,7 @@ def ExecuteRemoteCommand(self, CommandSetList):
if not "onewordcommand" in button_command.keys():
self.LogError("Error on ExecuteRemoteCommand, invalid dict: " + str(button_command))
return "Error: invalid input in ExecuteRemoteCommand (2)"
# make a copy of the dict so we can add the input without modifying the origianl
# make a copy of the dict so we can add the input without modifying the original
returndict = self.GetButtons(singlebuttonname = button_command["onewordcommand"])
if returndict == None:
self.LogError("Error on ExecuteRemoteCommand, command not found: " + str(button_command))
Expand All @@ -890,21 +891,21 @@ def ExecuteRemoteCommand(self, CommandSetList):
return "Error: invalid command in ExecuteRemoteCommand (2)"

# selected_command from genmon, button_command from UI
if not "command_sequence" in selected_command or not "command_sequence" in button_command:
if not "command_sequence" in selected_command.keys() or not "command_sequence" in button_command.keys():
self.LogError("Error on ExecuteRemoteCommand, command sequence mismatch: " + str(button_command))
return "Error on ExecuteRemoteCommand, command sequence mismatch"
if not (len(selected_command["command_sequence"]) == len(button_command["command_sequence"])):
self.LogError("Error on ExecuteRemoteCommand, command sequence mismatch (2): " + str(button_command))
return "Error on ExecuteRemoteCommand, command sequence mismatch (2)"
# iterate thru both lists of commands
for gm_cmd, ui_cmd in zip(selected_command["command_sequence"], button_command["command_sequence"]):
if "input_title" in gm_cmd and "value" in ui_cmd:
if "bounds_regex" in gm_cmd:
if "input_title" in gm_cmd.keys() and "value" in ui_cmd.keys():
if "bounds_regex" in gm_cmd.keys():
if not re.match(gm_cmd["bounds_regex"], str(ui_cmd["value"])):
self.LogError("Error in ExecuteRemoteCommand: Failed bounds check: " + str(ui_cmd))
return "Error in ExecuteRemoteCommand: Failed bounds check"
if "type" in gm_cmd and gm_cmd["type"] == "int":
if not "length" in gm_cmd or ("length" in gm_cmd and gm_cmd["length"] == 2):
if "type" in gm_cmd.keys() and gm_cmd["type"] == "int":
if not "length" in gm_cmd.keys() or ("length" in gm_cmd.keys() and gm_cmd["length"] == 2):
gm_cmd["value"] = "%04x" % int(ui_cmd["value"])
elif "length" in gm_cmd and gm_cmd["length"] == 4:
gm_cmd["value"] = "%08x" % int(ui_cmd["value"])
Expand All @@ -914,8 +915,9 @@ def ExecuteRemoteCommand(self, CommandSetList):
else:
self.LogError("Error in ExecuteRemoteCommand, unsupported type: " + str(ui_cmd))
return "Error in ExecuteRemoteCommand, unsupported type"
elif not "reg" in gm_cmd or not "value" in gm_cmd:
elif not "reg" in gm_cmd.keys() or not "value" in gm_cmd.keys():
self.LogError("Error in ExecuteRemoteCommand, invalid command in sequence: " + str(selected_command))
self.LogDebug(str(button_command))
return "Error in ExecuteRemoteCommand, invalid command in sequence"
# execute the command selected_command
return self.ExecuteCommandSequence(selected_command["command_sequence"])
Expand Down Expand Up @@ -972,7 +974,7 @@ def ExecuteCommandSequence(self, command_sequence):
self.LogDebug("Error in ExecuteCommandSequence: invalid value type")
return "Command not found."

return "Remote command sent successfully"
return "OK"
except Exception as e1:
self.LogErrorLine("Error in ExecuteCommandSequence: " + str(e1))
self.LogDebug(str(command_sequence))
Expand All @@ -988,7 +990,7 @@ def GetButtons(self, singlebuttonname = None):
# get full simplified list for GUI
return {}
except Exception as e1:
self.LogErrorLine("Error in SetButton: " + str(e1))
self.LogErrorLine("Error in GetButtons: " + str(e1))
return {}
# ------------ GeneratorController::GetStartInfo ----------------------------
# return a dictionary with startup info for the gui
Expand Down
14 changes: 5 additions & 9 deletions genmonlib/custom_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,15 +1290,8 @@ def GetDisplayList(self, inputdict, key_name, JSONNum=False, no_units=False):
return ReturnValue
return ReturnValue

# -------------CustomController:SetButton------------------------------------
def SetButton(self):
try:
pass
except Exception as e1:
self.LogErrorLine("Error in SetButton: " + str(e1))
return {}
# -------------CustomController:GetButtons-----------------------------------
def GetButtons(self):
# -------------CustomController:GetButtons--------------------------------
def GetButtons(self, singlebuttonname = None):
try:
button_list = self.controllerimport.get("buttons", None)

Expand Down Expand Up @@ -1358,6 +1351,9 @@ def GetButtons(self):
if CommandError:
continue

if singlebuttonname != None and singlebuttonname == button["onewordcommand"]:
return button

return_buttons.append(button)

return return_buttons
Expand Down
2 changes: 1 addition & 1 deletion genserv.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def ProcessCommand(command):

except Exception as e1:
data = "Retry"
LogError("Error on command function: " + str(e1))
LogErrorLine("Error on command function: " + str(e1))

if command in [
"status_json",
Expand Down
Loading

0 comments on commit 9191608

Please sign in to comment.