Example #1
0
        public cam_settings()
        {
            InitializeComponent();

            string arch = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE").ToString();

            if (arch.IndexOf("86") != -1)
            {
                SettingFilePath = Environment.ExpandEnvironmentVariables("%CommonProgramFiles%\\ASCOM\\Camera\\cam8s\\cam8_v05.xml");
            }
            else
            {
                SettingFilePath = Environment.ExpandEnvironmentVariables("%CommonProgramFiles(x86)%\\ASCOM\\Camera\\cam8s\\cam8_v05.xml");
            }

            //extract gain, offset settings
            if (File.Exists(SettingFilePath))
            {
                try
                {
                    using (Stream stream = new FileStream(SettingFilePath, FileMode.Open))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(iniSettings));

                        iniSettings iniSet = (iniSettings)serializer.Deserialize(stream);
                        //check gain/offset validity
                        if ((iniSet.gain < 0) || (iniSet.gain > 63))
                        {
                            iniSet.gain = 0;
                        }
                        if ((iniSet.offset < -127) || (iniSet.offset > 127))
                        {
                            iniSet.offset = 0;
                        }
                        GainTrackBar.Value   = iniSet.gain;
                        OffsetTrackBar.Value = iniSet.offset;
                        GainTextBox.Text     = iniSet.gain.ToString();
                        OffsetTextBox.Text   = iniSet.offset.ToString();
                    }
                }
                catch
                {
                    System.Windows.Forms.MessageBox.Show(SettingFilePath + " damaged, use settings by default.");
                    GainTrackBar.Value   = 34;
                    OffsetTrackBar.Value = -7;
                    GainTextBox.Text     = "34";
                    OffsetTextBox.Text   = "-7";
                }
            }
        }
Example #2
0
        //Camera start exposure
        public void StartExposure(double Duration, bool Light)
        {
            if ((Duration < ExposureMin) || (Duration > ExposureMax))
            {
                throw new ASCOM.InvalidValueException("StartExposure: Invalid Duration");
            }
            //Set LastExposureDuration;
            m_LastExposureDuration = Duration;
            //Set LasExposureStartTime;
            m_LastExposureStartTime = System.DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss");
            //Read & set gain and offset parameters
            m_Gain   = short.Parse(settings_form.GainTextBox.Text);
            m_Offset = short.Parse(settings_form.OffsetTextBox.Text);
            //Set camera settings, if fail - exception
            if (CameraSetGain(m_Gain) == false)
            {
                throw new ASCOM.InvalidOperationException("Cant set gain to cam8");
            }
            if (CameraSetOffset(m_Offset) == false)
            {
                throw new ASCOM.InvalidOperationException("Cant set offset to cam8");
            }
            //save gain, offset settings
            iniSettings iniSet = new iniSettings();

            iniSet.gain   = m_Gain;
            iniSet.offset = m_Offset;
            using (Stream writer = new FileStream(SettingFilePath, FileMode.Create))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(iniSettings));
                serializer.Serialize(writer, iniSet);
            }
            //Call function from cam8sll55.dll to start exposure
            CameraStartExposure((int)m_BinX, m_StartX, m_StartY, m_NumX, m_NumY, Duration, Light);
            return;
        }
Example #3
0
 //Camera start exposure
 public void StartExposure(double Duration, bool Light)
 {
     if ((Duration < ExposureMin) || (Duration > ExposureMax)) throw new ASCOM.InvalidValueException("StartExposure: Invalid Duration");
     //Set LastExposureDuration;
     m_LastExposureDuration = Duration;
     //Set LasExposureStartTime;
     m_LastExposureStartTime = System.DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss");
     //Read & set gain and offset parameters
     m_Gain = short.Parse(settings_form.GainTextBox.Text);
     m_Offset = short.Parse(settings_form.OffsetTextBox.Text);
     //Set camera settings, if fail - exception
     if (CameraSetGain(m_Gain) == false) throw new ASCOM.InvalidOperationException("Cant set gain to cam8");
     if (CameraSetOffset(m_Offset) == false) throw new ASCOM.InvalidOperationException("Cant set offset to cam8");
     //save gain, offset settings
     iniSettings iniSet = new iniSettings();
     iniSet.gain = m_Gain;
     iniSet.offset = m_Offset;
     using (Stream writer = new FileStream(SettingFilePath, FileMode.Create))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(iniSettings));
         serializer.Serialize(writer, iniSet);
     }
     //Call function from cam8sll55.dll to start exposure
     CameraStartExposure((int)m_BinX, m_StartX, m_StartY, m_NumX, m_NumY, Duration, Light);
     return;
 }