Exemplo n.º 1
0
        public RadioTelescopeControllerManagementThread(RadioTelescopeController controller)
        {
            RTController = controller;

            ManagementThread = new Thread(new ThreadStart(SpinRoutine))
            {
                Name = "RTControllerManagementThread (ID=" + RadioTelescopeID.ToString() + ")"
            };

            ManagementMutex           = new Mutex();
            KeepThreadAlive           = false;
            _NextObjectiveOrientation = null;
            InterruptAppointmentFlag  = false;

            ActiveOverrides     = new List <Override>();
            Sensors             = new List <Sensor>();
            OverallSensorStatus = true;

            Sensors.Add(new Sensor(SensorItemEnum.WIND, SensorStatusEnum.NORMAL));

            // Commented out because we will not be using this functionality in the future.
            // We will switch to connecting to a server on the cloud
            // Kate Kennelly 2/14/2020
            // TCPListener = new RemoteListener(8090, IPAddress.Parse("10.127.7.112"), controller);
        }
Exemplo n.º 2
0
        private void SpinRoutine()
        {
            bool KeepAlive = KeepThreadAlive;

            while (KeepAlive)
            {
                Appointment NextAppointment = WaitForNextAppointment();

                if (NextAppointment != null)
                {
                    logger.Info("Starting appointment...");

                    // Calibrate telescope
                    if (NextAppointment.Type != AppointmentTypeEnum.FREE_CONTROL)
                    {
                        logger.Info("Calibrating RadioTelescope");
                        RTController.CalibrateRadioTelescope();
                    }

                    // Create movement thread
                    Thread AppointmentMovementThread = new Thread(() => PerformRadioTelescopeMovement(NextAppointment))
                    {
                        Name = "RTControllerIntermediateThread (ID=" + RadioTelescopeID.ToString() + ")"
                    };

                    // Start SpectraCyber
                    StartReadingData(NextAppointment);

                    // Start movement thread
                    AppointmentMovementThread.Start();

                    // End PLC thread & SpectraCyber
                    AppointmentMovementThread.Join();
                    StopReadingRFData();

                    // Stow Telescope
                    EndAppointment();

                    logger.Info("Appointment completed.");
                }
                else
                {
                    if (InterruptAppointmentFlag)
                    {
                        logger.Info("Appointment interrupted in loading routine.");
                        ManagementMutex.WaitOne();
                        InterruptAppointmentFlag = false;
                        ManagementMutex.ReleaseMutex();
                    }

                    logger.Info("Appointment does not have an orientation associated with it.");
                }

                KeepAlive = KeepThreadAlive;

                Thread.Sleep(100);
            }
        }
Exemplo n.º 3
0
        public RadioTelescopeControllerManagementThread(RadioTelescopeController controller)
        {
            RTController = controller;

            ManagementThread = new Thread(new ThreadStart(SpinRoutine))
            {
                Name = "RTControllerManagementThread (ID=" + RadioTelescopeID.ToString() + ")"
            };

            ManagementMutex           = new Mutex();
            KeepThreadAlive           = false;
            _NextObjectiveOrientation = null;
            InterruptAppointmentFlag  = false;
        }
Exemplo n.º 4
0
        private void SpinRoutine()
        {
            bool KeepAlive = KeepThreadAlive;

            while (KeepAlive)
            {
                NextAppointment = WaitForNextAppointment();

                //Compares the ID of each appointment to see if they have changed
                if (NextAppointment != null && NextAppointment.Equals(OldAppointment))
                {
                    logger.Info(Utilities.GetTimeStamp() + ": Waiting for next Appointment");
                }


                if (NextAppointment != null)
                {
                    logger.Info(Utilities.GetTimeStamp() + ": Starting appointment...");
                    endAppt = false;

                    // Calibrate telescope
                    if (NextAppointment._Type != AppointmentTypeEnum.FREE_CONTROL)
                    {
                        logger.Info(Utilities.GetTimeStamp() + ": Thermal Calibrating RadioTelescope");
                        RTController.ThermalCalibrateRadioTelescope(MovementPriority.Appointment);

                        // If the temperature is low and there's precipitation, dump the dish
                        if (RTController.RadioTelescope.WeatherStation.GetOutsideTemp() <= 40.00 && RTController.RadioTelescope.WeatherStation.GetTotalRain() > 0.00)
                        {
                            RTController.SnowDump(MovementPriority.Appointment);
                        }
                    }

                    // Create movement thread
                    Thread AppointmentMovementThread = new Thread(() => PerformRadioTelescopeMovement(NextAppointment))
                    {
                        Name = "RTControllerIntermediateThread (ID=" + RadioTelescopeID.ToString() + ")"
                    };

                    // Start SpectraCyber if the next appointment is NOT an appointment created by the control form
                    // This is to allow for greater control of the spectra cyber output from the control form
                    if (NextAppointment._Type != AppointmentTypeEnum.FREE_CONTROL)
                    {
                        StartReadingData(NextAppointment);
                    }

                    // Start movement thread
                    AppointmentMovementThread.Start();

                    if (NextAppointment._Type != AppointmentTypeEnum.FREE_CONTROL)
                    {
                        // End PLC thread & SpectraCyber
                        AppointmentMovementThread.Join();
                        StopReadingRFData();
                        // Stow Telescope
                        EndAppointment();
                    }
                    else
                    {
                        while (endAppt == false)
                        {
                            ;
                        }
                    }

                    logger.Info(Utilities.GetTimeStamp() + ": Appointment completed.");
                }
                else
                {
                    if (InterruptAppointmentFlag)
                    {
                        logger.Info(Utilities.GetTimeStamp() + ": Appointment interrupted in loading routine.");
                        ManagementMutex.WaitOne();
                        InterruptAppointmentFlag = false;
                        ManagementMutex.ReleaseMutex();
                    }

                    if (NextAppointment != null && NextAppointment.Equals(OldAppointment))
                    {
                        logger.Info(Utilities.GetTimeStamp() + ": Appointment does not have an orientation associated with it.");
                    }
                }

                KeepAlive = KeepThreadAlive;

                OldAppointment = NextAppointment;

                Thread.Sleep(100);
            }
        }