private RFData AddToRFDataDatabase(SpectraCyberResponse spectraCyberResponse, Appointment appt)
        {
            RFData rfData = RFData.GenerateFrom(spectraCyberResponse);

            appt = DatabaseOperations.GetUpdatedAppointment(appt);
            rfData.Appointment = appt;
            rfData.Intensity   = rfData.Intensity * MiscellaneousHardwareConstants.SPECTRACYBER_VOLTS_PER_STEP;

            // Add to database
            DatabaseOperations.AddRFData(rfData);

            configVals.rfData = rfData.Intensity;

            if (configVals.spectraCyberMode == SpectraCyberModeTypeEnum.SPECTRAL)
            {
                if (configVals.bandscan > configVals.frequency / 2)
                {
                    configVals.bandscan = -1 * (configVals.frequency / 2);
                }
                else
                {
                    configVals.bandscan = configVals.bandscan + MiscellaneousHardwareConstants.SPECTRACYBER_BANDWIDTH_STEP;
                }
            }
            else if (configVals.spectraCyberMode == SpectraCyberModeTypeEnum.CONTINUUM)
            {
                configVals.scanTime = configVals.scanTime + configVals.integrationStep;
            }

            return(rfData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add RF Data to the grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ReceivedRFOut(object sender, EventArgs e)
        {
            RFData rf     = ((RFData)e);
            string output = rf.ToString();

            lock (lockme)
            {
                // Have we seen this one before?
                DataGridViewRow row = FindRowHash(rf.HashKey);

                if (row == null)
                {
                    DataGridViewRow newrow = new DataGridViewRow();
                    int             rowID  = dataGridView1.Rows.Add(newrow);
                    row = dataGridView1.Rows[rowID];
                    row.Cells["Key"].Value = rf.HashKey;
                }

                foreach (var field in rf.Fields)
                {
                    if (false == dataGridView1.Columns.Contains(field.Key))
                    {
                        dataGridView1.Columns.Add(field.Key, field.Key);
                    }

                    row.Cells[field.Key].Value = field.Value;
                }
            }
        }
Exemplo n.º 3
0
        public void TestSendingEmailWithAttachment()
        {
            string testpath = $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@".\PushNotificationTestResults\test-out-{System.DateTime.Now.ToString("yyyyMMddHHmmss")}")}";

            string sender  = "*****@*****.**";
            string subject = "Amazon SES Test WITH ATTACHMENT";
            string body    = "AmazonSES Test (.NET) with Attachment\r\nThis email and its attachment were sent through AmazonSES using the AWS SDK for .NET.";

            // If you want to actually get emails while testing, change the email address below to whatever one you want to receive at.
            // This was already done earlier.
            User fakeUser = new User("Test", "User", "*****@*****.**", NotificationTypeEnum.ALL);

            // Gather dummy data
            RFData junkdata = new RFData();

            junkdata.Id             = 0;
            junkdata.appointment_id = 0;
            junkdata.TimeCaptured   = System.DateTime.Now;
            junkdata.Intensity      = 8675309;

            List <RFData> JunkRFData = new List <RFData>();

            JunkRFData.Add(junkdata);

            DataToCSV.ExportToCSV(JunkRFData, testpath);

            // Execute task
            Task <bool> task = EmailNotifications.sendToUser(fakeUser, subject, body, sender, $"{testpath}.csv", true);

            // Wait for main task to finish before assertion
            task.Wait();

            Assert.IsTrue(task.Result);
        }
        private static RFData GenerateRFData(SpectraCyberResponse spectraCyberResponse)
        {
            RFData rfData = new RFData();

            rfData.TimeCaptured = spectraCyberResponse.DateTimeCaptured;
            rfData.Intensity    = spectraCyberResponse.DecimalData;
            return(rfData);
        }
Exemplo n.º 5
0
        private RFData AddToRFDataDatabase(SpectraCyberResponse spectraCyberResponse, int appId)
        {
            RFData rfData = RFData.GenerateFrom(spectraCyberResponse);

            //
            // Add to database
            //
            DatabaseOperations.CreateRFData(appId, rfData);

            return(rfData);
        }
