我正在爲我的跟蹤代理中的特定確認消息寫入解析器。在解析時,我想檢索跟蹤器的所有掛起命令/固件更新,以便我可以將它們與確認內容進行比較並更新相關操作,以便它們在QuarkIoE中相應顯示。Cumulocity找到跟蹤器的所有掛起操作
我該怎麼做?例如,也許我可以使用OperationsHelper.getOperationsByStatusAndAgent()?但是,我如何才能訪問此級別的OperationsHelper?
編輯
這是我現在要去嘗試:
TrackerDevice:
public Iterable<OperationRepresentation> getPendingOps() {
OperationFilter opsFilter = new OperationFilter().byStatus(OperationStatus.PENDING)
.byAgent(this.gid.getValue());
return deviceControl.getOperationsByFilter(opsFilter).get().allPages();
}
我自定義分析器:
TrackerDevice trackerDevice = trackerAgent.getOrCreateTrackerDevice(reportCtx.getEntry(POS_IMEI));
// Looking into pending operations...
for (OperationRepresentation operation: trackerDevice.getPendingOps()) {
Firmware frm = operation.get(Firmware.class);
// ...for firmware updates
if (frm != null) {
String command = (String) frm.getProperty("command");
// (GL200Fallback associated a command string to these)
if (command != null) {
Matcher m = commandPattern.matcher(command);
// In each command there is a random count number...
if (m.find()) {
String cmdCountNumber = command.substring(m.start(), m.end());
// ...that must match with the acknowledgement's
if (cmdCountNumber.equals(reportCtx.getEntry(POS_COUNT_NUMBER))) {
trackerDevice.setOperationSuccessful(operation);
return true;
}
}
}
}
}
你能說出這個類的OperationsHelper來自哪裏嗎?我無法在跟蹤代理或通用Java客戶端中找到它。 – TyrManuZ
/tracker-agent/src/main/java/c8y/trackeragent/operations/OperationsHelper.java –
好吧,它已被更名爲OperationExecutor在較新的版本,但一般功能仍然是相同的 – TyrManuZ