📄 commanddispatcher.java
字号:
reply.setRawReadIDs(rawReadTypeReturn);
}
else if (command.getReadIDs() != null) {
log.debug("Calling Source.readIDs()");
ReadReport report;
// Check if the optional parameter dataSelector is set
DataSelector ds = null;
if (command.getReadIDs().getDataSelector() != null
&& !command.getReadIDs().getDataSelector().equals(
"null")) {
ds = readerDevice.getDataSelector(command.getReadIDs()
.getDataSelector());
} else {
ds = readerDevice.getCurrentDataSelector();
}
report = source.readIDs(ds);
ReadIDs readIDReturn = replyFactory
.createSourceReplyReadIDs();
ReadReportType reportReply = createReadReportReply(report,
ds);
readIDReturn.setReturnValue(reportReply);
reply.setReadIDs(readIDReturn);
}
else if (command.getRead() != null) {
log.debug("Calling Source.read()");
ReadReport report = null;
// Check if the optional parameter dataSelector is set
DataSelector ds = null;
if (command.getRead().getDataSelector() != null
&& !command.getRead().getDataSelector().equals(
"null")) {
ds = readerDevice.getDataSelector(command.getRead()
.getDataSelector());
/*
* TODO: passwords currently not implemented in the HAL -
* set passwords to null
*/
} else {
ds = readerDevice.getCurrentDataSelector();
}
report = source.read(ds, null);
SourceReply.Read readReturn = replyFactory
.createSourceReplyRead();
ReadReportType reportReply = createReadReportReply(report,
ds);
readReturn.setReturnValue(reportReply);
reply.setRead(readReturn);
}
else if (command.getWriteID() != null) {
log.debug("Calling Source.writeID()");
String[] passwords = null;
TagSelector[] selectors = null;
if (command.getWriteID().getPasswords() != null) {
passwords = getString(command.getWriteID()
.getPasswords());
}
if (command.getWriteID().getSelectors() != null) {
selectors = getTagSelector(command.getWriteID()
.getSelectors());
}
String id = new String(command.getWriteID().getId());
source.writeID(id, passwords, selectors);
// return void
NoParamType voidType = replyFactory.createNoParamType();
reply.setWriteID(voidType);
}
else if (command.getWrite() != null) {
log.debug("Calling Source.write()");
Write writeCommand = command.getWrite();
String[] passwords = null;
TagSelector[] selectors = null;
TagFieldValue[] tfValues = null;
if (writeCommand.getData() != null) {
tfValues = getTagFieldValue(writeCommand.getData());
}
if (writeCommand.getPasswords() != null) {
passwords = getString(writeCommand.getPasswords());
}
if (writeCommand.getSelectors() != null) {
selectors = getTagSelector(writeCommand.getSelectors());
}
source.write(tfValues, passwords, selectors);
NoParamType voidType = replyFactory.createNoParamType();
reply.setWrite(voidType);
}
else if (command.getKill() != null) {
log.debug("Calling Source.kill()");
Kill killCommand = command.getKill();
String[] passwords = null;
TagSelector[] selectors = null;
if (killCommand.getPasswords() != null) {
passwords = getString(killCommand.getPasswords());
}
if (killCommand.getSelectors() != null) {
selectors = getTagSelector(killCommand.getSelectors());
}
source.kill(passwords, selectors);
// return void
NoParamType voidType = replyFactory.createNoParamType();
reply.setKill(voidType);
}
else if (command.getGetReadCyclesPerTrigger() != null) {
log.debug("Calling Source.getReadCyclesPerTrigger()");
IntReturnType intReturn = replyFactory
.createIntReturnType();
intReturn.setReturnValue(source.getReadCyclesPerTrigger());
reply.setGetReadCyclesPerTrigger(intReturn);
}
else if (command.getSetReadCyclesPerTrigger() != null) {
log.debug("Calling Source.setReadCyclesPerTrigger()");
int readCycles = command.getSetReadCyclesPerTrigger()
.getCycles();
source.setReadCyclesPerTrigger(readCycles);
NoParamType voidType = replyFactory.createNoParamType();
reply.setSetReadCyclesPerTrigger(voidType);
}
else if (command.getGetMaxReadDutyCycle() != null) {
log.debug("Calling Source.getMayReadDutyCycle()");
IntReturnType intReturn = replyFactory
.createIntReturnType();
intReturn.setReturnValue(source.getMaxReadDutyCycles());
reply.setGetMaxReadDutyCycle(intReturn);
}
else if (command.getSetMaxReadDutyCycle() != null) {
log.debug("Calling Source.setMaxReadDutyCycle()");
int dutyCycles = command.getSetMaxReadDutyCycle()
.getDutyCycle();
source.setMaxReadDutyCycles(dutyCycles);
NoParamType voidType = replyFactory.createNoParamType();
reply.setSetMaxReadDutyCycle(voidType);
}
else if (command.getGetReadTimeout() != null) {
log.debug("Calling Source.getReadTimeout()");
IntReturnType intReturn = replyFactory
.createIntReturnType();
intReturn.setReturnValue(source.getReadTimeout());
reply.setGetReadTimeout(intReturn);
}
else if (command.getSetReadTimeout() != null) {
log.debug("Calling Source.setReadTimeout()");
int readTimeout = command.getSetReadTimeout().getTimeout();
source.setReadTimeout(readTimeout);
NoParamType voidType = replyFactory.createNoParamType();
reply.setSetReadTimeout(voidType);
}
else if (command.getGetSession() != null) {
log.debug("Calling Source.getSession() not yet supported.");
// TODO: Fehler in XSD
}
else if (command.getSetSession() != null) {
log.debug("Calling Source.setSession() not yet supported.");
// TODO: Fehler in XSD
}
}
return reply;
} catch (JAXBException e) {
log.error(e);
return null;
}
}
/**
* Executes a command on the ReadPoint object.
*
* @param command
* The command to be executed.
* @param targetName
* The unique identifier (object name) of a
* <code>ReadPoint</code> instance or <code>null</code> if it
* is a static method.
* @param im
* The <code>IncomingMessage</code> that caused this command.
* @return The reply of a command execution.
* @throws ReaderProtocolException
* Exceptions from the Trigger
*/
private ReadPointReply executeCommand(final ReadPointCommand command,
final String targetName, final IncomingMessage im) {
log.debug("Calling a ReaderPoint Command.");
ReadPointReply reply = replyFactory.createReadPointReply();
if (command.getGetName() != null) {
log.debug("Calling ReadPoint.getName()");
StringReturnType stringReturn = replyFactory
.createStringReturnType();
// Irrelevant command, simply return the targetName
stringReturn.setReturnValue(targetName);
reply.setGetName(stringReturn);
}
return reply;
}
/**
* Executes a command on the Trigger object.
*
* @param command
* The command to be executed.
* @param targetName
* The unique identifier (object name) of a <code>Trigger</code>
* instance or <code>null</code> if it is a static method.
* @param im
* The <code>IncomingMessage</code> that caused this command.
* @return The reply of a command execution.
* @throws ReaderProtocolException
* Exceptions from the Trigger
*/
private TriggerReply executeCommand(final TriggerCommand command,
final String targetName, final IncomingMessage im)
throws ReaderProtocolException {
TriggerReply reply = replyFactory.createTriggerReply();
Trigger trigger = null;
log.debug("Calling a Trigger Command.");
if (command.getCreate() != null) {
log.debug("Calling Trigger.create()");
org.fosstrak.reader.rprm.core.msg.command.TriggerCommand.Create createCommand = command
.getCreate();
String name = createCommand.getName();
String triggerTypeName = createCommand.getTriggerType();
String triggerValue = createCommand.getTriggerValue();
trigger = Trigger.create(name, triggerTypeName, triggerValue,
readerDevice);
TriggerReturnType triggerReturn = replyFactory
.createTriggerReturnType();
triggerReturn.setReturnValue(trigger.getName());
reply.setCreate(triggerReturn);
}
else if (command.getGetName() != null) {
log.debug("Calling Trigger.getName()");
StringReturnType stringReturn = replyFactory
.createStringReturnType();
// irrelevant command, simply return the targetName
stringReturn.setReturnValue(targetName);
reply.setGetName(stringReturn);
}
else {
// Check the existence of the target
if (targetName == null) {
throw new ReaderProtocolException(
MessagingConstants.ERROR_TRIGGER_NOT_FOUND_STR,
MessagingConstants.ERROR_TRIGGER_NOT_FOUND);
} else {
trigger = readerDevice.getTrigger(targetName);
}
if (command.getGetMaxNumberSupported() != null) {
log.debug("Calling Trigger.getMaxNumberSupported()");
IntReturnType intReturn = replyFactory
.createIntReturnType();
intReturn.setReturnValue(trigger.getMaxNumberSupported());
reply.setGetMaxNumberSupported(intReturn);
}
else if (command.getGetType() != null) {
log.debug("Calling Trigger.getType()");
TriggerTypeReturnType triggerTypeReturn = replyFactory
.createTriggerTypeReturnType();
triggerTypeReturn.setReturnValue(trigger.getType());
reply.setGetType(triggerTypeReturn);
}
else if (command.getGetValue() != null) {
log.debug("Calling Trigger.getValue()");
TriggerValueReturnType triggerValueReturn = replyFactory
.createTriggerValueReturnType();
triggerValueReturn.setReturnValue(trigger.getValue());
reply.setGetValue(triggerValueReturn);
}
else if (command.getFire() != null) {
log.debug("Calling Trigger.fire()");
trigger.fire();
// return void
NoParamType voidType = replyFactory.createNoParamType();
reply.setFire(voidType);
}
}
return reply;
}
/**
* Executes a command on the TagSelector object.
*
* @param command
* The command to be executed.
* @param targetName
* The unique identifier (object name) of a
* <code>TagSelector</code> instance or <code>null</code> if
* it is a static method.
* @param im
* The <code>IncomingMessage</code> that caused this command.
* @return The reply of a command execution.
* @throws ReaderProtocolException
* Exceptions from the TagSelector
*/
private TagSelectorReply executeCommand(final TagSelectorCommand command,
final String targetName, final IncomingMessage im)
throws ReaderProtoco
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -