def togglePatternSeq(self, _iLCr, _Conf, _doStart): """ Connect to lightcrafter and start/stop the current pattern sequence """ if not self.isLCrUsed(_Conf) and _iLCr not in [0, 1]: return LCr = lcr.Lightcrafter(_logLevel=2, _funcLog=ssp.Log.write) result = LCr.connect(_iLCr) errC = result[0] if errC == lcr.ERROR.OK: try: if _doStart: res = LCr.startPatternSequence() else: res = LCr.stopPatternSequence() if res[0] is lcr.ERROR.OK: done = False n = 10 while not done and n > 0: time.sleep(0.2) res = LCr.getMainStatus(_logLev=3) done = res[2]["SeqRunning"] is _doStart n -= 1 if n == 0: ssp.Log.write("WARNING", "Toggle pattern sequence timeout") finally: LCr.disconnect()
def connectLCrs(_Conf=None, _Stim=None): if not (_Stim is None) and not (_Stim.isUseLCr): return [] if _Conf is None: if not (glo.QDSpy_use_Lightcrafter): return [] else: if not (_Conf.useLCr): return [] LCrList = lcr.enumerateLightcrafters() LCrs = [] nLCrOk = 0 for iLCr, LCr in enumerate(LCrList): LCrs.append( lcr.Lightcrafter(_isCheckOnly=False, _funcLog=ssp.Log.write, _logLevel=glo.QDSpy_LCr_LogLevel)) result = LCrs[iLCr].connect(iLCr) if result[0] != lcr.ERROR.OK: LCrs[iLCr] = None else: nLCrOk += 1 if nLCrOk == 0: ssp.Log.write("WARNING", "This script requires a lightcrafter") return LCrs
def sendLEDChangesToLCr(self, _Conf): """ Connect to lightcrafter and update LED currents and enabled state """ if not self.isLCrUsed(_Conf): return # Generate a new lightcrafter object # LCr = lcr.Lightcrafter(_logLevel=glo.QDSpy_LCr_LogLevel, _funcLog=ssp.Log.write) for iDev, Dev in enumerate(lcr.LCrDeviceList): try: result = LCr.connect(iDev) if result[0] == lcr.ERROR.OK: # Set LEDs on the device(s) # currents = [0] * 3 enabled = [False] * 3 for iLED, LED in enumerate(self.LEDs): if LED["devIndex"] == iDev: currents[LED["LEDIndex"]] = LED["current"] enabled[LED["LEDIndex"]] = LED["enabled"] LCr.setLEDCurrents(currents[0:3]) LCr.setLEDEnabled(enabled[0:3], self.isLEDSeqEnabled[iDev]) finally: LCr.disconnect()
def updateLEDs(self, _Conf): """ Connect to lightcrafter to get LED currents and enabled state, und update LED dictionary """ # Check configuration file and, if not available, also globals if # the lightcrafter should be used # if (_Conf is None ) or not (_Conf.useLCr) or not (glo.QDSpy_use_Lightcrafter): return # Generate a new lightcrafter object # LCr = lcr.Lightcrafter(_logLevel=glo.QDSpy_LCr_LogLevel, _funcLog=ssp.Log.write) for iDev, Dev in enumerate(lcr.LCrDeviceList): try: result = LCr.connect(iDev) if result[0] == lcr.ERROR.OK: # Get LED settings on the device(s) # current = [0] * 3 enabled = [False] * 3 result = LCr.getLEDCurrents() if result[0] == lcr.ERROR.OK: current = list(result[1]) result = LCr.getLEDEnabled() if result[0] == lcr.ERROR.OK: enabled = list(result[1]) seqEnabled = result[2] self.isLEDSeqEnabled[iDev] = seqEnabled for iCurr, Curr in enumerate(current): for iLED, LED in enumerate(self.LEDs): if (iDev == LED["devIndex"]) and ( iCurr == LED["LEDIndex"]): self.LEDs[iLED]["current"] = Curr self.LEDs[iLED]["enabled"] = enabled[iCurr] finally: LCr.disconnect()
def getLCrStatus(_devIndex, _funcLog=None, _logLev=-1): """ Return complete status of the lightcrafter as list of dictionaries """ status = [] if glo.QDSpy_use_Lightcrafter: LCr = lcr.Lightcrafter(_logLevel=_logLev, _funcLog=_funcLog) result = LCr.connect(_devIndex) errC = result[0] if errC == lcr.ERROR.OK: try: hw_res = LCr.getHardwareStatus() sys_res = LCr.getSystemStatus() main_res = LCr.getMainStatus() vid_res = LCr.getVideoSignalDetectStatus() status = [hw_res, sys_res, main_res, vid_res] finally: LCr.disconnect() return status
def getLCrFirmwareVer(_devIndex): """ Return firmware version of connected lightcrafter as list (e.g. [3,0,0]) or an empty list, if lightcrafter use is not enabled or device could not be connected """ ver = [] if glo.QDSpy_use_Lightcrafter: LCr = lcr.Lightcrafter(_logLevel=-1) result = LCr.connect(_devIndex) errC = result[0] if errC == lcr.ERROR.OK: try: result = LCr.getFirmwareVersion() errC = result[0] if errC == lcr.ERROR.OK: ver = result[2]["applicationSoftwareRev"] finally: LCr.disconnect() return ver
""" # --------------------------------------------------------------------- __author__ = "*****@*****.**" import pickle import numpy as np import QDSpy_global as glo import QDSpy_stim_support as ssp import QDSpy_stim_draw as drw import QDSpy_stim_movie as mov import QDSpy_stim_video as vid import QDSpy_core_shader as csh if glo.QDSpy_use_Lightcrafter: import Devices.lightcrafter as lcr _LCr = lcr.Lightcrafter(_isCheckOnly=True, _funcLog=ssp.Log.write) else: _LCr = None # --------------------------------------------------------------------- class ColorMode: _0_255 = 0 _0_1 = 1 LC_first = 2 LC_G9B9 = 2 COL_bitDepthRGB_888 = (8, 8, 8) COL_bitShiftRGB_000 = (0, 0, 0)
# -*- coding: utf-8 -*- import Devices.lightcrafter as lcr import time # Generate lightcrafter object and try to connect to it dev = lcr.Lightcrafter(_isCheckOnly=False, _logLevel=3) res = dev.connect() if res[0] is not lcr.ERROR.OK: # No connection exit() # Print report and video signal status dev.getFirmwareVersion() dev.getHardwareStatus() dev.getMainStatus() dev.getSystemStatus() dev.getVideoSignalDetectStatus() dev.stopPatternSequence() # Go back to normal video mode dev.setInputSource(lcr.SourceSel.HDMI, lcr.SourcePar.Bit24) dev.setDisplayMode(lcr.DispMode.Video) dev.getMainStatus() dev.getSystemStatus() dev.disconnect()
#!/usr/bin/env python # -*- coding: utf-8 -*- # # --------------------------------------------------------------------- import random import QDS import Devices.lightcrafter as LCr QDS.Initialize("Test1", "Test for Lightcrafter") print("---") dev = LCr.Lightcrafter() result = dev.connect() if result[0] == LCr.ERROR.OK: dev.getHardwareStatus() dev.getSystemStatus() dev.getMainStatus() dev.getVideoSignalDetectStatus() dev.disconnect() else: print("WARNING: This script required a lightcrafter") print("---") QDS.LC_setLEDCurrents(0, [0,50,0]) random.seed(1) p = {} p['nTrials'] = 20 p['nRows'] = 2 p['nCols'] = 2 p['boxDx'] = 50