Ejemplo n.º 1
0
 def loadSettings(self, settings):
     if type(settings) is str:
         if os.path.exists(settings):
             settingsDict = inLib.load_settings(settings)
             settings = settingsDict
     if type(settings) is dict:
         try:
             roi = settings['roi']
             x0 = roi[0]
             y0 = roi[2]
             xsize = roi[1] - x0
             ysize = roi[3] - y0
             print(("Setting ROI to: %i,%i. And size: %i,%i." %
                    (x0, y0, xsize, ysize)))
             self._setROI(x0, y0, xsize, ysize)
             time.sleep(0.05)
             self._setROI(x0, y0, xsize, ysize)
         except:
             print("Unable to set new ROI")
         try:
             exposure_time = settings['exposure_time']
             print(("Setting exposure time to: %.2f ms" %
                    (exposure_time * 1000)))
             self.setExposureTime(exposure_time, inMillisec=False)
         except:
             print("Unable to set new timings")
Ejemplo n.º 2
0
 def newSettings(self, filename):
     settings_dict = inLib.load_settings(filename)
     if settings_dict.has_key('devices'):
         settings_dict = settings_dict['devices']['shutters']['settings']#['channel_settings']
     settings_dict['settings_filename'] = filename
     self.saved_settings = [settings_dict] + self.saved_settings
     return self.saved_settings
Ejemplo n.º 3
0
 def newSettings(self, filename, settings_dict=None):
     if settings_dict is None:
         settings_dict = inLib.load_settings(filename)
         if settings_dict.has_key('devices'):
             settings_dict = settings_dict['devices']['camera']
         settings_dict['settings_filename'] = filename
     self.saved_settings = [settings_dict] + self.saved_settings
Ejemplo n.º 4
0
 def newSettings(self, filename):
     settings_dict = inLib.load_settings(filename)
     if 'devices' in settings_dict:
         settings_dict = settings_dict['devices']['shutters']['settings']#['channel_settings']
     settings_dict['settings_filename'] = filename
     self.saved_settings = [settings_dict] + self.saved_settings
     return self.saved_settings
Ejemplo n.º 5
0
 def newSettings(self, filename, settings_dict=None):
     if settings_dict is None:
         settings_dict = inLib.load_settings(filename)
         if settings_dict.has_key('devices'):
             settings_dict = settings_dict['devices']['camera']['settings']
         print settings_dict
         settings_dict['settings_filename'] = filename
     self.saved_settings = [settings_dict] + self.saved_settings
     return self.saved_settings
Ejemplo n.º 6
0
 def newSettings(self, filename, settings_dict=None):
     if settings_dict is None:
         settings_dict = inLib.load_settings(filename)
         if 'devices' in settings_dict:
             settings_dict = settings_dict['devices']['camera']['settings']
         print(settings_dict)
         settings_dict['settings_filename'] = filename
     self.saved_settings = [settings_dict] + self.saved_settings
     return self.saved_settings
Ejemplo n.º 7
0
    def __init__(self):
        '''
        Reads the settings and loads all specified devices and modules.
        Sets up instrument-wide properties and calls the UI.
        '''
        print('inControl: Starting up...')
        if len(sys.argv) > 1:
            settings_filename = sys.argv[1]
        else:
            print('Loading default settings.')
            settings_filename = 'settings_default.yaml'
        self._settings = inLib.load_settings(settings_filename)

        # 1. Call device UI APIs

        #: A dictionary of all devices run by InControl.
        #: The keys are the name of a device, the value is an instance of the device's
        #: Control class. This dictionary is updated into the namespace of InControl's main
        #: control class. Devices are simple implementations to control one device.
        self._device_controls = {}
        if self._settings['devices']:
            for device in self._settings['devices']:
                device_dict = self._settings['devices'][device]
                if device_dict['active']:
                    device_path = inLib.get_device_path(device_dict)
                    device_module = inLib.import_module(device_path)
                    device_settings_dict = device_dict['settings']
                    device_settings_dict[
                        'settings_filename'] = settings_filename
                    print(device_settings_dict)
                    device_control = device_module.Control(
                        device_settings_dict)
                    self._device_controls[device] = inLib.CommandQueue(
                        device_control)
        self.__dict__.update(self._device_controls)

        # 2. Call module UI APIs

        #: A dictionary of all modules run by InControl.
        #: The keys are the name of a module, the value is an instance of the module's
        #: Control class. This dictionary is updated into the namespace of InControl's main
        #: control class. InControl modules do not run a particular device, but have access to
        #: all device and other module control classes. Therefore, InControl's main control class
        #: is passed to the module object upon initiation. Modules should be used whenever a task
        #: with multiple devices needs to be performed.
        self._module_controls = {}
        for module in self._settings['modules']:
            if self._settings['modules'][module]['active']:
                module_path = inLib.get_module_path(module)
                module_module = inLib.import_module(module_path)
                module_settings = self._settings['modules'][module]['settings']
                module_control = module_module.Control(self, module_settings)
                self._module_controls[module] = inLib.CommandQueue(
                    module_control)
        self.__dict__.update(self._module_controls)

        self.setWorkingDir(self._settings['working_dir'])
