Example #1
0
        public static IntPtr GetCameras(out int Count)
        {
            uint   success;
            IntPtr CameraListRef = new IntPtr();

            success = EDSDK.EdsGetCameraList(out CameraListRef);
            if (success != EDSDK.EDS_ERR_OK)
            {
                Console.WriteLine("GetCameraList failed");
            }
            else
            {
                Console.WriteLine("GetCameraList success");
            }

            success = EDSDK.EdsGetChildCount(CameraListRef, out Count);
            if (success != EDSDK.EDS_ERR_OK)
            {
                Console.WriteLine("GetChildCount failed");
            }
            else
            {
                Console.WriteLine("GetChildCount success\t" + "child num is:" + Count.ToString());
            }
            return(CameraListRef);
        }
        public IEnumerable <Camera> GetCameras()
        {
            UInt32 returnValue;

            IntPtr cameraListPointer;

            returnValue = EDSDK.EdsGetCameraList(out cameraListPointer);
            ReturnValueManager.HandleFunctionReturnValue(returnValue);

            try
            {
                Int32 cameraListCount;
                returnValue = EDSDK.EdsGetChildCount(cameraListPointer, out cameraListCount);
                ReturnValueManager.HandleFunctionReturnValue(returnValue);

                for (var i = 0; i < cameraListCount; ++i)
                {
                    IntPtr cameraPointer;
                    returnValue = EDSDK.EdsGetChildAtIndex(cameraListPointer, i, out cameraPointer);
                    ReturnValueManager.HandleFunctionReturnValue(returnValue);

                    Camera camera = new Camera(cameraPointer);

                    yield return(camera);
                }
            }
            finally
            {
                // Release Camera List Pointer
                if (cameraListPointer != IntPtr.Zero)
                {
                    EDSDK.EdsRelease(cameraListPointer);
                }
            }
        }
Example #3
0
        private void Initialize()
        {
            SDKHelper.CheckError(EDSDK.EdsInitializeSDK());
            SDKHelper.CheckError(EDSDK.EdsGetCameraList(out _cameraListPointer));

            LoadCamerasList(_cameraListPointer);
        }
Example #4
0
        private void btn_connect_click(object sender, RoutedEventArgs e)
        {
            IntPtr cameraList = new IntPtr(0);

            camera = new IntPtr(0);

            Int32 cameraCount = 0;
            EDSDK sdk         = new EDSDK();

            EDSDK.EdsInitializeSDK();
            EdsError = EDSDK.EdsGetCameraList(out cameraList);

            //EdsError = EdsGetCameraList(out cameraList);
            EDSDK.EdsGetChildCount(cameraList, out cameraCount);
            label.Content = "Connected camera count : " + cameraCount.ToString();


            if (cameraCount != 0)
            {
                EdsError = EDSDK.EdsGetChildAtIndex(cameraList, 0, out camera);
                //MessageBox.Show("EdsGetChildAtIndex err code : " + EdsError.ToString());
            }



            EdsError = EDSDK.EdsOpenSession(camera);
            if (EdsError == EDSDK.EDS_ERR_OK)
            {
                label.Content = "Camera connected";

                EDSDK.EdsSetPropertyEventHandler(camera, EDSDK.PropertyEvent_All, propertyEventHandler, IntPtr.Zero);


                SDKObjectEvnet += new EDSDK.EdsObjectEventHandler(objectEventHandler);
                //SDKObjectEvent += new SDKObjectEventHandler(objectEventHandler);

                EdsError = EDSDK.EdsSetObjectEventHandler(camera, EDSDK.ObjectEvent_All, SDKObjectEvnet, IntPtr.Zero);
                if (EdsError == EDSDK.EDS_ERR_OK)
                {
                    label.Content = "NO ERROR";
                }
                else
                {
                    label.Content = "ERROR : " + EdsError;
                }
                EDSDK.EdsSetCameraStateEventHandler(camera, EDSDK.StateEvent_All, cameraStateEventHandler, IntPtr.Zero);
            }
            else
            {
                label.Content = "Camera not connected";
            }
        }
