0
我想使用事件處理功能來創建派生測量。實時處理 - 讀取受管理對象片段
我們的設備報告了一個測量結果,該測量結果具有目標值,我們將其存儲在每個設備中的受管理對象片段中。我想創建一個設備測量,它是測量和目標之間的差異,它似乎是RTP/CEL實現的理想候選者。
我已經看過real time processing指南,但無法完全弄清楚如何從管理對象中讀取片段。
編輯。我更新了我的代碼,並且即將到達那裏,我無法弄清楚如何使用來自測量的傳入deviceId作爲獲取我的分段數據的地方。
create variable ManagedObject device = findManagedObjectById(m.measurement.source.value);
create variable BigDecimal setpoint = getNumber(device, "uty_Setpoint.value");
insert into CreateMeasurement
select
m.measurement.time as time,
m.measurement.source.value as source,
"uty_Pressure_delta" as type,
{"uty_Pressure_delta.T.value", getNumber(m, "uty_Pressure.pressure.value") - setpoint,
"uty_Pressure_delta.T.unit", "percent" } as fragments
from MeasurementCreated m
where getNumber(m, "uty_Pressure.pressure.value") is not null
你應該直接在聲明中做,而不是作爲外部變量。所以用getNumber替換設定點(findManagedObjectById(m.measurement.source.value),「uty_Setpoint.value」) 編輯:背景是像聲明它們的變量在部署語句時得到解決(這不會工作,因爲m .measurement.source.value無法解析) – TyrManuZ
這解釋了爲什麼每次重新部署它時都會起作用!謝謝。 –