我正在使用CEP以更新模式修改类型日期字段。
实体:
{
"id":"controller",
"type":"control",
"lasmodify":{
"type":"DataTime",
"value":""
}
}
{
"id":"Device01",
"type":"device",
"id_controller":{
"type":"Text",
"value":"controller01"
}
"datemodify":{
"type":"DataTime",
"value":"2018-12-04T20:05:00.00Z"
}
}
我希望拍摄Device01订阅,将使用device01实体的datemodify修改controller01属性lasmodify。
非常感谢您 最好的问候。
答案 0 :(得分:1)
如果我已正确理解,您想在CEP收到设备更改通知时更新控制器。 解决方案应类似于以下规则:
{
"name":"update_rule",
"text":"select ev.controler? as controlerID, ev.datemodify? as newDate, \"update_rule\" as ruleName from pattern [every ev=iotEvent(type=\"device\")]",
"action":{
"type":"update",
"parameters":{
"id":"${controlerID}",
"type":"control",
"attributes": [
{
"name":"lasmodify",
"type":"DataTime"
"value":"${newDate}"
}
]
}
}
}
我不知道您使用的是哪个版本的Perseo,但是如果使用perseo-fe和perseo-core的最新软件映像,则可以省略ruleName并使用NGSIv2
{
"name":"update_rule",
"text":"select ev.controler? as controlerID, ev.datemodify? as newDate from pattern [every ev=iotEvent(type=\"device\")]",
"action":{
"type":"update",
"parameters":{
"id":"${controlerID}",
"type":"control",
"version": "2",
"attributes": [
{
"name":"lasmodify",
"type":"DataTime"
"value":"${newDate}"
}
]
}
}
}