Example #1
0
        public void OutputDataConversionViaProc()
        {
            IDictionary <string, object> config = new Dictionary <string, object>(2);

            config["param1"] = 10;
            config["param2"] = 1;

            var srate = new Measurement(1000, "Hz");


            var outData = new OutputData(this.Data,
                                         srate, false)
                          .DataWithExternalDeviceConfiguration(devFake, new Dictionary <string, object>())
                          .DataWithStreamConfiguration(streamFake, new Dictionary <string, object>());

            outData.OutputTime = DateTimeOffset.Now;


            var expected = new OutputData(outData,
                                          outData.Data.Select(m => new Measurement(m.QuantityInBaseUnit * 10, 1, "foo")).ToList())
            {
                OutputTime = outData.OutputTime
            };


            var actual = outData.DataWithConversion((m) => new Measurement(m.QuantityInBaseUnit * 10, 1, "foo"));

            Assert.AreEqual(expected.Data, actual.Data);
            Assert.AreEqual(expected.NodeConfigurationWithName(IOData.EXTERNAL_DEVICE_CONFIGURATION_NAME),
                            actual.NodeConfigurationWithName(IOData.EXTERNAL_DEVICE_CONFIGURATION_NAME));
            Assert.AreEqual(expected.NodeConfigurationWithName(IOData.STREAM_CONFIGURATION_NAME),
                            actual.NodeConfigurationWithName(IOData.STREAM_CONFIGURATION_NAME));
            Assert.AreEqual(expected.OutputTime, actual.OutputTime);
        }
Example #2
0
        public void OutputDataCreation()
        {
            IDictionary <string, object> config = new Dictionary <string, object>(2);

            config["param1"] = 10;
            config["param2"] = 1;

            IMeasurement srate = new Measurement(1000, "Hz");

            IOutputData outData = new OutputData(this.Data,
                                                 srate, false);

            Assert.IsNotNull(outData);
            Assert.AreEqual(this.Data, outData.Data);
            Assert.IsNull(outData.NodeConfigurationWithName(IOData.EXTERNAL_DEVICE_CONFIGURATION_NAME));
            Assert.IsNull(outData.NodeConfigurationWithName(IOData.STREAM_CONFIGURATION_NAME));
            Assert.AreEqual(srate, outData.SampleRate);
            Assert.False(outData.IsLast);
        }
Example #3
0
        public void OutputData_SetsStreamConfig()
        {
            var config = new Dictionary <string, object>();

            IOutputData data = new OutputData(Data, UNUSED_SRATE, false);

            data = data.DataWithStreamConfiguration(streamFake, config);

            Assert.That(data.NodeConfigurationWithName(streamFake.Name).Configuration,
                        Is.EqualTo(config));
        }
Example #4
0
        public void OutputDataConversion()
        {
            IDictionary <string, object> config = new Dictionary <string, object>(2);

            config["param1"] = 10;
            config["param2"] = 1;

            IMeasurement srate = new Measurement(1000, "Hz");


            IOutputData outData = new OutputData(this.Data,
                                                 srate, false)
                                  .DataWithExternalDeviceConfiguration(devFake, new Dictionary <string, object>())
                                  .DataWithStreamConfiguration(streamFake, new Dictionary <string, object>());

            outData.OutputTime = DateTimeOffset.Now;

            Converters.Clear();
            ConvertProc fooConversion = (m) => new Measurement(m.QuantityInBaseUnit * 10, 1, "foo");

            Converters.Register("V", "foo", fooConversion);

            IOutputData expected = new OutputData(outData,
                                                  outData.Data.Select(m => new Measurement(m.QuantityInBaseUnit * 10, 1, "foo")).ToList());

            expected.OutputTime = outData.OutputTime;

            Assert.NotNull(expected.NodeConfigurationWithName(devFake.Name));
            Assert.NotNull(expected.NodeConfigurationWithName(streamFake.Name));
            IOutputData actual = outData.DataWithUnits("foo");

            Assert.AreEqual(expected.Data, actual.Data);
            Assert.AreEqual(expected.NodeConfigurationWithName(devFake.Name),
                            actual.NodeConfigurationWithName(devFake.Name));
            Assert.AreEqual(expected.NodeConfigurationWithName(streamFake.Name),
                            actual.NodeConfigurationWithName(streamFake.Name));
            Assert.AreEqual(expected.OutputTime, actual.OutputTime);
        }