> 文档中心 > edgexfoundry 事件event 触发导出到云端例子

edgexfoundry 事件event 触发导出到云端例子


1、向coredata库中集合valueDescriptor 写入两条数据

 

使用postman工具来实现提交这两条数据

1)打开postman,并导入raml文件

 

 

 

 

2)执行数据提交(两条)

 

POST to http://localhost:48080/api/v1/valuedescriptor

 

数据格式:application/json

 

第一条:温度数据描述记录

 

{

 

        "name": "temperature",

 

        "min": "-40",

 

        "max": "140",

 

        "type": "F",

 

        "uomLabel": "degree cel",

 

        "defaultValue": "0",

 

        "formatting": "%s",

 

        "labels": ["temp", "hvac"]

 

}

 

第二条:湿数据描述记录

 

{

 

        "name": "humidity",

 

        "min": "0",

 

        "max": "100",

 

        "type": "F",

 

        "uomLabel": "per",

 

        "defaultValue": "0",

 

        "formatting": "%s",

 

        "labels": ["humidity", "hvac"]

 

}

 

 

 

 

温度数据提交:

 

 

湿度数据提交:

 

 

 

两条数据保存到mongo库里了:

 

2、注册云端接收服务地址

在此注册种云端接收服务地址

1)MQTT消息

{

 

        "origin": 1471806386919,

 

        "name": "MQTTClient",

 

        "addressable": {

 

                "origin": 1471806386919,

 

                "name": "FuseTestMQTTBroker",

 

                "protocol": "TCP",

 

                "address": "localhost",

 

                "port": 1885,

 

                "publisher": "FuseExportPublisher",

 

                "user": "mqttuser",

 

                "password": "123456",

 

                "topic": "FuseDataTopic"

 

        },

 

        "format": "JSON",

 

        "enable": true,

 

        "destination": "MQTT_TOPIC"

 

}

2)RESTFUL消息

{

 

        "origin": 1471806386919,

 

        "name": "RESTClient",

 

        "addressable": {

 

                "origin": 1471806386919,

 

                "name": "FuseTestREST",

 

                "protocol": "HTTP",

 

                "address": "http://10.13.3.77",

 

                "port": 8080,

 

                "path": "/receiveData/receiveData.do"

 

        },

 

        "format": "JSON",

 

        "enable": true,

 

        "destination": "REST_ENDPOINT"

 

}

 

同样使用postman工具:

 

 

 

数据格式:application/json

POST to http://localhost:48071/api/v1/registration

1) mqtt

 

 

 

 

2)restful

 

 

后台数据库云端注册情况:

 

 

 

3、启动云端服务(测试能否接收到edgxfoundry发过来的消息)

 

1)端订阅FuseDataTopic mqtt消息,当有消息进入时,会打印出来

 edgexfoundry学习视频见网址:点击进入

 

 

 

 

2)restful 服务端 java编写,接收edgexfoundry发过来的请求

 

4、提交一个事件event,触发导出到云端

 

POST to http://localhost:48080/api/v1/event

数据格式:application/json

{
    "origin": 1471806386919,
    "device": "livingroomthermostat",
    "readings": [{
        "origin": 1471806386919,
        "name": "temperature",

        "value": "72"
    }, {
        "origin": 1471806386919,
        "name": "humidity",
        "value": "58"
    }]
}

提交事件:

mqtt云端收到消息

restful服务端收到请求

至此,导出到云端演示结束。
 

松山湖人才网