public FreeControlForm(ControlRoom new_controlRoom, int new_rtId)
        {
            InitializeComponent();
            // Set ControlRoom
            controlRoom = new_controlRoom;
            // Set RT id
            rtId = new_rtId;
            // Make coordCalc
            CoordCalc = controlRoom.RadioTelescopeControllers[rtId - 1].CoordinateController;
            // Set increment
            Increment = 1;
            UpdateIncrementButtons();
            // Add free control appt
            CurrentAppointment                    = new Appointment();
            CurrentAppointment.StartTime          = DateTime.UtcNow.AddSeconds(5);
            CurrentAppointment.EndTime            = DateTime.UtcNow.AddMinutes(15);
            CurrentAppointment.Status             = AppointmentStatusEnum.REQUESTED;
            CurrentAppointment.Type               = AppointmentTypeEnum.FREE_CONTROL;
            CurrentAppointment.SpectraCyberConfig = new SpectraCyberConfig(SpectraCyberModeTypeEnum.CONTINUUM);
            CurrentAppointment.TelescopeId        = rtId;
            CurrentAppointment.UserId             = 1;
            DatabaseOperations.AddAppointment(CurrentAppointment);
            //Calibrate Move
            CalibrateMove();

            logger.Info("FreeControl Form Initalized");
        }
Beispiel #2
0
        public void BuildUp()
        {
            NumAppointments = DatabaseOperations.GetTotalAppointmentCount();
            NumRTInstances  = DatabaseOperations.GetTotalRTCount();
            NumRFData       = DatabaseOperations.GetTotalRFDataCount();

            appt            = new Appointment();
            appt.start_time = DateTime.UtcNow;
            appt.end_time   = DateTime.UtcNow.AddMinutes(1);
            appt._Status    = AppointmentStatusEnum.IN_PROGRESS;
            appt._Priority  = AppointmentPriorityEnum.MANUAL;
            appt._Type      = AppointmentTypeEnum.FREE_CONTROL;
            appt.Coordinates.Add(new Coordinate(0, 0));
            appt.CelestialBody            = new CelestialBody();
            appt.CelestialBody.Coordinate = new Coordinate();
            appt.Orientation         = new Orientation();
            appt.SpectraCyberConfig  = new SpectraCyberConfig(SpectraCyberModeTypeEnum.CONTINUUM);
            appt.Telescope           = new RadioTelescope(new SpectraCyberController(new SpectraCyber()), new TestPLCDriver(PLCConstants.LOCAL_HOST_IP, PLCConstants.LOCAL_HOST_IP, 8089, 8089, false), new Location(), new Orientation());
            appt.Telescope._TeleType = RadioTelescopeTypeEnum.SLIP_RING;
            appt.User = DatabaseOperations.GetControlRoomUser();

            DatabaseOperations.AddRadioTelescope(appt.Telescope);
            DatabaseOperations.AddAppointment(appt);

            // RFData initialization
            data1 = new RFData();
            data2 = new RFData();
            data3 = new RFData();
            data4 = new RFData();
            DateTime now  = DateTime.UtcNow;
            DateTime date = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);

            Appointment RFappt = appt;

            data1.Intensity    = 9234875;
            data1.TimeCaptured = date;
            data1.Appointment  = RFappt;

            data2.Intensity    = 8739425;
            data2.TimeCaptured = date.AddSeconds(3);
            data2.Appointment  = RFappt;

            data3.Intensity    = 12987;
            data3.TimeCaptured = date.AddSeconds(4);
            data3.Appointment  = RFappt;

            data4.Intensity    = 12987;
            data4.TimeCaptured = date.AddSeconds(5);
            data4.Appointment  = RFappt;

            NumAppointments++;
            NumRTInstances++;
        }
