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
这解释了为什么每次重新部署它时都会起作用!谢谢。 –