⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sourceserializerimpl.java

📁 关于 RFID 读写器的相关内容
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#setObservedThreshold(int)
	 */
	public String setObservedThreshold(int threshold) {
		resetCommand();
		SourceCommand.SetObservedThreshold t = cmdFactory
				.createSourceCommandSetObservedThreshold();
		t.setThreshold(threshold);
		srcCommand.setSetObservedThreshold(t);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#getObservedTimeout()
	 */
	public String getObservedTimeout() {
		resetCommand();
		srcCommand.setGetObservedTimeout(cmdFactory.createNoParamType());
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#setObservedTimeout(int)
	 */
	public String setObservedTimeout(int timeout) {
		resetCommand();
		SourceCommand.SetObservedTimeout t = cmdFactory
				.createSourceCommandSetObservedTimeout();
		t.setTimeout(timeout);
		srcCommand.setSetObservedTimeout(t);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#getLostTimeout()
	 */
	public String getLostTimeout() {
		resetCommand();
		srcCommand.setGetLostTimeout(cmdFactory.createNoParamType());
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#setLostTimeout(int)
	 */
	public String setLostTimeout(int timeout) {
		resetCommand();
		SourceCommand.SetLostTimeout t = cmdFactory
				.createSourceCommandSetLostTimeout();
		t.setTimeout(timeout);
		srcCommand.setSetLostTimeout(t);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#rawReadIDs(org.fosstrak.reader.testclient.command.DataSelectorSerializer)
	 */
	public String rawReadIDs(DataSelector dataSelector) {
		resetCommand();
		SourceCommand.RawReadIDs r = cmdFactory
				.createSourceCommandRawReadIDs();
		// Set DataSelector if optional parameter is available
		if (dataSelector != null) {
			r.setDataSelector(dataSelector.getName());
		}
		srcCommand.setRawReadIDs(r);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#readIDs(org.fosstrak.reader.testclient.command.DataSelectorSerializer)
	 */
	public String readIDs(DataSelector dataSelector) {
		resetCommand();
		SourceCommand.ReadIDs r = cmdFactory
				.createSourceCommandReadIDs();
		// Set DataSelector if optional parameter is available
		if (dataSelector != null) {
			r.setDataSelector(dataSelector.getName());
		}
		srcCommand.setReadIDs(r);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#read(org.fosstrak.reader.testclient.command.DataSelectorSerializer,
	 *      java.util.Hashtable)
	 */
	public String read(DataSelector dataSelector, Hashtable passwords) {
		resetCommand();
		SourceCommand.Read r = cmdFactory.createSourceCommandRead();

		// Set DataSelector if optional parameter is available
		if (dataSelector != null) {
			r.setDataSelector(dataSelector.getName());
		}

		// TODO: @Markus: passwords sollte keine Hashtable sein
		// Convert Hashtable into String[]
		String[] strPasswords;
		if (passwords != null) {
			strPasswords = new String[passwords.size()];
			Iterator it = passwords.values().iterator();
			int index = 0;
			while (it.hasNext()) {
				String s = (String) it.next();
				strPasswords[index] = s;
				index++;
			}
		} else {
			strPasswords = new String[0];
		}

		// Set passwords if optional parameter is available
		if (passwords != null) {
			HexStringListType.List list = cmdFactory
					.createHexStringListTypeList();
			HexStringListType listType = cmdFactory
					.createHexStringListType();
			list.getValue().addAll(toHexStringList(strPasswords));
			listType.setList(list);
			r.setPasswords(listType);
		}

		srcCommand.setRead(r);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#writeID(java.lang.String,
	 *      java.lang.String[], org.fosstrak.reader.TagSelector[])
	 */
	public String writeID(String newID, String[] passwords,
			TagSelector[] tagSelectors) {
		resetCommand();
		SourceCommand.WriteID w = cmdFactory
				.createSourceCommandWriteID();
		w.setId(HexUtil.hexToByteArray(newID));

		// Set selectors if optional parameter is available
		if (tagSelectors != null) {
			TagSelectorListParamType.List list = cmdFactory
					.createTagSelectorListParamTypeList();
			TagSelectorListParamType listType = cmdFactory
					.createTagSelectorListParamType();
			list.getValue().addAll(toStringList(tagSelectors));
			listType.setList(list);
			w.setSelectors(listType);
		}

		// Set passwords if optional parameter is available
		if (passwords != null) {
			HexStringListType.List list = cmdFactory
					.createHexStringListTypeList();
			HexStringListType listType = cmdFactory
					.createHexStringListType();
			list.getValue().addAll(toHexStringList(passwords));
			listType.setList(list);
			w.setPasswords(listType);
		}

		srcCommand.setWriteID(w);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#write(org.fosstrak.reader.TagFieldValue[],
	 *      java.lang.String[], org.fosstrak.reader.TagSelector[])
	 */
	public String write(TagFieldValue[] tagFieldValues, String[] passwords,
			TagSelector[] tagSelectors) {
		resetCommand();
		try {
			SourceCommand.Write w = cmdFactory
					.createSourceCommandWrite();
			// Set data
			TagFieldValueListParamType.List tfList = cmdFactory
					.createTagFieldValueListParamTypeList();
			TagFieldValueListParamType tfListType = cmdFactory
					.createTagFieldValueListParamType();
			tfList.getValue().addAll(toTagFieldValueList(tagFieldValues));
			tfListType.setList(tfList);
			w.setData(tfListType);

			// Set Selectors if optional parameter is available
			if (tagSelectors != null) {
				TagSelectorListParamType.List list = cmdFactory
						.createTagSelectorListParamTypeList();
				TagSelectorListParamType listType = cmdFactory
						.createTagSelectorListParamType();
				list.getValue().addAll(toStringList(tagSelectors));
				listType.setList(list);
				w.setSelectors(listType);
			}
			// Set passwords if optional parameter available
			if (passwords != null) {
				HexStringListType.List list = cmdFactory
						.createHexStringListTypeList();
				HexStringListType listType = cmdFactory
						.createHexStringListType();
				list.getValue().addAll(toHexStringList(passwords));
				listType.setList(list);
				w.setPasswords(listType);
			}

			srcCommand.setWrite(w);
			return serializeCommand();
		} catch (JAXBException e) {
			e.printStackTrace();
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#kill(java.lang.String[],
	 *      org.fosstrak.reader.TagSelector[])
	 */
	public String kill(String[] passwords, TagSelector[] tagSelectors) {
		resetCommand();
		SourceCommand.Kill k = cmdFactory.createSourceCommandKill();

		// Set Selectors if optional parameter is available
		if (tagSelectors != null) {
			TagSelectorListParamType.List list = cmdFactory
					.createTagSelectorListParamTypeList();
			TagSelectorListParamType listType = cmdFactory
					.createTagSelectorListParamType();
			list.getValue().addAll(toStringList(tagSelectors));
			listType.setList(list);
			k.setSelectors(listType);
		}
		// Set passwords if optional parameter available
		if (passwords != null) {
			HexStringListType.List list = cmdFactory
					.createHexStringListTypeList();
			HexStringListType listType = cmdFactory
					.createHexStringListType();
			list.getValue().addAll(toHexStringList(passwords));
			listType.setList(list);
			k.setPasswords(listType);
		}

		srcCommand.setKill(k);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#getReadCyclesPerTrigger()
	 */
	public String getReadCyclesPerTrigger() {
		resetCommand();
		srcCommand.setGetReadCyclesPerTrigger(cmdFactory.createNoParamType());
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#setReadCyclesPerTrigger(int)
	 */
	public String setReadCyclesPerTrigger(int cycles) {
		resetCommand();
		SourceCommand.SetReadCyclesPerTrigger c = cmdFactory
				.createSourceCommandSetReadCyclesPerTrigger();
		c.setCycles(cycles);
		srcCommand.setSetReadCyclesPerTrigger(c);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#getMaxReadDutyCycles()
	 */
	public String getMaxReadDutyCycles() {
		resetCommand();
		srcCommand.setGetMaxReadDutyCycle(cmdFactory.createNoParamType());
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#setMaxReadDutyCycles(int)
	 */
	public String setMaxReadDutyCycles(int cycles) {
		resetCommand();
		SourceCommand.SetMaxReadDutyCycle c = cmdFactory
				.createSourceCommandSetMaxReadDutyCycle();
		c.setDutyCycle(cycles);
		srcCommand.setSetMaxReadDutyCycle(c);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#getReadTimeout()
	 */
	public String getReadTimeout() {
		resetCommand();
		srcCommand.setGetReadTimeout(cmdFactory.createNoParamType());
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#setReadTimeout(int)
	 */
	public String setReadTimeout(int timeout) {
		resetCommand();
		SourceCommand.SetReadTimeout t = cmdFactory
				.createSourceCommandSetReadTimeout();
		t.setTimeout(timeout);
		srcCommand.setSetReadTimeout(t);
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#getSession()
	 */
	public String getSession() {
		resetCommand();
		srcCommand.setGetSession(cmdFactory.createNoParamType());
		return serializeCommand();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.fosstrak.reader.testclient.command.SourceSerializer#setSession(int)
	 */
	public String setSession(int session) {
		resetCommand();
		SourceCommand.SetSession s = cmdFactory
				.createSourceCommandSetSession();
		s.setSession(session);
		srcCommand.setSetSession(s);
		return serializeCommand();
	}

	/**
	 * Serializes an Source command.
	 */
	public String serializeCommand() {
		command.setSource(srcCommand);
		return super.serializeCommand();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -