Example #1
0
    def onBtnFindPhotometer(self, event):
        photName = self.ctrlPhotomType.GetStringSelection()
        #search all ports
        self.comPortLabel.SetLabel('Scanning ports...')
        self.Update()
        if 'PR655' in photName:
            self.photom = hardware.findPhotometer(device='PR655')
        elif 'PR650' in photName:
            self.photom = hardware.findPhotometer(device='PR650')
        elif 'LS100' in photName:
            self.photom = hardware.findPhotometer(device='LS100')
        elif 'ColorCAL' in photName:
            self.photom = hardware.findPhotometer(device='ColorCAL')
        if self.photom!=None and self.photom.OK:
            self.btnFindPhotometer.Disable()
            self.btnCalibrateGamma.Enable(True)
            self.btnTestGamma.Enable(True)
            if hasattr(self.photom, 'getLastSpectrum'):
                self.btnCalibrateColor.Enable(True)
            self.comPortLabel.SetLabel('%s found on %s' %(self.photom.type, self.photom.portString))
        else:
            self.comPortLabel.SetLabel('No photometers found')
            self.photom=None

        #does this device need a dark calibration?
        if hasattr(self.photom, 'getNeedsCalibrateZero') and self.photom.getNeedsCalibrateZero():
            #prompt user if we need a dark calibration for the device
            if self.photom.getNeedsCalibrateZero():
                dlg = wx.Dialog(self,title='Dark calibration of ColorCAL')
                msg='Your ColorCAL needs to be calibrated first. ' +\
                    'Please block all light from getting into the lens and press OK.'
                while self.photom.getNeedsCalibrateZero():
                    dlg = dialogs.MessageDialog(self,message=msg, 
                                                title='Dark calibration of ColorCAL',
                                                type='Info')#info dlg has only an OK button
                    resp=dlg.ShowModal()
                    if resp== wx.ID_CANCEL:
                        self.photom=None
                        self.comPortLabel.SetLabel('')
                        return 0
                    elif resp == wx.ID_OK:
                        self.photom.calibrateZero()
                    #this failed at least once. Try again.
                    msg = 'Try again. Cover the lens fully and press OK'
Example #2
0
    def onBtnFindPhotometer(self, event):

        # safer to get by index, but GetStringSelection will work for
        # nonlocalized techincal names:
        photName = self.ctrlPhotomType.GetStringSelection()
        # not sure how
        photPort = self.ctrlPhotomPort.GetValue().strip()
        # [0] == Scan all ports
        if not photPort or photPort == self._photomChoices[0]:
            photPort = None
        elif photPort.isdigit():
            photPort = int(photPort)
        # search all ports
        self.comPortLabel.SetLabel(_translate('Scanning ports...'))
        self.Update()
        self.photom = hardware.findPhotometer(device=photName, ports=photPort)
        if self.photom is not None and self.photom.OK:
            self.btnFindPhotometer.Disable()
            self.btnCalibrateGamma.Enable(True)
            self.btnTestGamma.Enable(True)
            if hasattr(self.photom, 'getLastSpectrum'):
                self.btnCalibrateColor.Enable(True)
            msg = _translate('%(photomType)s found on %(photomPort)s')
            self.comPortLabel.SetLabel(msg %
                                       {'photomType': self.photom.type,
                                        'photomPort': self.photom.portString})
        else:
            self.comPortLabel.SetLabel(_translate('No photometers found'))
            self.photom = None

        # does this device need a dark calibration?
        if (hasattr(self.photom, 'getNeedsCalibrateZero') and
                self.photom.getNeedsCalibrateZero()):
            # prompt user if we need a dark calibration for the device
            if self.photom.getNeedsCalibrateZero():
                dlg = wx.Dialog(self, title=_translate(
                    'Dark calibration of ColorCAL'))
                msg = _translate('Your ColorCAL needs to be calibrated first.'
                                 ' Please block all light from getting into '
                                 'the lens and press OK.')
                while self.photom.getNeedsCalibrateZero():
                    txt = _translate('Dark calibration of ColorCAL')
                    dlg = dialogs.MessageDialog(self, message=msg,
                                                title=txt,
                                                type='Info')
                    # info dlg has only an OK button
                    resp = dlg.ShowModal()
                    if resp == wx.ID_CANCEL:
                        self.photom = None
                        self.comPortLabel.SetLabel('')
                        return 0
                    elif resp == wx.ID_OK:
                        self.photom.calibrateZero()
                    # this failed at least once. Try again.
                    msg = _translate('Try again. Cover the lens fully and '
                                     'press OK')
