コード例 #1
0
        private void OnVideoState(VideoState state)
        {
            m_CurrentVideoState = state;

            if (NativeHelpers.CurrentCameraExposure != state.Exposure)
            {
                NativeHelpers.CurrentCameraExposure = state.Exposure;
                Trace.Write(string.Format("NativeHelpers.CurrentCameraExposure = {0}", NativeHelpers.CurrentCameraExposure));
            }

            try
            {
                float newGain = float.Parse(REGEX_FLOATING_POINT_VALUE.Match(state.Gain).Groups["Num"].Value.Trim());
                if (Math.Abs(newGain - NativeHelpers.CurrentCameraGain) > 0.01)
                {
                    NativeHelpers.CurrentCameraGain = newGain;
                    Trace.Write(string.Format("NativeHelpers.CurrentCameraGain = {0}", NativeHelpers.CurrentCameraGain));
                }
            }
            catch (Exception ex)
            {
                Trace.Write(string.Format("Cannot convert '{0}' into float gain: {1}", state.Gain, ex.GetFullStackTrace()));
            }

            try
            {
                float newGamma = 0;

                if (state.Gamma == "OFF") newGamma = 1.000f;
                else if (state.Gamma.StartsWith("LO")) newGamma = 0.45f;
                else if (state.Gamma.StartsWith("HI")) newGamma = 0.35f;
                else
                    newGamma = float.Parse(REGEX_FLOATING_POINT_VALUE.Match(state.Gamma).Groups["Num"].Value.Trim());

                if (Math.Abs(newGamma - NativeHelpers.CurrentCameraGamma) > 0.01)
                {
                    NativeHelpers.CurrentCameraGamma = newGamma;
                    Trace.Write(string.Format("NativeHelpers.CurrentCameraGamma = {0}", NativeHelpers.CurrentCameraGamma));
                }
            }
            catch (Exception ex)
            {
                Trace.Write(string.Format("Cannot convert '{0}' into float gamma: {1}", state.Gamma, ex.GetFullStackTrace()));
            }

            EventHelper.RaiseEvent(VideoStateUpdated, state);
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: hpavlov/occurec
 void VideoConnectionChanged(ASCOMConnectionState state)
 {
     RefreshASCOMStatusControls(state, tssCameraControl);
     if (state == ASCOMConnectionState.Connected || state == ASCOMConnectionState.Ready)
     {
         tsbCamControl.Text = "Control Camera";
         tsbCamControl.Enabled = true;
     }
     else if (state == ASCOMConnectionState.Disconnected || state == ASCOMConnectionState.Engaged)
     {
         tsbCamControl.Text = "Connect to Camera";
         tsbCamControl.Enabled = true;
         m_LastVideoCameraState = null;
     }
     else
     {
         tsbCamControl.Enabled = false;
     }
 }
コード例 #3
0
ファイル: frmMain.cs プロジェクト: hpavlov/occurec
        void VideoStateUpdated(VideoState state)
        {
            m_LastVideoCameraState = state;
            UpdateConnectedDevicesState();

            #if DEBUG
            Trace.WriteLine(state.AsSerialized().OuterXml);
            #endif
        }
コード例 #4
0
        public VideoState GetCurrentState(CameraStateQuery query)
        {
            var rv = new VideoState();

            if (m_Driver != null && m_Driver.IsConnected)
            {
                rv.MinGainIndex = m_Driver.MinGainIndex;
                rv.MaxGainIndex = m_Driver.MaxGainIndex;
                rv.MinGammaIndex = m_Driver.MinGammaIndex;
                rv.MaxGammaIndex = m_Driver.MaxGammaIndex;
                rv.MinExposureIndex = m_Driver.MinExposureIndex;
                rv.MaxExposureIndex = m_Driver.MaxExposureIndex;

                if (m_CurrentState == null)
                {
                    m_CurrentState = new WAT910BDCameraState();
                    query = CameraStateQuery.All;
                }

                WAT910BDCameraState camState = m_Driver.ReadCurrentCameraState(query);
                if ((query & CameraStateQuery.Gamma) == CameraStateQuery.Gamma)
                {
                    m_CurrentState.GammaIndex = camState.GammaIndex;
                    m_CurrentState.Gamma = camState.Gamma;
                    m_CurrentState.GammaSuccess = camState.GammaSuccess;
                }
                if ((query & CameraStateQuery.Gain) == CameraStateQuery.Gain)
                {
                    m_CurrentState.GainIndex = camState.GainIndex;
                    m_CurrentState.Gain = camState.Gain;
                    m_CurrentState.GainSuccess = camState.GainSuccess;
                }
                if ((query & CameraStateQuery.Shutter) == CameraStateQuery.Shutter)
                {
                    m_CurrentState.ExposureIndex = camState.ExposureIndex;
                    m_CurrentState.Exposure = camState.Exposure;
                    m_CurrentState.ExposureSuccess = camState.ExposureSuccess;
                }

                rv.GainIndex = m_CurrentState.GainIndex;
                rv.GammaIndex = m_CurrentState.GammaIndex;
                rv.ExposureIndex = m_CurrentState.ExposureIndex;

                rv.Gain = m_CurrentState.Gain;
                rv.Gamma = m_CurrentState.Gamma;
                rv.Exposure = m_CurrentState.Exposure;
            }

            return rv;
        }