created SeaConfigCreator

running frappy with 'seadesc' cfg does the same as previously
starting 'sea' cfg and performing seaconn:_describe automatically

create mbe.cfg
This commit is contained in:
2021-05-19 17:37:17 +02:00
parent 3e599a24d7
commit 70c3f5f37f
5 changed files with 86 additions and 41 deletions

8
cfg/develop/seadesc.cfg Normal file
View File

@ -0,0 +1,8 @@
[NODE]
description = sea client (communication only)
id = comm.sea.psi.ch
[seaconn]
class = secop_psi.sea.SeaConfigCreator
description = a SEA connection. will shut down after getting the description
visibility = 1

View File

@ -4,7 +4,7 @@ id = mbe.config.sea.psi.ch
[sea_main] [sea_main]
class = secop_psi.sea.SeaClient class = secop_psi.sea.SeaClient
description = SEA connection to mbe description = main sea connection for mbe.config
config = mbe.config config = mbe.config
service = main service = main
@ -13,23 +13,12 @@ class = secop_psi.sea.SeaDrivable
iodev = sea_main iodev = sea_main
sea_object = tt sea_object = tt
[cc]
class = secop_psi.sea.SeaReadable
iodev = sea_main
sea_object = cc
[p] [p]
class = secop_psi.sea.SeaReadable class = secop_psi.sea.SeaReadable
iodev = sea_main iodev = sea_main
sea_object = p sea_object = p
extra_modules = vacuumpump, gasflow
[vacuumpump] [table]
class = secop_psi.sea.SeaWritable class = secop_psi.sea.SeaReadable
iodev = sea_main iodev = sea_main
single_module = p.vacuumpump sea_object = table
[gasflow]
class = secop_psi.sea.SeaWritable
iodev = sea_main
single_module = p.gasflow

29
cfg/sea/mbe.cfg Normal file
View File

@ -0,0 +1,29 @@
[NODE]
description = thin film oven for AMOR
id = mbe.config.sea.psi.ch
[sea_main]
class = secop_psi.sea.SeaClient
description = main sea connection for mbe.config
config = mbe.config
service = main
[tt]
class = secop_psi.sea.SeaDrivable
iodev = sea_main
sea_object = tt
[cc]
class = secop_psi.sea.SeaReadable
iodev = sea_main
sea_object = cc
[p]
class = secop_psi.sea.SeaReadable
iodev = sea_main
sea_object = p
[table]
class = secop_psi.sea.SeaReadable
iodev = sea_main
sea_object = table

View File

@ -1,4 +1,5 @@
{"tt": {"base": "/tt", "params": [{"path": "", "type": "float", "readonly": false, "cmd": "run tt", "description": "tt", "kids": 14}, {"tt": {"base": "/tt", "params": [
{"path": "", "type": "float", "readonly": false, "cmd": "run tt", "description": "tt", "kids": 14},
{"path": "send", "type": "text", "readonly": false, "cmd": "tt send", "visibility": 3}, {"path": "send", "type": "text", "readonly": false, "cmd": "tt send", "visibility": 3},
{"path": "status", "type": "text", "visibility": 3}, {"path": "status", "type": "text", "visibility": 3},
{"path": "is_running", "type": "int", "readonly": false, "cmd": "tt is_running", "visibility": 3}, {"path": "is_running", "type": "int", "readonly": false, "cmd": "tt is_running", "visibility": 3},
@ -48,7 +49,10 @@
{"path": "set/integ", "type": "float", "readonly": false, "cmd": "tt set/integ", "description": "bigger means faster"}, {"path": "set/integ", "type": "float", "readonly": false, "cmd": "tt set/integ", "description": "bigger means faster"},
{"path": "set/deriv", "type": "float", "readonly": false, "cmd": "tt set/deriv"}, {"path": "set/deriv", "type": "float", "readonly": false, "cmd": "tt set/deriv"},
{"path": "display", "type": "text", "readonly": false, "cmd": "tt display"}, {"path": "display", "type": "text", "readonly": false, "cmd": "tt display"},
{"path": "remote", "type": "bool"}]}, "cc": {"base": "/cc", "params": [{"path": "", "type": "bool", "kids": 96}, {"path": "remote", "type": "bool"}]},
"cc": {"base": "/cc", "params": [
{"path": "", "type": "bool", "kids": 96},
{"path": "send", "type": "text", "readonly": false, "cmd": "cc send", "visibility": 3}, {"path": "send", "type": "text", "readonly": false, "cmd": "cc send", "visibility": 3},
{"path": "status", "type": "text", "visibility": 3}, {"path": "status", "type": "text", "visibility": 3},
{"path": "autodevice", "type": "bool", "readonly": false, "cmd": "cc autodevice"}, {"path": "autodevice", "type": "bool", "readonly": false, "cmd": "cc autodevice"},
@ -144,10 +148,24 @@
{"path": "tm", "type": "float", "visibility": 3}, {"path": "tm", "type": "float", "visibility": 3},
{"path": "tv", "type": "float", "visibility": 3}, {"path": "tv", "type": "float", "visibility": 3},
{"path": "tq", "type": "float", "visibility": 3}, {"path": "tq", "type": "float", "visibility": 3},
{"path": "bdl", "type": "float", "readonly": false, "cmd": "cc bdl"}]}, "p": {"base": "/p", "params": [{"path": "", "type": "float", "kids": 6}, {"path": "bdl", "type": "float", "readonly": false, "cmd": "cc bdl"}]},
"p": {"base": "/p", "params": [
{"path": "", "type": "float", "kids": 6},
{"path": "send", "type": "text", "readonly": false, "cmd": "p send", "visibility": 3}, {"path": "send", "type": "text", "readonly": false, "cmd": "p send", "visibility": 3},
{"path": "status", "type": "text", "visibility": 3}, {"path": "status", "type": "text", "visibility": 3},
{"path": "vacuumpump", "type": "bool", "readonly": false, "cmd": "p vacuumpump"}, {"path": "vacuumpump", "type": "bool", "readonly": false, "cmd": "p vacuumpump"},
{"path": "gasflow", "type": "bool", "readonly": false, "cmd": "p gasflow"}, {"path": "gasflow", "type": "bool", "readonly": false, "cmd": "p gasflow"},
{"path": "tlimit", "type": "float", "readonly": false, "cmd": "p tlimit"}, {"path": "tlimit", "type": "float", "readonly": false, "cmd": "p tlimit"},
{"path": "tlimit_without_vacuum", "type": "float", "readonly": false, "cmd": "p tlimit_without_vacuum"}]}} {"path": "tlimit_without_vacuum", "type": "float", "readonly": false, "cmd": "p tlimit_without_vacuum"}]},
"table": {"base": "/table", "params": [
{"path": "", "type": "none", "kids": 8},
{"path": "send", "type": "text", "readonly": false, "cmd": "table send", "visibility": 3},
{"path": "status", "type": "text", "visibility": 3},
{"path": "fix_tt_set_prop", "type": "bool", "readonly": false, "cmd": "table fix_tt_set_prop"},
{"path": "val_tt_set_prop", "type": "float"},
{"path": "tbl_tt_set_prop", "type": "text", "readonly": false, "cmd": "table tbl_tt_set_prop", "description": "enter value pair separated with colon T1:par1 T2:par2 ..."},
{"path": "fix_tt_set_integ", "type": "bool", "readonly": false, "cmd": "table fix_tt_set_integ"},
{"path": "val_tt_set_integ", "type": "float"},
{"path": "tbl_tt_set_integ", "type": "text", "readonly": false, "cmd": "table tbl_tt_set_integ", "description": "enter value pair separated with colon T1:par1 T2:par2 ..."}]}}

