class RemoteAutomatedRunMonitor(AutomatedRunMonitor): handle = None def __init__(self, host, port, kind, *args, **kw): super(RemoteAutomatedRunMonitor, self).__init__(*args, **kw) self.handle = EthernetCommunicator() self.handle.host = host self.handle.port = port self.handle.kind = kind def _get_value(self, name): p = self.handle.ask('Read {}'.format(name)) return self._float(p) def get_pressure(self, controller, name): cmd = 'GetPressure {}, {}'.format(controller, name) p = self.handle.ask(cmd) return self._float(p, default=1.0) def _float(self, p, default=0.0): try: p = float(p) except (ValueError, TypeError): p = default return p
def __init__(self, *args, **kw): super(FirmwareClient, self).__init__(*args, **kw) c = EthernetCommunicator(host=self.host, port=self.port, use_end=True, kind='TCP') self._comm = c
def open(self): host = self.host port = self.port self._communicator = ec = EthernetCommunicator(host=host, port=port) r = ec.open() if r: self.connected = True return r
def _handle_factory(self): handle = EthernetCommunicator() handle.host = self.host handle.port = self.port handle.kind = self.kind handle.message_frame = self.frame handle.use_end = True return handle
def setup_communicator(self): host = self.host port = self.port self.communicator = ec = EthernetCommunicator( host=host, port=port, kind=self.kind, use_end=self.use_end, message_frame=self.message_frame) r = ec.open() if r: r = self.opened() self.connected = bool(r) return r
class RemotePyScriptRunner(PyScriptRunner): handle = None def __init__(self, host, port, kind, *args, **kw): super(RemotePyScriptRunner, self).__init__(*args, **kw) self.handle = EthernetCommunicator() self.handle.host = host self.handle.port = port self.handle.kind = kind # self.handle.open() def _get_resource(self, name): r = RemoteResource() r.name = name r.handle = self.handle return r def connect(self): return self.handle.open()
def __init__(self, host, port, kind, *args, **kw): super(RemotePyScriptRunner, self).__init__(*args, **kw) self.handle = EthernetCommunicator() self.handle.host = host self.handle.port = port self.handle.kind = kind
def _handle_factory(self, h, p, k): ec = EthernetCommunicator() ec.trait_set(host=h, port=p, kind=k) return ec
def __init__(self, host, port, kind, *args, **kw): super(RemoteAutomatedRunMonitor, self).__init__(*args, **kw) self.handle = EthernetCommunicator() self.handle.host = host self.handle.port = port self.handle.kind = kind