Exemple #1
0
        public Apdu(TLV tlv)
            : this()
        {
            base.Identifier = BerIdentifier.Encode(BerIdentifier.Application, BerIdentifier.Constructed, 1);
            base.Bytes      = tlv.Bytes;
            ByteArraySegment pdu = tlv.Value.Bytes;

            pdu.Length = 0;
            TLV tmp = new TLV(pdu.EncapsulatedBytes());

            gocbRef = new VisibleString(tmp);

            pdu.Length       += tmp.Bytes.Length;
            tmp               = new TLV(pdu.EncapsulatedBytes());
            timeAllowedtoLive = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            datSet      = new VisibleString(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            if (IsGoIDTag(tmp.Tag.RawBytes))
            {
                goID = new VisibleString(tmp);
            }

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            t           = new UtcTime(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            stNum       = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            sqNum       = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            test        = new TAsn1.Boolean(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            confRev     = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            ndsCom      = new TAsn1.Boolean(tmp);

            pdu.Length      += tmp.Bytes.Length;
            tmp              = new TLV(pdu.EncapsulatedBytes());
            numDatSetEntries = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            int cnt = 0;
            //    int len = tmp.Value.Bytes.Length;

            TLV data = new TLV(tmp.Value.Bytes);

            allData.Add(new Data(data));
            cnt++;

            while (cnt < numDatSetEntries.Value)
            {
                data = new TLV(tmp.Value.Bytes.EncapsulatedBytes());
                tmp.Value.Bytes.Length += data.Bytes.Length;
                //TLV data = new TLV(tmp.Value.Bytes);
                allData.Add(new Data(data));
                cnt++;
                //tmp.Value.Bytes.Length += data.Bytes.Length;
            }
        }
Exemple #2
0
        public Asdu(TLV tlv)
            : this()
        {
            Bytes = tlv.Bytes;
            ByteArraySegment pdu = tlv.Value.Bytes;

            pdu.Length = 0;
            TLV tmp = new TLV(pdu.EncapsulatedBytes());

            svID        = new VisibleString(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            if (IsDatset(tmp))
            {
                datset      = new VisibleString(tmp);
                pdu.Length += tmp.Bytes.Length;
                tmp         = new TLV(pdu.EncapsulatedBytes());
            }

            smpCnt      = new Integer(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            confRev     = new Integer(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            if (IsRefrTm(tmp))
            {
                refrTm      = new UtcTime(tmp);
                pdu.Length += tmp.Bytes.Length;
                tmp         = new TLV(pdu.EncapsulatedBytes());
            }

            smpSynch    = new TAsn1.Boolean(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            if (!smpSynch.Value)
            {
                smpRate     = new TAsn1.Boolean(tmp);
                pdu.Length += tmp.Bytes.Length;
                tmp         = new TLV(pdu.EncapsulatedBytes());
            }


            tmp = new TLV(pdu.EncapsulatedBytes());

            ByteArraySegment chn = tmp.Value.Bytes;

            chn.Length = Channel.ChannelLength;
            sample.Add(new Channel(chn));
            // Confirm the loop
            while (chn.Length + chn.Offset < chn.BytesLength)
            {
                chn        = chn.EncapsulatedBytes();
                chn.Length = Channel.ChannelLength;
                sample.Add(new Channel(chn));
            }
        }