accessibles: provide global counter
Change-Id: I65f4c8a1c0944e29c51eea1d40cdbbdb91c2ad18 Reviewed-on: https://forge.frm2.tum.de/review/18211 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
parent
22645b449b
commit
33e6ded5b8
@ -59,7 +59,15 @@ from secop.datatypes import DataType, EnumType, TupleOf, StringType, FloatRange,
|
|||||||
EVENT_ONLY_ON_CHANGED_VALUES = False
|
EVENT_ONLY_ON_CHANGED_VALUES = False
|
||||||
|
|
||||||
|
|
||||||
class Parameter(object):
|
class CountedObj(object):
|
||||||
|
ctr = [0]
|
||||||
|
def __init__(self):
|
||||||
|
cl = self.__class__.ctr
|
||||||
|
cl[0] += 1
|
||||||
|
self.ctr = cl[0]
|
||||||
|
|
||||||
|
|
||||||
|
class Parameter(CountedObj):
|
||||||
"""storage for Parameter settings + value + qualifiers
|
"""storage for Parameter settings + value + qualifiers
|
||||||
|
|
||||||
if readonly is False, the value can be changed (by code, or remote)
|
if readonly is False, the value can be changed (by code, or remote)
|
||||||
@ -88,6 +96,7 @@ class Parameter(object):
|
|||||||
timestamp=0,
|
timestamp=0,
|
||||||
optional=False,
|
optional=False,
|
||||||
ctr=None):
|
ctr=None):
|
||||||
|
super(Parameter, self).__init__()
|
||||||
if not isinstance(datatype, DataType):
|
if not isinstance(datatype, DataType):
|
||||||
if issubclass(datatype, DataType):
|
if issubclass(datatype, DataType):
|
||||||
# goodie: make an instance from a class (forgotten ()???)
|
# goodie: make an instance from a class (forgotten ()???)
|
||||||
@ -112,7 +121,7 @@ class Parameter(object):
|
|||||||
self.timestamp = 0
|
self.timestamp = 0
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(
|
return '%s_%d(%s)' % (self.__class__.__name__, self.ctr, ', '.join(
|
||||||
['%s=%r' % (k, v) for k, v in sorted(self.__dict__.items())]))
|
['%s=%r' % (k, v) for k, v in sorted(self.__dict__.items())]))
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
@ -136,13 +145,15 @@ class Parameter(object):
|
|||||||
return self.datatype.export_value(self.value)
|
return self.datatype.export_value(self.value)
|
||||||
|
|
||||||
|
|
||||||
class Override(object):
|
class Override(CountedObj):
|
||||||
"""Stores the overrides to ba applied to a Parameter
|
"""Stores the overrides to ba applied to a Parameter
|
||||||
|
|
||||||
note: overrides are applied by the metaclass during class creating
|
note: overrides are applied by the metaclass during class creating
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwds):
|
def __init__(self, **kwds):
|
||||||
|
super(Override, self).__init__()
|
||||||
self.kwds = kwds
|
self.kwds = kwds
|
||||||
|
self.kwds['ctr'] = self.ctr
|
||||||
|
|
||||||
def apply(self, paramobj):
|
def apply(self, paramobj):
|
||||||
if isinstance(paramobj, Parameter):
|
if isinstance(paramobj, Parameter):
|
||||||
@ -160,10 +171,11 @@ class Override(object):
|
|||||||
paramobj)
|
paramobj)
|
||||||
|
|
||||||
|
|
||||||
class Command(object):
|
class Command(CountedObj):
|
||||||
"""storage for Commands settings (description + call signature...)
|
"""storage for Commands settings (description + call signature...)
|
||||||
"""
|
"""
|
||||||
def __init__(self, description, arguments=None, result=None, optional=False):
|
def __init__(self, description, arguments=None, result=None, optional=False):
|
||||||
|
super(Command, self).__init__()
|
||||||
# descriptive text for humans
|
# descriptive text for humans
|
||||||
self.description = description
|
self.description = description
|
||||||
# list of datatypes for arguments
|
# list of datatypes for arguments
|
||||||
@ -174,7 +186,7 @@ class Command(object):
|
|||||||
self.optional = optional
|
self.optional = optional
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(
|
return '%s_%d(%s)' % (self.__class__.__name__, self.ctr, ', '.join(
|
||||||
['%s=%r' % (k, v) for k, v in sorted(self.__dict__.items())]))
|
['%s=%r' % (k, v) for k, v in sorted(self.__dict__.items())]))
|
||||||
|
|
||||||
def for_export(self):
|
def for_export(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user