Exemplo n.º 6
0
        public void TestCreateRFData_InvalidDate()
        {
            data3.TimeCaptured = DateTime.UtcNow.AddDays(1);

            DatabaseOperations.AddRFData(data3);

            List <RFData> datas = DatabaseOperations.GetListOfRFData();

            RFData testData = appt.RFDatas.ToList().Find(x => x.Id == data3.Id);

            Assert.AreEqual(null, datas.Find(t => t.Id == data3.Id));
        }
Exemplo n.º 7
0
        public void TestCreateRFData_InvalidIntensity()
        {
            data4.Intensity = -239458;

            DatabaseOperations.AddRFData(data4);

            List <RFData> datas = DatabaseOperations.GetListOfRFData();

            RFData testData = appt.RFDatas.ToList().Find(x => x.Id == data4.Id);

            Assert.AreEqual(null, datas.Find(t => t.Id == data4.Id));
        }
 /// <summary>
 /// Creates and stores and RFData reading in the local database.
 /// </summary>
 /// <param name="data">The RFData reading to be created/stored.</param>
 public static void CreateRFData(int apptId, RFData data)
 {
     if (VerifyRFData(data))
     {
         using (RTDbContext Context = InitializeDatabaseContext())
         {
             var appt = Context.Appointments.Find(apptId);
             appt.RFDatas.Add(data);
             SaveContext(Context);
         }
     }
 }
Exemplo n.º 9
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++;
        }
        /// <summary>
        /// Verifies that the RFData being created/stored in the database has an
        /// intensity greater than 0 and that the time it was captured is not in
        /// the future for any reason. (1 minute into the future to allow leeway
        /// for processing time).
        /// </summary>
        /// <param name="data"> The RFData that is being created/stored. </param>
        /// <returns> A boolean indicating whether or not the RFData is valid. </returns>
        private static bool VerifyRFData(RFData data)
        {
            if (data.Intensity <= 0)
            {
                return(false);
            }
            else if (data.TimeCaptured > DateTime.UtcNow.AddMinutes(1))
            {
                return(false);
            }

            return(true);
        }
        public void TestCreateRFData_InvalidIntensity()
        {
            data1.Intensity = -239458;

            DatabaseOperations.CreateRFData(appt.Id, data1);

            // update appt
            appt = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(NumRTInstances).Find(x => x.Id == appt.Id);

            RFData testData = appt.RFDatas.ToList().Find(x => x.Id == data1.Id);

            Assert.AreEqual(null, testData);
        }
        public void TestCreateRFData_InvalidDate()
        {
            data1.TimeCaptured = DateTime.UtcNow.AddDays(1);

            DatabaseOperations.CreateRFData(appt.Id, data1);

            // update appt
            appt = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(NumRTInstances).Find(x => x.Id == appt.Id);

            RFData testData = appt.RFDatas.ToList().Find(x => x.Id == data1.Id);

            Assert.AreEqual(null, testData);
        }
        /// <summary>
        /// Creates and stores and RFData reading in the local database.
        /// </summary>
        /// <param name="data">The RFData reading to be created/stored.</param>
        public static void AddRFData(RFData data)
        {
            if (VerifyRFData(data))
            {
                using (RTDbContext Context = InitializeDatabaseContext())
                {
                    // add the rf data to the list in appointment
                    data.Appointment.RFDatas.Add(data);

                    // add the rf data to the database
                    Context.RFDatas.AddOrUpdate(data);

                    Context.Entry(data.Appointment.User).State = EntityState.Unchanged;
                    Context.Entry(data.Appointment).State      = EntityState.Unchanged;
                    if (data.Appointment.Orientation != null)
                    {
                        Context.Entry(data.Appointment.Orientation).State = EntityState.Unchanged;
                    }
                    if (data.Appointment.CelestialBody != null)
                    {
                        if (data.Appointment.CelestialBody.Coordinate != null)
                        {
                            Context.Entry(data.Appointment.CelestialBody.Coordinate).State = EntityState.Unchanged;
                        }
                        Context.Entry(data.Appointment.CelestialBody).State = EntityState.Unchanged;
                    }
                    Context.Entry(data.Appointment.SpectraCyberConfig).State = EntityState.Unchanged;
                    Context.Entry(data.Appointment.Telescope).State          = EntityState.Unchanged;

                    // Only perform the following operations on a real telescope
                    // (i.e. the fields will not be null)
                    if (data.Appointment.Telescope.Location != null)
                    {
                        Context.Entry(data.Appointment.Telescope.Location).State = EntityState.Unchanged;
                    }

                    if (data.Appointment.Telescope.CurrentOrientation != null)
                    {
                        Context.Entry(data.Appointment.Telescope.CurrentOrientation).State = EntityState.Unchanged;
                    }

                    if (data.Appointment.Telescope.CalibrationOrientation != null)
                    {
                        Context.Entry(data.Appointment.Telescope.CalibrationOrientation).State = EntityState.Unchanged;
                    }

                    Context.SaveChanges();
                }
            }
        }
