Exemple #1
0
        //---------------------------------------------------------------------
        private static void Run(string name, double instrumentPrecision, double compressionDeviation)
        {
            var dataPointReader = new DataPointSerializer();

            IEnumerable <DataPoint> compressed = dataPointReader
                                                 .Read($"{name}.csv", dateTimeFormat: "yyyy-MM-dd_HH:mm:ss")
                                                 .DeadBandCompression(instrumentPrecision)
                                                 .SwingingDoorCompression(compressionDeviation);

            dataPointReader.Write($"{name}_compressed.csv", compressed, dateTimeFormat: "yyyy-MM-dd_HH:mm:ss");

            GnuPlot(name);
            ShowChart(name);
        }
Exemple #2
0
        static void Main()
        {
            Environment.CurrentDirectory = Path.Combine(Directory.GetCurrentDirectory(), "data");

            var dataPointReader = new DataPointSerializer();

            IEnumerable <DataPoint> compressed = dataPointReader
                                                 .Read("coolant-temp.csv")
                                                 .DeadBandCompression(1d);

            dataPointReader.Write("coolant-temp_compressed.csv", compressed, header: ("Oh", "Temp"));

            GnuPlot();
            ShowChart();
        }
Exemple #3
0
        public void Write_Read_roundtrip_with_datetime___OK([Values(true, false)] bool writeHeader)
        {
            DateTime now = new DateTime(2019, 12, 16, 21, 57, 13);

            DateTime[] dts =
            {
                now.AddMinutes(-12),
                now
            };

            DataPoint[] dataPoints =
            {
                new DataPoint(dts[0], 2),
                new DataPoint(dts[1], -1)
            };

            var    sut  = new DataPointSerializer();
            string file = _tmpFile;

            const string datetimeFormat = "yyyy-MM-dd:HHmmss";

            if (writeHeader)
            {
                sut.Write(file, dataPoints, header: ("x", "y"), dateTimeFormat: datetimeFormat);
            }
            else
            {
                sut.Write(file, dataPoints, dateTimeFormat: datetimeFormat);
            }
            DataPoint[] actual = sut.Read(file, firstLineIsHeader: writeHeader, dateTimeFormat: datetimeFormat).ToArray();

            Assert.Multiple(() =>
            {
                Assert.AreEqual(2, actual.Length);

                Assert.AreEqual(dts[0], new DateTime((long)(actual[0].X)));
                Assert.AreEqual(dataPoints[0].Y, actual[0].Y, 1e-3);

                Assert.AreEqual(dts[1], new DateTime((long)(actual[1].X)));
                Assert.AreEqual(dataPoints[1].Y, actual[1].Y, 1e-3);
            });
        }
Exemple #4
0
        public void Write_Read_roundtrip___OK([Values(true, false)] bool writeHeader)
        {
            DataPoint[] dataPoints =
            {
                DataPoint.Origin,
                new DataPoint(1, 2),
                new DataPoint(2, -1)
            };

            var    sut  = new DataPointSerializer();
            string file = _tmpFile;

            if (writeHeader)
            {
                sut.Write(file, dataPoints, header: ("x", "y"));
            }
            else
            {
                sut.Write(file, dataPoints);
            }
            DataPoint[] actual = sut.Read(file, firstLineIsHeader: writeHeader).ToArray();

            CollectionAssert.AreEqual(dataPoints, actual);
        }
Exemple #5
0
 //---------------------------------------------------------------------
 private static IEnumerable <DataPoint> RawDataForTrend() => _ser.Read("../../../../../doc/data/dead-band/trend_raw.csv");
Exemple #6
0
 //---------------------------------------------------------------------
 private static IEnumerable <DataPoint> RawDataForTrend() => _ser.Read("../../../../../doc/data/swinging-door/trend_raw.csv");