简体   繁体   中英

CEP 5.4.3, not triggering basic condition

using CEP i'm trying to make a basic example of communication between Proton and Orion. I simply want Proton to receive a notification of temperature from Orion and send back a payload changing one boolean attribute if the temperature value is superior or equal to 20.

Here is the definition i'm using.

{
    "epn":
    {
        "events":
        [
            {
                "name": "TemperatureContextUpdate",
                "attributes":
                [
                    {
                        "dimension": 0,
                        "description": "The certainty that this event happen (value between 0 to 1)",
                        "name": "Certainty",
                        "defaultValue": "1",
                        "type": "Double"
                    },
                    {
                        "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": "OccurrenceTime",
                        "type": "Date"
                    },
                    {
                        "dimension": 0,
                        "name": "ExpirationTime",
                        "type": "Date"
                    },
                    {
                        "dimension": 0,
                        "description": "The cost of this event occurrence. Negative if this is an opportunity",
                        "name": "Cost",
                        "type": "Double"
                    },
                    {
                        "dimension": 0,
                        "description": "Used in case the this event occur within an interval",
                        "name": "Duration",
                        "defaultValue": "0",
                        "type": "Double"
                    },
                    {
                        "dimension": "0",
                        "name": "entityId",
                        "type": "String"
                    },
                    {
                        "dimension": "0",
                        "name": "entityType",
                        "type": "String"
                    },
                    {
                        "dimension": "0",
                        "name": "temperature",
                        "type": "Integer"
                    },
                    {
                        "dimension": "0",
                        "name": "chaud",
                        "type": "Boolean"
                    }
                ],
                "createdDate": "Wed Feb 22 2017"
            },
            {
                "name": "Out_TemperatureContextUpdate",
                "attributes":
                [
                    {
                        "dimension": 0,
                        "description": "The certainty that this event happen (value between 0 to 1)",
                        "name": "Certainty",
                        "defaultValue": "1",
                        "type": "Double"
                    },
                    {
                        "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": "OccurrenceTime",
                        "type": "Date"
                    },
                    {
                        "dimension": 0,
                        "name": "ExpirationTime",
                        "type": "Date"
                    },
                    {
                        "dimension": 0,
                        "description": "The cost of this event occurrence. Negative if this is an opportunity",
                        "name": "Cost",
                        "type": "Double"
                    },
                    {
                        "dimension": 0,
                        "description": "Used in case the this event occur within an interval",
                        "name": "Duration",
                        "defaultValue": "0",
                        "type": "Double"
                    },
                    {
                        "dimension": "0",
                        "name": "entityId",
                        "type": "String"
                    },
                    {
                        "dimension": "0",
                        "name": "entityType",
                        "type": "String"
                    },
                    {
                        "dimension": "0",
                        "name": "temperature",
                        "type": "Integer"
                    },
                    {
                        "dimension": "0",
                        "name": "chaud",
                        "type": "Boolean"
                    }
                ],
                "createdDate": "Wed Feb 22 2017"
            }
        ],
        "name": "TemperatureDemo",
        "consumers":
        [
            {
                "events":
                [
                    {
                        "name": "Out_TemperatureContextUpdate"
                    }
                ],
                "name": "Consumer_Rest",
                "properties":
                [
                    {
                        "name": "URL",
                        "value": "http://172.17.0.3:1026/v2/entities"
                    },
                    {
                        "name": "contentType",
                        "value": "application/json"
                    },
                    {
                        "name": "formatter",
                        "value": "json_ngsi"
                    },
                    {
                        "name": "delimiter",
                        "value": ";"
                    },
                    {
                        "name": "tagDataSeparator",
                        "value": "="
                    },
                    {
                        "name": "dateFormat",
                        "value": "dd/MM/yyyy-HH:mm:ss"
                    }
                ],
                "type": "Rest",
                "createdDate": "Wed Feb 22 2017"
            },
            {
                "events":
                [
                    {
                        "name": "TemperatureContextUpdate"
                    }
                ],
                "name": "Consumer_File",
                "properties":
                [
                    {
                        "name": "filename",
                        "value": "/home/work/Documents/test.txt"
                    },
                    {
                        "name": "formatter",
                        "value": "json"
                    },
                    {
                        "name": "delimiter",
                        "value": ";"
                    },
                    {
                        "name": "tagDataSeparator",
                        "value": "="
                    }
                ],
                "type": "File",
                "createdDate": "Wed Feb 22 2017"
            }
        ],
        "epas":
        [
            {
                "inputEvents":
                [
                    {
                        "instanceSelectionPolicy": "First",
                        "alias": "TemperatureContextUpdate",
                        "filterExpression": "TemperatureContextUpdate.temperature>=20",
                        "name": "TemperatureContextUpdate",
                        "consumptionPolicy": "Consume"
                    }
                ],
                "derivedEvents":
                [
                    {
                        "name": "Out_TemperatureContextUpdate",
                        "reportParticipants": false,
                        "expressions":
                        {
                            "Cost": "TemperatureContextUpdate.Cost",
                            "Certainty": "TemperatureContextUpdate.Certainty",
                            "OccurrenceTime": "TemperatureContextUpdate.OccurrenceTime",
                            "Duration": "TemperatureContextUpdate.Duration",
                            "entityId": "TemperatureContextUpdate.entityId",
                            "ExpirationTime": "TemperatureContextUpdate.ExpirationTime",
                            "chaud": "true",
                            "entityType": "TemperatureContextUpdate.entityType",
                            "temperature": "TemperatureContextUpdate.temperature"
                        }
                    }
                ],
                "evaluationPolicy": "Immediate",
                "name": "EPA_Change",
                "internalSegmentation":
                [
                ],
                "context": "always",
                "epaType": "Basic",
                "cardinalityPolicy": "Single",
                "localPlacement": true,
                "createdDate": "Wed Feb 22 2017",
                "computedVariables":
                [
                ]
            }
        ],
        "optimization":
        {
        },
        "contexts":
        {
            "temporal":
            [
                {
                    "terminators":
                    [
                    ],
                    "neverEnding": true,
                    "atStartup": true,
                    "name": "always",
                    "type": "TemporalInterval",
                    "createdDate": "Wed Feb 22 2017",
                    "initiators":
                    [
                    ]
                }
            ],
            "segmentation":
            [
            ],
            "composite":
            [
            ]
        },
        "producers":
        [
        ]
    }
}

