Esempio n. 1
0
        public int Decode_Ack_Service_Request(ref Byte[] apdu, UInt16 apdu_len, ref BACnet_Read_Property_Data rpdata, int pos = 0)
        {
            Byte   tag_number     = 0;
            UInt32 len_value_type = 0;
            int    tag_len        = 0; /* length of tag decode */
            int    len            = 0; /* total length of decodes */
            UInt16 object_type    = 0; /* object type */
            UInt32 property       = 0; /* for decoding */
            UInt32 array_value    = 0; /* for decoding */

            len  = 1;
            len += BasicalProcessor.Decode_Object_Id(ref apdu, ref object_type, ref rpdata.object_instance, len);
            rpdata.object_type = (BACNET_OBJECT_TYPE)object_type;
            len += BasicalProcessor.Decode_Tag_number_and_Value(ref apdu, ref tag_number, ref len_value_type, len);
            if (tag_number != 1)
            {
                return(-1);
            }
            len += BasicalProcessor.Decode_Enumerated(ref apdu, len_value_type, ref property, len);
            rpdata.object_property = (BACNET_PROPERTY_ID)property;
            /* Tag 2: Optional Array Index 没有 */
            rpdata.array_index = BacnetConst.BACNET_ARRAY_ALL;
            if (BasicalProcessor.Decode_Is_Opening_Tag_Number(ref apdu, 3, pos + len))
            {
                len++;
            }
            rpdata.application_data_pos = len;
            rpdata.application_data_len = (int)apdu_len - len - 1;
            return(len);
        }
Esempio n. 2
0
        private int Decode_Service_Request(ref Byte[] apdu, uint request_len, ref ACKNOWLEDGE_ALARM_DATA Ack_data)
        {
            int len = 0;

            int    section_length = 0;
            UInt32 value          = 0;

            /* tag 0 - processIdentifier */
            section_length = BasicalProcessor.Decode_Context_Unsigned(ref apdu, 0, ref Ack_data.ProcessIdentifier, len);
            len           += section_length;
            /* tag 1 - eventObjectIdentifier */
            section_length = BasicalProcessor.Decode_Object_Id(ref apdu, ref Ack_data.EventIdentifier.type, ref Ack_data.EventIdentifier.instance, len);
            len           += section_length;
            /* tag2  EventStare */
            section_length             = BasicalProcessor.Decode_Enumerated(ref apdu, 2, ref value, len);
            Ack_data.StateAcknowledged = (BACNET_EVENT_STATE)value;
            len += section_length;

            /* tag 3 - timeStamp */
            section_length = BasicalProcessor.Decode_Context_Timestamp(ref apdu, 3, ref Ack_data.TimeStamp, len);
            len           += section_length;
            /* tag 4 Acknowledgment Source */
            section_length = BasicalProcessor.Decode_Context_Character_String(ref apdu, 4, ref Ack_data.Source, len);
            len           += section_length;

            /* tag 5 - AcktimeStamp */
            section_length = BasicalProcessor.Decode_Context_Timestamp(ref apdu, 5, ref Ack_data.TimeOfAcknowledgment, len);
            len           += section_length;

            return(len);
        }
Esempio n. 3
0
        private int Decode_Service_Request(ref Byte[] request, uint request_len, ref BACnet_Read_Property_Data rpdata)
        {
            int    len            = 0;
            Byte   tag_number     = 0;
            UInt32 len_value_type = 0;
            UInt16 type           = 0; /* for decoding */
            UInt32 property       = 0; /* for decoding */
            UInt32 array_value    = 0; /* for decoding */

            //此处有对于错误请求的判断 decode_is_context_tag(&apdu[len++], 0)
            len++;
            len += BasicalProcessor.Decode_Object_Id(ref request, ref type, ref rpdata.object_instance, len);
            rpdata.object_type = (BACNET_OBJECT_TYPE)type;



            len += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value_type, len);
            //if (tag_number != 1)...


            len += BasicalProcessor.Decode_Enumerated(ref request, len_value_type, ref property, len);
            rpdata.object_property = (BACNET_PROPERTY_ID)property;
            // /* Tag 2: Optional Array Index */if (len < apdu_len)

            rpdata.application_data_len = (int)request_len - len - 1;
            return(len);
        }
