Beispiel #1
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);
        }