CEP List as single items (iterate over managed obejects)

半城伤御伤魂 提交于 2019-12-11 09:02:52

问题


in CEP, I can get managed objects as a list, for example with the function "...ManagedObjectByType". After getting the list, I use the AllOf function to filter the list. Now, I would like to put every single Mangaged Object from the list into a new stream ({A,B,C} -> A,B,C), so they are seperated from each other in order to generate for example alarms in the next stage. Unfortunately, I have no clue how I can produce single events (Managed Objects) from a List. Can someone help?

Best, Nico


回答1:


You can do something like this:

create schema Device as ManagedObject;

create schema CollectedDevices(
    devices List
);

create schema SingleDevice(
    device Device
);

insert into CollectedDevices
select
    findAllManagedObjectByFragmentType("c8y_IsDevice") as devices
from pattern[timer:interval(10 seconds)];

insert into SingleDevice
select
    singleDevice as device
from 
    CollectedDevices as devices unidirectional,
    CollectedDevices[devices@type(Device)] as singleDevice;

The last statement will then be triggered for each element int the list.

You can find the esper documentation for the joins here: http://esper.espertech.com/release-5.4.0/esper-reference/html/epl_clauses.html#epl-join



来源:https://stackoverflow.com/questions/50674210/cep-list-as-single-items-iterate-over-managed-obejects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!