Esempio n. 4
0
        private int Unconfirm_Cov_Decode(ref Byte[] request, uint service_len, ref BACNET_COV_DATA data)
        {
            int    len           = 0; /* return value */
            Byte   tag_number    = 0;
            UInt32 len_value     = 0;
            UInt32 decoded_value = 0; /* for decoding */
            UInt16 decoded_type  = 0; /* for decoding */
            UInt32 property      = 0; /* for decoding */

            /* value in list */
            /* tag 0 - subscriberProcessIdentifier */
            //  if (decode_is_context_tag(&apdu[len], 0))
            len += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value, len);
            len += BasicalProcessor.Decode_Unsigned(ref request, len_value, ref decoded_value, len);
            data.subscriberProcessIdentifier = decoded_value;
            /* tag 1 - initiatingDeviceIdentifier */
            len += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value, len);
            len += BasicalProcessor.Decode_Object_Id(ref request, ref decoded_type, ref data.initiatingDeviceIdentifier, len);
            /* tag 2 - monitoredObjectIdentifier */
            len += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value, len);
            len += BasicalProcessor.Decode_Object_Id(ref request, ref decoded_type, ref data.monitoredObjectIdentifier.instance, len);
            /* tag 3 - timeRemaining */
            len += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value, len);
            len += BasicalProcessor.Decode_Unsigned(ref request, len_value, ref decoded_value, len);
            data.timeRemaining = decoded_value;

            /* tag 4: opening context tag - listOfValues */
            //   if (!decode_is_opening_tag_number(&apdu[len], 4)) {
            len++;

            while (true) //应该设置遇到时间戳就BREAK? 下面CLOSING TAG有break
            {
                BACNET_PROPERTY_VALUE value = new BACNET_PROPERTY_VALUE();
                /* tag 0 - propertyIdentifier */

                if (BasicalProcessor.Decode_Is_Context_Tag(ref request, 0, len))
                {
                    len += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value, len);
                    len += BasicalProcessor.Decode_Enumerated(ref request, len_value, ref property, len);
                    value.propertyIdentifier = (BACNET_PROPERTY_ID)property;
                }
                else
                {
                    return(-1);
                }
                /* tag 1 - propertyArrayIndex OPTIONAL */
                if (BasicalProcessor.Decode_Is_Context_Tag(ref request, 1, len))
                {
                    len += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value, len);
                    len += BasicalProcessor.Decode_Unsigned(ref request, len_value, ref decoded_value, len);
                    value.propertyArrayIndex = (UInt32)decoded_value;
                }
                else
                {
                    value.propertyArrayIndex = BacnetConst.BACNET_ARRAY_ALL;//#define BACNET_ARRAY_ALL (~(unsigned int)0)
                }
                /* tag 2: opening context tag - value */
                if (!BasicalProcessor.Decode_Is_Opening_Tag_Number(ref request, 2, len))
                {
                    return(-1);
                }
                len++;
                len += BasicalProcessor.Decode_Application_Data(ref request, (uint)(service_len - len), ref value.value, len);

                if (!BasicalProcessor.Decode_Is_Closing_Tag_Number(ref request, 2, len))
                {
                    return(-1);
                }
                len++;

                /* tag 3 - priority OPTIONAL */
                if (BasicalProcessor.Decode_Is_Context_Tag(ref request, 3, len))
                {
                    len           += BasicalProcessor.Decode_Tag_number_and_Value(ref request, ref tag_number, ref len_value, len);
                    len           += BasicalProcessor.Decode_Unsigned(ref request, len_value, ref decoded_value, len);
                    value.priority = (Byte)decoded_value;
                }
                else
                {
                    value.priority = 0;
                }
                data.listOfValues.Add(value);
                if (BasicalProcessor.Decode_Is_Closing_Tag_Number(ref request, 4, len))
                {
                    break;
                }
            }

            return(len);
        }