Ejemplo n.º 8
0
 def newSettings(self, settings):
     if type(settings) is str:
         if os.path.exists(settings):
             settingsDict = inLib.load_settings(settings)
             settingsDict['settings_filename'] = settings
             settings = settingsDict
     if type(settings) is dict:
         if not settings.has_key('settings_filename'):
             settings['settings_filename'] = 'unknown'
         self.savedSettings = [settings] + self.savedSettings
     return self.savedSettings
Ejemplo n.º 9
0
 def newSettings(self, settings):
     if type(settings) is str:
         if os.path.exists(settings):
             settingsDict = inLib.load_settings(settings)
             settingsDict['settings_filename'] = settings
             settings = settingsDict
     if type(settings) is dict:
         if not settings.has_key('settings_filename'):
             settings['settings_filename'] = 'unknown'
         self.savedSettings = [settings] + self.savedSettings
     return self.savedSettings
Ejemplo n.º 10
0
 def loadSettings(self, settings):
     if type(settings) is str:
         if os.path.exists(settings):
             settingsDict = inLib.load_settings(settings)
             settings = settingsDict
     if type(settings) is dict:
         try:
             roi = settings['roi']
             x0 = roi[0] 
             y0 = roi[2] 
             xsize = roi[1] - x0
             ysize = roi[3] - y0
             print "Setting ROI to: %i,%i. And size: %i,%i." % (x0,y0,xsize,ysize)
             self._setROI(x0,y0,xsize,ysize)
             time.sleep(0.05)
             self._setROI(x0,y0,xsize,ysize)
         except:
             print "Unable to set new ROI"
         try:
             exposure_time = settings['exposure_time']
             print "Setting exposure time to: %.2f ms" % (exposure_time*1000)
             self.setExposureTime(exposure_time, inMillisec=False)
         except:
             print "Unable to set new timings"
Ejemplo n.º 11
0
    def loadSettings(self, settings):
        if type(settings) is str:
            if os.path.exists(settings):
                settingsDict = inLib.load_settings(settings)
                settings = settingsDict

        if type(settings) is dict:
            self._api.setTemperature(settings['temperature'])
            self._api.setExposureTime(settings['exposure_time'])
            self._setADChannel(settings['ad_channel'])
            self._setROIAndBinning(settings['roi'], settings['binning'])
            self._setHSSpeed(settings['ad_channel'], settings['hs_speed'])
            self._api.setVSAmplitude(settings['vs_amplitude'])
            self._setEMCCDGain(settings['em_gain'])
            self._setVSSpeed(settings['vs_speed'])
            self._setPreAmpGain(settings['preamp_gain'])

            self._api.setAcquisitionMode(settings['acquisition_mode'])
            self._api.setReadMode(settings['read_mode'])
            self._api.setTriggerMode(settings['trigger_mode'])
            self._api.setKineticCycleTime(settings['kinetic_time'])
            self._api.setEMGainMode(settings['em_gain_mode'])
            self._api.setBaselineClamp(settings['baseline_clamp'])
            self._api.setFrameTransferMode(settings['frame_transfer_mode'])