Ejemplo n.º 1
0
 def detect(self):
     retval = []
     try:
         from ophir import OphirUSBI
         ophir = OphirUSBI()
         olist = ophir.scanUSBI()
         for i in range(len(olist)):
             # found device
             retval.append([str(i), "OphirUSBI", "Ophir" + olist[i]])
     except:
         pass
     return retval
Ejemplo n.º 2
0
 def __init__(self):
     InputDevice.__init__(self)
     self.config = ['holdoff', 'mode', 'pulselength', 'wavelength', 'range', 'MM_mode', 'MM_samples', 'frequency']
     self.holdoff = 0.0
     self.mode = 0
     self.pulselength = 0
     self.wavelength = 0
     self.range = 0
     self.MM_mode = 0
     self.MM_samples = 1
     self.frequency = 1000
     self.units = ["V"]
     self.qtynames = [""]
     try:
         from ophir import OphirUSBI
         self.device = OphirUSBI()
         self.connected = False
     except:
         self.device = None
         self.connected = False
Ejemplo n.º 3
0
class OphirDevice(InputDevice):
    """
    
        Device driver for Ophir USB interface adapter
    
    """
    def __init__(self):
        InputDevice.__init__(self)
        self.config = ['holdoff', 'mode', 'pulselength', 'wavelength', 'range', 'MM_mode', 'MM_samples', 'frequency']
        self.holdoff = 0.0
        self.mode = 0
        self.pulselength = 0
        self.wavelength = 0
        self.range = 0
        self.MM_mode = 0
        self.MM_samples = 1
        self.frequency = 1000
        self.units = ["V"]
        self.qtynames = [""]
        try:
            from ophir import OphirUSBI
            self.device = OphirUSBI()
            self.connected = False
        except:
            self.device = None
            self.connected = False
    
    def initialize(self):
        if self.device != None:
            try:
                self.device.connect(int(self.address))
                self.connected = True
                
                # apply settings
                self.device.set_measurement_mode(self.mode)
                self.device.set_wavelength(self.wavelength)
                self.device.set_pulse_length(self.pulselength)
                self.device.set_range(self.range)
                if(self.MM_mode == 0):
                    self.device.set_default_mode()
                elif(self.MM_mode == 1):
                    self.device.set_turbo_mode(self.frequency)
                else:
                    self.device.set_immediate_mode()
            except:
                self.connected = False

    def reset(self):
        if self.device != None and self.connected == True:
            self.device.reset()
            self.device.disconnect()
            self.device.connect()
    
    def get_error(self):
        return 0
        
    def read(self):        
        if self.device != None and self.connected == True:
            sleep(self.holdoff)
            data = self.device.read_data(self.MM_samples)        
            if data == []:
                return None
            if len(data[1]) > 1:                
                val = 0.0
                for i in range(len(data[1])):
                    val += data[1][i] / len(data[1])
                return [val]
            elif len(data[1]) == 1:
                return data[1]
            else:
                return None                        
        else:
            return None
    
    def configure(self):
        if self.device != None and self.connected == True:
            dlg = OphirConfig(self)
            if (dlg.ShowModal() == wx.ID_OK):
                # read settings from config dialog
                if dlg.txt_holdoff.GetValue() == "":
                    dlg.txt_holdoff.SetValue("0.0")
                if dlg.txt_MM_samples.GetValue() == "" or int(dlg.txt_MM_samples.GetValue()) < 1:
                    dlg.txt_MM_samples.SetValue("1")
                if dlg.txt_frequency.GetValue() == "" or int(dlg.txt_frequency.GetValue()) < 1:
                    dlg.txt_frequency.SetValue("1")
                
                self.holdoff = float(dlg.txt_holdoff.GetValue())
                self.MM_samples = int(dlg.txt_MM_samples.GetValue())
                self.frequency = float(dlg.txt_frequency.GetValue())
                self.mode = dlg.choice_mode.GetSelection()
                self.pulselength = dlg.choice_pulselength.GetSelection()
                self.wavelength = dlg.choice_wavelength.GetSelection()
                self.range = dlg.choice_range.GetSelection()
                self.MM_mode = dlg.choice_MM_mode.GetSelection()
                
                # apply new settings
                self.device.set_measurement_mode(self.mode)
                self.device.set_wavelength(self.wavelength)
                self.device.set_pulse_length(self.pulselength)
                self.device.set_range(self.range)
                if(self.MM_mode == 0):
                    self.device.set_default_mode()
                elif(self.MM_mode == 1):
                    self.device.set_turbo_mode(self.frequency)
                else:
                    self.device.set_immediate_mode()
                    
            dlg.Destroy()
            
    def detect(self):
        retval = []
        try:
            from ophir import OphirUSBI
            ophir = OphirUSBI()
            olist = ophir.scanUSBI()
            for i in range(len(olist)):
                # found device
                retval.append([str(i), "OphirUSBI", "Ophir" + olist[i]])
        except:
            pass
        return retval