def init_device(self): Device.init_device(self) # PROTECTED REGION ID(SRIlockin830.init_device) ENABLED START # try: self.ser = serial.Serial(port=self.SerialPort, baudrate=self.Speed, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=1, timeout=0.5) self.ser.write(bytes("*IDN?\n", "ascii")) identification = self.ser.read_until(bytes("\r", "ascii")) except: self.set_state(PyTango.DevState.FAULT) self.set_status("Can't connect to SRI 830") self.debug_stream("Can't connect to SRI 830") return if (identification[0:31] != bytes("Stanford_Research_Systems,SR830", "ascii")): self.set_state(PyTango.DevState.FAULT) self.set_status("I do not find an SRI 830 on the serial port") self.debug_stream("I do not find an SRI 830 on the serial port") return self.set_status("Connected to SRI 830") self.debug_stream("Connected to SRI 830") self.set_state(PyTango.DevState.ON)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(FUGMCP.init_device) ENABLED START # try: self.ser = serial.Serial(port=self.SerialPort, baudrate=self.Speed, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=1, timeout=0.5) self.ser.write(bytes("*IDN?\n", "ascii")) self.identification = self.ser.readline() except: self.set_state(PyTango.DevState.FAULT) self.set_status("Can't connect to FUG MCP") self.debug_stream("Can't connect to FUG MCP") return if (self.identification[0:16] != bytes("FUG HCP 140-1250", "ascii") and self.identification[0:15] != bytes("FUG MCP140-1250", "ascii")): self.set_state(PyTango.DevState.FAULT) self.set_status("I do not find a FUG MCP on the serial port") self.debug_stream("I do not find a FUG MCP on the serial port") return self.set_status("Connected to FUG MCP") self.debug_stream("Connected to FUG MCP") self.ser.write(bytes(">BON?\n", "ascii")) resp = self.ser.readline() if (resp[:-1] == bytes("BON:1", "ascii")): self.set_state(PyTango.DevState.ON) else: self.set_state(PyTango.DevState.OFF)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(SMSGateway.init_device) ENABLED START # self.get_device_properties() addr = str(self.IP) try: socket.inet_aton(addr) url = 'http://' + addr except socket.error: self.set_state(PyTango.DevState.UNKNOWN) self.set_status('Invalid IP address') logging.error('Invalid IP address', traceback.format_exc()) try: test_connection = requests.get(url) time.sleep(3) test_connection.raise_for_status() self.set_state(PyTango.DevState.ON) self.set_status('Connected with SMS Gateway') self.url = url except socket.error: self.set_state(PyTango.DevState.UNKNOWN) self.set_status('Bad request made, a 4XX client error or 5XX server error response') logging.error('Bad request made, a 4XX client error or 5XX server error response', traceback.format_exc())
def init_device(self): Device.init_device(self) for attr in ("state", "status", "last_error", "last_point_nb", "acq_mode", "acq_expo_time", "acq_nb_points", "acq_channels"): self.set_change_event(attr, True, False) self.__last_error = "" self.__last_point_nb = -1 self.__last_point_nb_timestamp = 0. try: config = get_config() util = PyTango.Util.instance() if util.is_svr_starting(): self.device = CT2Device(config, self.card_name) dispatcher.connect(self.__on_error, signal=ErrorSignal, sender=self.device) dispatcher.connect(self.__on_point_nb, signal=PointNbSignal, sender=self.device) dispatcher.connect(self.__on_stop, signal=StopSignal, sender=self.device) else: self.apply_config() switch_state(self, DevState.ON, "Ready!") except Exception as e: msg = "Exception initializing device: {0}".format(e) self.error_stream(msg) switch_state(self, DevState.FAULT, msg)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(WeatherUnderground.init_device) ENABLED START # self.set_state(tango.DevState.ON) self.debug_stream("api_key_file: %s" % self.api_key_file) try: key_file = open(self.api_key_file) _wu_api_key = key_file.readline() self.wu_api_key = _wu_api_key.strip() self.debug_stream("api_key: %s" % self.wu_api_key) except: self.error_stream("failed to read wu_api_key") self.set_state(tango.DevState.FAULT) self._Grenoble_t = 0.0 self._Grenoble_t_last_read = 0 self._Paris_t = 0.0 self._Paris_t_last_read = 0 self._Trieste_t = 0.0 self._Trieste_t_last_read = 0 self._Barcelona_t = 0.0 self._Barcelona_t_last_read = 0 self._Hamburg_t = 0.0 self._Hamburg_t_last_read = 0 self._Lund_t = 0.0 self._Lund_t_last_read = 0 self._Cape_Town_t = 0.0 self._Cape_Town_t_last_read = 0 self._Munich_t = 0.0 self._Munich_t_last_read = 0 self._all_towns_attr = {'Grenoble':self.read_Grenoble_t, 'Paris':self.read_Paris_t, 'Trieste':self.read_Trieste_t, 'Barcelona':self.read_Barcelona_t, 'Hamburg': self.read_Hamburg_t, 'Lund':self.read_Lund_t, 'Cape Town':self.read_Cape_Town_t, 'Munich':self.read_Munich_t} self.http = urllib3.PoolManager()
def init_device(self): self.debug_stream("In init_device:") Device.init_device(self) self.db = pt.Database() self.set_state(pt.DevState.UNKNOWN) self.debug_stream("Init camera controller {0}".format( self.camera_name)) params = dict() params["imageoffsetx"] = self.roi[0] params["imageoffsety"] = self.roi[1] params["imagewidth"] = self.roi[2] params["imageheight"] = self.roi[3] params["triggermode"] = "Off" try: if self.dev_controller is not None: self.dev_controller.stop_thread() except Exception as e: self.error_info("Error stopping camera controller: {0}".format(e)) try: self.setup_spectrometer() self.dev_controller = SpectrometerCameraDeviceController( self.camera_name, params, self.wavelengthvector_data, self.max_value) # self.dev_controller = CameraDeviceController(self.camera_name, params) except Exception as e: self.error_stream( "Error creating camera controller: {0}".format(e)) return self.debug_stream("init_device finished") # self.set_state(pt.DevState.ON) self.dev_controller.add_state_callback(self.change_state)
def init_device(self): Device.init_device(self) self.set_state(DevState.STANDBY) self.__elementLoggingLevel = 5 self.__storageLoggingLevel = 5 self.__centralLoggingLevel = 5 logger.setLevel(logging.DEBUG)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(SEAWaterflowmeter.init_device) ENABLED START # self.channel0data=0.0 self.channel1data=0.0 self.channel2data=0.0 self.channel3data=0.0 for i in self.channels.split(","): count[int(i)]=0.0 self.listofnames=self.channelnames.split(",") #print(self.channel0.get_attribute_list) #self.channel0.set_label(listofnames[0]) #self.channel1.set_label(listofnames[1]) #self.channel2.set_label(listofnames[2]) #self.channel3.set_label(listofnames[3]) GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering for i in count: GPIO.setup(i,GPIO.IN) for i in count: GPIO.add_event_detect(i, GPIO.RISING, callback=my_callback) self.set_state(PyTango.DevState.ON) self.set_status("Measurement thread is running") self.stop_ctrloop = 0 ctrlloop = ControlThread(self) ctrlloop.start()
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(AGPolaritySwitch.init_device) ENABLED START # try: self.ser = serial.Serial(self.SerialPort, baudrate=self.Speed, bytesize=8, parity="N", stopbits=1, timeout=1) self.ser.write(bytearray("*STAT?\n", "ascii")) resp = self.ser.readline() dummy = self.ser.readline() except: self.set_state(PyTango.DevState.FAULT) self.set_status("Can't connect to AGPolaritySwitch") self.debug_stream("Can't connect to AGPolaritySwitch") return self.set_status("Connected to AGPolaritySwitch") self.debug_stream("Connected to AGPolaritySwitch") if (resp == "positive"): # Only check first gauge to set device status self.set_state(PyTango.DevState.ON) else: self.set_state(PyTango.DevState.OFF)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(CryoCon32.init_device) ENABLED START # try: self.ser = serial.Serial(self.SerialPort, self.SerialSpeed, bytesize=8, parity="N", stopbits=1, timeout=0.5) self.ser.write("*IDN?\n") idn = self.ser.readline() if (idn[0:16] != "Cryocon Model 32"): self.set_status("Not a CryoCon32 on serial port") self.debug_stream("Not a CryoCon32 on serial port") return self.ser.write("INPUT A:UNITS K\n") self.ser.write("LOOP 1:TYPE PID\n") self.ser.write("CONTROL?\n") mode = self.ser.readline() if mode[0:3] == "OFF": self.set_state(PyTango.DevState.OFF) else: self.set_state(PyTango.DevState.ON) except: self.set_state(PyTango.DevState.FAULT) self.set_status("Can't connect to CryoCon32") self.debug_stream("Can't connect to CryoCon32") return self.set_status("Connected to CryoCon32") self.debug_stream("Connected to CryoCon32")
def __init__(self, klass, name): self.wavelengthvector_data = np.array([]) self.max_value = 1.0 self.controller = None # type: SpectrometerCameraController self.state_dispatcher = None # type: StateDispatcher self.db = None Device.__init__(self, klass, name)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(SKABaseDevice.init_device) ENABLED START # # Initialize attribute values. self._build_state = '{}, {}, {}'.format(release.name, release.version, release.description) self._version_id = release.version self._central_logging_level = 0 self._element_logging_level = 0 self._storage_logging_level = 0 self._health_state = 0 self._admin_mode = 0 self._control_mode = 0 self._simulation_mode = False self._test_mode = "" #logger.setLevel(logging.DEBUG) # create TANGO Groups objects dict, according to property self.debug_stream("Groups definitions: {}".format(self.GroupDefinitions)) try: self.groups = get_groups_from_json(self.GroupDefinitions) self.info_stream("Groups loaded: {}".format(sorted(self.groups.keys()))) except GroupDefinitionsError: self.info_stream("No Groups loaded for device: {}".format( self.get_name()))
def init_device(self): Device.init_device(self) self.__tape = {} self.__head = 0 self.__state = self.initial_state self.__final_states = [] self.__transition_function = None self.set_state(DevState.RUNNING)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(PfeifferDCU002.init_device) ENABLED START # self.ser = serial.Serial(self.SerialPort, 9600, bytesize=8, parity="N", stopbits=1)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(WebCam.init_device) ENABLED START # pygame.camera.init() #pygame.camera.list_cameras() self.cam = pygame.camera.Camera(self.webcamdevice, (self.width, self.height)) self.cam.start()
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(Keithley2100.init_device) ENABLED START # #instr=usbtmc.Instrument(idVendor,idProduct) self.instr=usbtmc.Instrument(0x05e6,0x2100) self.set_status("Connected to DVMM Keithley 2100") self.debug_stream("Connected to DVMM Keithley 2100") self.set_state(PyTango.DevState.ON)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(RaspberrySwitch.init_device) ENABLED START # GPIO.setmode(GPIO.BCM) if (self.PullUPorDOWN == True): GPIO.setup(self.GPIOport, GPIO.IN, pull_up_down=GPIO.PUD_UP) else: GPIO.setup(self.GPIOport, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
def set_status(self, status, force=False): """Set the status and push events if necessary.""" with self._exception_lock: if force or self.connected: Device.set_status(self, status) if self.push_events: status_attr = self.get_device_attr().get_attr_by_name('Status') status_attr.fire_change_event()
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(MFC.init_device) ENABLED START # self.ser = serial.Serial(self.SerialPort, baudrate=38400, bytesize=8, parity="N", stopbits=1) self.set_state(PyTango.DevState.ON)
def __init__(self, klass, name): self.controller = None # type: PataraControl self.setup_attr_params = dict() self.idle_params = dict() self.scan_params = dict() self.analyse_params = dict() self.db = None self.state_dispatcher = None # type: StateDispatcher Device.__init__(self, klass, name)
def init_device(self): Device.init_device(self) try: self.dyn_attrs_dict = {} self.extract_attributes_from_property() self.create_dyn_attributes() except Exception, e: self.set_state(DevState.FAULT) self.set_status(e.message)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(ELogSender.init_device) ENABLED START # self._entries_que = [] self._number_of_rejected_entries = 0 self._total_number_of_rejected_entries = 0 self.lock = RLock() self.set_state(PyTango.DevState.STANDBY) self.set_status('No entries in que.')
def __init__(self, klass, name): self.max_value = 1.0 self.controller = None # type: FrogController self.setup_attr_params = dict() self.idle_params = dict() self.scan_params = dict() self.analyse_params = dict() self.db = None self.frogstate_dispatcher = None # type: FrogStateDispatcher Device.__init__(self, klass, name)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(RaspberryButton.init_device) ENABLED START # GPIO.setmode(GPIO.BCM) GPIO.setup(self.Pin, GPIO.OUT) if (self.TrueHigh == True): GPIO.output(self.Pin, 0) else: GPIO.output(self.Pin, 1) self.set_state(PyTango.DevState.OFF)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(MKSGauge.init_device) ENABLED START # self.ser = serial.Serial(self.SerialPort, baudrate=self.Speed, bytesize=8, parity="N", stopbits=1, timeout=0.5) self.set_state(PyTango.DevState.ON)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(LiberaManager.init_device) ENABLED START # if self.IncludedLiberas == None: self.set_state(DevState.FAULT) self.set_status("The IncludedLiberas property isn't filled") return self.init_thread = threading.Thread(target=self.init_thread) self.init_thread.start() self.set_state(DevState.INIT) self.set_status("LiberaManager initialization started....")
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(MCC1208LS.init_device) ENABLED START # self.ubox=usb_1208LS.usb_1208LS() self.ADC0gain = usb_1208LS.usb_1208LS.BP_10_00V self.ADC1gain = usb_1208LS.usb_1208LS.BP_1_00V self.ADC0value= 2 self.ADC1value= 8 self.set_status("Connected to MCC1208LS") self.debug_stream("Connected to MCC1208LS") self.set_state(PyTango.DevState.ON)
def init_device(self): Device.init_device(self) self.__always_executed_hook_count = 0 self.__read_attribute_hardware_count = 0 self.__write_attribute_counter_count = 0 self.__scalar_reads_count = 0 self.__spectrum_reads_count = 0 self.__image_reads_count = 0 self.__pipe_reads_count = 0 self.__scalar_writes_count = 0 self.__spectrum_writes_count = 0 self.__image_writes_count = 0 self.__pipe_writes_count = 0 self.__command_calls_count = 0 self.__reset_time = time.time() self.__benchmark_scalar_attribute = 0.0 self.__benchmark_spectrum_attribute = np.zeros(shape=[1024], dtype=float) self.__benchmark_image_attribute = np.zeros(shape=[1024, 2048], dtype=float) self.__benchmark_pipe = ('PipeBlob', ( { 'name': 'DevLong64', 'value': 123, }, { 'name': 'DevULong', 'value': np.uint32(123) }, { 'name': 'DevVarUShortArray', 'value': range(5), 'dtype': ('uint16', ) }, { 'name': 'DevVarDoubleArray', 'value': [1.11, 2.22], 'dtype': ('float64', ) }, { 'name': 'DevBoolean', 'value': True }, )) self.set_change_event("BenchmarkScalarAttribute", True, False) self.set_change_event("BenchmarkSpectrumAttribute", True, False) self.set_change_event("BenchmarkImageAttribute", True, False)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(HuttingerPFGRF.init_device) ENABLED START # self.ser = serial.Serial(self.SerialPort, baudrate=9600, bytesize=8, parity="N", stopbits=1, timeout=0.5) (address, command, data) = self.parse_response(self.sendcommand(0, "CE", 0)) self.set_state(PyTango.DevState.OFF)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(GammaIonPump.init_device) ENABLED START # self.ser = serial.Serial(self.SerialPort, baudrate=9600, bytesize=8, parity="N", stopbits=1) if (self.sendcommand(" 05 61 1 ")[9:-4]) == "YES": self.set_state(PyTango.DevState.ON) else: self.set_state(PyTango.DevState.OFF)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(PySocket.init_device) ENABLED START # self.info_stream('init_device()') if not hasattr(self, 'sobj'): self.sobj = None self.set_change_event('State', True, False) self.process_state(DevState.CLOSE) self.buffer = '' self.info_stream('init_device(): done')
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(V4L2Camera.init_device) ENABLED START # self.video_capture = cv2.VideoCapture(0) if not self.video_capture.isOpened(): self.set_status("Cannnot connect to camera") self.debug_stream("Cannot connet to camera") self.set_state(PyTango.DevState.FAULT) self.set_status("Connected to camera") self.set_state(PyTango.DevState.ON) self.video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640) self.video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(PIDcontroller.init_device) ENABLED START # self.kd = 0.0 self.ki = 0.0 self.kp = 1.0 self.ev = 0.0 self.ev1 = 0.0 self.ev2 = 0.0 self.sp = 0.0 self.last_compute = 0.0 self.controlled_object = PyTango.DeviceProxy(self.ControlledDeviceProxy)
def init_device(self): Device.init_device(self) self.info_stream('In Python init_device method') self.set_state(PyTango.DevState.ON) # Attribute initialization for joint in self.joints: # Filtered setattr(self, '_' + joint, (0, 0, 0)) # Unfiltered setattr(self, '_' + joint + "_raw", (0, 0, 0)) self._moves = (0, 0) # Hand status is initilized at True (i.e. open hand) self._hand_left_status = True self._hand_right_status = True
def init_device(self): self.__log = logging.getLogger(self.get_name()) Device.init_device(self) self.set_change_event("State", True, True) self.set_change_event("Status", True, True) self.set_change_event("Position", True, False) self.set_change_event("StepSize", True, False) switch_state(self, DevState.INIT, "Pending connection to " + self.SpecMotor) self.__spec_motor = None self.__spec_motor_name = None self.__spec_version_name = None self.__step_size = 1 spec_info = find_spec_name(self, self.SpecMotor) if spec_info is None: return spec_version, motor = spec_info self.__spec_version_name = spec_version self.__spec_motor_name = motor cb=dict(connected=self.__motorConnected, disconnected=self.__motorDisconnected, motorPositionChanged=self.__motorPositionChanged, motorStateChanged=self.__motorStateChanged) #motorLimitsChanged=self.__motorLimitsChanged) try: self.__log.debug("Start creating Spec motor %s", motor) self.__spec_motor = SpecMotorA(callbacks=cb) except SpecClientError as spec_error: status = "Error creating Spec motor {0}".format(motor) switch_state(self, DevState.FAULT, status) else: self.__motorConnect() self.__log.debug("End creating Spec motor %s", motor)
def init_device(self): Device.init_device(self) self.set_change_event("AttributeOkList", True, False) self.set_change_event("AttributeNokList", True, False) self.set_change_event("AttributeOnList", True, False) self.set_change_event("AttributeOffList", True, False) self.set_change_event("ArchiverList", True, False) self.set_change_event("ArchiverOnList", True, False) self.set_change_event("ArchiverOffList", True, False) self.set_change_event("AttributeValues", True, False) self.set_change_event("AttributeWrongList", True, False) self.set_change_event("AttributeLostList", True, False) self.set_change_event("AttributeNoevList", True, False) self.set_change_event("AttributeStalledList", True, False) # PROTECTED REGION ID(SchemaManager.init_device) ENABLED START # check_attribute_value.expire = self.CacheTime check_attribute_events.expire = self.CacheTime self.schema = self.Schemas[0] self.api = pyta.api(self.schema) self.klass = '' self.is_hpp = None self.update_time = 0 self.attributes = [] self.values = {} self.arch_on = [] self.arch_off = [] self.attr_on = [] self.attr_off = [] self.attr_ok = [] self.attr_lost = [] self.attr_nok = [] self.attr_err = [] self.attr_nevs = [] self.attr_stall = [] self.UpdateArchivers() self.threadDict = self.initThreadDict() if self.Threaded else None
def init_device(self): Device.init_device(self) self.__current = 0.0 self.set_state(DevState.STANDBY)
async def init_device(self): Device.init_device(self) self.proxy = await AttributeProxy(self.Attribute) self.set_state(DevState.ON)
def init_device(self): Device.init_device(self)
def init_device(self): self.debug_stream("In init_device:") Device.init_device(self) self.phase_val = 0.0 self.dac_dev = pt.DeviceProxy(self.dac_ds_name) self.set_state(pt.DevState.ON)
def delete_device(self): Device.delete_device(self) for att in self.dyn_attrs_dict.keys(): listener_name = att + 'Listener' self.dyn_attrs_dict[att][0].removeListener(self.__dict__[listener_name])
def delete_device(self): Device.delete_device(self) self.__spec_motor = None
def init_device(self): """ Start device server """ Device.init_device(self) self.reconnect_tries = 0 self.set_state_ok(DevState.INIT) self.board_connect() # connect to the board
def init_device(self): Device.init_device(self) # PROTECTED REGION ID(ZObject.init_device) ENABLED START # self._internal_state = np.array([1.0, 5.0]) self._matrix = np.array([[0.6, 0.3], [0.3, 0.6]]) self.set_state(PyTango.DevState.ON)
def init_device(self): Device.init_device(self) self.proxy = yield From(AttributeProxy(self.Attribute)) self.set_state(DevState.ON)
def get_device_properties(self, cls=None): """Raise a ValueError if a property is missing.""" Device.get_device_properties(self, cls) for key, value in self.device_property_list.items(): if value[2] is None: raise ValueError('missing property: ' + key)
def __init__(self, *args, **kwargs): Device.__init__(self, *args, **kwargs)
def init_device(self): Device.init_device(self) self.__coordinates = (0, 0) self.set_state(DevState.STANDBY)
def __init__(self, *args, **kwargs): self.gpib = None Device.__init__(self, *args, **kwargs)
def init_device(self): Device.init_device(self) kwargs = dict(url=self.url, pad=self.pad, sad=self.sad, timeout=self.timeout, tmo=self.tmo) self.gpib = _Gpib(**kwargs) self.gpib.open()
def dev_state(self): """Update attributes and return the state.""" if not self.push_events: self.update_all() return Device.dev_state(self)