/** {@inheritDoc} */ public Content encodeXML(String name, Namespace ns) { // element in namespace defined by parent element Element element = new Element(name, ns); // child element are always in default LLRP namespace ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE); if (opSpecID == null) { LOGGER.warn(" opSpecID not set"); throw new MissingParameterException(" opSpecID not set"); } else { element.addContent(opSpecID.encodeXML("OpSpecID", ns)); } if (accessPassword == null) { LOGGER.warn(" accessPassword not set"); throw new MissingParameterException(" accessPassword not set"); } else { element.addContent(accessPassword.encodeXML("AccessPassword", ns)); } if (mB == null) { LOGGER.warn(" mB not set"); throw new MissingParameterException(" mB not set"); } else { element.addContent(mB.encodeXML("MB", ns)); } // element.addContent(reserved0.encodeXML("reserved",ns)); if (wordPointer == null) { LOGGER.warn(" wordPointer not set"); throw new MissingParameterException(" wordPointer not set"); } else { element.addContent(wordPointer.encodeXML("WordPointer", ns)); } if (wordCount == null) { LOGGER.warn(" wordCount not set"); throw new MissingParameterException(" wordCount not set"); } else { element.addContent(wordCount.encodeXML("WordCount", ns)); } // parameters return element; }
/** {@inheritDoc} */ public LLRPBitList encodeBinarySpecific() { LLRPBitList resultBits = new LLRPBitList(); if (opSpecID == null) { LOGGER.warn(" opSpecID not set"); throw new MissingParameterException( " opSpecID not set for Parameter of Type C1G2BlockErase"); } resultBits.append(opSpecID.encodeBinary()); if (accessPassword == null) { LOGGER.warn(" accessPassword not set"); throw new MissingParameterException( " accessPassword not set for Parameter of Type C1G2BlockErase"); } resultBits.append(accessPassword.encodeBinary()); if (mB == null) { LOGGER.warn(" mB not set"); throw new MissingParameterException(" mB not set for Parameter of Type C1G2BlockErase"); } resultBits.append(mB.encodeBinary()); resultBits.append(reserved0.encodeBinary()); if (wordPointer == null) { LOGGER.warn(" wordPointer not set"); throw new MissingParameterException( " wordPointer not set for Parameter of Type C1G2BlockErase"); } resultBits.append(wordPointer.encodeBinary()); if (wordCount == null) { LOGGER.warn(" wordCount not set"); throw new MissingParameterException( " wordCount not set for Parameter of Type C1G2BlockErase"); } resultBits.append(wordCount.encodeBinary()); return resultBits; }
/** {@inheritDoc} */ protected void decodeBinarySpecific(LLRPBitList binary) { int position = 0; int tempByteLength; int tempLength = 0; int count; SignedShort type; int fieldCount; Custom custom; opSpecID = new UnsignedShort(binary.subList(position, UnsignedShort.length())); position += UnsignedShort.length(); accessPassword = new UnsignedInteger(binary.subList(position, UnsignedInteger.length())); position += UnsignedInteger.length(); mB = new TwoBitField(binary.subList(position, TwoBitField.length())); position += TwoBitField.length(); position += reserved0.length(); wordPointer = new UnsignedShort(binary.subList(position, UnsignedShort.length())); position += UnsignedShort.length(); wordCount = new UnsignedShort(binary.subList(position, UnsignedShort.length())); position += UnsignedShort.length(); }
/** {@inheritDoc} */ protected void decodeBinarySpecific(LLRPBitList binary) throws InvalidLLRPMessageException { int position = 0; int tempByteLength; int tempLength = 0; int count; SignedShort type; int fieldCount; Custom custom; resetToFactoryDefault = new Bit(binary.subList(position, Bit.length())); position += Bit.length(); position += reserved0.length(); // look ahead to see type // may be optional or exactly once type = null; tempByteLength = 0; tempLength = 0; try { // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } } catch (IllegalArgumentException le) { // if an IllegalArgumentException is thrown, list was not long enough so the parameter is // missing LOGGER.info( "SET_READER_CONFIG misses optional parameter of type ReaderEventNotificationSpec"); } if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = readerEventNotificationSpec.length(); } if ((type != null) && type.equals(ReaderEventNotificationSpec.TYPENUM)) { readerEventNotificationSpec = new ReaderEventNotificationSpec(binary.subList(position, tempLength)); position += tempLength; LOGGER.debug( " readerEventNotificationSpec is instantiated with ReaderEventNotificationSpec with length" + tempLength); } else { LOGGER.info( "SET_READER_CONFIG misses optional parameter of type ReaderEventNotificationSpec"); } // list of parameters antennaPropertiesList = new LinkedList<AntennaProperties>(); LOGGER.debug("decoding parameter antennaPropertiesList "); while (position < binary.length()) { // store if one parameter matched boolean atLeastOnce = false; // look ahead to see type // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } // add parameter to list if type number matches if ((type != null) && type.equals(AntennaProperties.TYPENUM)) { // if first bit is 1 it is a TV Parameter if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = AntennaProperties.length(); } antennaPropertiesList.add(new AntennaProperties(binary.subList(position, tempLength))); LOGGER.debug("adding AntennaProperties to antennaPropertiesList "); atLeastOnce = true; position += tempLength; } if (!atLeastOnce) { // no parameter matched therefore we jump out of the loop break; } } // if list is still empty no parameter matched if (antennaPropertiesList.isEmpty()) { LOGGER.info("encoded message does not contain parameter for optional antennaPropertiesList"); } // list of parameters antennaConfigurationList = new LinkedList<AntennaConfiguration>(); LOGGER.debug("decoding parameter antennaConfigurationList "); while (position < binary.length()) { // store if one parameter matched boolean atLeastOnce = false; // look ahead to see type // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } // add parameter to list if type number matches if ((type != null) && type.equals(AntennaConfiguration.TYPENUM)) { // if first bit is 1 it is a TV Parameter if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = AntennaConfiguration.length(); } antennaConfigurationList.add( new AntennaConfiguration(binary.subList(position, tempLength))); LOGGER.debug("adding AntennaConfiguration to antennaConfigurationList "); atLeastOnce = true; position += tempLength; } if (!atLeastOnce) { // no parameter matched therefore we jump out of the loop break; } } // if list is still empty no parameter matched if (antennaConfigurationList.isEmpty()) { LOGGER.info( "encoded message does not contain parameter for optional antennaConfigurationList"); } // look ahead to see type // may be optional or exactly once type = null; tempByteLength = 0; tempLength = 0; try { // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } } catch (IllegalArgumentException le) { // if an IllegalArgumentException is thrown, list was not long enough so the parameter is // missing LOGGER.info("SET_READER_CONFIG misses optional parameter of type ROReportSpec"); } if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = rOReportSpec.length(); } if ((type != null) && type.equals(ROReportSpec.TYPENUM)) { rOReportSpec = new ROReportSpec(binary.subList(position, tempLength)); position += tempLength; LOGGER.debug(" rOReportSpec is instantiated with ROReportSpec with length" + tempLength); } else { LOGGER.info("SET_READER_CONFIG misses optional parameter of type ROReportSpec"); } // look ahead to see type // may be optional or exactly once type = null; tempByteLength = 0; tempLength = 0; try { // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } } catch (IllegalArgumentException le) { // if an IllegalArgumentException is thrown, list was not long enough so the parameter is // missing LOGGER.info("SET_READER_CONFIG misses optional parameter of type AccessReportSpec"); } if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = accessReportSpec.length(); } if ((type != null) && type.equals(AccessReportSpec.TYPENUM)) { accessReportSpec = new AccessReportSpec(binary.subList(position, tempLength)); position += tempLength; LOGGER.debug( " accessReportSpec is instantiated with AccessReportSpec with length" + tempLength); } else { LOGGER.info("SET_READER_CONFIG misses optional parameter of type AccessReportSpec"); } // look ahead to see type // may be optional or exactly once type = null; tempByteLength = 0; tempLength = 0; try { // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } } catch (IllegalArgumentException le) { // if an IllegalArgumentException is thrown, list was not long enough so the parameter is // missing LOGGER.info("SET_READER_CONFIG misses optional parameter of type KeepaliveSpec"); } if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = keepaliveSpec.length(); } if ((type != null) && type.equals(KeepaliveSpec.TYPENUM)) { keepaliveSpec = new KeepaliveSpec(binary.subList(position, tempLength)); position += tempLength; LOGGER.debug(" keepaliveSpec is instantiated with KeepaliveSpec with length" + tempLength); } else { LOGGER.info("SET_READER_CONFIG misses optional parameter of type KeepaliveSpec"); } // list of parameters gPOWriteDataList = new LinkedList<GPOWriteData>(); LOGGER.debug("decoding parameter gPOWriteDataList "); while (position < binary.length()) { // store if one parameter matched boolean atLeastOnce = false; // look ahead to see type // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } // add parameter to list if type number matches if ((type != null) && type.equals(GPOWriteData.TYPENUM)) { // if first bit is 1 it is a TV Parameter if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = GPOWriteData.length(); } gPOWriteDataList.add(new GPOWriteData(binary.subList(position, tempLength))); LOGGER.debug("adding GPOWriteData to gPOWriteDataList "); atLeastOnce = true; position += tempLength; } if (!atLeastOnce) { // no parameter matched therefore we jump out of the loop break; } } // if list is still empty no parameter matched if (gPOWriteDataList.isEmpty()) { LOGGER.info("encoded message does not contain parameter for optional gPOWriteDataList"); } // list of parameters gPIPortCurrentStateList = new LinkedList<GPIPortCurrentState>(); LOGGER.debug("decoding parameter gPIPortCurrentStateList "); while (position < binary.length()) { // store if one parameter matched boolean atLeastOnce = false; // look ahead to see type // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } // add parameter to list if type number matches if ((type != null) && type.equals(GPIPortCurrentState.TYPENUM)) { // if first bit is 1 it is a TV Parameter if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = GPIPortCurrentState.length(); } gPIPortCurrentStateList.add(new GPIPortCurrentState(binary.subList(position, tempLength))); LOGGER.debug("adding GPIPortCurrentState to gPIPortCurrentStateList "); atLeastOnce = true; position += tempLength; } if (!atLeastOnce) { // no parameter matched therefore we jump out of the loop break; } } // if list is still empty no parameter matched if (gPIPortCurrentStateList.isEmpty()) { LOGGER.info( "encoded message does not contain parameter for optional gPIPortCurrentStateList"); } // look ahead to see type // may be optional or exactly once type = null; tempByteLength = 0; tempLength = 0; try { // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } } catch (IllegalArgumentException le) { // if an IllegalArgumentException is thrown, list was not long enough so the parameter is // missing LOGGER.info("SET_READER_CONFIG misses optional parameter of type EventsAndReports"); } if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = eventsAndReports.length(); } if ((type != null) && type.equals(EventsAndReports.TYPENUM)) { eventsAndReports = new EventsAndReports(binary.subList(position, tempLength)); position += tempLength; LOGGER.debug( " eventsAndReports is instantiated with EventsAndReports with length" + tempLength); } else { LOGGER.info("SET_READER_CONFIG misses optional parameter of type EventsAndReports"); } // list of parameters customList = new LinkedList<Custom>(); LOGGER.debug("decoding parameter customList "); while (position < binary.length()) { // store if one parameter matched boolean atLeastOnce = false; // look ahead to see type // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } // custom if ((type != null) && type.equals(Custom.TYPENUM)) { Custom cus = new Custom(binary.subList(position, tempLength)); // allowed custom parameters for this parameter // end allowed parameters // if none matched continue wasn't called and we add just cus as we found no specific vendor // implementation customList.add(cus); position += tempLength; atLeastOnce = true; } if (!atLeastOnce) { // no parameter matched therefore we jump out of the loop break; } } // if list is still empty no parameter matched if (customList.isEmpty()) { LOGGER.info("encoded message does not contain parameter for optional customList"); } }
/** {@inheritDoc} */ protected void decodeBinarySpecific(LLRPBitList binary) throws InvalidLLRPMessageException { int position = 0; int tempByteLength; int tempLength = 0; int count; SignedShort type; int fieldCount; Custom custom; // look ahead to see type // may be optional or exactly once type = null; tempByteLength = 0; tempLength = 0; try { // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } } catch (IllegalArgumentException le) { // if an IllegalArgumentException is thrown, list was not long enough so the parameter is // missing LOGGER.warn("GET_ACCESSSPECS_RESPONSE misses non optional parameter of type LLRPStatus"); throw new InvalidLLRPMessageException( "GET_ACCESSSPECS_RESPONSE misses non optional parameter of type LLRPStatus"); } if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = lLRPStatus.length(); } if ((type != null) && type.equals(LLRPStatus.TYPENUM)) { lLRPStatus = new LLRPStatus(binary.subList(position, tempLength)); position += tempLength; LOGGER.debug(" lLRPStatus is instantiated with LLRPStatus with length" + tempLength); } else { LOGGER.warn("GET_ACCESSSPECS_RESPONSE misses non optional parameter of type LLRPStatus"); throw new InvalidLLRPMessageException( "GET_ACCESSSPECS_RESPONSE misses non optional parameter of type LLRPStatus"); } // list of parameters accessSpecList = new LinkedList<AccessSpec>(); LOGGER.debug("decoding parameter accessSpecList "); while (position < binary.length()) { // store if one parameter matched boolean atLeastOnce = false; // look ahead to see type // if first bit is one it is a TV Parameter if (binary.get(position)) { // do not take the first bit as it is always 1 type = new SignedShort(binary.subList(position + 1, 7)); } else { type = new SignedShort(binary.subList(position + RESERVEDLENGTH, TYPENUMBERLENGTH)); tempByteLength = new UnsignedShort( binary.subList( position + RESERVEDLENGTH + TYPENUMBERLENGTH, UnsignedShort.length())) .toShort(); tempLength = 8 * tempByteLength; } // add parameter to list if type number matches if ((type != null) && type.equals(AccessSpec.TYPENUM)) { // if first bit is 1 it is a TV Parameter if (binary.get(position)) { // length can statically be determined for TV Parameters tempLength = AccessSpec.length(); } accessSpecList.add(new AccessSpec(binary.subList(position, tempLength))); LOGGER.debug("adding AccessSpec to accessSpecList "); atLeastOnce = true; position += tempLength; } if (!atLeastOnce) { // no parameter matched therefore we jump out of the loop break; } } // if list is still empty no parameter matched if (accessSpecList.isEmpty()) { LOGGER.info("encoded message does not contain parameter for optional accessSpecList"); } }