def PreStartOne(self, axis): """Prepare axis for generation. """ tg = self.attributes[axis] self._log.debug('PreStartOne(%d): entering...' % axis) ch_generator = tg['ch_generator'] state = ch_generator.getAttribute('State') sta = from_tango_state_to_state(state.read().value) if sta is State.On: ch_generator.stop() ch_position = tg['ch_position'] state = ch_position.getAttribute('State') sta = from_tango_state_to_state(state.read().value) if sta is State.On: ch_position.stop() #configure the position source counter channel output_behaviour = ch_position.getAttribute('OutputEventBehaviour') output_behaviour.write('Pulse') zindex = ch_position.getAttribute('ZindexVal') zindex.write(4294967294) initialpos = ch_position.getAttribute('InitialPos') initialpos.write(4294967294) units = ch_position.getAttribute('Units') units.write('Ticks') decoding = ch_position.getAttribute('Decoding') decoding.write('X1') pulsesperrevolution = ch_position.getAttribute('PulsesPerRevolution') pulsesperrevolution.write(1) # configure the trigger counter channel sample_mode = ch_generator.getAttribute('SampleMode') sample_mode.write('Finite') sample_timing_type = ch_generator.getAttribute('SampleTimingType') sample_timing_type.write('Implicit') self._log.debug('PreStartOne(%d): entering...' % axis) return True
def StateOne(self, axis): try: state = from_tango_state_to_state(self.epsDevice.state()) except Exception as e: state = State.Alarm status = 'Verifying state of eps tange device thrown the ' \ 'following exception:\n {}'.format(e) return state, status status = 'The EPS device is in {}'.format(repr(state)) isFeControlDisabled = self.epsDevice.read_attribute( self.IsFeControlDisabledAttribute).value if isFeControlDisabled: state = State.Alarm status += '\nControl over fe is disabled from the Control Room' isFeFirstValveClosed = self.epsDevice.read_attribute( self.IsFeFirstValveClosedAttribute).value if isFeFirstValveClosed: state = State.Alarm status += '\nFirst valve of the fe is closed' isFeInterlocked = self.epsDevice.read_attribute( self.IsFeInterlockedAttribute).value if isFeInterlocked: state = State.Alarm status += '\nfe is interlocked' return state, status
def StateOne(self, axis): tango_attr = self.devsExtraAttributes[axis][TANGO_ATTR] try: dev_proxy = self.devsExtraAttributes[axis][DPROXY] or \ self._buildProxy(axis) except Exception as e: return (State.Init, str(e)) llabels = len(self.devsExtraAttributes[axis][LABELS]) lcalibration = len(self.devsExtraAttributes[axis][CALIBRATION]) readFailed = self.devsExtraAttributes[axis][READFAILED] if tango_attr is None or dev_proxy is None: return (State.Disable, "Not yet configured the Tango Attribute, " "or cannot proxy it") if not lcalibration == 0 and not llabels == lcalibration: return(State.Disable, "Bad configuration of the extra attributes, " "this cannot be operated") else: dev_state = dev_proxy.state() if readFailed and not dev_state == DevState.MOVING: return (State.Alarm, "Fault on read attibute.\nThe tango device " "status says: %s" % dev_proxy.status()) # IF PROXY DEVICE IS IN FAULT, MASK IT AS 'ALARM' # AND INFORM IN STATUS state = dev_proxy.state() status = dev_proxy.status() if state in (DevState.FAULT, DevState.UNKNOWN): status = 'Masked ALARM state, tango device is in %s ' \ 'state with status: %s' % (state, status) state = State.Alarm else: state = from_tango_state_to_state(state) return (state, status)
def eval_state(state): """This function converts Ni660X device states into counters state.""" if state == PyTango.DevState.RUNNING: return State.Moving elif state == PyTango.DevState.STANDBY: return State.On else: return from_tango_state_to_state(state)
def _getState(self, axis): channel = self.channels[axis] state = channel.read_attribute('State').value if state == PyTango.DevState.RUNNING: return State.Moving elif state == PyTango.DevState.STANDBY: return State.On else: return from_tango_state_to_state(state)
def StateAll(self): self._hw_state = self.AIDevice.state() if self._hw_state == tango.DevState.RUNNING: self._state = State.Moving self._status = 'The Adlink is acquiring' elif self._hw_state == tango.DevState.ON: self._state = State.On self._status = 'The Adlink is ready to acquire' else: self._state = from_tango_state_to_state(self._hw_state) self._status = 'The Adlink state is: %s' % self._hw_state
def SetAxisPar(self, axis, name, value): """Set axis parameter. """ tg = self.attributes[axis] ch_generator = tg['ch_generator'] ch_position = tg['ch_position'] name = name.lower() # TODO: write of some attrs require that the device is STANDBY # For the moment Sardana leaves the TriggerGate elements in the # state that they finished the last generation. In case of # Ni660XCounter, write of some attributes require the channel # to be in STANDBY state. Due to that we stop the channel. state = ch_position.getAttribute('State') sta = from_tango_state_to_state(state.read().value) if sta is not State.Standby: ch_position.stop() state = ch_generator.getAttribute('State') sta = from_tango_state_to_state(state.read().value) if sta is not State.Standby: ch_generator.stop() if name in self._ch_gen_attr: attr_name = self.attribute_relations[name] attr = ch_generator.getAttribute(attr_name) if name == 'offset': offset = self._fromUserToHardware(axis, value) if offset < 4: offset = 4 value = offset elif name == 'repetitions': value = int(value) attr.write(value) elif name in self._ch_pos_attr: if name == 'initialpos': attr = int(value) attr = ch_position.getAttribute(name) attr.write(value) else: tg[name] = value
def StateAll(self): self._hw_state = self.AIDevice.state() if self._hw_state == tango.DevState.RUNNING: self._state = State.Moving self._status = 'The Adlink is acquiring' elif self._hw_state == tango.DevState.ON: # Verify if we read all the channels data: if self._last_index_read != (self._repetitions-1) and \ self._synchronization == AcqSynch.HardwareTrigger: self._log.warning( 'The Adlink finished but the ctrl did not ' 'read all the data yet. Last index readed %r' % self._last_index_read) self._state = State.Moving self._status = 'The Adlink is acquiring' else: self._state = State.On self._status = 'The Adlink is ready to acquire' else: self._state = from_tango_state_to_state(self._hw_state) self._status = 'The Adlink state is: %s' % self._hw_state