I try to create a file while first update is receive but this file is always empty, btw it is correctly create in my directory and change everytime I change definition. The rest payload is never send like the condition is never triggered.

The payload I send :

{
 "subscriptionId": "51c04a21d714fb3b37d7d5a7",
 "data": 
[ {
"id": "temp1",
 "type": "Temperature",
 "temperature": {
    "type":"integer",
    "value": 28,
    "metadata":{}
},
"chaud": {
    "type":"boolean",
    "value": false,
    "metadata":{}
},
    "Certainty": {
        "value": "1",
        "type": "Float"
    },
    "Cost": {
        "value": "0",
        "type": "Float"
    },
    "Name": {
        "value": "",
        "type": "String"
    },
    "EventSource": {
        "value": "",
        "type": "String"
    },
    "Duration": {
        "value": "0",
        "type": "Float"
    }
}
]
}

The log catalina.out :

INFOS: started event message body reader févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader parseVTwoFormat INFOS: Event: TemperatureContextUpdate févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom INFOS: finished event message body reader févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom INFOS: EventJSONNgsiMessageReader: read event TemperatureContextUpdate; entityId=temp1; EventId=ba868559-7589-4720-ab75-658b920a3f14; chaud=false; entityType=Temperature; Chronon=null; temperature=28; DetectionTime=1487845415319; Name=; Certainty=1; Cost=0; EventSource=; OccurrenceTime=null; Duration=0; Annotation=; ExpirationTime=null; from broker... févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent INFOS: starting submitNewEvent févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent INFOS: events sent to proton runtime...

So any idea where is my problem ?

Thanks.

your mistake is that you send an event with an empty name. I am sorry the same information is duplicated in the input, however this steams from the integration between Proton and Orion, each of which requires the information in different form and the difference was not patched smoothly.

The input you should send should contain the input event name, like this :

 { "subscriptionId": "51c04a21d714fb3b37d7d5a7", "data": [ { "id": "temp1", "type": "Temperature", "temperature": { "type":"integer", "value": "28", "metadata":{} }, "chaud": { "type":"boolean", "value": false, "metadata":{} }, "Certainty": { "value": "1", "type": "Float" }, "Cost": { "value": "0", "type": "Float" }, "Name": { "value": "TemperatureContextUpdate", "type": "String" }, "EventSource": { "value": "", "type": "String" }, "Duration": { "value": "0", "type": "Float" } } ] } 

Note that the name attribute now has value "TemperatureContextUpdate"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM