public PDU Decode(BACPacket cm) { pduType = (BACnetPDU)(cm.getByte() >> 4); switch (pduType) { case BACnetPDU.PDU_CONFIRMED_REQUEST: pduType = BACnetPDU.PDU_CONFIRMED_REQUEST; cm.SetAction(BACPacket.Action_Type.REQUEST); return(new PDUConfirmedService().Decode(cm)); case BACnetPDU.PDU_UNCONFIRMED_SERVICE_REQUEST: pduType = BACnetPDU.PDU_UNCONFIRMED_SERVICE_REQUEST; cm.SetAction(BACPacket.Action_Type.REQUEST); return(new PDUUnConfirmedService().Decode(cm)); case BACnetPDU.PDU_SIMPLEACK: pduType = BACnetPDU.PDU_SEGMENTACK; cm.SetAction(BACPacket.Action_Type.RESPONSE); return(new PDUSimpleAck().Decode(cm)); case BACnetPDU.PDU_COMPLEXACK: pduType = BACnetPDU.PDU_COMPLEXACK; cm.SetAction(BACPacket.Action_Type.RESPONSE); return(new PDUComplexAck().Decode(cm)); case BACnetPDU.PDU_SEGMENTACK: case BACnetPDU.PDU_ERROR: pduType = BACnetPDU.PDU_ERROR; cm.SetAction(BACPacket.Action_Type.RESPONSE); return(new PDUError().Decode(cm)); case BACnetPDU.PDU_REJECT: pduType = BACnetPDU.PDU_REJECT; cm.SetAction(BACPacket.Action_Type.RESPONSE); return(new PDUReject().Decode(cm)); case BACnetPDU.PDU_ABORT: return(this); } return(this); }