コード例 #1
0
        public static int Encode_Bitstring(ref Byte[] apdu, ref BACNET_BIT_STRING bit_string, int pos)
        {
            int  len = 0;
            Byte remaining_used_bits = 0;
            Byte used_bytes          = 0;
            Byte i = 0;

            if (bit_string.bits_used == 0)
            {
                apdu[pos] = 0;
                len++;
            }
            else
            {
                used_bytes          = bit_string.bytes_used();
                remaining_used_bits = (Byte)(bit_string.bits_used - ((used_bytes -
                                                                      1) * 8));
                apdu[pos + len++] = (Byte)(8 - remaining_used_bits);
                for (i = 0; i < used_bytes; i++)
                {
                    apdu[pos + len++] = bit_string.byte_reverse_bits(bit_string.bitstring_octet(i));
                }
            }
            return(len);
        }
コード例 #2
0
        public static int Encode_Context_Bitstring(ref Byte[] apdu, Byte tag_number, ref BACNET_BIT_STRING bit_string, int pos)
        {
            int    len = 0;
            UInt32 bit_string_encoded_length = 1;

            bit_string_encoded_length += bit_string.bytes_used();
            len  = Encode_Tag(ref apdu, tag_number, true, bit_string_encoded_length, pos + len);
            len += Encode_Bitstring(ref apdu, ref bit_string, pos + len);


            return(len);
        }