diff --git a/base.py b/base.py index 6f4438d..c0eb505 100644 --- a/base.py +++ b/base.py @@ -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"] diff --git a/client/cssFiles/SEAWebClientGroup.css b/client/cssFiles/SEAWebClientGroup.css index 5b5c8eb..6fe5ba7 100644 --- a/client/cssFiles/SEAWebClientGroup.css +++ b/client/cssFiles/SEAWebClientGroup.css @@ -48,7 +48,7 @@ } .row-waiting-for-answer { - background-color: orangered; + background-color: LightGoldenrodYellow; } /* ------------------------------ icon-modules ------------------------------ */ diff --git a/client/jsFiles/SEAWebClientCommunication.js b/client/jsFiles/SEAWebClientCommunication.js index 5974359..7634c7b 100644 --- a/client/jsFiles/SEAWebClientCommunication.js +++ b/client/jsFiles/SEAWebClientCommunication.js @@ -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); diff --git a/client/jsFiles/SEAWebClientGroup.js b/client/jsFiles/SEAWebClientGroup.js index 30ca0a1..2df49e1 100644 --- a/client/jsFiles/SEAWebClientGroup.js +++ b/client/jsFiles/SEAWebClientGroup.js @@ -223,7 +223,12 @@ function createValue (component) { value.classList.add('col-right-value-with-write-permission'); } 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; } diff --git a/secop.py b/secop.py index 51ff6a2..471c2b3 100644 --- a/secop.py +++ b/secop.py @@ -150,17 +150,17 @@ class SecopInteractor(SecopClient): if module not in self.modules: return None logging.info('SENDCOMMAND %r', command) - try: - if is_param: + 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 + except Exception as e: + print(f"{e!r} converting {strvalue} to {self.modules[module]['parameters'][parameter]['datatype']}") + 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, {}