Example #3
0
 def onBtnFindPhotometer(self, event):
     photName = self.ctrlPhotomType.GetStringSelection()
     #search all ports
     self.comPortLabel.SetLabel('Scanning ports...')
     self.Update()
     if 'PR655' in photName:
         self.photom = hardware.findPhotometer(device='PR655')
     elif 'PR650' in photName:
         self.photom = hardware.findPhotometer(device='PR650')
     elif 'LS100' in photName:
         self.photom = hardware.findPhotometer(device='LS100')
     
     if self.photom!=None and self.photom.OK:
         self.btnFindPhotometer.Disable()
         self.btnCalibrateGamma.Enable(True)
         self.btnTestGamma.Enable(True)
         if hasattr(self.photom, 'getLastSpectrum'):
             self.btnCalibrateColor.Enable(True)
         self.comPortLabel.SetLabel('%s found on %s' %(self.photom.type, self.photom.portString))
     else:
         self.comPortLabel.SetLabel('None found (for LS100 try again)')
         self.photom=None
Example #4
0
    def onBtnFindPhotometer(self, event):
        photName = self.ctrlPhotomType.GetStringSelection()
        #search all ports
        self.comPortLabel.SetLabel('Scanning ports...')
        self.Update()
        if 'PR655' in photName:
            self.photom = hardware.findPhotometer(device='PR655')
        elif 'PR650' in photName:
            self.photom = hardware.findPhotometer(device='PR650')
        elif 'LS100' in photName:
            self.photom = hardware.findPhotometer(device='LS100')

        if self.photom != None and self.photom.OK:
            self.btnFindPhotometer.Disable()
            self.btnCalibrateGamma.Enable(True)
            self.btnTestGamma.Enable(True)
            if hasattr(self.photom, 'getLastSpectrum'):
                self.btnCalibrateColor.Enable(True)
            self.comPortLabel.SetLabel(
                '%s found on %s' % (self.photom.type, self.photom.portString))
        else:
            self.comPortLabel.SetLabel('None found (for LS100 try again)')
            self.photom = None
Example #5
0
    def onBtnFindPhotometer(self, event):
        photName = self.ctrlPhotomType.GetStringSelection()
        photPort = self.ctrlPhotomPort.GetValue().strip()
        if not photPort or photPort == "Scan all ports":
            photPort = None
        elif photPort.isdigit():
            photPort = int(photPort)
        #search all ports
        self.comPortLabel.SetLabel('Scanning ports...')
        self.Update()
        self.photom = hardware.findPhotometer(device=photName, ports=photPort)
        if self.photom is not None and self.photom.OK:
            self.btnFindPhotometer.Disable()
            self.btnCalibrateGamma.Enable(True)
            self.btnTestGamma.Enable(True)
            if hasattr(self.photom, 'getLastSpectrum'):
                self.btnCalibrateColor.Enable(True)
            self.comPortLabel.SetLabel(
                '%s found on %s' % (self.photom.type, self.photom.portString))
        else:
            self.comPortLabel.SetLabel('No photometers found')
            self.photom = None

        #does this device need a dark calibration?
        if hasattr(self.photom, 'getNeedsCalibrateZero'
                   ) and self.photom.getNeedsCalibrateZero():
            #prompt user if we need a dark calibration for the device
            if self.photom.getNeedsCalibrateZero():
                dlg = wx.Dialog(self, title='Dark calibration of ColorCAL')
                msg='Your ColorCAL needs to be calibrated first. ' +\
                    'Please block all light from getting into the lens and press OK.'
                while self.photom.getNeedsCalibrateZero():
                    dlg = dialogs.MessageDialog(
                        self,
                        message=msg,
                        title='Dark calibration of ColorCAL',
                        type='Info')  #info dlg has only an OK button
                    resp = dlg.ShowModal()
                    if resp == wx.ID_CANCEL:
                        self.photom = None
                        self.comPortLabel.SetLabel('')
                        return 0
                    elif resp == wx.ID_OK:
                        self.photom.calibrateZero()
                    #this failed at least once. Try again.
                    msg = 'Try again. Cover the lens fully and press OK'
Example #6
0
def test_PR655():
    pr655 = hardware.findPhotometer(device='PR655')
    if pr655==None:
        logging.warning('no device found')
    else:
        print 'type:', pr655.type
        print 'SN:', pr655.getDeviceSN()
        pr655.measure()
        print 'lum', pr655.lastLum
        print 'uv',pr655.lastUV
        print 'xy', pr655.lastXY
        print 'tristim', pr655.lastTristim
        nm, spec = pr655.getLastSpectrum()
        print 'nm', nm
        print 'spec', spec
        print 'temperature', pr655.lastColorTemp

    print 'DONE'