Beispiel #3
0
        public void TestAddAppointment()
        {
            var new_appt = new Appointment();

            new_appt.start_time = DateTime.UtcNow;
            new_appt.end_time   = DateTime.UtcNow.AddMinutes(1);
            new_appt._Status    = AppointmentStatusEnum.REQUESTED;
            new_appt._Priority  = AppointmentPriorityEnum.MANUAL;
            new_appt._Type      = AppointmentTypeEnum.POINT;
            new_appt.Coordinates.Add(new Coordinate(15, 15));
            new_appt.CelestialBody            = new CelestialBody();
            new_appt.CelestialBody.Coordinate = new Coordinate();
            new_appt.Orientation        = new Orientation();
            new_appt.SpectraCyberConfig = new SpectraCyberConfig(SpectraCyberModeTypeEnum.CONTINUUM);
            new_appt.Telescope          = appt.Telescope;
            new_appt.User = DatabaseOperations.GetControlRoomUser();

            //new_appt.Telescope.type = appt.Telescope.type;

            //DatabaseOperations.AddRadioTelescope(new_appt.Telescope);
            DatabaseOperations.AddAppointment(new_appt);

            var output_appts = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(new_appt.Telescope.Id);

            Assert.IsTrue(2 == output_appts.Count()); // Should be two appointments retrieved

            //Assert.AreEqual(new_appt.start_time.ToString(), output_appts[0].start_time.ToString());
            //Assert.AreEqual(new_appt.end_time.ToString(), output_appts[0].end_time.ToString());
            Assert.AreEqual(new_appt._Status, output_appts[1]._Status);
            Assert.AreEqual(new_appt._Priority, output_appts[1]._Priority);
            Assert.AreEqual(new_appt._Type, output_appts[1]._Type);

            // Coordinates
            Assert.AreEqual(new_appt.Id, output_appts[1].Coordinates.First().apptId);
            Assert.AreEqual(new_appt.Coordinates.First().hours, output_appts[1].Coordinates.First().hours);
            Assert.AreEqual(new_appt.Coordinates.First().minutes, output_appts[1].Coordinates.First().minutes);
            Assert.AreEqual(new_appt.Coordinates.First().Declination, output_appts[1].Coordinates.First().Declination);
            Assert.AreEqual(new_appt.Coordinates.First().RightAscension, output_appts[1].Coordinates.First().RightAscension);

            // Other entities that Appointment uses
            Assert.AreEqual(new_appt.celestial_body_id, output_appts[1].celestial_body_id);
            Assert.AreEqual(new_appt.orientation_id, output_appts[1].orientation_id);
            Assert.AreEqual(new_appt.spectracyber_config_id, output_appts[1].spectracyber_config_id);
            Assert.AreEqual(new_appt.telescope_id, output_appts[1].telescope_id);
            Assert.AreEqual(new_appt.user_id, output_appts[1].user_id);
        }
        public void TestAddAppointment()
        {
            var new_appt = new Appointment();

            new_appt.StartTime = DateTime.UtcNow;
            new_appt.EndTime   = DateTime.UtcNow.AddMinutes(1);
            new_appt.Status    = AppointmentStatusEnum.REQUESTED;
            new_appt.Type      = AppointmentTypeEnum.POINT;
            new_appt.Coordinates.Add(new Coordinate(0, 0));
            new_appt.SpectraCyberConfig = new SpectraCyberConfig(SpectraCyberModeTypeEnum.CONTINUUM);
            new_appt.TelescopeId        = 1;
            new_appt.UserId             = 1;

            DatabaseOperations.AddAppointment(new_appt);
            var output_appts = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(1);

            Assert.IsTrue(1 == output_appts.Where(x => x.Id == new_appt.Id).Count());
        }
