Exemple #1
0
        /// <summary>
        // If we haven't checked in a long enough time (10 minutes ?!?)
        //  get temperature and pressure.
        /// </summary>
        public void prepareRefractionData(bool calculateRefraction)
        {
            const int freqOCFetchMinutes = 10;

            initOCH();

            if (!calculateRefraction)
            {
                refractionOption = RefractionOption.NoRefraction;
                return;
            }
            DateTime now   = DateTime.Now;
            int      month = now.Month - 1;

            onSurface.Temperature = averageTemperatures[month];
            onSurface.Pressure    = averagePressures[month];

            if (och != null && now.Subtract(lastOCFetch).TotalMinutes > freqOCFetchMinutes)
            {
                try
                {
                    double timeSinceLastUpdate = och.TimeSinceLastUpdate("Temperature");

                    if (timeSinceLastUpdate > (freqOCFetchMinutes * 60))
                    {
                        onSurface.Temperature = och.Temperature;
                        onSurface.Pressure    = och.Pressure;
                        refractionOption      = RefractionOption.LocationRefraction;
                        lastOCFetch           = now;
                    }
                }
                catch { }
            }
        }
Exemple #2
0
        private void RefreshWeather()
        {
            if (groupBoxWeather.Visible)
            {
                try
                {
                    ObservingConditions oc = wisesite.observingConditions;

                    groupBoxWeather.Text = string.Format(" {0} v{1} ", oc.Name, oc.DriverVersion);
                    labelAgeValue.Text   = ((int)Math.Round(oc.TimeSinceLastUpdate(""), 2)).ToString() + "sec";

                    double d = oc.CloudCover;
                    if (d == 0.0)
                    {
                        labelCloudCoverValue.Text = "Clear";
                    }
                    else if (d == 50.0)
                    {
                        labelCloudCoverValue.Text = "Cloudy";
                    }
                    else if (d == 90.0)
                    {
                        labelCloudCoverValue.Text = "VeryCloudy";
                    }
                    else
                    {
                        labelCloudCoverValue.Text = "Unknown";
                    }

                    labelDewPointValue.Text  = oc.DewPoint.ToString() + "°C";
                    labelSkyTempValue.Text   = oc.SkyTemperature.ToString() + "°C";
                    labelTempValue.Text      = oc.Temperature.ToString() + "°C";
                    labelHumidityValue.Text  = oc.Humidity.ToString() + "%";
                    labelPressureValue.Text  = oc.Pressure.ToString() + "mB";
                    labelRainRateValue.Text  = (oc.RainRate > 0.0) ? "Wet" : "Dry";
                    labelWindSpeedValue.Text = oc.WindSpeed.ToString() + "m/s";
                    labelWindDirValue.Text   = oc.WindDirection.ToString() + "°";
                }
                catch (ASCOM.PropertyNotImplementedException e)
                {
                    debugger.WriteLine(Debugger.DebugLevel.DebugLogic, "OC: exception: {0}", e.Message);
                }
            }
        }
        public void RefreshDisplay()
        {
            //if (!panelControls.Visible)
            //    return;

            DateTime now = DateTime.Now;
            DateTime utc = now.ToUniversalTime();

            ASCOM.Utilities.Util u = new Utilities.Util();

            labelDate.Text          = utc.ToLongDateString();
            labelLTValue.Text       = now.TimeOfDay.ToString(@"hh\hmm\mss\.f\s");
            labelUTValue.Text       = utc.TimeOfDay.ToString(@"hh\hmm\mss\.f\s");
            labelSiderealValue.Text = wisesite.LocalSiderealTime.ToString();

            labelRightAscensionValue.Text = Angle.FromHours(wisetele.RightAscension).ToNiceString();
            labelDeclinationValue.Text    = Angle.FromDegrees(wisetele.Declination).ToNiceString();
            labelHourAngleValue.Text      = Angle.FromHours(wisetele.HourAngle, Angle.Type.HA).ToNiceString();

            labelNewRA.Text         = "";
            labelNewRARadians.Text  = Angle.FromHours(wisetele.RightAscension).Radians.ToString();
            labelNewDec.Text        = "";
            labelNewDecRadians.Text = Angle.FromDegrees(wisetele.Declination).Radians.ToString();

            labelAltitudeValue.Text = Angle.FromDegrees(wisetele.Altitude).ToNiceString();
            labelAzimuthValue.Text  = Angle.FromDegrees(wisetele.Azimuth).ToNiceString();

            labelHAEncValue.Text  = wisetele.HAEncoder.Value.ToString();
            labelDecEncValue.Text = wisetele.DecEncoder.Value.ToString();

            axisValue.Text = wisetele.HAEncoder.AxisValue.ToString();
            wormValue.Text = wisetele.HAEncoder.WormValue.ToString();

            string why;

            if (wisesite.computerControl == null)
            {
                labelTelescopeComputerControl.ForeColor = Color.Yellow;
                why = "Cannot read the computer control switch!";
            }
            else if (wisesite.computerControl.IsSafe)
            {
                labelTelescopeComputerControl.ForeColor = Color.Green;
                why = "Computer control is enabled.";
            }
            else
            {
                labelTelescopeComputerControl.ForeColor = Color.Red;
                why = why = "Computer control switch is OFF!";
            }
            toolTip.SetToolTip(labelTelescopeComputerControl, why);

            if (wisesite.safeToOpen == null)
            {
                labelTelescopeSafeToOpen.ForeColor = Color.Yellow;
                why = "Cannot connect to the safeToOpen driver!";
            }
            else if (wisesite.safeToOpen.IsSafe)
            {
                labelTelescopeSafeToOpen.ForeColor = Color.Green;
                why = "Conditions are safe to open the dome.";
            }
            else
            {
                labelTelescopeSafeToOpen.ForeColor = Color.Red;
                why = wisesite.safeToOpen.CommandString("unsafeReasons", false);
            }
            toolTip.SetToolTip(labelTelescopeSafeToOpen, why);

            if (wisesite.safeToImage == null)
            {
                labelTelescopeSafeToImage.ForeColor = Color.Yellow;
                why = "Cannot connect to the safeToImage driver!";
            }
            else if (wisesite.safeToImage.IsSafe)
            {
                labelTelescopeSafeToImage.ForeColor = Color.Green;
                why = "Conditions are safe to image.";
            }
            else
            {
                labelTelescopeSafeToImage.ForeColor = Color.Red;
                why = wisesite.safeToImage.CommandString("unsafeReasons", false);
            }
            toolTip.SetToolTip(labelTelescopeSafeToImage, why);

            checkBoxPrimaryIsActive.Checked   = wisetele.AxisIsMoving(TelescopeAxes.axisPrimary);
            checkBoxSecondaryIsActive.Checked = wisetele.AxisIsMoving(TelescopeAxes.axisSecondary);
            string activeSlewers = wisetele.slewers.ToString();

            checkBoxSlewingIsActive.Text     = (activeSlewers == string.Empty) ? "Slewing" : "Slewing (" + activeSlewers + ")";
            checkBoxSlewingIsActive.Checked  = wisetele.Slewing;
            checkBoxTrackingIsActive.Checked = wisetele.Tracking;

            WiseVirtualMotor m;

            m = null;
            if (wisetele.WestMotor.isOn)
            {
                m = wisetele.WestMotor;
            }
            else if (wisetele.EastMotor.isOn)
            {
                m = wisetele.EastMotor;
            }

            checkBoxPrimaryIsActive.Text = "Primary";
            if (m != null)
            {
                checkBoxPrimaryIsActive.Text += ": " + m.Name.Remove(m.Name.IndexOf('M')) + "@" +
                                                WiseTele.RateName(m.currentRate).Replace("rate", "");
            }

            m = null;
            if (wisetele.NorthMotor.isOn)
            {
                m = wisetele.NorthMotor;
            }
            else if (wisetele.SouthMotor.isOn)
            {
                m = wisetele.SouthMotor;
            }


            checkBoxSecondaryIsActive.Text = "Secondary";
            if (m != null)
            {
                checkBoxSecondaryIsActive.Text += ": " + m.Name.Remove(m.Name.IndexOf('M')) + "@" +
                                                  WiseTele.RateName(m.currentRate).Replace("rate", "");
            }

            checkBoxTrack.Checked = wisetele.Tracking;

            if (scopeBackgroundMover != null && scopeBackgroundMover.IsBusy)
            {
                TextBoxLog.Text = "Working ...";
            }

            if (resultsAvailable)
            {
                TextBoxLog.Clear();
                if (results.Count == 0)
                {
                    TextBoxLog.Text = "Cancelled by user!";
                }
                else
                {
                    TelescopeAxes axis = results[0].axis;

                    for (int i = 0; i < results.Count; i++)
                    {
                        TextBoxLog.Text += string.Format("[{0}]: ({2})\r\n{1}",
                                                         i, results[i].ToString(), results[i].cancelled ? "cancelled" : "completed");
                    }
                }
                resultsAvailable = false;
            }

            if (panelDome.Visible)
            {
                labelDomeAzimuthValue.Text       = domeSlaveDriver.Azimuth;
                labelDomeStatusValue.Text        = domeSlaveDriver.Status;
                labelDomeShutterStatusValue.Text = domeSlaveDriver.ShutterStatus;
                checkBoxVent.Checked             = WiseDome.Instance.Vent;
            }

            if (groupBoxWeather.Visible)
            {
                if (!wisesite.observingConditions.Connected)
                {
                    string nc = "???";

                    labelAgeValue.Text        = nc;
                    labelCloudCoverValue.Text = nc;
                    labelCloudCoverValue.Text = nc;
                    labelDewPointValue.Text   = nc;
                    labelSkyTempValue.Text    = nc;
                    labelTempValue.Text       = nc;
                    labelHumidityValue.Text   = nc;
                    labelPressureValue.Text   = nc;
                    labelRainRateValue.Text   = nc;
                    labelWindSpeedValue.Text  = nc;
                    labelWindDirValue.Text    = nc;
                }
                else
                {
                    try
                    {
                        ObservingConditions oc = wisesite.observingConditions;

                        labelAgeValue.Text = ((int)Math.Round(oc.TimeSinceLastUpdate(""), 2)).ToString() + "sec";

                        double d = oc.CloudCover;
                        if (d == 0.0)
                        {
                            labelCloudCoverValue.Text = "Clear";
                        }
                        else if (d == 50.0)
                        {
                            labelCloudCoverValue.Text = "Cloudy";
                        }
                        else if (d == 90.0)
                        {
                            labelCloudCoverValue.Text = "VeryCloudy";
                        }
                        else
                        {
                            labelCloudCoverValue.Text = "Unknown";
                        }

                        labelDewPointValue.Text  = oc.DewPoint.ToString() + "°C";
                        labelSkyTempValue.Text   = oc.SkyTemperature.ToString() + "°C";
                        labelTempValue.Text      = oc.Temperature.ToString() + "°C";
                        labelHumidityValue.Text  = oc.Humidity.ToString() + "%";
                        labelPressureValue.Text  = oc.Pressure.ToString() + "mB";
                        labelRainRateValue.Text  = (oc.RainRate > 0.0) ? "Wet" : "Dry";
                        labelWindSpeedValue.Text = oc.WindSpeed.ToString() + "m/s";
                        labelWindDirValue.Text   = oc.WindDirection.ToString() + "°";
                    }
                    catch (PropertyNotImplementedException e)
                    {
                        debugger.WriteLine(Debugger.DebugLevel.DebugLogic, "OC: exception: {0}", e.Message);
                    }
                }
            }

            if (panelFocuser.Visible)
            {
                labelFocusCurrentValue.Text = wisefocuser.position.ToString();;
            }
        }