public static void BringUp(TestContext context) { ControlRoom = new ControlRoom(new SimulationWeatherStation(100), 81); // End the CR's listener's server. We have to do this until we stop hard-coding that dang value. // TODO: Remove this logic when the value is no longer hard-coded (issue #350) // PrivateObject listener = new PrivateObject(ControlRoom.mobileControlServer); //((TcpListener)listener.GetFieldOrProperty("server")).Stop(); CRController = new ControlRoomController(ControlRoom); CalibrationOrientation = new Orientation(0, 90); }
public static void BringUp(TestContext context) { ControlRoom = new ControlRoom(new SimulationWeatherStation(100)); CRController = new ControlRoomController(ControlRoom); CalibrationOrientation = new Orientation(0, 90); }
/// <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(); */ } }