Example #7
0
def test_PR655():
    pr655 = hardware.findPhotometer(device='PR655')
    if pr655 == None:
        logging.warning('no device found')
    else:
        print 'type:', pr655.type
        print 'SN:', pr655.getDeviceSN()
        pr655.measure()
        print 'lum', pr655.lastLum
        print 'uv', pr655.lastUV
        print 'xy', pr655.lastXY
        print 'tristim', pr655.lastTristim
        nm, spec = pr655.getLastSpectrum()
        print 'nm', nm
        print 'spec', spec
        print 'temperature', pr655.lastColorTemp

    print 'DONE'
Example #8
0
    def onBtnFindPhotometer(self, event):
        photName = self.ctrlPhotomType.GetStringSelection()
        photPort = self.ctrlPhotomPort.GetValue().strip()
        if not photPort or photPort == "Scan all ports":
            photPort = None
        elif photPort.isdigit():
            photPort = int(photPort)
        # search all ports
        self.comPortLabel.SetLabel("Scanning ports...")
        self.Update()
        self.photom = hardware.findPhotometer(device=photName, ports=photPort)
        if self.photom is not None and self.photom.OK:
            self.btnFindPhotometer.Disable()
            self.btnCalibrateGamma.Enable(True)
            self.btnTestGamma.Enable(True)
            if hasattr(self.photom, "getLastSpectrum"):
                self.btnCalibrateColor.Enable(True)
            self.comPortLabel.SetLabel("%s found on %s" % (self.photom.type, self.photom.portString))
        else:
            self.comPortLabel.SetLabel("No photometers found")
            self.photom = None

        # does this device need a dark calibration?
        if hasattr(self.photom, "getNeedsCalibrateZero") and self.photom.getNeedsCalibrateZero():
            # prompt user if we need a dark calibration for the device
            if self.photom.getNeedsCalibrateZero():
                dlg = wx.Dialog(self, title="Dark calibration of ColorCAL")
                msg = (
                    "Your ColorCAL needs to be calibrated first. "
                    + "Please block all light from getting into the lens and press OK."
                )
                while self.photom.getNeedsCalibrateZero():
                    dlg = dialogs.MessageDialog(
                        self, message=msg, title="Dark calibration of ColorCAL", type="Info"
                    )  # info dlg has only an OK button
                    resp = dlg.ShowModal()
                    if resp == wx.ID_CANCEL:
                        self.photom = None
                        self.comPortLabel.SetLabel("")
                        return 0
                    elif resp == wx.ID_OK:
                        self.photom.calibrateZero()
                    # this failed at least once. Try again.
                    msg = "Try again. Cover the lens fully and press OK"
Example #9
0
def test_PR655():
    pr655 = hardware.findPhotometer(device='PR655')
    if pr655 is None:
        logging.warning('no device found')
    else:
        print(('type:', pr655.type))
        print(('SN:', pr655.getDeviceSN()))
        #on linux we do actually find a device that returns 'D'
        if pr655.type == 'D':
            pytest.skip()
        pr655.measure()
        print(('lum', pr655.lastLum))
        print(('uv', pr655.lastUV))
        print(('xy', pr655.lastXY))
        print(('tristim', pr655.lastTristim))
        nm, spec = pr655.getLastSpectrum()
        print(('nm', nm))
        print(('spec', spec))
        print(('temperature', pr655.lastColorTemp))

    print('DONE')
Example #10
0
def test_PR655():
    pr655 = hardware.findPhotometer(device="PR655")
    if pr655 is None:
        logging.warning("no device found")
    else:
        print "type:", pr655.type
        print "SN:", pr655.getDeviceSN()
        # on linux we do actually find a device that returns 'D'
        if pr655.type == "D":
            pytest.skip()
        pr655.measure()
        print "lum", pr655.lastLum
        print "uv", pr655.lastUV
        print "xy", pr655.lastXY
        print "tristim", pr655.lastTristim
        nm, spec = pr655.getLastSpectrum()
        print "nm", nm
        print "spec", spec
        print "temperature", pr655.lastColorTemp

    print "DONE"
