2016-09-29 31 views
0

使用CEP质子我想检查在一个时间间隔内接收到的事件,第二个和后续事件的ID是否包含在第一个事件中的类型数组的属性中。比方说,第一个事件是由称为组的整数属性(10,20,30)的属性组成的。以下事件将带有一个ID,例如20,25等。我想检查这些事件的ID是否包含在第一个事件中包含的属性组中。 对于我在EPAEPA CEP质子内的阵列条件

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"}} 
+0

请添加标签“fiware-cep”。 – urishani

回答

1

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

根据您提供的信息,不清楚它是哪种类型的EPA(要访问一系列事件,您需要有状态的EPA,并且您需要确保以这种方式编写应用程序以便能够区分第一个和后续事件)。

此外,还不清楚为什么您尝试访问表达式的两个部分中的相同事件实例myevent。 (数组,值)作为操作数。 你通过它(价值,价值),这就是假设“myevent.id”也是一个数组,从你的描述我明白它不是?

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

0

我回顾了JSON应用程序,存在多个问题: 1)您正在使用类型为aggregate的EPA来计算COUNT。伯爵是为了计数事件。它是一个整数变量。没有布尔值可以分配给它。 因此比较表达式如“count == true” 或布尔值的分配如:“count:ArrayContains(ArrayGet(gupsyupdate.neighbours,0),ArrayGet(gupsyupdate.id,ArraySize(gupsyupdate.id)-1))” 无效。 2)此外,假设您在某处使用此表达式,而不是在count变量中: -gupsyupdate事件没有属性“id”,因此您不能在表达式中使用此表达式。 -ArrayGet(gupsyupdate.neighbours,0) - 将返回一个数组中的单个对象...因此,您不能在ArrayContains表达式中使用它,该表达式应该接收数组

3)EPA的策略不会'没有道理......这是一个聚合EPA,但你可以使用评估政策“立即”和基数政策“单一”。这意味着这个环保局只会在收到第一个Gupsyupdate事件时立即评估一次。所以它不会真正充当聚合器......

请根据此输入修改您的应用程序。