Exemplo n.º 1
0
        public void TestAddAndRetrieveRadioTelescope()
        {
            RadioTelescope telescope = new RadioTelescope();

            // not saved in the database
            telescope.SpectraCyberController = new SpectraCyberController(new SpectraCyber());
            telescope.PLCDriver = new TestPLCDriver(PLCConstants.LOCAL_HOST_IP, PLCConstants.LOCAL_HOST_IP, 8089, 8089, false);

            // saved in the database
            telescope.online                 = 1;
            telescope.CurrentOrientation     = new Orientation(25, 25);
            telescope.CalibrationOrientation = new Orientation(30, 30);
            telescope.Location               = new Location(1, 2, 3, "test");
            telescope._TeleType              = RadioTelescopeTypeEnum.SLIP_RING;

            DatabaseOperations.AddRadioTelescope(telescope);

            RadioTelescope retrievedTele = DatabaseOperations.FetchLastRadioTelescope();
            RadioTelescope teleByID      = DatabaseOperations.FetchRadioTelescopeByID(retrievedTele.Id);


            // online
            Assert.IsTrue(telescope.online == retrievedTele.online);

            // type
            Assert.IsTrue(telescope.teleType == retrievedTele.teleType);

            // location
            Assert.IsTrue(telescope.Location.Latitude == retrievedTele.Location.Latitude);
            Assert.IsTrue(telescope.Location.Longitude == retrievedTele.Location.Longitude);
            Assert.IsTrue(telescope.Location.Altitude == retrievedTele.Location.Altitude);
            Assert.IsTrue(telescope.Location.Name == retrievedTele.Location.Name);

            // current orientation (not yet implemented)
            Assert.IsTrue(telescope.CurrentOrientation.Azimuth == retrievedTele.CurrentOrientation.Azimuth);
            Assert.IsTrue(telescope.CurrentOrientation.Elevation == retrievedTele.CurrentOrientation.Elevation);

            // calibration orientation (not yet implemented)
            Assert.IsTrue(telescope.CalibrationOrientation.Azimuth == retrievedTele.CalibrationOrientation.Azimuth);
            Assert.IsTrue(telescope.CalibrationOrientation.Elevation == retrievedTele.CalibrationOrientation.Elevation);

            // test FetchByID
            // we will never have this many telescopes, just ensuring null operation performed correctly
            Assert.IsTrue(DatabaseOperations.FetchRadioTelescopeByID(32323232) == null);

            Assert.IsFalse(teleByID == null);
            Assert.IsFalse(teleByID.Location == null);
            Assert.IsFalse(teleByID.CalibrationOrientation == null);
            Assert.IsFalse(teleByID.CurrentOrientation == null);
            Assert.IsTrue(teleByID.Id == retrievedTele.Id);
            Assert.IsTrue(teleByID.Location.Latitude == retrievedTele.Location.Latitude);
            Assert.IsTrue(teleByID.Location.Longitude == retrievedTele.Location.Longitude);
            Assert.IsTrue(teleByID.Location.Altitude == retrievedTele.Location.Altitude);
            Assert.IsTrue(teleByID.Location.Name == retrievedTele.Location.Name);
            Assert.IsTrue(teleByID.CurrentOrientation.Azimuth == retrievedTele.CurrentOrientation.Azimuth);
            Assert.IsTrue(teleByID.CurrentOrientation.Elevation == retrievedTele.CurrentOrientation.Elevation);
            Assert.IsTrue(teleByID.CalibrationOrientation.Azimuth == retrievedTele.CalibrationOrientation.Azimuth);
            Assert.IsTrue(teleByID.CalibrationOrientation.Elevation == retrievedTele.CalibrationOrientation.Elevation);
        }
        public void TestUpdateTelescope()
        {
            RadioTelescope telescope = new RadioTelescope();

            // saved in the database
            telescope.online                 = 0;
            telescope.CurrentOrientation     = new Orientation(0, 0);
            telescope.CalibrationOrientation = new Orientation(0, 0);
            telescope.Location               = new Location(0, 0, 0, "");
            telescope._TeleType              = RadioTelescopeTypeEnum.NONE;
            telescope.maxElevationDegrees    = MiscellaneousConstants.MAX_SOFTWARE_STOP_EL_DEGREES;
            telescope.minElevationDegrees    = MiscellaneousConstants.MIN_SOFTWARE_STOP_EL_DEGREES;
            DatabaseOperations.AddRadioTelescope(telescope);
            RadioTelescope retrievedTele = DatabaseOperations.FetchLastRadioTelescope();


            // not saved in the database
            telescope.SpectraCyberController = new SpectraCyberController(new SpectraCyber());
            telescope.PLCDriver = new TestPLCDriver(PLCConstants.LOCAL_HOST_IP, PLCConstants.LOCAL_HOST_IP, 8089, 8089, false);

            // saved in the database
            telescope.Id                     = retrievedTele.Id;
            telescope.online                 = 1;
            telescope.CurrentOrientation     = new Orientation(25, 25);
            telescope.CalibrationOrientation = new Orientation(30, 30);
            telescope.Location               = new Location(1, 2, 3, "test");
            telescope._TeleType              = RadioTelescopeTypeEnum.SLIP_RING;
            telescope.maxElevationDegrees    = 90;
            telescope.minElevationDegrees    = 0;

            DatabaseOperations.UpdateTelescope(telescope);

            retrievedTele = DatabaseOperations.FetchLastRadioTelescope();

            // online
            Assert.IsTrue(telescope.online == retrievedTele.online);

            // type
            Assert.IsTrue(telescope.teleType == retrievedTele.teleType);

            // location
            Assert.IsTrue(telescope.Location.Latitude == retrievedTele.Location.Latitude);
            Assert.IsTrue(telescope.Location.Longitude == retrievedTele.Location.Longitude);
            Assert.IsTrue(telescope.Location.Altitude == retrievedTele.Location.Altitude);
            Assert.IsTrue(telescope.Location.Name == retrievedTele.Location.Name);

            // current orientation (not yet implemented)
            Assert.IsTrue(telescope.CurrentOrientation.Azimuth == retrievedTele.CurrentOrientation.Azimuth);
            Assert.IsTrue(telescope.CurrentOrientation.Elevation == retrievedTele.CurrentOrientation.Elevation);

            // calibration orientation (not yet implemented)
            Assert.IsTrue(telescope.CalibrationOrientation.Azimuth == retrievedTele.CalibrationOrientation.Azimuth);
            Assert.IsTrue(telescope.CalibrationOrientation.Elevation == retrievedTele.CalibrationOrientation.Elevation);

            // elevation thresholds
            Assert.IsTrue(telescope.maxElevationDegrees == retrievedTele.maxElevationDegrees);
            Assert.IsTrue(telescope.minElevationDegrees == retrievedTele.minElevationDegrees);
        }
Exemplo n.º 3
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++;
        }