View File

@ -271,9 +271,27 @@ class SeaClient(ProxyClient, Module):
reply = self.request(command) reply = self.request(command)
return reply return reply
@Command(result=StringType()) @Command(StringType(), result=StringType())
def describe(self): def query(self, cmd):
"""save objects (and sub-objects) description""" """a request checking for errors and accepting 0 or 1 line as result"""
errors = []
reply = None
for line in self.request(cmd).split('\n'):
if line.strip().startswith('ERROR:'):
errors.append(line[6:].strip())
elif reply is None:
reply = line.strip()
else:
self.log.info('SEA: superfluous reply %r to %r', reply, cmd)
if errors:
raise HardwareError('; '.join(errors))
return reply
class SeaConfigCreator(SeaClient):
def startModule(self, started_callback):
"""save objects (and sub-objects) description and exit"""
self._connect(lambda: None)
reply = self.request('describe_all') reply = self.request('describe_all')
reply = ''.join('' if line.startswith('WARNING') else line for line in reply.split('\n')) reply = ''.join('' if line.startswith('WARNING') else line for line in reply.split('\n'))
description, reply = json.loads(reply) description, reply = json.loads(reply)
@ -300,28 +318,11 @@ class SeaClient(ProxyClient, Module):
nodedescr=description.get(filename, filename))) nodedescr=description.get(filename, filename)))
for obj in descr: for obj in descr:
fp.write(CFG_MODULE % dict(modcls=modcls[obj], module=obj, seaconn=seaconn)) fp.write(CFG_MODULE % dict(modcls=modcls[obj], module=obj, seaconn=seaconn))
content = json.dumps(descr).replace('}, {', '},\n{') content = json.dumps(descr).replace('}, {', '},\n{').replace('[{', '[\n{').replace('}]}, ', '}]},\n\n')
with open(join(seaconfdir, filename + '.json'), 'w') as fp: with open(join(seaconfdir, filename + '.json'), 'w') as fp:
fp.write(content + '\n') fp.write(content + '\n')
result.append('%s: %s' % (filename, ','.join(n for n in descr))) result.append('%s: %s' % (filename, ','.join(n for n in descr)))
return '; '.join(result) raise SystemExit('; '.join(result))
@Command(StringType(), result=StringType())
def query(self, cmd):
"""a request checking for errors and accepting 0 or 1 line as result"""
errors = []
reply = None
for line in self.request(cmd).split('\n'):
if line.strip().startswith('ERROR:'):
errors.append(line[6:].strip())
elif reply is None:
reply = line.strip()
else:
self.log.info('SEA: superfluous reply %r to %r', reply, cmd)
if errors:
raise HardwareError('; '.join(errors))
return reply
SEA_TO_SECOPTYPE = { SEA_TO_SECOPTYPE = {
'float': FloatRange(), 'float': FloatRange(),