连接协议-OpcUAClient

更新时间:2018-07-13 19:13:36

一、框图

image | left

  • opcua driver:LinkEdge中负责连接opcua server,数据转换的模块

  • config:驱动配置信息,包含连接的server信息和设备信息,保存在配置中心,详见第二部分介绍

  • tsl:产品物模型描述信息,部分信息为opcua特有,保存在配置中心,详见第三部分介绍

二、config:

{
    "DriverConfig":{
       /******控制台需要自行录入部分******/
       "ServerList":[  //----------------------------opcua服务器列表
       {
            "serverId":0,  //------------------------服务器索引,由0顺序递增,用来设备与服务器关联
            "url": "opc.tcp://localhost:4840",  //---服务器连接地址
            "userName": "",  //----------------------登录用户名,如果没有账户和密码,填空字符串
            "password": "",  //----------------------账户密码,如果没有账户和密码,填空字符串
            "secPolicy":"None",
            "secMode":"None",
            "certificate":"",
            "privateKey":"",
            "timeout":5  //--------------------------方法调用超时时间
        }]
       /********************************/
    },
    "DeviceList": [
        {
            "ProductKey":"",
            "DeviceName":"",
            "DeviceConfig":{
                /****控制台需要自行录入部分****/
                "serverId":0,    //-----------------服务器索引,用来设备与服务器关联
                "displayName":"" //-----------------设备节点的displayName
                /****************************/
            }
        },
        {
            "ProductKey":"",
            "DeviceName":"",
            "DeviceConfig":{
                /****控制台需要自行录入部分****/
                "serverId":0,  //-----------------服务器索引,用来设备与服务器关联
                "displayName":"Objects"  //-------设备节点的displayName
                /****************************/
             }
        }]
}

三、TSL

{
"profile":{
    "productKey": "0LAIGKYmweU"
},
"properties":
[
    {
        "identifier" : "battery",
        "accessMode" : "r",
        "dataType":{
            "type" : "int",
            "specs":{
            "max":"100",
            "min":"0",
            "unit":"%"
            }
        },
        "desc" : "电池电量",
        "displayName":"Battery01"    /****opcua特有:节点的displayName****/
    },
    {
        "identifier" : "state",
        "accessMode" : "r",
        "dataType":{
            "type" : "enum",
            "specs":{
            "0":"正常锁门",
            "2":"门没有上锁",
            "3":"门内反锁"
            }
        },
        "desc" : "门状态",
        "displayName":"DoorState"    /****opcua特有:节点的displayName****/
    }
],
"events":
[
    {
        "identifier" : "action",
        "type" : "info",
        "outputData":
        [
            {
                "identifier" : "user_type",
                "dataType":{
                    "type":"enum",
                    "specs":{
                    "0":"密码用户",
                    "1":"无线用户",
                    "3":"卡用户",
                    "4":"指纹用户"
                    }
                },
                "index":0    /****opcua特有:参数索引,在该事件下的序列编号****/
            },
            {
                "identifier" : "state",
                "dataType":{
                    "type":"enum",
                    "specs":{
                    "1":"锁门",
                    "2":"开门"
                    }
                },
                "index":1    /****opcua特有:参数索引,在该事件下的序列编号****/
            }
        ],
            "desc" : "门操作",
            "displayName":"Action"    /****opcua特有:节点的displayName****/
    }
],
"services":
[
    {
        "identifier" : "get",
        "inputData":
        [
            "ieee_addr",
            "battery",
            "state"
        ],
        "outputData":
        [
            {
                "identifier" : "battery",
                "dataType":{
                    "type" : "int",
                    "specs":{
                    "max":"100",
                    "min":"0",
                    "unit":"%"
                    }
                },
                "desc" : "电池电量",
                "displayName":"Battery01"    /****opcua特有:节点的displayName****/
            },
            {
                "identifier" : "state",
                "dataType":{
                    "type" : "enum",
                    "specs":{
                    "0":"正常锁门",
                    "2":"门没有上锁",
                    "3":"门内反锁"
                    }
                },
                "desc" : "门状态",
                "displayName":"DoorState"    /****opcua特有:节点的displayName****/
            }
        ],
        "desc" : "获取属性"
    },
    {
            "identifier" : "control",
            "inputData":[
            {
                "identifier" : "action",
                "dataType":{
                    "type":"enum",
                    "specs":{
                    "0":"close",
                    "1":"open"
                    }
                },
                "index":0    /****opcua特有:参数索引,在该方法下的序列编号****/
            }
        ],
        "outputData":[
        ],
        "desc" : "门操作",
        "displayName":"control"    /****opcua特有:节点的displayName****/
    }
]
}

四、部署步骤

  1. 导入设备三元组到配置中心
  2. 导入config到配置中心
  3. 导入tsl到配置中心
  4. 执行startOpcua.sh

results matching ""

    No results matching ""