Beispiel #5
0
        public void TestGetFreeControlOrientation()
        {
            DateTime date = new DateTime(2018, 10, 30, 12, 0, 0);

            // Test free control appointment
            Appointment free_control_appt = new Appointment();

            free_control_appt.Type   = AppointmentTypeEnum.FREE_CONTROL;
            free_control_appt.Status = AppointmentStatusEnum.REQUESTED;
            Orientation test_orientation = new Orientation(30, 30);

            free_control_appt.Orientation = test_orientation;
            DatabaseOperations.AddAppointment(free_control_appt);

            // Test free control calibration
            var free_control_orientation_1 = CoordinateCalculationController.CalculateOrientation(free_control_appt, date);

            free_control_appt = DatabaseOperations.GetUpdatedAppointment(free_control_appt.Id);
            Assert.IsTrue(free_control_orientation_1.Elevation == test_orientation.Elevation);
            Assert.IsTrue(free_control_orientation_1.Azimuth == test_orientation.Azimuth);
            Assert.IsTrue(free_control_appt.Orientation == null);

            // Test free control move
            free_control_appt.Coordinates.Add(new Coordinate(0, 0));
            DatabaseOperations.UpdateAppointment(free_control_appt);
            var free_control_orientation_2 = CoordinateCalculationController.CalculateOrientation(free_control_appt, date);

            free_control_appt = DatabaseOperations.GetUpdatedAppointment(free_control_appt.Id);
            Assert.AreEqual(-37.14, free_control_orientation_2.Elevation, 0.05);
            Assert.AreEqual(309.5, free_control_orientation_2.Azimuth, 0.05);
            Assert.IsTrue(free_control_appt.Coordinates.Count == 0);

            // Test free control move without coords
            var free_control_orientation_3 = CoordinateCalculationController.CalculateOrientation(free_control_appt, date);

            free_control_appt = DatabaseOperations.GetUpdatedAppointment(free_control_appt.Id);
            Assert.IsTrue(free_control_orientation_3 == null);
            Assert.IsTrue(free_control_appt.Coordinates.Count == 0);
        }
Beispiel #6
0
        public void TestCalculateOrientation()
        {
            DateTime start = new DateTime(2018, 10, 30, 12, 0, 0);
            DateTime end   = new DateTime(2018, 10, 30, 13, 0, 0);

            // Test point appointment
            Appointment point_appt = new Appointment();

            point_appt.Type      = AppointmentTypeEnum.POINT;
            point_appt.Status    = AppointmentStatusEnum.REQUESTED;
            point_appt.StartTime = start;
            point_appt.EndTime   = end;
            point_appt.Coordinates.Add(new Coordinate(0, 0));
            var point_orientation = CoordinateCalculationController.CalculateOrientation(point_appt, start);

            Assert.IsTrue(point_orientation != null);

            // Test celesital body appointment
            Appointment sun_appt = new Appointment();

            sun_appt.Type          = AppointmentTypeEnum.CELESTIAL_BODY;
            sun_appt.Status        = AppointmentStatusEnum.REQUESTED;
            sun_appt.StartTime     = start;
            sun_appt.EndTime       = end;
            sun_appt.CelestialBody = new CelestialBody(CelestialBodyConstants.SUN);
            var sun_orientation = CoordinateCalculationController.CalculateOrientation(sun_appt, start);

            Assert.IsTrue(sun_orientation != null);

            // Test raster appointment
            Appointment raster_appt = new Appointment();

            raster_appt.Type      = AppointmentTypeEnum.RASTER;
            raster_appt.Status    = AppointmentStatusEnum.REQUESTED;
            raster_appt.StartTime = start;
            raster_appt.EndTime   = end;
            raster_appt.Coordinates.Add(new Coordinate(0, 0));
            raster_appt.Coordinates.Add(new Coordinate(5, 5));
            var raster_orientation = CoordinateCalculationController.CalculateOrientation(raster_appt, start);

            Assert.IsTrue(raster_orientation != null);

            // Test drift scan appointment
            Appointment drift_scan_appt = new Appointment();

            drift_scan_appt.Type        = AppointmentTypeEnum.DRIFT_SCAN;
            drift_scan_appt.Status      = AppointmentStatusEnum.REQUESTED;
            drift_scan_appt.StartTime   = start;
            drift_scan_appt.EndTime     = end;
            drift_scan_appt.Orientation = new Orientation(30, 30);
            var orientation_orientation = CoordinateCalculationController.CalculateOrientation(drift_scan_appt, start);

            Assert.IsTrue(orientation_orientation != null);

            // Test free control appointment
            Appointment free_control_appt = new Appointment();

            free_control_appt.Type        = AppointmentTypeEnum.FREE_CONTROL;
            free_control_appt.Status      = AppointmentStatusEnum.REQUESTED;
            free_control_appt.StartTime   = start;
            free_control_appt.EndTime     = end;
            free_control_appt.Orientation = new Orientation(30, 30);
            DatabaseOperations.AddAppointment(free_control_appt);
            var free_control_orientation_1 = CoordinateCalculationController.CalculateOrientation(free_control_appt, start);

            free_control_appt = DatabaseOperations.GetUpdatedAppointment(free_control_appt.Id);
            Assert.IsTrue(free_control_orientation_1 != null);
            Assert.IsTrue(free_control_appt.Orientation == null);

            free_control_appt.Coordinates.Add(new Coordinate(0, 0));
            DatabaseOperations.UpdateAppointment(free_control_appt);
            var free_control_orientation_2 = CoordinateCalculationController.CalculateOrientation(free_control_appt, end);

            free_control_appt = DatabaseOperations.GetUpdatedAppointment(free_control_appt.Id);
            Assert.IsTrue(free_control_orientation_2 != null);
            Assert.IsTrue(free_control_appt.Coordinates.Count == 0);
        }
