Beispiel #1
0
        public AndorCamera(CameraParameters p)
        {
            int _numCameras = 0;

            ret = sdk.GetAvailableCameras(ref _numCameras);
            if (ret == AndorSDK.DRV_SUCCESS && _numCameras == 1)
            {
                numCameras = _numCameras;
                int handle = 0;
                ret = sdk.GetCameraHandle(0, ref handle);
                if (ret == AndorSDK.DRV_SUCCESS)
                {
                    ret = sdk.SetCurrentCamera(handle);
                    if (ret == AndorSDK.DRV_SUCCESS)
                    {
                        ret = sdk.Initialize(p.Dir);
                        if (ret != AndorSDK.DRV_SUCCESS)
                        {
                            Log.Debug("ANDOR: " + ErrorCodes.Decoder(ret));
                            sdk.ShutDown();
                        }
                        else
                        {
                            int _Serial = 0;
                            sdk.GetCameraSerialNumber(ref _Serial);
                            Serial = _Serial;

                            // get properties
                            ret = sdk.GetCapabilities(ref caps);
                            if (ret == AndorSDK.DRV_SUCCESS && (AndorSDK.AC_FEATURES_FTEXTERNALEXPOSURE & caps.ulTriggerModes) != 1)
                            {
                                Log.Debug("ANDOR: " + "Does not support external exposure");
                            }

                            int nAD = 0;
                            sdk.GetNumberADChannels(ref nAD);
                            NumberADChannels = nAD; // number of ADCs

                            int _BitDepth = 0;
                            sdk.GetBitDepth(_BitDepth, ref _BitDepth); // dynamic range
                            BitDepth = _BitDepth;

                            int _XDim = 0, _YDim = 0;
                            sdk.GetDetector(ref _XDim, ref _YDim); // detector dimensions
                            XDim = _XDim; YDim = _YDim;

                            int _MCPGainMin = 0; int _MCPGainMax = 0;
                            sdk.GetMCPGainRange(ref _MCPGainMin, ref _MCPGainMax); // gain settings
                            MCPGainMin = _MCPGainMin; MCPGainMax = _MCPGainMax;

                            // set properties
                            SetUpAndor();
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public AndorCamera(CameraParameters p)
        {
            if (p == null)
            {
                throw new ArgumentException();
            }

            if (p.Dir != null)
            {
                InitVal = AndorSdk.Initialize(p.Dir);
                AndorSdk.GetCapabilities(ref Capabilities);
                AndorSdk.FreeInternalMemory();
                AndorSdk.GetDetector(ref _Width, ref _Height);

                AndorSdk.GetNumberADChannels(ref _NumberADChannels);
                ADChannel = DefaultADChannel;

                AndorSdk.GetBitDepth(ADChannel, ref _BitDepth);
                SaturationLevel = p.SaturationLevel;

                AndorSdk.GetMaximumBinning(ReadModeImage, 0, ref _MaxHorizontalBinSize);
                AndorSdk.GetMaximumBinning(ReadModeImage, 1, ref _MaxVerticalBinSize);

                _Image = new ImageArea(1, 1, 0, Width, 0, Height);
                Image  = p.Image;

                GateMode  = Constants.GatingModeSMBOnly;
                MCPGating = 1; // enable the MCP

                AndorSdk.GetMCPGainRange(ref _MinMCPGain, ref _MaxMCPGain);
                IntensifierGain = p.InitialGain;

                AcquisitionMode = AcquisitionModeSingle;
                TriggerMode     = TriggerModeExternal;
                DDGTriggerMode  = DDGTriggerModeExternal;
                ReadMode        = p.ReadMode;

                // quick hack for optimal camera setting for spectroscopy
                AndorSdk.SetHighCapacity(0);      // Note: 0 enables high sensitivity.
                AndorSdk.SetPreAmpGain(2);        // 2 = 4x , 1 = 2x, 0 = 1x;
                AndorSdk.SetDDGInsertionDelay(1); // set to fast insertion delay, intelligate off.
            }

            LoadCalibration(p.CalFile);

            p.Image    = Image;
            p.ReadMode = ReadMode;
        }
Beispiel #3
0
        public bool Initialize() // configure the camera to capture a single, full image from the camera
        {
            uint   uiErrorCode;
            string errMsg = "";

            SystemInitialized = false;

            // initialize the camera
            try
            {
                uiErrorCode = MyCamera.Initialize("");
            }
            catch (Exception e)
            {
                PostError("Andor SDK did not load: " + e.Message);
                return(false);
            }
            bool success = CheckCameraResult(uiErrorCode, ref errMsg);

            if (!success)
            {
                PostError("Camera: " + errMsg);
                return(false);
            }

            // get capabilities

            AndorSDK.AndorCapabilities caps = new AndorSDK.AndorCapabilities();
            caps.ulSize = 256; // had to guess at the size since sizeof(AndorSDK.AndorCapabilities) isn't allowed
            uiErrorCode = MyCamera.GetCapabilities(ref caps);
            success     = CheckCameraResult(uiErrorCode, ref errMsg);
            if (!success)
            {
                PostError("Camera: " + errMsg);
                return(false);
            }

            uiErrorCode = MyCamera.GetBitDepth(0, ref bitDepth);
            success     = CheckCameraResult(uiErrorCode, ref errMsg);
            if (!success)
            {
                PostError("Camera: " + errMsg);
                return(false);
            }

            // Get Detector Format, returns size of sensor in xPixels and yPixels
            uiErrorCode = MyCamera.GetDetector(ref xPixels, ref yPixels);
            success     = CheckCameraResult(uiErrorCode, ref errMsg);
            if (!success)
            {
                PostError("Camera: " + errMsg);
                return(false);
            }

            if (xPixels == 1024 && yPixels == 1024)
            {
                isEMCCD = true;
            }
            else
            {
                isEMCCD = false;
            }

            // Set Camera EM Gain Mode
            if (isEMCCD)
            {
                uiErrorCode = MyCamera.SetEMGainMode(3);
                success     = CheckCameraResult(uiErrorCode, ref errMsg);
                if (!success)
                {
                    PostError("Camera: " + errMsg);
                    return(false);
                }
            }

            SystemInitialized = true;
            PostMessage("Camera initialized");

            // ADDED by BG, 26 Mar 2014, Want camera to start cooling right away.  Also added MyCamera.CoolerOFF() in destructor
            CameraTemperature = GlobalVars.CameraTargetTemperature;
            SetCoolerTemp(CameraTemperature);
            MyCamera.SetImageRotate(1); // 0 = no rotate, 1 = 90 degs CW, 2 = 90 CCW

            return(true);
        }