fixes in sea
- call explicitely __set_name__ on produced parameters - as Parameters.override has changed, do not use it
This commit is contained in:
parent
7d2eacfe5c
commit
3d9e9c59d6
@ -41,7 +41,7 @@ from secop.client import ProxyClient
|
|||||||
from secop.datatypes import ArrayOf, BoolType, \
|
from secop.datatypes import ArrayOf, BoolType, \
|
||||||
EnumType, FloatRange, IntRange, StringType
|
EnumType, FloatRange, IntRange, StringType
|
||||||
from secop.errors import ConfigError, HardwareError, secop_error, NoSuchModuleError
|
from secop.errors import ConfigError, HardwareError, secop_error, NoSuchModuleError
|
||||||
from secop.lib import getGeneralConfig, mkthread
|
from secop.lib import getGeneralConfig, mkthread, formatExtendedStack
|
||||||
from secop.lib.asynconn import AsynConn, ConnectionClosed
|
from secop.lib.asynconn import AsynConn, ConnectionClosed
|
||||||
from secop.modules import Attached, Command, Done, Drivable, \
|
from secop.modules import Attached, Command, Done, Drivable, \
|
||||||
Module, Parameter, Property, Readable, Writable
|
Module, Parameter, Property, Readable, Writable
|
||||||
@ -124,6 +124,7 @@ class SeaClient(ProxyClient, Module):
|
|||||||
if config:
|
if config:
|
||||||
self.default_json_file[name] = config.split()[0] + '.json'
|
self.default_json_file[name] = config.split()[0] + '.json'
|
||||||
self.io = None
|
self.io = None
|
||||||
|
self.asyncio = None
|
||||||
ProxyClient.__init__(self)
|
ProxyClient.__init__(self)
|
||||||
Module.__init__(self, name, log, opts, srv)
|
Module.__init__(self, name, log, opts, srv)
|
||||||
|
|
||||||
@ -153,7 +154,7 @@ class SeaClient(ProxyClient, Module):
|
|||||||
"""send a request and wait for reply"""
|
"""send a request and wait for reply"""
|
||||||
with self._write_lock:
|
with self._write_lock:
|
||||||
if not self.io or not self.io.connection:
|
if not self.io or not self.io.connection:
|
||||||
if not self.asyncio.connection:
|
if not self.asyncio or not self.asyncio.connection:
|
||||||
self._connect(None)
|
self._connect(None)
|
||||||
self.io = AsynConn(self.uri)
|
self.io = AsynConn(self.uri)
|
||||||
assert self.io.readline() == b'OK'
|
assert self.io.readline() == b'OK'
|
||||||
@ -314,12 +315,14 @@ class SeaConfigCreator(SeaClient):
|
|||||||
stripped, _, ext = filename.rpartition('.')
|
stripped, _, ext = filename.rpartition('.')
|
||||||
service = SERVICE_NAMES[ext]
|
service = SERVICE_NAMES[ext]
|
||||||
seaconn = 'sea_' + service
|
seaconn = 'sea_' + service
|
||||||
with open(join(seaconfdir, stripped + '.cfg'), 'w') as fp:
|
cfgfile = join(seaconfdir, stripped + '.cfg')
|
||||||
|
with open(cfgfile, 'w') as fp:
|
||||||
fp.write(CFG_HEADER % dict(config=filename, seaconn=seaconn, service=service,
|
fp.write(CFG_HEADER % dict(config=filename, seaconn=seaconn, service=service,
|
||||||
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{').replace('[{', '[\n{').replace('}]}, ', '}]},\n\n')
|
content = json.dumps(descr).replace('}, {', '},\n{').replace('[{', '[\n{').replace('}]}, ', '}]},\n\n')
|
||||||
|
result.append('%s\n' % cfgfile)
|
||||||
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)))
|
||||||
@ -495,7 +498,8 @@ class SeaModule(Module):
|
|||||||
if key in cls.accessibles:
|
if key in cls.accessibles:
|
||||||
if key == 'target':
|
if key == 'target':
|
||||||
kwds['readonly'] = False
|
kwds['readonly'] = False
|
||||||
pobj = cls.accessibles[key].override(**kwds)
|
pobj = cls.accessibles[key]
|
||||||
|
pobj.init(kwds)
|
||||||
datatype = kwds.get('datatype', cls.accessibles[key].datatype)
|
datatype = kwds.get('datatype', cls.accessibles[key].datatype)
|
||||||
else:
|
else:
|
||||||
pobj = Parameter(**kwds)
|
pobj = Parameter(**kwds)
|
||||||
@ -542,12 +546,17 @@ class SeaModule(Module):
|
|||||||
# create standard parameters like value and status, if not yet there
|
# create standard parameters like value and status, if not yet there
|
||||||
for pname, pobj in cls.accessibles.items():
|
for pname, pobj in cls.accessibles.items():
|
||||||
if pname == 'pollinterval':
|
if pname == 'pollinterval':
|
||||||
attributes[pname] = pobj.override(export=False)
|
pobj.export = False
|
||||||
|
attributes[pname] = pobj
|
||||||
|
pobj.__set_name__(cls, pname)
|
||||||
elif pname not in attributes and isinstance(pobj, Parameter):
|
elif pname not in attributes and isinstance(pobj, Parameter):
|
||||||
attributes[pname] = pobj.override(poll=False, needscfg=False)
|
pobj.poll = False
|
||||||
|
pobj.needscfg = False
|
||||||
|
attributes[pname] = pobj
|
||||||
|
pobj.__set_name__(cls, pname)
|
||||||
|
|
||||||
classname = '%s_%s' % (cls.__name__, sea_object)
|
classname = '%s_%s' % (cls.__name__, sea_object)
|
||||||
# print(name, attributes)
|
attributes['pollerClass'] = None
|
||||||
newcls = type(classname, (cls,), attributes)
|
newcls = type(classname, (cls,), attributes)
|
||||||
return Module.__new__(newcls)
|
return Module.__new__(newcls)
|
||||||
|
|
||||||
@ -640,5 +649,6 @@ class SeaDrivable(SeaModule, Drivable):
|
|||||||
if value is not None:
|
if value is not None:
|
||||||
self.target = value
|
self.target = value
|
||||||
|
|
||||||
|
@Command()
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._iodev.query('%s is_running 0' % self.sea_object)
|
self._iodev.query('%s is_running 0' % self.sea_object)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user