Beispiel #7
0
        public FreeControlForm(ControlRoom new_controlRoom, int new_rtId, RTControlFormData controlFormData)
        {
            InitializeComponent();
            // Set ControlRoom
            controlRoom = new_controlRoom;
            // Set RT id
            rtId = new_rtId;
            // Make coordCalc
            rtController = controlRoom.RadioTelescopeControllers.Find(x => x.RadioTelescope.Id == rtId);
            CoordCalc    = rtController.CoordinateController;
            // Set increment
            Increment = 1;
            UpdateIncrementButtons();

            // set form data object
            formData       = controlFormData;
            formData.speed = 1;

            // set form data
            controlScriptsCombo.SelectedIndex = formData.controlScriptIndex;
            scanTypeComboBox.SelectedIndex    = formData.spectraCyberScanIndex;
            frequency.Text       = formData.frequency;
            DCGain.SelectedIndex = formData.DCGainIndex;
            integrationStepCombo.SelectedIndex = formData.integrationStepIndex;
            speedTextBox.Text             = formData.speed.ToString();
            offsetVoltage.Text            = formData.offsetVoltage;
            IFGainVal.Text                = formData.IFGain;
            immediateRadioButton.Checked  = formData.immediateStopBool;
            ControlledButtonRadio.Checked = formData.controlledStopBool;
            manual_save_state             = formData.manualControlEnabled;
            save_state = formData.freeControlEnabled;

            ControlRoomUser = DatabaseOperations.GetControlRoomUser();

            // Add free control appt
            CurrentAppointment                          = new Appointment();
            CurrentAppointment.start_time               = DateTime.UtcNow.AddSeconds(5);
            CurrentAppointment.end_time                 = DateTime.UtcNow.AddMinutes(15);
            CurrentAppointment._Status                  = AppointmentStatusEnum.REQUESTED;
            CurrentAppointment._Type                    = AppointmentTypeEnum.FREE_CONTROL;
            CurrentAppointment._Priority                = AppointmentPriorityEnum.MANUAL;
            CurrentAppointment.SpectraCyberConfig       = new SpectraCyberConfig(SpectraCyberModeTypeEnum.SPECTRAL);
            CurrentAppointment.CelestialBody            = new CelestialBody();
            CurrentAppointment.CelestialBody.Coordinate = new Coordinate(0, 0);

            CurrentAppointment.Orientation = rtController.GetCurrentOrientation();
            CurrentAppointment.Telescope   = controlRoom.RadioTelescopes.Find(x => x.Id == rtId);
            CurrentAppointment.User        = ControlRoomUser;

            rtController.RadioTelescope.SpectraCyberController.Schedule.Mode = SpectraCyberScanScheduleMode.OFF;

            DatabaseOperations.AddAppointment(CurrentAppointment);

            //Calibrate Move
            CalibrateMove();
            runControlScriptButton.Enabled = false;

            //Initialize Free control Box based on manual control
            if (!save_state)
            {
                editButton.Text = "Edit Position";
                if (manual_save_state)
                {
                    editButton.BackColor          = System.Drawing.Color.DarkGray;
                    freeControlGroupbox.BackColor = System.Drawing.Color.DarkGray;
                    editButton.Enabled            = false;
                }
                else
                {
                    editButton.BackColor          = System.Drawing.Color.Red;
                    freeControlGroupbox.BackColor = System.Drawing.Color.DarkGray;
                    editButton.Enabled            = true;
                }

                decIncGroupbox.BackColor = System.Drawing.Color.DarkGray;
                RAIncGroupbox.BackColor  = System.Drawing.Color.DarkGray;
            }
            else
            {
                editButton.Text               = "Save Position";
                editButton.BackColor          = System.Drawing.Color.LimeGreen;
                freeControlGroupbox.BackColor = System.Drawing.Color.Gainsboro;
                decIncGroupbox.BackColor      = System.Drawing.Color.Gray;
                RAIncGroupbox.BackColor       = System.Drawing.Color.Gray;
                manualControlButton.Enabled   = !formData.freeControlEnabled;
                manualControlButton.BackColor = System.Drawing.Color.DarkGray;
            }
            PosDecButton.Enabled      = formData.freeControlEnabled;
            NegDecButton.Enabled      = formData.freeControlEnabled;
            PosRAButton.Enabled       = formData.freeControlEnabled;
            NegRAButton.Enabled       = formData.freeControlEnabled;
            oneForthButton.Enabled    = formData.freeControlEnabled;
            oneForthButtonDec.Enabled = formData.freeControlEnabled;
            oneButton.Enabled         = formData.freeControlEnabled;
            oneButtonDec.Enabled      = formData.freeControlEnabled;
            fiveButton.Enabled        = formData.freeControlEnabled;
            fiveButtonDec.Enabled     = formData.freeControlEnabled;
            tenButton.Enabled         = formData.freeControlEnabled;
            tenButtonDec.Enabled      = formData.freeControlEnabled;

            //Initialize Manual control Box based on previous data (false by default)
            if (!manual_save_state)
            {
                manualControlButton.Text = "Activate Manual Control";
                // if free control is active, this button will be disabled. Gray it out if so
                if (save_state)
                {
                    manualControlButton.BackColor = System.Drawing.Color.DarkGray;
                    manualControlButton.Enabled   = false;
                }
                else
                {
                    manualControlButton.BackColor = System.Drawing.Color.Red;
                    manualControlButton.Enabled   = true;
                }
                manualGroupBox.BackColor = System.Drawing.Color.DarkGray;
            }
            else if (manual_save_state)
            {
                manualControlButton.Text      = "Deactivate Manual Control";
                manualControlButton.BackColor = System.Drawing.Color.LimeGreen;
                manualGroupBox.BackColor      = System.Drawing.Color.Gainsboro;
            }
            plusElaButton.Enabled         = formData.manualControlEnabled;
            cwAzJogButton.Enabled         = formData.manualControlEnabled;
            ccwAzJogButton.Enabled        = formData.manualControlEnabled;
            subElaButton.Enabled          = formData.manualControlEnabled;
            ControlledButtonRadio.Enabled = formData.manualControlEnabled;
            immediateRadioButton.Enabled  = formData.manualControlEnabled;
            speedTextBox.Enabled          = formData.manualControlEnabled;
            speedTrackBar.Enabled         = formData.manualControlEnabled;
            speedTrackBar.Value           = 10;


            //Initialize Start and Stop Scan buttons as disabled
            spectraEditActive         = true;
            startScanButton.BackColor = System.Drawing.Color.DarkGray;
            startScanButton.Enabled   = false;
            stopScanButton.BackColor  = System.Drawing.Color.DarkGray;
            stopScanButton.Enabled    = false;

            // finalize settings should be based on values in scan combo box
            finalizeSettingsButton.Enabled = allScanInputsValid();

            this.FormClosing += FreeControlForm_Closing;

            logger.Info(Utilities.GetTimeStamp() + ": Radio Telescope Control Form Initalized");
        }