この例では、Cepheus-CEP 内で Date 属性とGeo:Point 属性を使用しています。

これは完全にルームとフロアの例に基づいています。

dategeo:point 属性とメタデータを定義する方法を示しています。

セットアップ

センサーが、ポジションを送信するための location メタデータと、temperature 属性に time メタデータを追加したとします :

 {
     "id": "Room31", // Room 1 on floor 3 (could be anything else)
     "type":"Room",  // all sensors must use the same "Room" type
     "attributes": [
        {
            "name":"temperature",
            "type":"double",
            "value":"21",
            "metadatas": [
                { "name":"time", "type":"date", "value":"2015-10-26T22:47:09Z" },
                { "name":"location", "type":"geo:point", "value":"45.2334, 1.4233" }
            ]
        },
        { "name":"floor", "type":"string", "value":"3" }, // the room is on the third foor
     ]
 }

CEPの設定

Cepheus-CEP の設定フォーマットに変換されているので、入力として室温を受け入れるための以下の "in "セクションがあります :

"in": [
    {
        "id":"Room1",
        "type":"Room",
        "attributes":[
            {
                "name":"temperature",
                "type":"double",
                "metadata": [
                  { "name":"time", "type":"date" },
                  { "name":"location", "type":"geo:point"}
                ]
            },
            { "name":"floor", "type":"string" }
        ]
    }
]

"out" セクションは、フロアの NGSI コンテキスト・エンティティにも似ています :

"out":[
    {
        "id":"Floor1",
        "type":"Floor",
        "attributes":[
            {
                "name":"temperature",
                "type":"double",
                "metadata": [
                  { "name":"time", "type":"date" },
                  { "name":"location", "type":"geo:point"}
                ]
            }
        ]
    }
]

temperaturetimelocation のメタデータを送信するため、temperature_timetemperature_location を"そのまま"送信する EPL ルールを伝える必要があります :

INSERT INTO Floor
SELECT floor as id, avg(temperature) as temperature, temperature_time, temperature_location
FROM Room.win:time(10 minutes)
GROUP BY floor
OUTPUT LAST EVERY 1 min

EPL でのメタデータ命名の詳細については、CEP/マッピングのセクションを参照してください。

config.jsonは、完全な設定のセットアップを持っています。

セットアップをテスト

run.sh ファイルを端末で実行し、Cepheus CEPのログをチェックすることで、CEP に送信されたルームの温度と CEP がイベントに反応することを確認できます。

最初の端末で、Cepheus-CEP を起動します :

cd cepheus-cep
mvn spring-boot:run

デフォルト設定では、マシン上の port :8080で起動する必要があります。

今度は別のターミナルで、run.sh スクリプトを起動します :

cd doc/examples/8_DateAndGeoPoint
sh run.sh

スクリプトは最初に config.json ファイルを Cepheus-CEP に送信し、温度の更新を送信します。

CEP を開始した端末に戻ります。"EventIn" が記録されていると温度が表示されます。

数秒後、"EventOut" ログに各フロアの平均温度をトリガする CEP が表示されます。