Пример #1
0
        public int Decode(byte[] buffer, int offset, uint count)
        {
            int len = 0;

            byte periodType;

            len += ASN1.decode_tag_number(buffer, offset + len, out periodType); // -> type

            switch (periodType)
            {
            case 0:     //calendarEntry
                var calendar = new BACnetCalendarEntry();
                len   += calendar.Decode(buffer, offset + len, count);
                Period = calendar;
                len   += 1;   // -> closingtag
                break;

            case 1:     //calendarReference
                var calRef = new BacnetObjectId();
                len   += ASN1.decode_object_id(buffer, offset + len, out calRef.type, out calRef.instance);
                Period = calRef;
                break;
            }

            ListOfTimeValues = new List <BacnetTimeValue>();

            if (ASN1.IS_OPENING_TAG(buffer[offset + len]))
            {
                len++;
                //end of daily sched
                while (!ASN1.IS_CLOSING_TAG(buffer[offset + len]))
                {
                    var timeVal = new BacnetTimeValue();
                    len += timeVal.Decode(buffer, offset + len, count);
                    ListOfTimeValues.Add(timeVal);
                }
                //closing tag
                len++;
            }


            uint evPr;

            len          += ASN1.decode_context_unsigned(buffer, offset + len, 3, out evPr);
            EventPriority = (byte)evPr;
            return(len);
        }
Пример #2
0
        public int Decode(byte[] buffer, int offset, uint count)
        {
            int len = 0;

            DaySchedule = new List <BacnetTimeValue>();
            //begin of daily sched
            if (ASN1.IS_OPENING_TAG(buffer[offset + len]))
            {
                len++;
                //end of daily sched
                while (!ASN1.IS_CLOSING_TAG(buffer[offset + len]))
                {
                    var timeVal = new BacnetTimeValue();
                    len += timeVal.Decode(buffer, offset + len, count);
                    DaySchedule.Add(timeVal);
                }
                //closing tag
                len++;
            }

            return(len);
        }