implement SECoP commands on the server side
This commit is contained in:
9
secop.py
9
secop.py
@ -19,17 +19,24 @@ def convert_par(module, name, par):
|
|||||||
|
|
||||||
|
|
||||||
def convert_cmd(module, name, cmd):
|
def convert_cmd(module, name, cmd):
|
||||||
result = dict(type='input', button=True, name=module+":"+name, title=name)
|
result = dict(type='pushbutton', name=module+":"+name, title=name)
|
||||||
result['command'] = 'do %s:%s' % (module, name)
|
result['command'] = 'do %s:%s' % (module, name)
|
||||||
argument = cmd['datainfo'].get('argument')
|
argument = cmd['datainfo'].get('argument')
|
||||||
if cmd['datainfo'].get('result'):
|
if cmd['datainfo'].get('result'):
|
||||||
result['result'] = True
|
result['result'] = True
|
||||||
|
else:
|
||||||
|
if not argument: # simple command like stop
|
||||||
|
return result
|
||||||
|
result['button'] = not argument
|
||||||
|
# result['type'] = pushbutton will be replaced below
|
||||||
if argument:
|
if argument:
|
||||||
if argument['type'] == 'enum':
|
if argument['type'] == 'enum':
|
||||||
result['enum_names'] = [dict(title=k, value=v) for k, v in argument['members'].items()]
|
result['enum_names'] = [dict(title=k, value=v) for k, v in argument['members'].items()]
|
||||||
result['type'] = 'enum'
|
result['type'] = 'enum'
|
||||||
elif argument['type'] == 'bool':
|
elif argument['type'] == 'bool':
|
||||||
result['type'] = 'checkbox'
|
result['type'] = 'checkbox'
|
||||||
|
else:
|
||||||
|
result['type'] = 'input'
|
||||||
else:
|
else:
|
||||||
result['type'] = 'rdonly'
|
result['type'] = 'rdonly'
|
||||||
if cmd['description']:
|
if cmd['description']:
|
||||||
|
Reference in New Issue
Block a user