Exemplo n.º 14
0
        public void TestGenerateListFrom()
        {
            SpectraCyberResponse response1 = new SpectraCyberResponse();
            SpectraCyberResponse response2 = new SpectraCyberResponse();
            SpectraCyberResponse response3 = new SpectraCyberResponse();
            DateTime             date1     = DateTime.UtcNow;
            DateTime             date2     = date1.AddHours(1);
            DateTime             date3     = date2.AddMinutes(30);

            response1.DateTimeCaptured  = date1;
            response1.DecimalData       = 15;
            response1.RequestSuccessful = true;
            response1.SerialIdentifier  = 'c';
            response1.Valid             = true;

            response2.DateTimeCaptured  = date2;
            response2.DecimalData       = 10;
            response2.RequestSuccessful = true;
            response2.SerialIdentifier  = 'c';
            response2.Valid             = true;

            response3.DateTimeCaptured  = date3;
            response3.DecimalData       = 1500;
            response3.RequestSuccessful = true;
            response3.SerialIdentifier  = 'c';
            response3.Valid             = true;

            List <SpectraCyberResponse> responses = new List <SpectraCyberResponse>
            {
                response1,
                response2,
                response3
            };

            List <RFData> rfDatas = RFData.GenerateListFrom(responses);

            Assert.IsTrue(rfDatas != null);

            Assert.IsTrue(rfDatas[0] != null);
            Assert.AreEqual(date1.Date, rfDatas[0].TimeCaptured.Date);
            Assert.AreEqual(response1.DecimalData, rfDatas[0].Intensity);

            Assert.IsTrue(rfDatas[1] != null);
            Assert.AreEqual(date2.Date, rfDatas[1].TimeCaptured.Date);
            Assert.AreEqual(response2.DecimalData, rfDatas[1].Intensity);

            Assert.IsTrue(rfDatas[2] != null);
            Assert.AreEqual(date3.Date, rfDatas[2].TimeCaptured.Date);
            Assert.AreEqual(response3.DecimalData, rfDatas[2].Intensity);
        }
