예제 #1
0
        private int Notify_Encode_Data(ref Byte[] apdu, BACNET_COV_DATA cov_data, int pos)
        {
            int len      = 0;                   /* length of each encoding */
            int apdu_len = 0;
            BACNET_PROPERTY_VALUE value = null; /* value in list */

            /* tag 0 - subscriberProcessIdentifier */
            len       = BasicalProcessor.Encode_Context_Unsigned(ref apdu, 0, cov_data.subscriberProcessIdentifier, pos + apdu_len);
            apdu_len += len;
            /* tag 1 - initiatingDeviceIdentifier */
            len       = BasicalProcessor.Encode_Context_ObjectId(ref apdu, 1, (int)BACNET_OBJECT_TYPE.OBJECT_DEVICE, cov_data.initiatingDeviceIdentifier, pos + apdu_len);
            apdu_len += len;
            /* tag 2 - monitoredObjectIdentifier */
            len       = BasicalProcessor.Encode_Context_ObjectId(ref apdu, 2, (int)cov_data.monitoredObjectIdentifier.type, cov_data.monitoredObjectIdentifier.instance, pos + apdu_len);
            apdu_len += len;
            /* tag 3 - timeRemaining */
            len       = BasicalProcessor.Encode_Context_Unsigned(ref apdu, 3, cov_data.timeRemaining, pos + apdu_len);
            apdu_len += len;
            /* tag 4 - listOfValues */
            len       = BasicalProcessor.Encode_Opening_Tag(ref apdu, 4, pos + apdu_len);
            apdu_len += len;
            /* the first value includes a pointer to the next value, etc */



            for (int count = 0; count < cov_data.listOfValues.Count; count++)
            {
                value = cov_data.listOfValues[count];
                /* tag 0 - propertyIdentifier */
                len       = BasicalProcessor.Encode_Context_Enumerate(ref apdu, 0, (uint)value.propertyIdentifier, pos + apdu_len);
                apdu_len += len;
                /* tag 1 - propertyArrayIndex OPTIONAL */
                if (value.propertyArrayIndex != BacnetConst.BACNET_ARRAY_ALL)
                {
                    len =
                        BasicalProcessor.Encode_Context_Unsigned(ref apdu, 1,
                                                                 (uint)value.propertyArrayIndex, apdu_len);
                    apdu_len += len;
                }
                /* tag 2 - value */
                len       = BasicalProcessor.Encode_Opening_Tag(ref apdu, 2, pos + apdu_len);
                apdu_len += len;
                len       = BasicalProcessor.Encode_Application_Data(ref apdu, ref value.value, apdu_len + pos);
                apdu_len += len;
                len       = BasicalProcessor.Encode_Closing_Tag(ref apdu, 2, apdu_len + pos);
                apdu_len += len;
                /* tag 3 - priority OPTIONAL */
                if (value.priority != 0)
                {
                    len =
                        BasicalProcessor.Encode_Context_Unsigned(ref apdu, 3, value.priority, apdu_len);
                    apdu_len += len;
                }
            }

            len       = BasicalProcessor.Encode_Closing_Tag(ref apdu, 4, pos + apdu_len);
            apdu_len += len;

            return(apdu_len);
        }
예제 #2
0
        public int Device_Read_Property(ref Byte[] apdu, ref BACnet_Read_Property_Data rpdata, int pos)
        {
            int len = 0;
            BACNET_APPLICATION_DATA_VALUE value = new BACNET_APPLICATION_DATA_VALUE();

            value.context_specific = false;
            switch (rpdata.object_property)
            {
            case BACNET_PROPERTY_ID.PROP_LIFT_Car_Direction:
            {
                value.tag = 2;
                value.value.Unsigned_Int = Form_main.true_lift.Car_Direction;
                break;
            }

            case BACNET_PROPERTY_ID.PROP_LIFT_Car_Position:
            {
                value.tag = 2;
                value.value.Unsigned_Int = 4;
                break;
            }

            case BACNET_PROPERTY_ID.PROP_LIFT_Device_Identifer:
            {
                value.tag = (Byte)BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_CHARACTER_STRING;
                for (int i = 0; i < Form_main.lift_count; i++)
                {
                    if (Form_main.lift_list[i].Object_Identifier.instance == rpdata.object_instance)
                    {
                        String result = Form_main.lift_list[i].Identification_Number;

                        value.value.Character_String          = new BACNET_CHARACTER_STRING(result.Length);
                        value.value.Character_String.size     = (uint)result.Length;
                        value.value.Character_String.encoding = 1;
                        value.value.Character_String.value    = result.ToCharArray();
                    }
                }


                break;
            }
            }


            len = BasicalProcessor.Encode_Application_Data(ref apdu, ref value, pos);

            //此处读出属性 加打入编码app类型和值
            //X
            // uint 61
            return(len);
        }