Example #11
0
def test_PR655():
    pr655 = hardware.findPhotometer(device='PR655')
    if pr655 is None:
        logging.warning('no device found')
    else:
        print(('type:', pr655.type))
        print(('SN:', pr655.getDeviceSN()))
        #on linux we do actually find a device that returns 'D'
        if pr655.type=='D':
            pytest.skip()
        pr655.measure()
        print(('lum', pr655.lastLum))
        print(('uv',pr655.lastUV))
        print(('xy', pr655.lastXY))
        print(('tristim', pr655.lastTristim))
        nm, spec = pr655.getLastSpectrum()
        print(('nm', nm))
        print(('spec', spec))
        print(('temperature', pr655.lastColorTemp))

    print('DONE')
Example #12
0
def test_findPhotometer():
    # findPhotometer with no ports should return None
    assert hw.findPhotometer(ports=[]) is None
    # likewise, if an empty device list is used return None
    assert hw.findPhotometer(device=[]) is None
    # even when both are empty
    assert hw.findPhotometer(device=[], ports=[]) is None

    # non-existant photometers return None, for now
    assert hw.findPhotometer(device="thisIsNotAPhotometer!") is None

    # if the photometer raises an exception don't crash, return None
    assert hw.findPhotometer(device=[_exceptionRaisingPhotometer], ports="foobar") is None

    # specifying a photometer should work
    assert hw.findPhotometer(device=[_workingPhotometer], ports="foobar") == _MockPhotometer

    # one broken, one working
    device = [_exceptionRaisingPhotometer, _workingPhotometer]
    assert hw.findPhotometer(device=device, ports="foobar") == _MockPhotometer
Example #13
0
def test_findPhotometer():
    # findPhotometer with no ports should return None
    assert (hw.findPhotometer(ports=[]) is None)
    # likewise, if an empty device list is used return None
    assert (hw.findPhotometer(device=[]) is None)
    # even when both are empty
    assert (hw.findPhotometer(device=[],ports=[]) is None)

    # non-existent photometers return None, for now
    assert (hw.findPhotometer(device="thisIsNotAPhotometer!") is None)

    # if the photometer raises an exception don't crash, return None
    assert (hw.findPhotometer(device=[_exceptionRaisingPhotometer],ports="foobar") is None)

    # specifying a photometer should work
    assert hw.findPhotometer(device=[_workingPhotometer],ports="foobar") == _MockPhotometer


    # one broken, one working
    device = [_exceptionRaisingPhotometer,_workingPhotometer]
    assert hw.findPhotometer(device=device,ports="foobar") == _MockPhotometer
Example #14
0
import glob
from psychopy import core, log, hardware

log.console.setLevel(log.DEBUG)

pr655 = hardware.findPhotometer(device="PR655")
if pr655 == None:
    log.warning("no device found")
else:
    print "type:", pr655.type
    print "SN:", pr655.getDeviceSN()
    pr655.measure()
    print "lum", pr655.lastLum
    print "uv", pr655.lastUV
    print "xy", pr655.lastXY
    print "tristim", pr655.lastTristim
    nm, spec = pr655.getLastSpectrum()
    print "nm", nm
    print "spec", spec
    print "temperature", pr655.lastColorTemp

print "DONE"
Example #15
0
from psychopy import hardware, log
from psychopy import monitors
from psychopy.hardware import minolta
import serial
#phot = minolta.LS100('COM3')
#print phot

log.console.setLevel(log.DEBUG)
#phot = pr.PR650('/dev/tty.USA19H1d1P1.1')
phot = hardware.findPhotometer(ports=[3])
if phot != None:
    print phot.getLum()
print 'done'
Example #16
0
from psychopy import hardware, logging
from psychopy import monitors
from psychopy.hardware import minolta
import serial
#phot = minolta.LS100('COM3')
#print phot

logging.console.setLevel(logging.DEBUG)
#phot = pr.PR650('/dev/tty.USA19H1d1P1.1')
phot = hardware.findPhotometer(ports=[3])
if phot!=None:
    print phot.getLum()
print 'done' 
Example #17
0
import glob
from psychopy import core, logging, hardware

logging.console.setLevel(logging.DEBUG)

pr655 = hardware.findPhotometer(device='PR655')
if pr655==None:
    logging.warning('no device found')
else:
    print 'type:', pr655.type
    print 'SN:', pr655.getDeviceSN()
    pr655.measure()
    print 'lum', pr655.lastLum
    print 'uv',pr655.lastUV
    print 'xy', pr655.lastXY
    print 'tristim', pr655.lastTristim
    nm, spec = pr655.getLastSpectrum()
    print 'nm', nm
    print 'spec', spec
    print 'temperature', pr655.lastColorTemp

print 'DONE'