Exemplo n.º 15
0
        public void BuildUp()
        {
            rfdata = new RFData();

            id           = 0;
            timeCaptured = new DateTime();
            intensity    = 0;
            appt         = new Appointment();
            apptId       = 1;
            appt.Id      = apptId;
            DateTime start = DateTime.UtcNow;

            appt.StartTime = start;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Data received from rflink
        /// </summary>
        void ReceivedRFOut(object sender, EventArgs e)
        {
            RFData rf = e as RFData;

            if (PackageHost.GetSettingValue <bool>("Log"))
            {
                PackageHost.WriteInfo("RfLink data receive : {0}", rf.ToString());
            }

            // Push state object
            if (rf.Fields.ContainsKey("ID"))
            {
                var param = this.GetCustomSoParams(rf.Fields["ID"]);
                PackageHost.PushStateObject(param.Item1, rf.Fields, lifetime: param.Item2);
            }
        }
Exemplo n.º 17
0
        public void TestGenerateFrom()
        {
            SpectraCyberResponse response = new SpectraCyberResponse();
            DateTime             date     = DateTime.UtcNow;

            response.DateTimeCaptured  = date;
            response.DecimalData       = 15;
            response.RequestSuccessful = true;
            response.SerialIdentifier  = 'c';
            response.Valid             = true;

            RFData data = RFData.GenerateFrom(response);

            Assert.IsTrue(data != null);
            Assert.AreEqual(response.DateTimeCaptured, data.TimeCaptured);
            Assert.AreEqual(response.DecimalData, data.Intensity);
        }
Exemplo n.º 18
0
        private void SendData(string message, int retry = 1)
        {
            try
            {
                rfLinkClient.SendRawData(message, retry);

                RFData rf = ProtocolParser.ProcessData(message);
                if (rf.Fields.ContainsKey("ID"))
                {
                    var param = this.GetCustomSoParams(rf.Fields["ID"]);
                    PackageHost.PushStateObject(param.Item1, rf.Fields, lifetime: param.Item2);
                }
            }
            catch (Exception ex)
            {
                PackageHost.WriteError(ex.Message);
            }
        }
Exemplo n.º 19
0
        public void BuildUp()
        {
            // Initialize appointment entity
            appointment_1 = new Appointment();
            greaterThan   = new Appointment();

            // Initialize data for fields
            controlRoomUser   = new User("control", "room", "*****@*****.**", NotificationTypeEnum.SMS);
            startTime_1       = DateTime.UtcNow;
            endTime_1         = DateTime.UtcNow.AddHours(1);
            celestial_body    = new CelestialBody(CelestialBodyConstants.SUN);
            orientation       = new Orientation(20, 20);
            coordinate        = new Coordinate(20, 20);
            spectraCyber      = new SpectraCyber();
            telescope         = new RadioTelescope(new SpectraCyberController(spectraCyber), new TestPLCDriver(PLCConstants.LOCAL_HOST_IP, PLCConstants.LOCAL_HOST_IP, 8089, 8089, false), new Location(), new Orientation());
            rf_data           = new RFData();
            rf_data.Intensity = 100;
            status            = AppointmentStatusEnum.REQUESTED;
            type = AppointmentTypeEnum.POINT;
            spectracyber_config = new SpectraCyberConfig(SpectraCyberModeTypeEnum.CONTINUUM);

            startTime_2 = DateTime.UtcNow.AddDays(1);
            endTime_2   = DateTime.UtcNow.AddDays(1).AddHours(1);

            // Initialize fields we are testing against
            appointment_1.User          = controlRoomUser;
            appointment_1.start_time    = startTime_1;
            appointment_1.end_time      = endTime_1;
            appointment_1.CelestialBody = celestial_body;
            appointment_1.Orientation   = orientation;
            appointment_1.Coordinates.Add(coordinate);
            appointment_1.RFDatas.Add(rf_data);
            appointment_1._Status            = status;
            appointment_1._Type              = type;
            appointment_1.SpectraCyberConfig = spectracyber_config;
            appointment_1.Telescope          = telescope;

            greaterThan.start_time = startTime_2;
            greaterThan.end_time   = endTime_2;

            equalTo = appointment_1;
        }
Exemplo n.º 20
0
        public void TestCreateRFData()
        {
            DatabaseOperations.AddRFData(data1);
            DatabaseOperations.AddRFData(data2);

            Assert.AreEqual(DatabaseOperations.GetTotalRFDataCount(), NumRFData + 2);

            List <RFData> datas   = DatabaseOperations.GetListOfRFData();
            RFData        dbData1 = datas.Find(x => x.Id == data1.Id);
            RFData        dbData2 = datas.Find(x => x.Id == data2.Id);

            Assert.IsTrue(dbData1 != null);
            Assert.IsTrue(dbData2 != null);

            Assert.AreEqual(dbData1.Intensity, data1.Intensity);
            Assert.AreEqual(dbData2.Intensity, data2.Intensity);

            Assert.IsTrue(dbData1.TimeCaptured == data1.TimeCaptured);
            Assert.IsTrue(dbData2.TimeCaptured == data2.TimeCaptured);
        }
Exemplo n.º 21
0
        public void BuildUp()
        {
            // Initialize appointment entity
            appointment_1 = new Appointment();
            appointment_2 = new Appointment();

            // Initialize data for fields
            user_id           = 1;
            startTime_1       = DateTime.UtcNow;
            endTime_1         = DateTime.UtcNow.AddHours(1);
            celestial_body    = new CelestialBody(CelestialBodyConstants.SUN);
            orientation       = new Orientation(20, 20);
            coordinate        = new Coordinate(20, 20);
            rf_data           = new RFData();
            rf_data.Intensity = 100;
            telescope_id      = 1;
            status            = AppointmentStatusEnum.REQUESTED;
            type = AppointmentTypeEnum.POINT;
            spectracyber_config = new SpectraCyberConfig(SpectraCyberModeTypeEnum.CONTINUUM);

            startTime_2 = DateTime.UtcNow.AddDays(1);
            endTime_2   = DateTime.UtcNow.AddDays(1).AddHours(1);

            // Initialize fields we are testing against
            appointment_1.UserId        = user_id;
            appointment_1.StartTime     = startTime_1;
            appointment_1.EndTime       = endTime_1;
            appointment_1.CelestialBody = celestial_body;
            appointment_1.Orientation   = orientation;
            appointment_1.Coordinates.Add(coordinate);
            appointment_1.RFDatas.Add(rf_data);
            appointment_1.TelescopeId        = telescope_id;
            appointment_1.Status             = status;
            appointment_1.Type               = type;
            appointment_1.SpectraCyberConfig = spectracyber_config;

            appointment_2.StartTime = startTime_2;
            appointment_2.EndTime   = endTime_2;
        }
        public void BuildUp()
        {
            // Initialize context
            DatabaseOperations.PopulateLocalDatabase(NumRTInstances);

            // RFData initialization
            data1 = new RFData();
            data2 = new RFData();
            data3 = new RFData();
            DateTime date = DateTime.UtcNow;

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

            data2.Intensity    = 8739425;
            data2.TimeCaptured = date.AddSeconds(5);

            data3.Intensity    = 12987;
            data3.TimeCaptured = date.AddSeconds(10);

            // Init appt
            appt = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(NumRTInstances)[0];
        }
Exemplo n.º 23
0
        public void TestConvertDataToCSV()
        {
            string testpath = $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@".\DeleteCSVTestResults\test-out-{System.DateTime.Now.ToString("yyyyMMddHHmmss")}")}";
            RFData junk1    = new RFData();

            junk1.Id             = 0;
            junk1.appointment_id = 0;
            junk1.TimeCaptured   = new DateTime();
            junk1.Intensity      = 10000;

            RFData junk2 = new RFData();

            junk2.Id             = 1;
            junk2.appointment_id = 0;
            junk2.TimeCaptured   = new DateTime();
            junk2.Intensity      = 20000;

            List <RFData> JunkRFData = new List <RFData>();

            JunkRFData.Add(junk1);
            JunkRFData.Add(junk2);

            Assert.IsTrue(DataToCSV.ExportToCSV(JunkRFData, testpath));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Method used to calibrate the Radio Telescope before each observation.
        ///
        /// The implementation of this functionality is on a "per-RT" basis, as
        /// in this may or may not work, it depends on if the derived
        /// AbstractRadioTelescope class has implemented it.
        /// </summary>
        public MovementResult ThermalCalibrateRadioTelescope(MovementPriority priority)
        {
            MovementResult moveResult = MovementResult.None;

            // Return if incoming priority is equal to or less than current movement
            if (priority <= RadioTelescope.PLCDriver.CurrentMovementPriority)
            {
                return(MovementResult.AlreadyMoving);
            }

            // We only want to do this if it is safe to do so. Return false if not
            if (!AllSensorsSafe)
            {
                return(MovementResult.SensorsNotSafe);
            }

            // If a lower-priority movement was running, safely interrupt it.
            RadioTelescope.PLCDriver.InterruptMovementAndWaitUntilStopped();

            // If the thread is locked (two moves coming in at the same time), return
            if (Monitor.TryEnter(MovementLock))
            {
                Orientation current = GetCurrentOrientation();

                moveResult = RadioTelescope.PLCDriver.MoveToOrientation(MiscellaneousConstants.THERMAL_CALIBRATION_ORIENTATION, current);

                if (moveResult != MovementResult.Success)
                {
                    if (RadioTelescope.PLCDriver.CurrentMovementPriority != MovementPriority.Critical)
                    {
                        RadioTelescope.PLCDriver.CurrentMovementPriority = MovementPriority.None;
                    }
                    Monitor.Exit(MovementLock);
                    return(moveResult);
                }

                // start a timer so we can have a time variable
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                // temporarily set spectracyber mode to continuum
                RadioTelescope.SpectraCyberController.SetSpectraCyberModeType(SpectraCyberModeTypeEnum.CONTINUUM);

                // read data
                SpectraCyberResponse response = RadioTelescope.SpectraCyberController.DoSpectraCyberScan();

                // end the timer
                stopWatch.Stop();
                double time = stopWatch.Elapsed.TotalSeconds;

                RFData rfResponse = RFData.GenerateFrom(response);

                // move back to previous location
                moveResult = RadioTelescope.PLCDriver.MoveToOrientation(current, MiscellaneousConstants.THERMAL_CALIBRATION_ORIENTATION);
                if (moveResult != MovementResult.Success)
                {
                    if (RadioTelescope.PLCDriver.CurrentMovementPriority != MovementPriority.Critical)
                    {
                        RadioTelescope.PLCDriver.CurrentMovementPriority = MovementPriority.None;
                    }
                    RadioTelescope.SpectraCyberController.StopScan();
                    Monitor.Exit(MovementLock);
                    return(moveResult);
                }

                // analyze data
                // temperature (Kelvin) = (intensity * time * wein's displacement constant) / (Planck's constant * speed of light)
                double weinConstant   = 2.8977729;
                double planckConstant = 6.62607004 * Math.Pow(10, -34);
                double speedConstant  = 299792458;
                double temperature    = (rfResponse.Intensity * time * weinConstant) / (planckConstant * speedConstant);

                // convert to fahrenheit
                temperature = temperature * (9 / 5) - 459.67;

                // check against weather station reading
                double weatherStationTemp = RadioTelescope.WeatherStation.GetOutsideTemp();

                // Set SpectraCyber mode back to UNKNOWN
                RadioTelescope.SpectraCyberController.SetSpectraCyberModeType(SpectraCyberModeTypeEnum.UNKNOWN);

                // return true if working correctly, false if not
                if (Math.Abs(weatherStationTemp - temperature) < MiscellaneousConstants.THERMAL_CALIBRATION_OFFSET)
                {
                    moveResult = RadioTelescope.PLCDriver.MoveToOrientation(MiscellaneousConstants.Stow, current);
                }

                if (RadioTelescope.PLCDriver.CurrentMovementPriority != MovementPriority.Critical)
                {
                    RadioTelescope.PLCDriver.CurrentMovementPriority = MovementPriority.None;
                }

                RadioTelescope.SpectraCyberController.StopScan();
                Monitor.Exit(MovementLock);
            }
            else
            {
                moveResult = MovementResult.AlreadyMoving;
            }

            return(moveResult);
        }
        public static List <RFData> GetRFData(string criteria, string type)
        {
            var    dbUtil = new DatabaseManager();
            var    rfcoas = new List <RFData>();
            string stored = "";

            switch (type)
            {
            case "coa":
                stored = "spDisGetPCFCOAAriel";
                break;

            case "subsidiary":
                stored = "spDisGetPCFSubsidiaryAriel";
                break;

            case "indvSubsidiary":
                stored = "spDisGetPCFIndvSubsidiaryAriel";
                break;

            case "supplementary":
                stored = "spDisGetPCFSupplementaryAriel";
                break;

            case "indvSupplementary":
                stored = "spDisGetPCFIndvSupplementaryAriel";
                break;
            }

            using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandText    = stored;
                    cmd.CommandTimeout = 180;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@str", criteria);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var rfcoa = new RFData
                            {
                                Data1 = ReferenceEquals(reader["Data1"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data1"]),
                                Data2 = ReferenceEquals(reader["Data2"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data2"]),
                                Data3 = ReferenceEquals(reader["Data3"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data3"]),
                                Data4 = ReferenceEquals(reader["Data4"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data4"]),
                                Data5 = ReferenceEquals(reader["Data5"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data5"]),
                                Data6 = ReferenceEquals(reader["Data6"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data6"]),
                                Data7 = ReferenceEquals(reader["Data7"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data7"]),
                                Data8 = ReferenceEquals(reader["Data8"], DBNull.Value) ? string.Empty : Convert.ToString(reader["Data8"])
                            };

                            rfcoas.Add(rfcoa);
                        }

                        return(rfcoas);
                    }
                }
            }
        }