예제 #1
0
        public HardwareForm(DriverAccess.Telescope tele)
        {
            InitializeComponent();

            _tele = tele;

            HardwareMetaDigest meta = JsonConvert.DeserializeObject <HardwareMetaDigest>(
                _tele.Action("hardware-meta-digest", ""));

            BoardControls = new List <BoardControl>();

            foreach (BoardMetaDigest mb in meta.Boards)
            {
                BoardControls.Add(new BoardControl(mb, this));
            }
        }
예제 #2
0
        public void timerHardwareRefresh_Tick(object sender, EventArgs e)
        {
            HardwareDigest hw = JsonConvert.DeserializeObject <HardwareDigest>(_tele.Action("hardware-digest", ""));

            for (int b = 0; b < BoardControls.Count; b++)
            {
                for (int d = 0; d < BoardControls[b].DaqControls.Count; d++)
                {
                    ushort val = hw.Boards[b].Daqs[d].Value;

                    for (int bit = 0; bit < BoardControls[b].DaqControls[d].nbits; bit++)
                    {
                        if (BoardControls[b].DaqControls[d].cbs[bit] != null)
                        {
                            BoardControls[b].DaqControls[d].cbs[bit].Checked = ((val & (1 << bit)) == 0) ? false : true;
                        }
                    }
                }
            }
        }
예제 #3
0
        private void CheckSituation()
        {
            if (ShuttingDown)
            {
                return;
            }

            #region GetStatus
            try
            {
                UpdateCheckingStatus("telescope status");
                telescopeDigest = JsonConvert.DeserializeObject <TelescopeDigest>(wisetelescope.Action("status", ""));

                UpdateCheckingStatus("safetooperate status");
                safetooperateDigest = JsonConvert.DeserializeObject <SafeToOperateDigest>(wisesafetooperate.Action("status", ""));
            } catch (Exception ex)
            {
                UpdateCheckingStatus("");
                Log(string.Format("CheckSituation:Exception: {0}", ex.InnerException == null ? ex.Message : ex.InnerException.Message));
                return;
            }
            #endregion

            #region UpdateDisplay

            UpdateConditionsBypassToolStripMenuItem(safetooperateDigest.Bypassed);

            #region ComputerControlLabel
            if (safetooperateDigest.ComputerControlIsSafe)
            {
                labelComputerControl.Text      = "Operational";
                labelComputerControl.ForeColor = safeColor;
                toolTip.SetToolTip(labelComputerControl, "Computer Control is ON");
            }
            else
            {
                labelComputerControl.Text      = "Maintenance";
                labelComputerControl.ForeColor = unsafeColor;
                toolTip.SetToolTip(labelComputerControl, "Computer Control is OFF");
            }
            #endregion

            #region ActivityLabel
            if (telescopeDigest.Active)
            {
                labelActivity.Text      = "Active";
                labelActivity.ForeColor = safeColor;
                toolTip.SetToolTip(labelActivity, string.Join(",", telescopeDigest.Activities));
            }
            else
            {
                labelActivity.Text      = "Idle";
                labelActivity.ForeColor = unsafeColor;
                toolTip.SetToolTip(labelActivity, "");
            }
            #endregion

            UpdateProjectorControls();
            #endregion

            #region DecideIfShutdownIsNeeded
            List <string> reasonsList = new List <string>();

            if (!safetooperateDigest.Safe)
            {
                reasonsList.Add(string.Join(Const.recordSeparator, safetooperateDigest.UnsafeReasons));
            }

            if (!telescopeDigest.Active)
            {
                reasonsList.Add("Telescope is Idle");
            }

            if (reasonsList.Count != 0)
            {
                #region ShouldShutdown
                string shutdownReason = String.Join(" and ", reasonsList);

                if (telescopeDigest.ShuttingDown)
                {
                    Log("Wise40 already shutting down");
                }
                else if (ObservatoryIsLogicallyParked && ObservatoryIsPhysicallyParked)
                {
                    Log("Wise40 already parked.");
                }
                else
                {
                    if (!safetooperateDigest.ComputerControlIsSafe)
                    {
                        Log("No ComputerControl, shutdown skipped.");
                    }
                    else
                    {
                        DoShutdownObservatory(shutdownReason);
                    }
                }
                #endregion
            }
            else
            {
                #region NoNeedToShutdown
                string safetyMessage = "", activityMessage = "";

                if (safetooperateDigest.Safe)
                {
                    safetyMessage = "Safe";
                    if (safetooperateDigest.Bypassed)
                    {
                        safetyMessage += " (due to safety bypass)";
                    }
                }
                else
                {
                    safetyMessage = "Not safe";
                    if (safetooperateDigest.UnsafeBecauseNotReady)
                    {
                        safetyMessage += " (inconclusive safety info)";
                    }
                    else if (!safetooperateDigest.HumanInterventionIsSafe)
                    {
                        safetyMessage += " (intervention)";
                    }
                }

                if (telescopeDigest.Active)
                {
                    activityMessage = "active (" + string.Join(", ", telescopeDigest.Activities) + ")";
                }
                else
                {
                    activityMessage = "idle";
                }

                Log(safetyMessage + " and " + activityMessage);
                #endregion
            }
            #endregion
        }