Ejemplo n.º 1
0
        public override APDUService Decode(BACPacket cm)
        {
            if (cm.hasMore() == true)
            {
                ObjId = (BACVnetObjectIdentifier) new BACVnetObjectIdentifier().Decode(cm, BACVnetVar.CONTEXT_TAG.OBJECT);
            }
            else
            {
                MissReqPar = true;
                return(this);
            }
            if (cm.hasMore() == true)
            {
                PropId = new BACVnetPropertyId().Decode(cm, BACVnetVar.CONTEXT_TAG.ENUM);
            }
            else
            {
                MissReqPar = true;
                return(this);
            }

            // Index of the desired property to read (if requesting the data)
            // If omitted with an array value; returns the entire array list

            if (cm.hasMore() == true)
            {
                if (cm.GetAction() == BACPacket.Action_Type.REQUEST)
                {
                    switch (ObjId.getObjectType())
                    {
                    case BACVnetObjectIdentifier.BACnetObjectType.ANALOG_INPUT:
                    case BACVnetObjectIdentifier.BACnetObjectType.ANALOG_OUTPUT:
                    case BACVnetObjectIdentifier.BACnetObjectType.ANALOG_VALUE:
                        AnyVar = new BACVnetVar().Decode(cm, BACVnetVar.CONTEXT_TAG.REAL);
                        break;

                    case BACVnetObjectIdentifier.BACnetObjectType.BINARY_INPUT:
                    case BACVnetObjectIdentifier.BACnetObjectType.BINARY_OUTPUT:
                    case BACVnetObjectIdentifier.BACnetObjectType.BINARY_VALUE:
                        AnyVar = new BACVnetVar().Decode(cm, BACVnetVar.CONTEXT_TAG.BSTRING);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    AnyVar = new BACVnetVar().Decode(cm);
                }
            }

            return(this);
        }
Ejemplo n.º 2
0
 public override NSDU Decode(BACPacket cm)
 {
     nlm = (Network_Layer_Message)cm.getNextByte();
     while (cm.hasMore() == true)
     {
         nNumbers.Add(new networkNumberID().Decode(cm));
     }
     return(this);
 }
Ejemplo n.º 3
0
 public override NSDU Decode(BACPacket cm)
 {
     nlm = (Network_Layer_Message)cm.getNextByte();
     if (cm.hasMore() == true)
     {
         networkNumber = new byte[2];
         for (int x = 0; x < 2; x++)
         {
             networkNumber[x] = cm.getNextByte();
         }
     }
     return(this);
 }
Ejemplo n.º 4
0
        new public PDU Decode(BACPacket cm)
        {
            cm.getNextByte();
            srvChoise = (BACnetUnconfirmedServiceChoice)cm.getNextByte();

            switch (srvChoise)
            {
            case BACnetUnconfirmedServiceChoice.I_AM:
                //a = new I_AM_Srv_Struct();
                while (cm.hasMore() == true)
                {
                    bv.Add(new BACVnetVar().Decode(cm));
                }
                break;

            case BACnetUnconfirmedServiceChoice.I_HAVE:
                while (cm.hasMore() == true)
                {
                    bv.Add(new BACVnetVar().Decode(cm));
                }
                break;

            case BACnetUnconfirmedServiceChoice.WHO_HAS:
                while (cm.hasMore() == true)
                {
                    bv.Add(new BACVnetVar().Decode(cm));
                }
                break;

            case BACnetUnconfirmedServiceChoice.WHO_IS:
                while (cm.hasMore() == true)
                {
                    bv.Add(new BACVnetVar().Decode(cm, BACVnetVar.CONTEXT_TAG.UINT));
                }
                break;

            case BACnetUnconfirmedServiceChoice.TIMESYNCHRONIZATION:
                while (cm.hasMore() == true)
                {
                    bv.Add(new BACVnetVar().Decode(cm));
                }
                break;

            default:
                while (cm.hasMore() == true)
                {
                    bv.Add(new BACVnetVar().Decode(cm));
                }
                break;
            }

            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);
        }