public void MeasurementCombinationValueTest1()
        {
            var pin1 = new APin ();
            var pin2 = new APin ();
            var meCom1 = new MeasurementCombination ();

            pin1.Slope = 1;
            pin1.Offset = 0;
            pin1.MeanValuesCount = 1;
            pin1.Interval = 1;
            pin1.Number = 0;

            pin2.Slope = 1;
            pin2.Offset = 0;
            pin2.MeanValuesCount = 1;
            pin2.Interval = 1;
            pin2.Number = 1;

            pin1.Value = new DateTimeValue (1, DateTime.Now);
            pin2.Value = new DateTimeValue (1, DateTime.Now);

            meCom1.AddPin (pin1);
            meCom1.AddPin (pin2);

            meCom1.Operation = OperationCompiler.CompileOperation ("A0+A1", meCom1.Pins.Select (o => o.DisplayNumberShort).ToArray ());

            Assert.AreEqual (2, meCom1.Value.Value);
        }
        public void MeasurementCombinationTests1()
        {
            var mecom = new MeasurementCombination ();
            var pin = new APin (){ Number = 0, RealNumber = 14, Interval = 1000, MeanValuesCount = 1 };

            Assert.AreEqual (0, mecom.Pins.Count);

            mecom.AddPin (pin);
            Assert.AreEqual (1, mecom.Pins.Count);
            Assert.AreEqual (false, mecom.AddPin (pin));

            var mecomcopy = new MeasurementCombination ();
            mecomcopy.AddPin (pin);

            Assert.AreEqual (mecom, mecomcopy);
        }
Example #3
0
        public void SerializeBoardConfigTest2()
        {
            var conf = new BoardConfiguration ();
            conf.Board.AnalogReferenceVoltageType = "INTERNAL";
            conf.Board.AnalogReferenceVoltage = 4.24;

            var pin = new APin (){ Number = 42 };

            var MeCom = new MeasurementCombination ();
            MeCom.AddPin (pin);

            conf.AddPin (pin);
            conf.AddMeasurementCombination (MeCom);

            Formator.Serialize (MemStream, conf);
            MemStream.Seek (0, SeekOrigin.Begin);

            var confClone = (BoardConfiguration)Formator.Deserialize (MemStream);

            Assert.AreEqual (conf.Pins [0], confClone.Pins [0]);
            Assert.AreEqual (conf.MeasurementCombinations [0], confClone.MeasurementCombinations [0]);
            Assert.AreEqual (4.24, conf.Board.AnalogReferenceVoltage, 0.000000001);
            Assert.AreEqual (4.24, confClone.Board.AnalogReferenceVoltage, 0.000000001);
            Assert.AreEqual ("INTERNAL", conf.Board.AnalogReferenceVoltageType);
            Assert.AreEqual ("INTERNAL", confClone.Board.AnalogReferenceVoltageType);
            Assert.AreSame (conf.Pins [0], conf.MeasurementCombinations [0].Pins [0]);
            Assert.AreSame (confClone.Pins [0], confClone.MeasurementCombinations [0].Pins [0]);

            conf.Pins [0].Name = "Dulli";
            Assert.AreEqual (conf.Pins [0].Name, conf.MeasurementCombinations [0].Pins [0].Name);
            Assert.AreEqual (19, confClone.AvailableDigitalPins.Length);
            Assert.AreEqual (6, confClone.AvailableAnalogPins.Length);

            conf.ClearPins ();
            Assert.AreEqual (0, conf.Pins.Count);
            Assert.AreEqual (0, conf.MeasurementCombinations.Count);
        }