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) result = node.handle_command(command)
if result is not None: if result is not None:
break break
if isinstance(result, str): if isinstance(result, dict):
return dict(type='accept-command', result=result) 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): def info(self):
return ["na"] return ["na"]

View File

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

View File

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

View File

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

View File

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