Exemplo n.º 1
0
 public void Bringdown()
 {
     // RTC0.RadioTelescope.PLCDriver.Bring_down();
     //  RTC1.RadioTelescope.PLCDriver.Bring_down();
     RTC0 = null;
     RTC1 = null;
     RTCMT0.RequestToKill();
     RTCMT1.RequestToKill();
     RTCMT1  = null;
     RTCMT0  = null;
     PLCCCH0 = null;
     PLCCCH1 = null;
     // PLCCCH0.Bring_down();
     Thread.Sleep(100);
 }
        public void BringUp()
        {
            IP    = PLCConstants.LOCAL_HOST_IP;
            Port0 = 8112;
            Port1 = 8115;

            JohnRudyPark           = MiscellaneousConstants.JOHN_RUDY_PARK;
            CalibrationOrientation = new Orientation(0, 90);

            PLCCCH0 = new SimulationPLCDriver(IP, IP, Port0, Port0, true, false);
            RTC0    = new RadioTelescopeController(new RadioTelescope(new SpectraCyberSimulatorController(new SpectraCyberSimulator()), PLCCCH0, JohnRudyPark, CalibrationOrientation, 1));
            RTCMT0  = new RadioTelescopeControllerManagementThread(RTC0);

            PLCCCH1 = new SimulationPLCDriver(IP, IP, Port1, Port1, true, false);
            RTC1    = new RadioTelescopeController(new RadioTelescope(new SpectraCyberSimulatorController(new SpectraCyberSimulator()), PLCCCH1, JohnRudyPark, CalibrationOrientation, 2));
            RTCMT1  = new RadioTelescopeControllerManagementThread(RTC1);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Eventhandler for the start button on the main GUI form. This method creates and
        /// initializes the configuration that is specified on the main GUI form if the correct
        /// fields are populated.
        /// </summary>
        /// <param name="sender"> Object specifying the sender of this Event. </param>
        /// <param name="e"> The eventargs from the button being clicked on the GUI. </param>
        private void button1_Click(object sender, EventArgs e)
        {
            logger.Info("Start Telescope Button Clicked");
            if (txtPLCPort.Text != null &&
                txtPLCIP.Text != null &&
                comboBox1.SelectedIndex > -1)
            {
                current_rt_id++;
                AbstractPLCDriver       APLCDriver = BuildPLCDriver();
                AbstractMicrocontroller ctrler     = build_CTRL();
                ctrler.BringUp();
                AbstractEncoderReader encoder         = build_encoder(APLCDriver);
                RadioTelescope        ARadioTelescope = BuildRT(APLCDriver, ctrler, encoder);


                // Add the RT/PLC driver pair and the RT controller to their respective lists
                AbstractRTDriverPairList.Add(new KeyValuePair <RadioTelescope, AbstractPLCDriver>(ARadioTelescope, APLCDriver));
                ProgramRTControllerList.Add(new RadioTelescopeController(AbstractRTDriverPairList[current_rt_id - 1].Key));
                ProgramPLCDriverList.Add(APLCDriver);

                if (checkBox1.Checked)
                {
                    logger.Info("Populating Local Database");
                    DatabaseOperations.PopulateLocalDatabase(current_rt_id);
                    Console.WriteLine(DatabaseOperations.GetNextAppointment(current_rt_id).StartTime.ToString());
                    logger.Info("Disabling ManualControl and FreeControl");
                    ManualControl.Enabled = false;
                    FreeControl.Enabled   = false;
                }
                else
                {
                    logger.Info("Enabling ManualControl and FreeControl");
                    ManualControl.Enabled = true;
                    FreeControl.Enabled   = true;
                }

                // If the main control room controller hasn't been initialized, initialize it.
                if (MainControlRoomController == null)
                {
                    logger.Info("Initializing ControlRoomController");
                    MainControlRoomController = new ControlRoomController(new ControlRoom(BuildWeatherStation()));
                }

                // Start plc server and attempt to connect to it.
                logger.Info("Starting plc server and attempting to connect to it");
                ProgramPLCDriverList[current_rt_id - 1].StartAsyncAcceptingClients();
//ProgramRTControllerList[current_rt_id - 1].RadioTelescope.PLCClient.ConnectToServer();//////####################################

                logger.Info("Adding RadioTelescope Controller");
                MainControlRoomController.AddRadioTelescopeController(ProgramRTControllerList[current_rt_id - 1]);

                logger.Info("Starting Weather Monitoring Routine");
                MainControlRoomController.StartWeatherMonitoringRoutine();

                // Start RT controller's threaded management
                logger.Info("Starting RT controller's threaded management");
                RadioTelescopeControllerManagementThread ManagementThread = MainControlRoomController.ControlRoom.RTControllerManagementThreads[current_rt_id - 1];
                int RT_ID = ManagementThread.RadioTelescopeID;
                List <Appointment> AllAppointments = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(RT_ID);

                logger.Info("Attempting to queue " + AllAppointments.Count.ToString() + " appointments for RT with ID " + RT_ID.ToString());
                foreach (Appointment appt in AllAppointments)
                {
                    logger.Info("\t[" + appt.Id + "] " + appt.StartTime.ToString() + " -> " + appt.EndTime.ToString());
                }

                if (ManagementThread.Start())
                {
                    logger.Info("Successfully started RT controller management thread [" + RT_ID.ToString() + "]");

                    if (APLCDriver is ProductionPLCDriver)
                    {
                        ProgramRTControllerList[current_rt_id - 1].ConfigureRadioTelescope(500, 500, 0, 0);
                    }
                }
                else
                {
                    logger.Info("ERROR starting RT controller management thread [" + RT_ID.ToString() + "]");
                }

                AddConfigurationToDataGrid();


                /*
                 * Console.WriteLine("at microtherad start");
                 * MicroctrlServerThread = new Thread(new ThreadStart(ControlRoomApplication.Controllers.BlkHeadUcontroler.MicroControlerControler.AsynchronousSocketListener.BringUp));
                 * MicroctrlServerThread.Start();
                 * //ControlRoomApplication.Controllers.BlkHeadUcontroler.MicroControlerControler.AsynchronousSocketListener.BringUp();
                 */
            }
        }