public void MeasurementCombinationValueTest3()
        {
            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);
            pin1.Value = new DateTimeValue(1, DateTime.Now);
            pin2.Value = new DateTimeValue(1, DateTime.Now);
            pin2.Value = new DateTimeValue(1, DateTime.Now);


            meCom1.MeanValuesCount = 2;
            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);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AComConfigDialog"/> class.
        /// </summary>
        /// <param name="pins">Pins.</param>
        /// <param name="signal">Signal.</param>
        /// <param name="pin">Pin.</param>
        /// <param name="parent">Parent.</param>
        /// <param name="units">Units.</param>
        public AComConfigDialog(APin[] pins, MeasurementCombination signal = null, APin pin = null, Gtk.Window parent = null, List <string> units = null)
            : base("Analog Inputs Combinations - Dialog", parent, Gtk.DialogFlags.Modal, new object[0])
        {
            this.Build();

            sbMeanValuesCount.Adjustment.Upper = int.MaxValue;
            sbMeanValuesCount.Adjustment.Lower = 1;

            APins = pins;

            cbColor.Color = GUIHelper.ColorHelper.GetRandomGdkColor();

            if (signal == null)
            {
                Combination_       = new MeasurementCombination();
                Combination_.Color = cbColor.Color;
            }
            else
            {
                Combination = signal;
                if (!string.IsNullOrEmpty(Combination.OperationString))
                {
                    CompileOperation();
                }
                else
                {
                    SetWarning();
                }
                buttonOk.Label = "Apply";
            }

            if (pin != null)
            {
                Combination_.AddPin(pin);
                Combination_.Unit = Combination_.Pins [0].Unit;
            }

            SetupNodeView();
            DrawNodeView();
            UpdateCBPins();
            SetApplyButton();

            entryOperation.Activated += (sender, e) => {
                if (!CompileTimer.Enabled)
                {
                    CompileTimer.Start();
                }
            };
            entryOperation.FocusInEvent += (sender, e) => {
                if (!CompileTimer.Enabled)
                {
                    CompileTimer.Start();
                }
            };

            CompileTimer.Elapsed += CompileTimerElapsed;

            Units = units;
            ListStore store = new ListStore(typeof(string));

            Units.ForEach(o => store.AppendValues(new object[] { o }));
            cbeUnit.Model = store;
            if (!string.IsNullOrEmpty(Combination_.Unit))
            {
                if (Units.Contains(Combination_.Unit))
                {
                    cbeUnit.Active = Array.IndexOf(Units.ToArray(), Combination_.Unit);
                }
                else
                {
                    store.AppendValues(new string[] { Combination_.Unit });
                    cbeUnit.Active = Units.Count;
                }
            }
        }