我从Orion收到一个ContextUpdate事件,并设置了一个规则来计算所接收事件的数量,可能在特定时间窗口内使用相同的“entityId”。 在聚合EPA的派生事件中,我希望“DeviceID”属性假定接收事件的“entityId”的值相同。 但是,无论是“Deferred”还是“Immediate”评估策略,在消费者输出(文本文件)的DeviceID属性中,我都有:
“的DeviceID”: “[Ljava.lang.Object; @ 4456c43f”
任何提示?
感谢。
这是json配置:
{
"epn": {
"events": [{
"name": "DCUPiazzaCarraraContextUpdate",
"createdDate": "Thu Oct 22 2015",
"attributes": [{
"name": "entityId",
"type": "String",
"dimension": 0
}, {
"name": "entityType",
"type": "String",
"dimension": 0
}, {
"name": "battery",
"type": "Double",
"dimension": 0
}, {
"name": "temperature",
"type": "Double",
"dimension": 0
}, {
"name": "stato",
"type": "Boolean",
"dimension": 0
}, {
"name": "rssi",
"type": "Integer",
"dimension": 0
}, {
"name": "lqi",
"type": "Integer",
"dimension": 0
}, {
"name": "timestamp",
"type": "String",
"dimension": 0
}, {
"name": "numprog",
"type": "Integer",
"dimension": 0
}, {
"name": "dcu",
"type": "String",
"dimension": 0
}]
}, {
"name": "DCUAbsence",
"createdDate": "Sat Nov 07 2015",
"attributes": [{
"name": "entityId",
"type": "String",
"dimension": 0
}, {
"name": "entityType",
"type": "String",
"dimension": 0
}, {
"name": "AlertType",
"type": "String",
"dimension": 0
}, {
"name": "eventnum",
"type": "Integer",
"dimension": 0
}, {
"name": "DeviceID",
"type": "String",
"dimension": 0
}, {
"name": "DeviceContext",
"type": "String",
"dimension": 0
}]
}],
"epas": [{
"name": "AbsenceDCU",
"createdDate": "Sat Nov 07 2015",
"epaType": "Aggregate",
"context": "AbsenceDCUComp",
"inputEvents": [{
"name": "DCUPiazzaCarraraContextUpdate",
"consumptionPolicy": "Reuse",
"instanceSelectionPolicy": "First"
}],
"computedVariables": [{
"name": "eventnum",
"aggregationType": "Count",
"DCUPiazzaCarraraContextUpdate": "1"
}],
"evaluationPolicy": "Immediate",
"cardinalityPolicy": "Unrestricted",
"internalSegmentation": [],
"derivedEvents": [{
"name": "DCUAbsence",
"reportParticipants": false,
"expressions": {
"entityId": "\"Alert\"",
"entityType": "\"PiazzaCarrara\"",
"AlertType": "\"006\"",
"eventnum": "eventnum",
"DeviceID": "DCUPiazzaCarraraContextUpdate.entityId",
"DeviceContext": "DCUPiazzaCarraraContextUpdate.entityType"
}
}]
}],
"contexts": {
"temporal": [{
"name": "AbsenceDCUWindow",
"createdDate": "Sat Nov 07 2015",
"type": "TemporalInterval",
"atStartup": false,
"neverEnding": false,
"initiators": [{
"initiatorType": "Event",
"initiatorPolicy": "Ignore",
"name": "DCUPiazzaCarraraContextUpdate"
}],
"terminators": [{
"terminatorType": "RelativeTime",
"terminationType": "Discard",
"relativeTime": "5000"
}]
}],
"segmentation": [{
"name": "AbsenceDCUID",
"createdDate": "Thu Dec 17 2015",
"participantEvents": [{
"name": "DCUPiazzaCarraraContextUpdate",
"expression": "DCUPiazzaCarraraContextUpdate.entityId"
}, {
"name": "DCUAbsence",
"expression": "DCUAbsence.DeviceID"
}]
}],
"composite": [{
"name": "AbsenceDCUComp",
"createdDate": "Thu Dec 17 2015",
"temporalContexts": [{
"name": "AbsenceDCUWindow"
}],
"segmentationContexts": [{
"name": "AbsenceDCUID"
}]
}]
},
"consumers": [{
"name": "OnFileAlert",
"createdDate": "Thu Oct 22 2015",
"type": "File",
"properties": [{
"name": "filename",
"value": "/var/log/tomcat7/Alert.json"
}, {
"name": "formatter",
"value": "json"
}, {
"name": "delimiter",
"value": ";"
}, {
"name": "tagDataSeparator",
"value": "="
}, {
"name": "SendingDelay",
"value": "1000"
}, {
"name": "dateFormat",
"value": "dd/MM/yyyy-HH:mm:ss"
}],
"events": [{
"name": "DCUAbsence"
}, {
"name": "DCUPiazzaCarraraContextUpdate"
}]
}],
"producers": [],
"name": "CounterExample"
}
}
答案 0 :(得分:0)
在聚合类型的EPA中,由于该类型的许多事件可以在上下文中到达,因此当您在派生表达式中引用输入事件属性时,会得到数组< / strong>保存该类型的所有参与者输入事件的属性。
在您的示例中, DCUPiazzaCarraraContextUpdate.entityId 将包含 entityId 的数组 。
如果你想要一个值,你可以使用数组访问函数从数组中获取一个值,或者因为你在entityId上使用了一个分段上下文,你可以从该上下文中获取entityId。
要从上下文中获取属性,请使用上下文。“segmentation-context-name”表达式,在您的情况下为:
context.AbsenceDCUID
在一般情况下,您可以使用数组访问函数从数组中获取特定条目。例如,从数组中获取最后一个值:
ArrayGet(DCUPiazzaCarraraContextUpdate.entityId, ArraySize(DCUPiazzaCarraraContextUpdate.entityId)-1)