Example #5
0
        private void scanToCameras()
        {
            IntPtr tmpptr;
            IntPtr tmpCameraPtr;
            int    tmpCount = 0;

            EDSDK.EdsGetCameraList(out tmpptr);
            EDSDK.EdsGetChildCount(tmpptr, out tmpCount);
            for (int i = 0; i < tmpCount; i++)
            {
                EDSDK.EdsGetChildAtIndex(tmpptr, i, out tmpCameraPtr);
                this.CameraList.Add(new Camera(tmpCameraPtr, ""));
                EDSDK.EdsSetPropertyEventHandler(tmpCameraPtr, EDSDK.PropertyEvent_All, cameraPropertyEventHandler, tmpCameraPtr);
                EDSDK.EdsSetCameraStateEventHandler(tmpCameraPtr, EDSDK.StateEvent_All, this.cameraStateEventHandler, tmpCameraPtr);
            }
        }
Example #6
0
        public bool Init()
        {
            IntPtr camList;
            int    camCount = 0;
            uint   err      = 0;

            //SETUP DELEGATES FOR LATER USE
            objEventHandlerDelegate   = new EDSDK.EdsObjectEventHandler(objEventHandler);
            propEventHandlerDelegate  = new EDSDK.EdsPropertyEventHandler(propEventHandler);
            stateEventHandlerDelegate = new EDSDK.EdsStateEventHandler(stateEventHandler);

            //INIT THE SDK THIS MUST BE CALLED BEFORE ANYTHING ELSE CAN BE DONE
            err = EDSDK.EdsInitializeSDK();
            if (err != EDSDK.EDS_ERR_OK)
            {
                if (errorEvent != null)
                {
                    errorEvent("Failed to init SDK");
                }

                return(false);
            }

            //GET ALL ATTACHED CAMERAS
            err = EDSDK.EdsGetCameraList(out camList);
            if (err != EDSDK.EDS_ERR_OK)
            {
                if (errorEvent != null)
                {
                    errorEvent("Failed to find a camera");
                }

                return(false);
            }

            //GET THE NUMBER OF ATTACHED CAMERAS
            err = EDSDK.EdsGetChildCount(camList, out camCount);
            if (err != EDSDK.EDS_ERR_OK)
            {
                if (errorEvent != null)
                {
                    errorEvent("Failed to get camera count");
                }

                return(false);
            }

            //IF THERE ARE 0 CAMERAS DETECETED THEN THROW AN ERROR
            if (camCount == 0)
            {
                if (errorEvent != null)
                {
                    errorEvent("No cameras found");
                }

                return(false);
            }

            //WE ONLY CARE ABOUT THE FIRST CAMERA WE FIND
            err = EDSDK.EdsGetChildAtIndex(camList, 0, out camObj);
            if (err != EDSDK.EDS_ERR_OK)
            {
                if (errorEvent != null)
                {
                    errorEvent("Failed to retrieve camera object");
                }

                return(false);
            }

            //SET THE EVENT HANDLERS FOR LATER USE
            err = EDSDK.EdsSetObjectEventHandler(camObj, EDSDK.ObjectEvent_All, objEventHandlerDelegate, IntPtr.Zero);
            if (err != EDSDK.EDS_ERR_OK)
            {
                if (errorEvent != null)
                {
                    errorEvent("Failed to set event handler");
                }

                return(false);
            }
            err = EDSDK.EdsSetPropertyEventHandler(camObj, EDSDK.PropertyEvent_All, propEventHandlerDelegate, IntPtr.Zero);
            if (err != EDSDK.EDS_ERR_OK)
            {
                if (errorEvent != null)
                {
                    errorEvent("Failed to set event handler");
                }

                return(false);
            }
            err = EDSDK.EdsSetCameraStateEventHandler(camObj, EDSDK.StateEvent_All, stateEventHandlerDelegate, IntPtr.Zero);
            if (err != EDSDK.EDS_ERR_OK)
            {
                if (errorEvent != null)
                {
                    errorEvent("Failed to set event handler");
                }

                return(false);
            }

            //OPEN THE SESSION TO THE CAMERA
            err = EDSDK.EdsOpenSession(camObj);

            //LET THE CALLING FUNCTION KNOW THIS ALL WORKED
            return(true);
        }
