public virtual BACVnetVar Decode(BACPacket cm, CONTEXT_TAG ct)
        {
            byte a = cm.getNextByte();

            classType = DecodeClass(a);
            length    = DecodeLenValType(a);

            switch (ct)
            {
            case CONTEXT_TAG.NULL:
                return(new BACVnetNull().Decode(cm));

            case CONTEXT_TAG.BOOLEAN:
                return(new BACVnetBoolean().Decode(cm));

            case CONTEXT_TAG.INT:
                return(new BACVnetInt().Decode(cm, length));

            case CONTEXT_TAG.UINT:
                return(new BACVnetUInt().Decode(cm, length));

            case CONTEXT_TAG.REAL:
                return(new BACVnetReal().Decode(cm, length));

            case CONTEXT_TAG.DOUBLE:
                return(new BACVnetDouble().Decode(cm, length));

            case CONTEXT_TAG.BSTRING:
                return(new BACVnetBString().Decode(cm, length));

            case CONTEXT_TAG.CSTRING:
                return(new BACVnetCString().Decode(cm, length));

            case CONTEXT_TAG.OSTRING:
                return(new BACVnetOString().Decode(cm, length));

            case CONTEXT_TAG.DATE:
                return(new BACVnetDate().Decode(cm, length));

            case CONTEXT_TAG.TIME:
                return(new BACVnetTime().Decode(cm, length));

            case CONTEXT_TAG.ENUM:     // 20.2.11 Encoding of an Enumerated Value; pg 1496
                return(new BACVnetEnum().Decode(cm, length));

            case CONTEXT_TAG.OBJECT:
                return(new BACVnetObjectIdentifier().Decode(cm, length));
            }
            return(this);
        }
        public virtual BACVnetVar Decode(BACPacket cm)
        {
            byte tag = cm.getByte();

            switch (DecodeClass(tag))
            {
            case CLASS.APPLICATION:
                CONTEXT_TAG ct = (CONTEXT_TAG)(cm.getByte() >> 4);
                return(Decode(cm, ct));

            case CLASS.CONTEXT:
                // IF this is an Openning Tag
                if ((tag & 0x0F) == 0x0E)
                {
                    BACVnetConstructed constr = new BACVnetConstructed();
                    cm.getNextByte();
                    while (cm.hasMore() == true)
                    {
                        tag = cm.getByte();
                        // IF this is the closing Tag
                        if ((tag & 0x0F) == 0x0F)
                        {
                            cm.getNextByte();
                            break;
                        }
                        BACVnetVar vn = new BACVnetVar().Decode(cm);
                        constr.AddVar(vn);
                        //constr.AddVar(cm.getNextByte());
                    }
                    return(constr);
                }
                else
                {
                    // This would be an error ??
                    CONTEXT_TAG ct1 = (CONTEXT_TAG)(cm.getByte() >> 4);
                    return(Decode(cm, ct1));
                }

            default:
                break;
            }

            return(this);
        }