fix simple command (e.g. stop)

This commit is contained in:
2025-05-05 14:01:18 +02:00
parent 268ebc7e93
commit 5c70017238
5 changed files with 30 additions and 20 deletions

View File

@ -93,9 +93,9 @@ class Client(HandlerBase):
result = node.handle_command(command)
if result is not None:
break
if isinstance(result, str):
if isinstance(result, dict):
return dict(type='accept-command', result=result)
return dict(type='accept-command') # TODO: how to handle result is None?
return dict(type='accept-command')
def info(self):
return ["na"]

View File

@ -48,7 +48,7 @@
}
.row-waiting-for-answer {
background-color: orangered;
background-color: LightGoldenrodYellow;
}
/* ------------------------------ icon-modules ------------------------------ */

View File

@ -277,13 +277,12 @@ function updateValue(component) {
for (var j = 0; j < matches.length; j++) {
let elem = matches[j];
let type = elem.__ctype__; // -> Show Dom-Properties
if (type == "rdonly" || type == "none") {
if (type == "rdonly") {
let text = htmlEscape(component.formatted);
if (text) {
elem.innerHTML = text;
}
}
else if (type == "input") {
} else if (type == "input") {
let row = elem.closest('div');
row.classList.remove('row-waiting-for-answer');
elem.actualValue = component.value;
@ -306,10 +305,10 @@ function updateValue(component) {
// elem.value = j + 1;
// }
// }
elem.value = component.value;
console.log('update pushbutton');
console.log('component.name:', component.name);
console.log('element', elem);
} else if (type == "none") {
// pushbutton (e.g. stop command)
let row = elem.closest('div');
row.classList.remove('row-waiting-for-answer');
}
}
}
@ -468,6 +467,12 @@ function successHandler(s, message) {
// Response to a "updategraph"-server-request.
case "accept-graph":
break;
case "accept-command":
console.log('ACCEPT', message.result)
if (message.result) {
updateValue(message.result);
}
break;
case "error":
console.log("%cError-Message received!", "color:white;background:red");
console.log(message);

View File

@ -223,7 +223,12 @@ function createValue (component) {
value.classList.add('col-right-value-with-write-permission');
}
value.setAttribute('name', component.name);
if (component.type == 'pushbutton') {
console.log('CREATE', component.name);
value.__ctype__ = 'none';
} else {
value.__ctype__ = 'rdonly';
}
return value;
}

View File

@ -150,17 +150,17 @@ class SecopInteractor(SecopClient):
if module not in self.modules:
return None
logging.info('SENDCOMMAND %r', command)
try:
if is_param:
try:
entry = self.setParameterFromString(module, parameter, strvalue)
item = {'name': f'{module}:{parameter}', 'value': str(entry), 'formatted': entry.formatted()}
self.updates[module, parameter] = item
result = True
else:
result = self.execCommandFromString(module, parameter, strvalue)[0]
except Exception as e:
print(f"{e!r} converting {strvalue} to {self.modules[module]['parameters'][parameter]['datatype']}")
return result
self.updates[module, parameter] = item
return True
# called a command
result = self.execCommandFromString(module, parameter, strvalue)
return {'name': f'{module}:{parameter}', 'value': str(result), 'formatted': result.formatted()}
def get_updates(self):
updates, self.updates = self.updates, {}