Example #7
0
        public override void GetEquipment()
        {
            Devices.Clear();

            Devices.Add(new Model.DummyDevice(Locale.Loc.Instance["LblNoCamera"]));

            /* ASI */
            try {
                Logger.Trace("Adding ASI Cameras");
                for (int i = 0; i < ASICameras.Count; i++)
                {
                    var cam = ASICameras.GetCamera(i, profileService);
                    if (!string.IsNullOrEmpty(cam.Name))
                    {
                        Logger.Trace(string.Format("Adding {0}", cam.Name));
                        Devices.Add(cam);
                    }
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* Altair */
            try {
                Logger.Trace("Adding Altair Cameras");
                foreach (var instance in Altair.AltairCam.EnumV2())
                {
                    var cam = new AltairCamera(instance, profileService);
                    Devices.Add(cam);
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* Atik */
            try {
                Logger.Trace("Adding Atik Cameras");
                var atikDevices = AtikCameraDll.GetDevicesCount();
                Logger.Trace($"Cameras found: {atikDevices}");
                if (atikDevices > 0)
                {
                    for (int i = 0; i < atikDevices; i++)
                    {
                        var cam = new AtikCamera(i, profileService);
                        Devices.Add(cam);
                    }
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* FLI */
            try {
                Logger.Trace("Adding FLI Cameras");
                List <string> cameras = FLICameras.GetCameras();

                if (cameras.Count > 0)
                {
                    foreach (var entry in cameras)
                    {
                        var camera = new FLICamera(entry, profileService);

                        if (!string.IsNullOrEmpty(camera.Name))
                        {
                            Logger.Debug($"Adding FLI camera {camera.Id} (as {camera.Name})");
                            Devices.Add(camera);
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* QHYCCD */
            try {
                Logger.Trace("Adding QHYCCD Cameras");
                uint numCameras = QHYCameras.Count;

                if (numCameras > 0)
                {
                    for (uint i = 0; i < numCameras; i++)
                    {
                        var cam = QHYCameras.GetCamera(i, profileService);
                        if (!string.IsNullOrEmpty(cam.Name))
                        {
                            Logger.Debug($"Adding QHY camera {i}: {cam.Id} (as {cam.Name})");
                            Devices.Add(cam);
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* ToupTek */
            try {
                Logger.Debug("Adding ToupTek Cameras");
                foreach (var instance in ToupTek.ToupCam.EnumV2())
                {
                    var cam = new ToupTekCamera(instance, profileService);
                    Devices.Add(cam);
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* Omegon */
            try {
                Logger.Debug("Adding Omegon Cameras");
                foreach (var instance in Omegon.Omegonprocam.EnumV2())
                {
                    var cam = new OmegonCamera(instance, profileService);
                    Devices.Add(cam);
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* ASCOM */
            try {
                foreach (ICamera cam in ASCOMInteraction.GetCameras(profileService))
                {
                    Devices.Add(cam);
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* CANON */
            try {
                IntPtr cameraList;
                try {
                    EDSDKLocal.Initialize();
                } catch (Exception ex) {
                    Logger.Error(ex);
                    Utility.Notification.Notification.ShowError(ex.Message);
                }

                uint err = EDSDK.EdsGetCameraList(out cameraList);
                if (err == EDSDK.EDS_ERR_OK)
                {
                    int count;
                    err = EDSDK.EdsGetChildCount(cameraList, out count);

                    for (int i = 0; i < count; i++)
                    {
                        IntPtr cam;
                        err = EDSDK.EdsGetChildAtIndex(cameraList, i, out cam);

                        EDSDK.EdsDeviceInfo info;
                        err = EDSDK.EdsGetDeviceInfo(cam, out info);

                        Logger.Trace(string.Format("Adding {0}", info.szDeviceDescription));
                        Devices.Add(new EDCamera(cam, info, profileService));
                    }
                }
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            /* NIKON */
            try {
                Devices.Add(new NikonCamera(profileService, telescopeMediator));
            } catch (Exception ex) {
                Logger.Error(ex);
            }

            Devices.Add(new Model.MyCamera.FileCamera(profileService, telescopeMediator));
            Devices.Add(new Model.MyCamera.Simulator.SimulatorCamera(profileService, telescopeMediator));

            DetermineSelectedDevice(profileService.ActiveProfile.CameraSettings.Id);
        }