public void TestMissingValues()
        {
            var contact = new Contact("Jim", "Does", "*****@*****.**", "Lollipops", "837773");
            var dataSet = new Dataset(new Site(4, "New Site", "Tim Jones", contact, contact, new GPSCoords(0, 0, "argis")));

            var sensor = new Sensor("Dummy Sensor", "Does stuff", 10, 0, "C", 5, dataSet);

            sensor.AddState(new SensorState(sensor, DateTime.Now));
            sensor.CurrentState.Values.Add(new DateTime(1990, 5, 1, 4, 0, 0), 15);
            sensor.CurrentState.Values.Add(new DateTime(1990, 5, 1, 5, 0, 0), 15);
            sensor.CurrentState.Values.Add(new DateTime(1991, 8, 2, 0, 0, 0), 15);

            dataSet.AddSensor(sensor);

            dataSet.DataInterval = 60;

            dataSet.HighestYearLoaded = 1;

            Assert.AreEqual(60, dataSet.DataInterval);

            var missingValues = missingValuesDetector.GetDetectedValues(sensor);

            for (var i = new DateTime(1990, 5, 1, 6, 0, 0); i < new DateTime(1991, 8, 2, 0, 0, 0); i = i.AddHours(1))
            {
                Assert.Contains(new ErroneousValue(i, missingValuesDetector, sensor), missingValues);
            }
        }
Esempio n. 2
0
        private async void Button_NewSensorClick(object sender, RoutedEventArgs e)
        {
            AddSensorDialog dialog = new AddSensorDialog();
            var             result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                if (_curDataset != null)
                {
                    double totalX    = floorplanImage.ActualWidth;
                    double totalY    = floorplanImage.ActualHeight;
                    Sensor sensor    = _curDataset.AddSensor(dialog.sensorName, dialog.sensorType, 0.0, 0.0, 23 / totalX, 15 / totalY);
                    int    typeIndex = GetSensorTypeIndex(dialog.sensorType);
                    SaveHome();
                    AddSeneorToCanvas(sensor);
                    if (typeIndex >= 0)
                    {
                        sensorListTypeSelect.SelectedIndex = -1;
                        sensorListTypeSelect.SelectedIndex = typeIndex;
                    }
                }
            }
        }
Esempio n. 3
0
        public void ExportAsCSVCorrectValueCount()
        {
            var dateTime = new DateTime(2011, 8, 4, 0, 0, 0);
            var givenDataSet = new Dataset(new Site(1, "Steven", "Kerry", Contact, Contact, new GPSCoords(0, 0, "arcGis")));
            var sampleData = new Dictionary<DateTime, float> { { dateTime.AddMinutes(15), 100 }, { dateTime.AddMinutes(30), 100 }, { dateTime.AddMinutes(45), 100 }, { dateTime.AddMinutes(60), 100 } };
            var s = new Sensor("Awesome Sensor", "Awesome");
            var ss = new SensorState(s, DateTime.Now, sampleData, null);
            s.AddState(ss);
            givenDataSet.AddSensor(s);

            Assert.AreEqual(4, givenDataSet.ExpectedDataPointCount);

            dateTime = new DateTime(2011, 8, 4, 0, 0, 0);
            givenDataSet = new Dataset(new Site(1, "Steven", "Kerry", Contact, Contact, new GPSCoords(0, 0, "arcGis")));

            sampleData = new Dictionary<DateTime, float> { { dateTime.AddMinutes(60), 100 }, { dateTime.AddMinutes(75), 100 }, { dateTime.AddMinutes(90), 100 }, { dateTime.AddMinutes(105), 100 } };
            s = new Sensor("Awesome Sensor", "Awesome");
            ss = new SensorState(s, DateTime.Now, sampleData, null);
            s.AddState(ss);
            givenDataSet.AddSensor(s);

            Assert.AreEqual(4, givenDataSet.ExpectedDataPointCount);
        }
Esempio n. 4
0
        public void ExportCSVWithIndividualDateColumns()
        {
            var dateTime = new DateTime(2011, 8, 4, 0, 0, 0);
            var givenDataSet = new Dataset(new Site(1, "Steven", "Kerry", Contact, Contact, new GPSCoords(0, 0, "arcGis")));
            var sampleData = new Dictionary<DateTime, float> { { dateTime.AddMinutes(15), 100 }, { dateTime.AddMinutes(30), 100 }, { dateTime.AddMinutes(45), 100 }, { dateTime.AddMinutes(60), 100 } };
            var s = new Sensor("Awesome Sensor", "Awesome");
            var ss = new SensorState(s, DateTime.Now, sampleData, null);
            s.AddState(ss);
            givenDataSet.AddSensor(s);

            DatasetExporter.Export(givenDataSet, _outputFilePath, ExportFormat.CSV, true, false, false, ExportedPoints.AllPoints, DateColumnFormat.OneDateColumn, loadInUnloadedValues: false);

            Assert.AreEqual(DatasetOutputWithIndividualColumns, File.ReadAllText(_outputFilePath));
        }