def doInit(self, mode): NamedDigitalOutput.doInit(self, mode) # Don't create PyTango device in simulation mode if mode != SIMULATION: self._remote = self._createPyTangoDevice(devname=self.remote) self._readback = self._createPyTangoDevice(devname=self.readback) self._error = self._createPyTangoDevice(devname=self.error) self._sleeptime = 0.1 else: self._remote = HardwareStub(self) self._readback = HardwareStub(self) self._error = HardwareStub(self)
def doPreinit(self, mode): tango.TemperatureController.doPreinit(self, mode) if mode != SIMULATION: self._controller = self._createPyTangoDevice(self.controller) else: self._controller = HardwareStub(self)
def _setMode(self, mode): super(EpicsDevice, self)._setMode(mode) # remove the PVs on entering simulation mode, to prevent # accidental access to the hardware if mode == SIMULATION: for key in self._pvs: self._pvs[key] = HardwareStub(self)
def doPreinit(self, mode): # Don't create PVs in simulation mode self._pvs = {} self._pvctrls = {} if mode != SIMULATION: # in case we get started in a thread, make sure to use the global # CA context in that thread if epics.ca.current_context() is None: epics.ca.use_initial_context() # When there are standard names for PVs (see motor record), the PV # names may be derived from some prefix. To make this more flexible, # the pv_parameters are obtained via a method that can be overridden # in subclasses. pv_parameters = self._get_pv_parameters() for pvparam in pv_parameters: # Retrieve the actual PV-name from (potentially overridden) method pvname = self._get_pv_name(pvparam) if not pvname: raise ConfigurationError(self, 'PV for parameter %s was ' 'not found!' % pvparam) pv = self._pvs[pvparam] = epics.pv.PV( pvname, connection_timeout=self.epicstimeout) pv.connect() if not pv.wait_for_connection(timeout=self.epicstimeout): raise CommunicationError(self, 'could not connect to PV %r' % pvname) self._pvctrls[pvparam] = pv.get_ctrlvars() or {} else: for pvparam in self._get_pv_parameters(): self._pvs[pvparam] = HardwareStub(self) self._pvctrls[pvparam] = {}
def _setMode(self, mode): super()._setMode(mode) # remove the TACO device on entering simulation mode, to prevent # accidental access to the hardware if mode == SIMULATION: # keep the device instance around to avoid destruction (which can # mess with the TACO connections in the main process if simulation # has been forked off) self._orig_dev = self._dev self._dev = HardwareStub(self)
def doPreinit(self, mode): if self.loglevel == 'debug': self._taco_guard = self._taco_guard_log if self.taco_class is None: raise ProgrammingError('missing taco_class attribute in class ' + self.__class__.__name__) if mode != SIMULATION: self._dev = self._create_client() else: self._dev = HardwareStub(self)
def doPreinit(self, mode): # Wrap PyTango client creation (so even for the ctor, logging and # exception mapping is enabled). self._createPyTangoDevice = self._applyGuardToFunc( self._createPyTangoDevice, 'constructor') self._dev = None # Don't create PyTango device in simulation mode if mode != SIMULATION: self._dev = self._createPyTangoDevice(self.tangodevice) else: self._dev = HardwareStub(self)
def doPreinit(self, mode): self._epics_wrapper = PvaWrapper() # Don't create PVs in simulation mode self._pvs = {} if mode != SIMULATION: for pvparam in self._get_pv_parameters(): # Retrieve the actual PV name pvname = self._get_pv_name(pvparam) if not pvname: raise ConfigurationError( self, 'PV for parameter %s was ' 'not found!' % pvparam) # Check pv exists - throws if cannot connect self._epics_wrapper.connect_pv(pvname, self.epicstimeout) self._pvs[pvparam] = pvname self._register_pv_callbacks() else: for pvparam in self._get_pv_parameters(): self._pvs[pvparam] = HardwareStub(self)
def doPreinit(self, mode): # Don't create PVs in simulation mode self._pvs = {} self._pvctrls = {} if mode != SIMULATION: # When there are standard names for PVs (see motor record), the PV names # may be derived from some prefix. To make this more flexible, the pv_parameters # are obtained via a method that can be overridden in subclasses. pv_parameters = self._get_pv_parameters() # For cases where for example readpv and writepv are the same, this dict makes # sure that only one Channel object is created per PV. pv_names = {} for pvparam in pv_parameters: # Retrieve the actual PV-name from (potentially overridden) method pv_name = self._get_pv_name(pvparam) try: pv = pv_names.setdefault(pv_name, self._create_pv(pv_name)) self._pvs[pvparam] = pv pv.setTimeout(self.epicstimeout) self._pvctrls[pvparam] = pv.get('display').toDict().get('display') if self._pvctrls[pvparam] is None: self._pvctrls[pvparam] = pv.get('control').toDict().get('control', {}) except pvaccess.PvaException: raise CommunicationError(self, 'could not connect to PV %r' % pv_name) else: for pvparam in self._get_pv_parameters(): self._pvs[pvparam] = HardwareStub(self) self._pvctrls[pvparam] = {}
def _setMode(self, mode): super(PyTangoDevice, self)._setMode(mode) # remove the Tango device on entering simulation mode, to prevent # accidental access to the hardware if mode == SIMULATION: self._dev = HardwareStub(self)
def _setMode(self, mode): IPCModBus._setMode(self, mode) if mode == SIMULATION: self._connection = HardwareStub(self)