示例#1
0
        public cam_settings()
        {
            InitializeComponent();

            //extract gain, offset settings
            if (File.Exists("cam8s_v05.xml"))
            {
                using (Stream stream = new FileStream("cam8s_v05.xml", 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();
                }
            }
        }
示例#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("cam8s_v05.xml", FileMode.Create))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(iniSettings));
                serializer.Serialize(writer, iniSet);
            }
            //Call function from cam8sll5.dll to start exposure
            CameraStartExposure((int)m_BinX, m_StartX, m_StartY, m_NumX, m_NumY, Duration, Light);
            return;
        }
示例#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("cam8s_v05.xml", FileMode.Create))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(iniSettings));
         serializer.Serialize(writer, iniSet);
     }
     //Call function from cam8sll5.dll to start exposure
     CameraStartExposure((int)m_BinX, m_StartX, m_StartY, m_NumX, m_NumY, Duration, Light);
     return;
 }