Example #1
0
        public void TestEncodeASDUsWithManyInformationObjectsSequenceOfIO()
        {
            ConnectionParameters cp = new ConnectionParameters();

            ASDU asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            int  addedCounter = 0;
            int  ioa          = 100;

            while (asdu.AddInformationObject(new SinglePointInformation(ioa, false, new QualityDescriptor())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(240, addedCounter);
            Assert.NotNull(asdu.AsByteArray());


            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new DoublePointInformation(ioa, DoublePointValue.OFF, new QualityDescriptor())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(240, addedCounter);
            Assert.NotNull(asdu.AsByteArray());


            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new MeasuredValueNormalized(ioa, 1f, new QualityDescriptor())))
            {
                ioa++;
                addedCounter++;
            }


            Assert.AreEqual(80, addedCounter);
            Assert.NotNull(asdu.AsByteArray());

            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new MeasuredValueScaled(ioa, 0, new QualityDescriptor())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(80, addedCounter);
            Assert.NotNull(asdu.AsByteArray());


            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new MeasuredValueShort(ioa, 0f, new QualityDescriptor())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(48, addedCounter);
            Assert.NotNull(asdu.AsByteArray());


            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new StepPositionInformation(ioa, 0, false, new QualityDescriptor())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(120, addedCounter);
            Assert.NotNull(asdu.AsByteArray());


            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new IntegratedTotals(ioa, new BinaryCounterReading())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(48, addedCounter);
            Assert.NotNull(asdu.AsByteArray());


            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new PackedSinglePointWithSCD(ioa, new StatusAndStatusChangeDetection(), new QualityDescriptor())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(48, addedCounter);
            Assert.NotNull(asdu.AsByteArray());


            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new PackedOutputCircuitInfo(ioa, new OutputCircuitInfo(), new QualityDescriptorP(), new CP16Time2a(10), new CP24Time2a())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(34, addedCounter);
            Assert.NotNull(asdu.AsByteArray());

            asdu         = new ASDU(cp, CauseOfTransmission.PERIODIC, false, false, 0, 1, true);
            addedCounter = 0;
            ioa          = 100;

            while (asdu.AddInformationObject(new PackedStartEventsOfProtectionEquipment(ioa, new StartEvent(), new QualityDescriptorP(), new CP16Time2a(0), new CP24Time2a())))
            {
                ioa++;
                addedCounter++;
            }

            Assert.AreEqual(34, addedCounter);
            Assert.NotNull(asdu.AsByteArray());
        }