0

CEP を使用して、Proton と Orion 間の通信の基本的な例を作成しようとしています。Proton が Orion から温度の通知を受け取り、温度値が 20 以上の場合に 1 つのブール属性を変更するペイロードを送り返すようにしたいだけです。

これが私が使用している定義です。

{
    "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":
        [
        ]
    }
}

最初の更新の受信中にファイルを作成しようとしましたが、このファイルは常に空です。ディレクトリに正しく作成され、定義を変更するたびに変更されます。残りのペイロードは、条件がトリガーされないように送信されることはありません。

私が送信するペイロード:

{
 "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"
    }
}
]
}

ログ catalina.out :

INFOS: イベント メッセージ本文リーダー févr を開始しました。23、2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader parseVTwoFormat 情報: イベント: TemperatureContextUpdate févr. 23、2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom INFOS: イベント メッセージ本文リーダー févr を終了しました。23、2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom INFOS: EventJSONNgsiMessageReader: イベント TemperatureContextUpdate を読み取ります。entityId=temp1; EventId=ba868559-7589-4720-ab75-658b920a3f14; chaud=false; entityType=温度; Chronon=null; 温度=28; 検出時間 = 1487845415319; 名前=; 確実性=1; コスト=0; イベントソース=; OccurrenceTime=null; 期間=0; 注釈=; ExpirationTime=null; ブローカーから... févr. 23、2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources。EventResource submitNewEvent INFOS: submitNewEvent févr を開始しています。23、2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent 情報: プロトン ランタイムに送信されたイベント...

だから、私の問題はどこにあるのでしょうか?

ありがとう。

4

1 に答える 1

0

あなたの間違いは、空の名前でイベントを送信することです。申し訳ありませんが、同じ情報が入力に重複していますが、これは Proton と Orion の統合によるものであり、それぞれが異なる形式の情報を必要とし、違いがスムーズに修正されませんでした。

送信する必要がある入力には、次のように入力イベント名が含まれている必要があります。

{
 "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"
    }
}
]
}

name 属性の値が「TemperatureContextUpdate」になっていることに注意してください。

于 2017-02-28T15:53:32.227 に答える