예제 #1
0
 public RadioTelescope(AbstractSpectraCyberController spectraCyberController, AbstractPLCDriver plcCommsHandler, Location location, Orientation calibrationOrientation)
 {
     PLCDriver = plcCommsHandler;
     SpectraCyberController = spectraCyberController;
     CalibrationOrientation = calibrationOrientation;
     Location           = location;
     CurrentOrientation = new Orientation();
 }
예제 #2
0
 /// <summary>
 /// start a simulated encoder and driver, the simulator runs a tcp server,
 ///the simulator uses the PLC as its source of position information,
 /// and the driver is an instance of a production encoder reader to comunicate with it
 /// </summary>
 /// <param name="plc"></param>
 /// <param name="micro_ctrl_IP"></param>
 /// <param name="port"></param>
 public SimulatedEncoder(AbstractPLCDriver plc, string micro_ctrl_IP, int port) : base(plc, micro_ctrl_IP, port)
 {
     keepalive          = true;
     driver             = new EncoderReader(micro_ctrl_IP, port);
     this.plc           = plc;
     this.micro_ctrl_IP = micro_ctrl_IP;
     this.port          = port;
     new Thread(new ThreadStart(run_simulation)).Start();
 }
예제 #3
0
 public RadioTelescope(AbstractSpectraCyberController spectraCyberController, AbstractPLCDriver plcCommsHandler, Location location, Orientation calibrationOrientation)
 {
     PLCDriver = plcCommsHandler;
     SpectraCyberController = spectraCyberController;
     CalibrationOrientation = calibrationOrientation;
     Location            = location;
     CurrentOrientation  = new Orientation();
     maxElevationDegrees = MiscellaneousConstants.MAX_SOFTWARE_STOP_EL_DEGREES;
     minElevationDegrees = MiscellaneousConstants.MIN_SOFTWARE_STOP_EL_DEGREES;
 }
예제 #4
0
 public RadioTelescope(AbstractSpectraCyberController spectraCyberController, AbstractPLCDriver plcCommsHandler, Location location, Orientation calibrationOrientation, int localDBID, AbstractMicrocontroller ctrler, AbstractEncoderReader encoder)
 {
     PLCDriver = plcCommsHandler;
     SpectraCyberController = spectraCyberController;
     CalibrationOrientation = calibrationOrientation;
     Location           = location;
     CurrentOrientation = new Orientation();
     Encoders           = encoder;
     Micro_controler    = ctrler;
     Id = localDBID;
 }
예제 #5
0
        /// <summary>
        /// Builds a radio telescope instance based off of the input from the GUI form.
        /// </summary>
        /// <returns> A radio telescope instance representing the configuration chosen. </returns>
        public RadioTelescope BuildRT(AbstractPLCDriver abstractPLCDriver, AbstractMicrocontroller ctrler, AbstractEncoderReader encoder)
        {
            logger.Info("Building RadioTelescope");

            // PLCClientCommunicationHandler PLCCommsHandler = new PLCClientCommunicationHandler(txtPLCIP.Text, int.Parse(txtPLCPort.Text));///###############################

            // Create Radio Telescope Location
            Location location = MiscellaneousConstants.JOHN_RUDY_PARK;

            // Return Radio Telescope
            RadioTelescope rt = new RadioTelescope(BuildSpectraCyber(), abstractPLCDriver, location, new Entities.Orientation(0, 90), current_rt_id, ctrler, encoder);

            logger.Info("RadioTelescope Built Successfully");
            return(rt);
        }
예제 #6
0
 public ClientWorking(TcpClient Client, AbstractPLCDriver plc)
 {
     PCL          = plc;
     this.Client  = Client;
     ClientStream = Client.GetStream();
 }
예제 #7
0
 public AbstractEncoderReader build_encoder(AbstractPLCDriver plc)
 {
     return(new SimulatedEncoder(plc, LocalIPCombo.Text, 1602));
 }
예제 #8
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();
                 */
            }
        }
예제 #9
0
 //
 // This is only to be used with a local DB instance!!
 //
 public RadioTelescope(AbstractSpectraCyberController spectraCyberController, AbstractPLCDriver plcCommsHandler, Location location, Orientation calibrationOrientation, int localDBID)
     : this(spectraCyberController, plcCommsHandler, location, calibrationOrientation)
 {
     Id = localDBID;
 }
예제 #10
0
 /// <summary>
 /// this should only be used for the simulator
 /// </summary>
 /// <param name="plc"></param>
 public AbstractEncoderReader(AbstractPLCDriver plc, string micro_ctrl_IP, int port)
 {
 }