def configure(self): ## Merge command into default values: prof = Profiler('Camera.CameraTask.configure', disabled=True) #print "CameraTask.configure" ## set default parameters, load params from command params = { 'triggerMode': 'Normal', } params.update(self.camCmd['params']) ## If we are sending a one-time trigger to start the camera, then it must be restarted to arm the trigger ## (bulb and strobe modes only require a restart if the trigger mode is not already set; this is handled later) restart = False if params['triggerMode'] == 'TriggerStart': restart = True ## If the DAQ is triggering the camera, then the camera must start before the DAQ if params['triggerMode'] != 'Normal': daqName = self.dev.camConfig['triggerInChannel']['device'] self.__startOrder[1].append(daqName) ## Make sure we haven't requested something stupid.. if self.camCmd.get('triggerProtocol', False) and self.dev.camConfig['triggerOutChannel']['device'] == daqName: raise Exception("Task requested camera to trigger and be triggered by the same device.") if 'pushState' in self.camCmd: stateName = self.camCmd['pushState'] self.dev.pushState(stateName, params=list(params.keys())) prof.mark('push params onto stack') (newParams, paramsNeedRestart) = self.dev.setParams(params, autoCorrect=True, autoRestart=False) ## we'll restart in a moment if needed.. restart = restart or paramsNeedRestart prof.mark('set params') ## If the camera is triggering the daq, stop acquisition now and request that it starts after the DAQ ## (daq must be started first so that it is armed to received the camera trigger) name = self.dev.name() if self.camCmd.get('triggerProtocol', False): restart = True daqName = self.dev.camConfig['triggerOutChannel']['device'] self.__startOrder = [daqName], [] prof.mark('conf 1') ## We want to avoid this if at all possible since it may be very expensive if restart: self.dev.stop(block=True) prof.mark('stop') ## connect using acqThread's connect method because there may be no event loop ## to deliver signals here. self.dev.acqThread.connectCallback(self.newFrame) ## Call the DAQ configure DAQGenericTask.configure(self) prof.mark('DAQ configure') prof.finish()
def configure(self): ### Record initial state or set initial value ##if 'holding' in self.cmd: ## self.dev.setHolding(self.cmd['mode'], self.cmd['holding']) if 'mode' in self.cmd: self.dev.setMode(self.cmd['mode']) self.ampState = {'mode': self.dev.getMode()} ### Do not configure daq until mode is set. Otherwise, holding values may be incorrect. DAQGenericTask.configure(self)
def configure(self): ## Record initial state or set initial value # if 'holding' in self.cmd: # self.dev.setHolding(self.cmd['mode'], self.cmd['holding']) if "mode" in self.cmd: self.dev.setMode(self.cmd["mode"]) self.ampState = {"mode": self.dev.getMode(), "LPF": self.dev.getLPF(), "gain": self.dev.getGain()} ## Do not configure daq until mode is set. Otherwise, holding values may be incorrect. DAQGenericTask.configure(self) self.mapping.setMode(self.ampState["mode"])
def configure(self): ## Get rate: first get name of DAQ, then ask the DAQ task for its rate daqName, ch = self.dev.getDAQName() if daqName is None: return tasks = self.parentTask().tasks daqTask = tasks[daqName] rate = daqTask.getChanSampleRate(self.dev.config[ch]['channel'][1]) ### do a power check if requested if self.cmd.get('checkPower', False): self.dev.outputPower() ### set wavelength if 'wavelength' in self.cmd: self.dev.setWavelength(self.cmd['wavelength']) ### send power/switch waveforms to device for pCell/qSwitch/shutter cmd calculation #print "Cmd:", self.cmd if 'powerWaveform' in self.cmd and not self.cmd.get( 'ignorePowerWaveform', False): calcCmds = self.dev.getChannelCmds( {'powerWaveform': self.cmd['powerWaveform']}, rate) elif 'switchWaveform' in self.cmd: calcCmds = self.dev.getChannelCmds( {'switchWaveform': self.cmd['switchWaveform']}, rate) elif 'pulse' in self.cmd: raise Exception( 'Support for (pulseTime/energy) pair commands is not yet implemented.' ) else: calcCmds = {} ### set up shutter, qSwitch and pCell -- self.cmd['daqProtocol'] points to the command structure that the DAQGeneric will use, don't set self.cmd['daqProtocol'] equal to something else! if 'shutter' in self.cmd: self.cmd['daqProtocol']['shutter'] = self.cmd['shutter'] self.cmd['daqProtocol']['shutter']['command'][-1] = 0 elif 'shutterMode' in self.cmd: if self.cmd['shutterMode'] is 'auto': if 'shutter' in calcCmds: self.cmd['daqProtocol']['shutter'] = { 'command': calcCmds['shutter'] } elif self.cmd['shutterMode'] is 'closed': #self.cmd['daqProtocol']['shutter']['command'] = np.zeros(len(calcCmds['shutter']), dtype=np.byte) self.cmd['daqProtocol']['shutter'] = {'preset': 0} elif self.cmd['shutterMode'] is 'open': self.cmd['daqProtocol']['shutter'] = {'preset': 1} # self.cmd['daqProtocol']['shutter'] = {'command': np.ones(len(calcCmds['shutter']), dtype=np.byte)} # ## set to holding value, not 0 # self.cmd['daqProtocol']['shutter']['command'][-1] = 0 if 'pCell' in self.cmd: self.cmd['daqProtocol']['pCell'] = self.cmd['pCell'] elif 'pCell' in calcCmds: self.cmd['daqProtocol']['pCell']['command'] = calcCmds['pCell'] if 'qSwitch' in self.cmd: self.cmd['daqProtocol']['qSwitch'] = self.cmd['qSwitch'] self.cmd['daqProtocol']['qSwitch']['command'][-1] = 0 elif 'qSwitch' in calcCmds: self.cmd['daqProtocol']['qSwitch']['command'] = calcCmds['qSwitch'] self.cmd['daqProtocol']['qSwitch']['command'][-1] = 0 #if 'powerWaveform' in self.cmd: ## send powerWaveform into daqProtocol so it can be downsampled with the other data #self.cmd['daqProtocol']['power']['command'] = self.cmd['powerWaveform'] self.currentPower = self.dev.getParam('currentPower') self.expectedPower = self.dev.getParam('expectedPower') DAQGenericTask.configure( self) ## DAQGenericTask will use self.cmd['daqProtocol']
def configure(self): ## Merge command into default values: prof = Profiler('Camera.CameraTask.configure', disabled=True) #print "CameraTask.configure" ## set default parameters, load params from command params = { 'triggerMode': 'Normal', } params.update(self.camCmd['params']) if 'pushState' in self.camCmd: stateName = self.camCmd['pushState'] self.dev.pushState(stateName) prof.mark('collect params') ## If we are sending a one-time trigger to start the camera, then it must be restarted to arm the trigger ## (bulb and strobe modes only require a restart if the trigger mode is not already set; this is handled later) if params['triggerMode'] == 'TriggerStart': restart = True ## If the DAQ is triggering the camera, then the camera must start before the DAQ if params['triggerMode'] != 'Normal': daqName = self.dev.camConfig['triggerInChannel']['device'] self.__startOrder[1].append(daqName) ## Make sure we haven't requested something stupid.. if self.camCmd.get('triggerProtocol', False) and self.dev.camConfig['triggerOutChannel']['device'] == daqName: raise Exception("Task requested camera to trigger and be triggered by the same device.") (newParams, restart) = self.dev.setParams(params, autoCorrect=True, autoRestart=False) ## we'll restart in a moment if needed.. prof.mark('set params') ## If the camera is triggering the daq, stop acquisition now and request that it starts after the DAQ ## (daq must be started first so that it is armed to received the camera trigger) name = self.dev.name() if self.camCmd.get('triggerProtocol', False): restart = True daqName = self.dev.camConfig['triggerOutChannel']['device'] self.__startOrder = [daqName], [] #startOrder.remove(name) #startOrder.insert(startOrder.index(daqName)+1, name) prof.mark('conf 1') ## If we are not triggering the daq, request that we start before everyone else ## (no need to stop, we will simply record frames as they are collected) #else: #startOrder.remove(name) #startOrder.insert(0, name) #prof.mark('conf 2') ## We want to avoid this if at all possible since it may be very expensive if restart: self.dev.stop(block=True) prof.mark('stop') ## connect using acqThread's connect method because there may be no event loop ## to deliver signals here. self.dev.acqThread.connectCallback(self.newFrame) ## Call the DAQ configure DAQGenericTask.configure(self) prof.mark('DAQ configure') prof.finish()
def configure(self): ## Get rate: first get name of DAQ, then ask the DAQ task for its rate daqName, ch = self.dev.getDAQName() if daqName is None: return tasks = self.parentTask().tasks daqTask = tasks[daqName] rate = daqTask.getChanSampleRate(self.dev.config[ch]['channel'][1]) ### do a power check if requested if self.cmd.get('checkPower', False): self.dev.outputPower() ### set wavelength if 'wavelength' in self.cmd: self.dev.setWavelength(self.cmd['wavelength']) ### send power/switch waveforms to device for pCell/qSwitch/shutter cmd calculation #print "Cmd:", self.cmd if 'powerWaveform' in self.cmd and not self.cmd.get('ignorePowerWaveform', False): calcCmds = self.dev.getChannelCmds({'powerWaveform':self.cmd['powerWaveform']}, rate) elif 'switchWaveform' in self.cmd: calcCmds = self.dev.getChannelCmds({'switchWaveform':self.cmd['switchWaveform']}, rate) elif 'pulse' in self.cmd: raise Exception('Support for (pulseTime/energy) pair commands is not yet implemented.') else: calcCmds = {} ### set up shutter, qSwitch and pCell -- self.cmd['daqProtocol'] points to the command structure that the DAQGeneric will use, don't set self.cmd['daqProtocol'] equal to something else! if 'shutter' in self.cmd: self.cmd['daqProtocol']['shutter'] = self.cmd['shutter'] self.cmd['daqProtocol']['shutter']['command'][-1] = 0 elif 'shutterMode' in self.cmd: if self.cmd['shutterMode'] is 'auto': if 'shutter' in calcCmds: self.cmd['daqProtocol']['shutter'] = {'command': calcCmds['shutter']} elif self.cmd['shutterMode'] is 'closed': #self.cmd['daqProtocol']['shutter']['command'] = np.zeros(len(calcCmds['shutter']), dtype=np.byte) self.cmd['daqProtocol']['shutter'] = {'preset': 0} elif self.cmd['shutterMode'] is 'open': self.cmd['daqProtocol']['shutter'] = {'command': np.ones(len(calcCmds['shutter']), dtype=np.byte)} ## set to holding value, not 0 self.cmd['daqProtocol']['shutter']['command'][-1] = 0 if 'pCell' in self.cmd: self.cmd['daqProtocol']['pCell'] = self.cmd['pCell'] elif 'pCell' in calcCmds: self.cmd['daqProtocol']['pCell']['command'] = calcCmds['pCell'] if 'qSwitch' in self.cmd: self.cmd['daqProtocol']['qSwitch'] = self.cmd['qSwitch'] self.cmd['daqProtocol']['qSwitch']['command'][-1] = 0 elif 'qSwitch' in calcCmds: self.cmd['daqProtocol']['qSwitch']['command'] = calcCmds['qSwitch'] self.cmd['daqProtocol']['qSwitch']['command'][-1] = 0 #if 'powerWaveform' in self.cmd: ## send powerWaveform into daqProtocol so it can be downsampled with the other data #self.cmd['daqProtocol']['power']['command'] = self.cmd['powerWaveform'] self.currentPower = self.dev.getParam('currentPower') self.expectedPower = self.dev.getParam('expectedPower') DAQGenericTask.configure(self) ## DAQGenericTask will use self.cmd['daqProtocol']