autopep8
Change-Id: I4e40e0ef8e80999832846eac3a415fdd767c6d98
This commit is contained in:
parent
241af728d6
commit
462b6a0a7e
@ -27,6 +27,7 @@ import code
|
||||
|
||||
|
||||
class NameSpace(dict):
|
||||
|
||||
def __init__(self):
|
||||
dict.__init__(self)
|
||||
self.__const = set()
|
||||
@ -63,6 +64,7 @@ from os import path
|
||||
|
||||
|
||||
class ClientConsole(object):
|
||||
|
||||
def __init__(self, cfgname, basepath):
|
||||
self.namespace = NameSpace()
|
||||
self.namespace.setconst('help', self.helpCmd)
|
||||
@ -98,6 +100,7 @@ from secop.protocol.messages import *
|
||||
|
||||
|
||||
class TCPConnection(object):
|
||||
|
||||
def __init__(self, connect, port, encoding, framing, **kwds):
|
||||
self.log = mlzlog.log.getChild('connection', False)
|
||||
self.encoder = ENCODERS[encoding]()
|
||||
@ -164,6 +167,7 @@ class TCPConnection(object):
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
||||
def __init__(self, opts):
|
||||
self.log = mlzlog.log.getChild('client', True)
|
||||
self._cache = dict()
|
||||
|
@ -46,6 +46,7 @@ EVENT_ONLY_ON_CHANGED_VALUES = False
|
||||
|
||||
|
||||
class PARAM(object):
|
||||
|
||||
def __init__(self,
|
||||
description,
|
||||
validator=float,
|
||||
@ -93,6 +94,7 @@ class PARAM(object):
|
||||
|
||||
# storage for CMDs settings (description + call signature...)
|
||||
class CMD(object):
|
||||
|
||||
def __init__(self, description, arguments, result):
|
||||
# descriptive text for humans
|
||||
self.description = description
|
||||
@ -117,6 +119,7 @@ class CMD(object):
|
||||
|
||||
|
||||
class DeviceMeta(type):
|
||||
|
||||
def __new__(mcs, name, bases, attrs):
|
||||
newtype = type.__new__(mcs, name, bases, attrs)
|
||||
if '__constructed__' in attrs:
|
||||
@ -251,7 +254,8 @@ class Device(object):
|
||||
self.PARAMS = params
|
||||
|
||||
# check and apply properties specified in cfgdict
|
||||
# moduleproperties are to be specified as '.<propertyname>=<propertyvalue>'
|
||||
# moduleproperties are to be specified as
|
||||
# '.<propertyname>=<propertyvalue>'
|
||||
for k, v in cfgdict.items():
|
||||
if k[0] == '.':
|
||||
if k[1:] in self.PROPERTIES:
|
||||
|
@ -30,9 +30,11 @@ from secop.protocol import status
|
||||
from secop.validators import floatrange, positive, enum, nonnegative, vector
|
||||
from secop.lib import clamp, mkthread
|
||||
|
||||
|
||||
class CryoBase(Driveable):
|
||||
pass
|
||||
|
||||
|
||||
class Cryostat(CryoBase):
|
||||
"""simulated cryostat with:
|
||||
|
||||
@ -81,7 +83,8 @@ class Cryostat(CryoBase):
|
||||
validator=nonnegative, default=0, unit="K",
|
||||
),
|
||||
pid=PARAM("regulation coefficients",
|
||||
validator=vector(nonnegative, floatrange(0, 100), floatrange(0, 100)),
|
||||
validator=vector(nonnegative, floatrange(
|
||||
0, 100), floatrange(0, 100)),
|
||||
default=(40, 10, 2), readonly=False,
|
||||
group='pid',
|
||||
),
|
||||
|
@ -31,13 +31,17 @@ try:
|
||||
from pvaccess import Channel # import EPIVSv4 functionallity, PV access
|
||||
except ImportError:
|
||||
class Channel(object):
|
||||
|
||||
def __init__(self, pv_name):
|
||||
self.pv_name = pv_name
|
||||
self.value = 0.0
|
||||
|
||||
def get(self):
|
||||
return self
|
||||
|
||||
def getDouble(self):
|
||||
return self.value
|
||||
|
||||
def put(self, value):
|
||||
try:
|
||||
self.value = value
|
||||
@ -48,10 +52,12 @@ try:
|
||||
from epics import PV
|
||||
except ImportError:
|
||||
class PV(object):
|
||||
|
||||
def __init__(self, pv_name):
|
||||
self.pv_name = pv_name
|
||||
self.value = 0.0
|
||||
|
||||
|
||||
class EpicsReadable(Readable):
|
||||
"""EpicsDriveable handles a Driveable interfacing to EPICS v4"""
|
||||
# Commmon PARAMS for all EPICS devices
|
||||
@ -71,7 +77,8 @@ class EpicsReadable(Readable):
|
||||
def _read_pv(self, pv_name):
|
||||
if self.epics_version == 'v4':
|
||||
pv_channel = Channel(pv_name)
|
||||
# TODO: cannot handle read of string (is there a .getText() or .getString() ?)
|
||||
# TODO: cannot handle read of string (is there a .getText() or
|
||||
# .getString() ?)
|
||||
return_value = pv_channel.get().getDouble()
|
||||
else: # Not EPICS v4
|
||||
# TODO: fix this, it does not work
|
||||
@ -95,7 +102,6 @@ class EpicsReadable(Readable):
|
||||
pv = PV(pv_name + ".VAL")
|
||||
pv.value = write_value
|
||||
|
||||
|
||||
def read_value(self, maxage=0):
|
||||
return self._read_pv(self.value_pv)
|
||||
|
||||
@ -109,7 +115,6 @@ class EpicsReadable(Readable):
|
||||
return (status.OK, 'no pv set')
|
||||
|
||||
|
||||
|
||||
class EpicsDriveable(Driveable):
|
||||
"""EpicsDriveable handles a Driveable interfacing to EPICS v4"""
|
||||
# Commmon PARAMS for all EPICS devices
|
||||
@ -133,7 +138,8 @@ class EpicsDriveable(Driveable):
|
||||
def _read_pv(self, pv_name):
|
||||
if self.epics_version == 'v4':
|
||||
pv_channel = Channel(pv_name)
|
||||
# TODO: cannot handle read of string (is there a .getText() or .getString() ?)
|
||||
# TODO: cannot handle read of string (is there a .getText() or
|
||||
# .getString() ?)
|
||||
return_value = pv_channel.get().getDouble()
|
||||
else: # Not EPICS v4
|
||||
# TODO: fix this, it does not work
|
||||
@ -177,9 +183,11 @@ class EpicsDriveable(Driveable):
|
||||
(status.BUSY, 'Moving')
|
||||
|
||||
|
||||
|
||||
"""Temperature control loop"""
|
||||
# should also derive from secop.core.temperaturecontroller, once its features are agreed upon
|
||||
# should also derive from secop.core.temperaturecontroller, once its
|
||||
# features are agreed upon
|
||||
|
||||
|
||||
class EpicsTempCtrl(EpicsDriveable):
|
||||
|
||||
PARAMS = {
|
||||
@ -219,4 +227,3 @@ class EpicsTempCtrl(EpicsDriveable):
|
||||
# TODO: add support for strings over epics pv
|
||||
# def write_heaterrange(self, range_value):
|
||||
# self._write_pv(self.heaterrange_pv, range_value)
|
||||
|
||||
|
@ -37,6 +37,7 @@ ITEM_TYPE_MODULE = QTreeWidgetItem.UserType + 2
|
||||
ITEM_TYPE_PARAMETER = QTreeWidgetItem.UserType + 3
|
||||
|
||||
|
||||
|
||||
class QSECNode(SECNode, QObject):
|
||||
newData = pyqtSignal(str, str, object) # module, parameter, data
|
||||
|
||||
@ -63,6 +64,7 @@ class QSECNode(SECNode, QObject):
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(MainWindow, self).__init__(parent)
|
||||
|
||||
|
@ -56,6 +56,7 @@ class ParameterButtons(QWidget):
|
||||
|
||||
|
||||
class ModuleCtrl(QWidget):
|
||||
|
||||
def __init__(self, node, module, parent=None):
|
||||
super(ModuleCtrl, self).__init__(parent)
|
||||
loadUi(self, 'modulectrl.ui')
|
||||
|
@ -32,6 +32,7 @@ from secop.protocol.errors import SECOPError
|
||||
|
||||
|
||||
class NodeCtrl(QWidget):
|
||||
|
||||
def __init__(self, node, parent=None):
|
||||
super(NodeCtrl, self).__init__(parent)
|
||||
loadUi(self, 'nodectrl.ui')
|
||||
|
@ -29,6 +29,7 @@ from secop.validators import validator_to_str
|
||||
|
||||
|
||||
class ParameterView(QWidget):
|
||||
|
||||
def __init__(self, node, module, parameter, parent=None):
|
||||
super(ParameterView, self).__init__(parent)
|
||||
loadUi(self, 'paramview.ui')
|
||||
|
@ -80,6 +80,7 @@ def format_time(timestamp=None):
|
||||
|
||||
|
||||
class Timezone(tzinfo):
|
||||
|
||||
def __init__(self, offset, name='unknown timezone'):
|
||||
self.offset = offset
|
||||
self.name = name
|
||||
|
@ -46,6 +46,7 @@ from secop.lib.parsing import format_time
|
||||
|
||||
|
||||
class Dispatcher(object):
|
||||
|
||||
def __init__(self, logger, options):
|
||||
self.equipment_id = options.pop('equipment_id')
|
||||
self.log = logger
|
||||
|
@ -36,6 +36,7 @@ DEMO_RE = re.compile(
|
||||
|
||||
|
||||
class DemoEncoder(MessageEncoder):
|
||||
|
||||
def decode(sef, encoded):
|
||||
# match [!][*|devicename][: *|paramname [: *|propname]] [=value]
|
||||
match = DEMO_RE.match(encoded)
|
||||
|
@ -92,6 +92,7 @@ DEMO_RE_OTHER = re.compile(
|
||||
|
||||
|
||||
class DemoEncoder(MessageEncoder):
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
MessageEncoder.__init__(self, *args, **kwds)
|
||||
self.result = [] # for decoding
|
||||
@ -321,6 +322,7 @@ DEMO_RE_MZ = re.compile(
|
||||
|
||||
|
||||
class DemoEncoder_MZ(MessageEncoder):
|
||||
|
||||
def decode(sef, encoded):
|
||||
m = DEMO_RE_MZ.match(encoded)
|
||||
if m:
|
||||
|
@ -135,15 +135,18 @@ class DemoEncoder(MessageEncoder):
|
||||
encode_cmd_result, ),
|
||||
WriteRequest: (
|
||||
WRITEREQUEST,
|
||||
lambda msg: "%s:%s" % (msg.module, msg.parameter) if msg.parameter else msg.module,
|
||||
lambda msg: "%s:%s" % (
|
||||
msg.module, msg.parameter) if msg.parameter else msg.module,
|
||||
'value', ),
|
||||
WriteReply: (
|
||||
WRITEREPLY,
|
||||
lambda msg: "%s:%s" % (msg.module, msg.parameter) if msg.parameter else msg.module,
|
||||
lambda msg: "%s:%s" % (
|
||||
msg.module, msg.parameter) if msg.parameter else msg.module,
|
||||
'value', ),
|
||||
PollRequest: (
|
||||
TRIGGERREQUEST,
|
||||
lambda msg: "%s:%s" % (msg.module, msg.parameter) if msg.parameter else msg.module,
|
||||
lambda msg: "%s:%s" % (
|
||||
msg.module, msg.parameter) if msg.parameter else msg.module,
|
||||
),
|
||||
HeartbeatRequest: (
|
||||
HEARTBEATREQUEST,
|
||||
@ -158,7 +161,8 @@ class DemoEncoder(MessageEncoder):
|
||||
encode_error_msg, ),
|
||||
Value: (
|
||||
EVENT,
|
||||
lambda msg: "%s:%s" % (msg.module, msg.parameter or (msg.command + '()')) if msg.parameter or msg.command else msg.module,
|
||||
lambda msg: "%s:%s" % (msg.module, msg.parameter or (
|
||||
msg.command + '()')) if msg.parameter or msg.command else msg.module,
|
||||
encode_value_data, ),
|
||||
}
|
||||
DECODEMAP = {
|
||||
|
@ -35,6 +35,7 @@ except ImportError:
|
||||
|
||||
|
||||
class PickleEncoder(MessageEncoder):
|
||||
|
||||
def encode(self, messageobj):
|
||||
"""msg object -> transport layer message"""
|
||||
return pickle.dumps(messageobj)
|
||||
|
@ -37,6 +37,7 @@ SCPMESSAGE = re.compile(
|
||||
|
||||
|
||||
class SCPEncoder(MessageEncoder):
|
||||
|
||||
def encode(self, msg):
|
||||
"""msg object -> transport layer message"""
|
||||
# fun for Humans
|
||||
|
@ -30,6 +30,7 @@ from secop.lib.parsing import *
|
||||
|
||||
|
||||
class TextEncoder(MessageEncoder):
|
||||
|
||||
def __init__(self):
|
||||
# build safe namespace
|
||||
ns = dict()
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
|
||||
class SECOPError(RuntimeError):
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
self.args = args
|
||||
for k, v in kwds.items():
|
||||
|
@ -35,6 +35,7 @@ from secop.protocol.messages import HelpMessage
|
||||
|
||||
|
||||
class TCPRequestHandler(SocketServer.BaseRequestHandler):
|
||||
|
||||
def setup(self):
|
||||
self.log = self.server.log
|
||||
self._queue = collections.deque(maxlen=100)
|
||||
|
@ -50,6 +50,7 @@ class Message(object):
|
||||
|
||||
|
||||
class Value(object):
|
||||
|
||||
def __init__(self,
|
||||
module,
|
||||
parameter=None,
|
||||
|
@ -95,6 +95,7 @@ class Message(object):
|
||||
|
||||
|
||||
class Value(object):
|
||||
|
||||
def __init__(self, value=Ellipsis, qualifiers=None, **kwds):
|
||||
self.dev = ''
|
||||
self.param = ''
|
||||
@ -166,6 +167,7 @@ class HelpMessage(Message):
|
||||
|
||||
|
||||
class NoSuchDeviceError(ErrorMessage):
|
||||
|
||||
def __init__(self, *devs):
|
||||
ErrorMessage.__init__(
|
||||
self,
|
||||
@ -175,6 +177,7 @@ class NoSuchDeviceError(ErrorMessage):
|
||||
|
||||
|
||||
class NoSuchParamError(ErrorMessage):
|
||||
|
||||
def __init__(self, dev, *params):
|
||||
ErrorMessage.__init__(
|
||||
self,
|
||||
@ -185,6 +188,7 @@ class NoSuchParamError(ErrorMessage):
|
||||
|
||||
|
||||
class ParamReadonlyError(ErrorMessage):
|
||||
|
||||
def __init__(self, dev, *params):
|
||||
ErrorMessage.__init__(
|
||||
self,
|
||||
@ -196,6 +200,7 @@ class ParamReadonlyError(ErrorMessage):
|
||||
|
||||
|
||||
class InvalidParamValueError(ErrorMessage):
|
||||
|
||||
def __init__(self, dev, param, value, e):
|
||||
ErrorMessage.__init__(
|
||||
self,
|
||||
@ -207,6 +212,7 @@ class InvalidParamValueError(ErrorMessage):
|
||||
|
||||
|
||||
class InternalError(ErrorMessage):
|
||||
|
||||
def __init__(self, err, **kwds):
|
||||
ErrorMessage.__init__(
|
||||
self, errorstring=str(err), errortype='InternalError', **kwds)
|
||||
|
@ -39,6 +39,7 @@ from secop.errors import ConfigError
|
||||
|
||||
|
||||
class Server(object):
|
||||
|
||||
def __init__(self, name, workdir, parentLogger=None):
|
||||
self._name = name
|
||||
self._workdir = workdir
|
||||
|
@ -200,6 +200,7 @@ class oneof(Validator):
|
||||
|
||||
|
||||
class enum(Validator):
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
self.mapping = {}
|
||||
# use given kwds directly
|
||||
|
Loading…
x
Reference in New Issue
Block a user