Пример #1
0
        static void Main(string[] args)
        {
            // Uncomment the code that's required
#if UseChooser
            // choose the device
            string id = ASCOM.DriverAccess.Camera.Choose("");
            if (string.IsNullOrEmpty(id))
                return;
            // create this device
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera(id);
#else
            // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera("ASCOM.test.Camera");
#endif
            // now run some tests, adding code to your driver so that the tests will pass.
            // these first tests are common to all drivers.
            Console.WriteLine("name " + device.Name);
            Console.WriteLine("description " + device.Description);
            Console.WriteLine("DriverInfo " + device.DriverInfo);
            Console.WriteLine("driverVersion " + device.DriverVersion);

            // TODO add more code to test the driver.
            device.Connected = true;


            device.Connected = false;
            Console.WriteLine("Press Enter to finish");
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            // Uncomment the code that's required
#if UseChooser
            // choose the device
            string id = ASCOM.DriverAccess.Camera.Choose("");
            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            // create this device
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera(id);
#else
            // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera("ASCOM.test.Camera");
#endif
            // now run some tests, adding code to your driver so that the tests will pass.
            // these first tests are common to all drivers.
            Console.WriteLine("name " + device.Name);
            Console.WriteLine("description " + device.Description);
            Console.WriteLine("DriverInfo " + device.DriverInfo);
            Console.WriteLine("driverVersion " + device.DriverVersion);

            // TODO add more code to test the driver.
            device.Connected = true;


            device.Connected = false;
            Console.WriteLine("Press Enter to finish");
            Console.ReadLine();
        }
Пример #3
0
        private void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                // cleanup managed resources (none to cleanup for now)
            }

            // Clean up the tracelogger and util objects
            if (m_mount != null)
            {
                SharedResources.DisconnectMount();
                m_mount  = null;
                m_camera = null;
            }

            SharedResources.PutTraceLogger();
            tl = null;

            utilities.Dispose();
            utilities = null;
            astroUtilities.Dispose();
            astroUtilities = null;
            transform.Dispose();
            transform = null;

            disposed = true;
        }
Пример #4
0
 private static void ConnectCameraInner()
 {
     s_camera.Connected = true;
     try
     {
         if (!s_camera.CanPulseGuide)
         {
             throw new ASCOM.DriverException("The selected camera does not support pulse guiding");
         }
     }
     catch (Exception)
     {
         try
         {
             s_camera.Connected = false;
         }
         catch (Exception)
         {
             // ignore
         }
         s_camera.Dispose();
         s_camera = null;
         throw;
     }
 }
Пример #5
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            if (IsConnected)
            {
                driver.Connected     = false;
                btnTakeImage.Enabled = false;
            }
            else
            {
                driver               = new ASCOM.DriverAccess.Camera(Properties.Settings.Default.DriverId);
                driver.Connected     = true;
                btnTakeImage.Enabled = true;
            }

            if (ApiContainer.DslrCamera.IsLiveViewMode && IsConnected)
            {
                btnTakeImage.Text  = "Live View";
                chkPreview.Checked = true;
            }
            else
            {
                btnTakeImage.Text  = "Take Image";
                chkPreview.Checked = false;
            }



            SetUIState();
        }
Пример #6
0
        private static void InstantiateCamera()
        {
            string cameraDriverId = GetCamDriverId();

            if (cameraDriverId.Length == 0)
            {
                throw new InvalidOperationException("Missing camera selection");
            }
            s_camera = new ASCOM.DriverAccess.Camera(cameraDriverId);
        }
Пример #7
0
        static void Main(string[] args)
        {
            // Uncomment the code that's required
#if UseChooser
            // choose the device
            string id = ASCOM.DriverAccess.Camera.Choose("");
            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            // create this device
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera(id);
#else
            // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
            ASCOM.DriverAccess.Camera device = new ASCOM.DriverAccess.Camera("ASCOM.SonyMirrorless.Camera");
#endif

            device.Connected = true;
            device.SetupDialog();
            // now run some tests, adding code to your driver so that the tests will pass.
            // these first tests are common to all drivers.
            Console.WriteLine("name " + device.Name);
            Console.WriteLine("description " + device.Description);
            Console.WriteLine("DriverInfo " + device.DriverInfo);
            Console.WriteLine("driverVersion " + device.DriverVersion);
            //            Console.WriteLine("sensorName " + device.SensorName);

            // TODO add more code to test the driver.
            int count = 0;

            ArrayList modes = device.ReadoutModes;

            device.FastReadout = true;

            Console.WriteLine(device.Gain);
            device.Gain = 10;
            Console.WriteLine(device.Gains.ToString());

/*            while (true)
 *          {
 *              device.StartExposure(0.1, true);
 *
 *              for (int i = 0; i < 100 && !device.ImageReady; i++)
 *                  Thread.Sleep(250);
 *
 *              object o = device.ImageArray;
 *              count++;
 *              Console.WriteLine("Got an image #" + count.ToString());
 *              GC.Collect();
 *          }
 */
            device.Connected = false;
            Console.WriteLine("Press Enter to finish");
            Console.ReadLine();
        }
Пример #8
0
 public static void FreeCamera()
 {
     lock (lockObject)
     {
         Debug.Assert(CamUseCnt == 0);
         if (s_camera != null)
         {
             s_camera.Dispose();
             s_camera = null;
         }
     }
 }
