0

使用 CEP Proton,我想检查在某个时间间隔内收到的事件,第二个和后续事件的 id 是否包含在第一个事件中的数组类型属性中。假设第一个事件带有名为 group 的属性,它是一个整数数组 (10, 20, 30)。以下事件将带有一个 id,例如 20、25 等。我想检查这些事件的 id 是否包含在第一个事件中包含的属性组中。为此,我在 EPA 中创建了一个条件

ArrayContains(ArrayGet(myevent.group,0),ArrayGet(myevent.id,ArraySize(myevent.id)-1))

但是,当我单击验证时出现错误

Error   Error in  EPA: expression error of undefined    myepa

我做错什么了吗?我不能使用访问属性数组ArrayGet吗?或者可能ArrayContains无法使用的结果ArrayGet

JSON

{"epn":{"events":[{"name":"GupsyContextUpdate","createdDate":"Thu Sep 29 2016","attributes":[{"name":"entityId","type":"String","dimension":0},{"name":"entityType","type":"String","dimension":0,"description":"The cost of this event occurrence. Negative if this is an opportunity"},{"name":"SF","type":"Integer","dimension":0,"description":"Used in case the this event occur within an interval"},{"name":"occupied","type":"Integer","dimension":"0"},{"name":"framecounter","type":"Integer","dimension":"0"},{"name":"RSSI","type":"String","dimension":"0"},{"name":"hwversion","type":"String","dimension":"0"},{"name":"swversion","type":"String","dimension":"0"},{"name":"compassz","type":"String","dimension":"0"},{"name":"MACBS","type":"String","dimension":"0"},{"name":"SNR","type":"String","dimension":"0"},{"name":"devEUI","type":"String","dimension":"0"},{"name":"battery","type":"String","dimension":"0"},{"name":"devicetype","type":"String","dimension":"0"},{"name":"compassx","type":"String","dimension":"0"},{"name":"compassy","type":"String","dimension":"0"},{"name":"compasst","type":"String","dimension":"0"},{"name":"neighbours","type":"String","dimension":"1"},{"name":"timestamp","type":"String","dimension":"0"}]},{"name":"gupsyoutput","createdDate":"Thu Sep 29 2016","attributes":[{"name":"Certainty","type":"Double","defaultValue":"1","dimension":0,"description":"The certainty that this event happen (value between 0 to 1)"},{"name":"OccurrenceTime","type":"Date","dimension":0,"description":"No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters"},{"name":"ExpirationTime","type":"Date","dimension":0},{"name":"Cost","type":"Double","dimension":0,"description":"The cost of this event occurrence. Negative if this is an opportunity"},{"name":"Duration","type":"Double","defaultValue":"0","dimension":0,"description":"Used in case the this event occur within an interval"},{"name":"test","type":"String","dimension":"1"}]}],"epas":[{"name":"gupsyepa","createdDate":"Thu Sep 29 2016","epaType":"Aggregate","context":"gupsyct","inputEvents":[{"name":"GupsyContextUpdate","alias":"gupsyupdate","consumptionPolicy":"Consume","instanceSelectionPolicy":"First"}],"computedVariables":[{"name":"count","aggregationType":"Count","gupsyupdate":"ArrayContains(ArrayGet(gupsyupdate.neighbours,0),ArrayGet(gupsyupdate.id,ArraySize(gupsyupdate.id)-1))"}],"assertion":"count == true","evaluationPolicy":"Immediate","cardinalityPolicy":"Single","internalSegmentation":[],"derivedEvents":[{"name":"gupsyoutput","reportParticipants":false,"expressions":{"Duration":"0","test":"ArrayContains(ArrayGet(gupsyupdate.neighbours,0),ArrayGet(gupsyupdate.devEUI,ArraySize(gupsyupdate.devEUI)-1))"}}]}],"contexts":{"temporal":[{"name":"gupsyct","createdDate":"Thu Sep 29 2016","type":"TemporalInterval","atStartup":false,"neverEnding":false,"initiators":[{"initiatorType":"Event","initiatorPolicy":"Ignore","name":"GupsyContextUpdate"}],"terminators":[{"terminatorType":"RelativeTime","terminationType":"Terminate","relativeTime":"15000"}]}],"segmentation":[],"composite":[]},"consumers":[{"name":"gupsyconsumer","createdDate":"Thu Sep 29 2016","type":"Rest","properties":[{"name":"URL","value":"http://127.0.0.1/ProtonParser/TestEvent2Log.php"},{"name":"contentType","value":"application/xml"},{"name":"formatter","value":"xml"},{"name":"delimiter","value":";"},{"name":"tagDataSeparator","value":"="},{"name":"dateFormat","value":"dd/MM/yyyy-HH:mm:ss"}],"events":[{"name":"gupsyoutput"}]}],"producers":[],"name":"gupsy"}}
4

2 回答 2

1

请分享您的应用程序的整个 JSON 定义。

根据您提供的信息,不清楚它是哪种类型的 EPA(要访问一系列事件,您需要有状态的 EPA,并且您需要确保以能够区分第一次和随后的事件)。

此外,不清楚为什么您尝试在表达式的两个部分中访问相同的事件实例 - myevent。

ArrayContains 接收 (array, value) 作为操作数。你传递它(值,值),并且假设“myevent.id”也是一个数组,从你的描述中我理解它不是?

无论如何,我看到你的表达有很多潜在的问题,因此我希望看到整个 JSON,或者至少是与“myepa”EPA 相关的部分。

于 2016-10-06T07:11:20.577 回答
0

我查看了 JSON 应用程序,存在多个问题: 1)您使用聚合类型的 EPA 来计算 COUNT。Count 用于计数事件。它是一个整数变量。不能为其分配任何布尔值。因此,比较表达式如“count == true”或布尔值的分配,如:“count : ArrayContains(ArrayGet(gupsyupdate.neighbours,0),ArrayGet(gupsyupdate.id,ArraySize(gupsyupdate.id)-1))”不是有效的。

2)另外,假设您在某处使用此表达式,而不是在计数变量中:-gupsyupdate 事件没有属性“id”,因此您不能在表达式中使用它。-ArrayGet(gupsyupdate.neighbours,0) - 将返回数组中的单个对象...所以你不能在应该接收数组的 ArrayContains 表达式中使用它

3) EPA 的策略没有意义......它是一个聚合 EPA,但是您将其与“立即”的评估策略和基数策略“单一”一起使用。这意味着该 EPA 将只被评估一次,即在它收到第一个 gupsyupdate 事件时立即进行评估。所以它不会真正充当聚合器....

请根据此输入修改您的申请。

于 2016-10-20T08:03:50.323 回答