public static int Encode_Application_Data(ref Byte[] apdu, ref BACNET_APPLICATION_DATA_VALUE value, int pos)
        {
            int apdu_len = 0;

            switch (value.tag)
            {
            case (Byte)BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_UNSIGNED_INT:
            {
                apdu_len  = BasicalProcessor.Encode_Unsigned(ref apdu, value.value.Unsigned_Int, pos + 1);
                apdu_len += BasicalProcessor.Encode_Tag(ref apdu, (Byte)BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_UNSIGNED_INT, false, (uint)apdu_len, pos);

                break;
            }

            case (Byte)BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_BOOLEAN:
            {
                apdu_len += BasicalProcessor.Encode_Application_Boolbean(ref apdu, value.value.Boolean, pos);
                break;
            }

            case (Byte)BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_DATE:
            {
                apdu_len = BasicalProcessor.Encode_Application_Date(ref apdu, ref value.value.Date, pos);

                break;
            }

            case (Byte)BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_TIME:
            {
                apdu_len = BasicalProcessor.Encode_Application_Time(ref apdu, ref value.value.Time, pos);
                break;
            }

            case (Byte)BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_CHARACTER_STRING:
            {
                apdu_len = BasicalProcessor.Encode_Application_Character_String(ref apdu, ref value.value.Character_String, pos);
                break;
            }
            }


            return(apdu_len);
        }