Пример #9
0
 private void buttonConnect_Click(object sender, EventArgs e)
 {
     if (IsConnected)
     {
         driver.Connected = false;
     }
     else
     {
         driver           = new ASCOM.DriverAccess.Camera(Properties.Settings.Default.DriverId);
         driver.Connected = true;
     }
     SetUIState();
 }
Пример #10
0
        public OperationResult Disconnect(Session session)
        {
            if (_camera.CanSetCCDTemperature)
            {
                _camera.CoolerOn = false;
            }

            _camera.Connected = false;
            _camera.Dispose();
            _camera = null;

            session.Camera.DisconnectCamera();
            session.Cooler.SetAvailable(false);

            return(OperationResult.Ok);
        }
Пример #11
0
        public static ASCOM.DriverAccess.Telescope ConnectMount(out ASCOM.DriverAccess.Camera outCam)
        {
            bool updateForm = false;

            lock (lockObject)
            {
                if (s_mount == null)
                {
                    InstantiateMount();
                }

                if (s_camera == null)
                {
                    InstantiateCamera();
                }

                if (MountUseCnt == 0)
                {
                    ConnectMountInner();
                    try
                    {
                        if (s_cam_connections == 0)
                        {
                            ConnectCameraInner();
                        }
                    }
                    catch (Exception)
                    {
                        DisconnectMountInner();
                        throw;
                    }
                    updateForm = true;
                }

                ++s_mount_connections;
            }

            if (updateForm)
            {
                Server.MainForm.UpdateState();
            }

            outCam = s_camera;
            return(s_mount);
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TCamera"/> class.
        /// Must be public for COM registration.
        /// </summary>
        public SSCamera(string DriverID, byte DriverType)
        {
            MyDriverType = DriverType;
            if (MyDriverType == 0)
            {
                MySSCamera = new ASCOM.DriverAccess.Camera(DriverID);
            }
            else
            {
                tl = new TraceLogger("", "TCamera");
                //ReadProfile(); // Read device configuration from the ASCOM Profile store

                tl.LogMessage("Camera", "Starting initialisation");

                connectedState = false;            // Initialise connected to false
                utilities      = new Util();       //Initialise util object
                astroUtilities = new AstroUtils(); // Initialise astro utilities object
                //TODO: Implement your additional construction here

                tl.LogMessage("Camera", "Completed initialisation");
            }
        }
Пример #13
0
        private void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                // free managed resources here
            }

            if (m_camera != null)
            {
                SharedResources.DisconnectCamera();
                m_camera = null;
            }

            SharedResources.PutTraceLogger();
            tl = null;

            disposed = true;
        }
Пример #14
0
        public OperationResult Connect(Session session)
        {
            var cameraId = session.Camera.Camera.Id;

            _coolerPowerAvailable = null;

            try
            {
                session.Camera.IsConnecting = true;

                try
                {
                    _camera = new ASCOM.DriverAccess.Camera(cameraId);

                    _camera.Connected = true;
                }
                catch (Exception ex)
                {
                    return(new OperationResult {
                        IsError = true, ErrorMessage = ex.Message
                    });
                }

                session.Camera.ConnectCamera();
                session.Camera.ChangeUnbinnedSize(_camera.CameraXSize, _camera.CameraYSize);

                session.Camera.SetMaxADU(_camera.MaxADU);
                session.Camera.SetExposureOptions(_camera.ExposureMin, _camera.ExposureMax, _camera.ExposureResolution);

                if (_camera.CanAsymmetricBin)
                {
                    var x = new List <string>();

                    for (var i = 1; i <= _camera.MaxBinX; i++)
                    {
                        x.Add(i.ToString());
                    }

                    var y = new List <string>();

                    for (var i = 1; i <= _camera.MaxBinY; i++)
                    {
                        y.Add(i.ToString());
                    }

                    session.SetAsymmetricBins(x, y);

                    session.Camera.ChangeBinX(_camera.BinX);
                    session.Camera.ChangeBinY(_camera.BinY);
                }
                else
                {
                    var bin = new List <string>();

                    for (var i = 1; i <= _camera.MaxBinY; i++)
                    {
                        bin.Add($"{i}x{i}");
                    }

                    session.SetSymmetricBins(bin);

                    session.Camera.ChangeBinXY(_camera.BinX);
                }

                try
                {
                    if (_camera.Gains.Count > 0)
                    {
                        session.SetGainSettings(false, 0, 0);

                        var gainOptions = _camera.Gains
                                          .ToArray()
                                          .Select(x => new GainOption {
                            Index = session.Camera.Gains.Count, Value = (string)x
                        })
                                          .ToList();

                        session.SetGainOptions(gainOptions);
                        session.Camera.ChangeGainMode(_camera.Gain);
                    }
                }
                catch (PropertyNotImplementedException) // happens when the camera does not support specific gain settings
                {
                    session.SetGainSettings(true, _camera.GainMin, _camera.GainMax);
                }

                session.Cooler.SetAvailable(_camera.CanSetCCDTemperature);

                if (_camera.CanSetCCDTemperature)
                {
                    session.Cooler.TargetTemperature = _camera.SetCCDTemperature;
                }

                session.Camera.SubFrameX      = _camera.StartX;
                session.Camera.SubFrameY      = _camera.StartY;
                session.Camera.SubFrameWidth  = _camera.NumX;
                session.Camera.SubFrameHeight = _camera.NumY;
            }
            finally
            {
                session.Camera.IsConnecting = false;
            }

            return(OperationResult.Ok);
        }