文章目录
- 1. 基本信息
- 1.1 注册rpc协议:
- 1.2 设置数据中心:
- 1.3 获取数据中心:
- 1.4 获取网关信息
- 1.5 设置网关
- 1.6 获取网关
- 1.7 清空数据
- 1.8 开始采集
- 1.9 关闭采集
- 2、设备管理
- 2.1 更新设备配置下发
- 2.2 设备状态
- 2.3 控制设备
- 2.4 获取采集数据
- 2.5 获取通道列表
- 2.6 获取设备列表
- 2.7 获取设备信息
- 2.8 设备调试
- 2.9 获取采集参数
- 3、远程服务
- 3.1 远程升级
- 3.2 执行指令
- 4、 时间型温控器
- 4.1 采集数据
- 4.2 温控器当前状态
- 4.3 设置定时时间
- 4.4 设置开关控制
- 4.5 设置计时状态
- 4.6 设置档位
- 4.7 设置工作模式
- 4.8 设置锁定方式
- 4.9 控制模块状态
- 4.10 读取控制模块状态
- 4.11 设置控制模块状态
1. 基本信息
1.1 注册rpc协议:
{
"id":1234,
"jsonrpc":"2.0",
"method":"registerAcquisitor",
"params":{
"gateway_id": gateway_id,
"secrectkey": "12345678", /* 8字节秘钥 */
"version":"3.1.0"
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"registerAcquisitor",
"result":
{
"valid": true,
"property":"上海宝格丽公寓",
"date":"2018-09-05 13:10:30"
}
}
1.2 设置数据中心:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setDataCenter",
"params":{
"gateway_id": gateway_id,
"secrectkey": key,
"dataCenter":"192.168.0.11",
"dataPort":9090
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setDataCenter",
"result":true
}
1.3 获取数据中心:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDataCenter"
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDataCenter",
"result":{
"gateway_id": gateway_id,
"secrectkey": key,
"dataCenter":"192.168.0.11",
"dataPort":9090,
"heartbeat":30
}
}
1.4 获取网关信息
{
"id":1234,
"jsonrpc":"2.0",
"method":"getAcquisitiorInfo"
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getAcquisitiorInfo",
"result":{
"totalDisk": "Avail %lld MB/Total %lld MB",
"gatewayId": gateway_id,
"version":"2.1.4",
"freeMemory":"%ld/%ld kB",
"hostname":"linux kernel armv7",
"sysVer":"linux version",
"macAddr":"mac地址",
"netcard":[IP地址列表],
"heartbeat":30
}
}
1.5 设置网关
{
"id":1234,
"jsonrpc":"2.0",
"method":"setGateway",
"params":
[
{
"dhcp":false,
"card":"eth0",
"ipAddr":"192.168.0.100",
"mask":"255.255.255.0",
"gateway":"192.168.0.1"
}
]
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setGateway",
"result":true
}
1.6 获取网关
{
"id":1234,
"jsonrpc":"2.0",
"method":"getGateway"
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getGateway",
"result":
[
{
"dhcp":false,
"card":"eth0",
"ipAddr":"192.168.0.100",
"mask":"255.255.255.0",
"gateway":"192.168.0.1"
}
]
}
1.7 清空数据
{
"id":1234,
"jsonrpc":"2.0",
"method":"clearData"
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"clearData",
"result":true
}
1.8 开始采集
{
"id":1234,
"jsonrpc":"2.0",
"method":"startAcquire"
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"startAcquire",
"result":true
}
1.9 关闭采集
{
"id":1234,
"jsonrpc":"2.0",
"method":"stopAcquire"
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"stopAcquire",
"result":true
}
2、设备管理
2.1 更新设备配置下发
{
"id" : 1234,
"jsonrpc" : "2.0",
"method" : "updateDeviceList",
"params" : {
"device" : [
{
"communication" : {
"addr" : {
"baudRate" : 9600,
"chn" : "COM1",
"dataBits" : 8,
"parity" : 2,
"stopBits" : 1
},
"delay" : 1500,
"mode" : "serial"
},
"devId" : 1067,
"id" : "137",
"model" : {
"id" : 18,
"name" : "dds228_I"
},
"name" : "研发办公用电",
"opt" : "up",
"sample" : 15,
"type" : 2
}
],
"model" : [
{
"acquire" : [
{
"acqid" : 101,
"expr" : "$float($data)",
"name" : "正向有功电能",
"parms" : "00H 00H",
"rate" : 1,
"reglen" : 2
}
],
"id" : 18,
"name" : "dds228_I",
"temp" : "#型号 modbus(crc16)\n#modbus协议\n\ndef crc16: $crc($1,0x8005,0xffff,0x0000,0)\n\n# $addr $len 都是输入的参数\n\ndef getaddr: [FFH 03H $1 $itom(2,$len) $crc16($group(0,$pos))]\ndef parseaddr:[$ditch(1) 03H 02H $ditch(2,$assign(&addr,$int($0))) $ditch(2)]\ndef send: [$addr 03H $1 $itom(2,$len) $crc16($group(0,$pos))]\ndef recv: [$addr 03H $ditch(1,$assign(&dl,$0)) $data($ditch($dl)) $ditch(2)]\ndef indict: [$addr 10H $1 00H 01H 02H $2 $crc16($group(0,$pos))]\ndef undict: [$data]"
}
]
}
}
返回:
{
"id" : 1234,
"jsonrpc" : "2.0",
"method" : "updateDeviceList",
"result":{"ret":true}
}
2.2 设备状态
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDevicesStatus",
"params":{
"devId":1067
}
}
“返回”:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDevicesStatus",
"result":true,
"status":true /* 设备开关状态 */
}
2.3 控制设备
{
"id":1234,
"jsonrpc":"2.0",
"method":"indicateDevice",
"params":{
"id":137,
"acqid":"ctrl4",//ctrl5 关
"data":""
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"indicateDevice",
"params":{
"id":137,
"acqid":"ctrl4",//ctrl5 关
"ret":true
}
}
2.4 获取采集数据
{
"id":1234,
"jsonrpc":"2.0",
"method":"getAcquireValues",
"params":{
"id":137
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getAcquireValues",
"result":[
{
"acq":"acqEndCool",
"name":"",
"value":12.9
}
]
}
2.5 获取通道列表
{
"id":1234,
"jsonrpc":"2.0",
"method":"getChnList"
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getChnList",
"result":
[
"COM1","COM2","COM3","COM4","tcp"
]
}
2.6 获取设备列表
按通道获取:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDeviceList",
"params":{"chn":"all"}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDeviceList",
"result":[{"chn":"COM1","devices":[{设备列表}]}
}
2.7 获取设备信息
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDeviceInfo",
"params":{"id":137}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getDeviceInfo",
"result":
{
"id":137,
"name":name,
"devId":"87",
"status":true,
"sample":15,
"type":1,
"model":{"id":133,"name":"型号"},
"communication":{
"mode":"serial",
"delay":1500,
"addr":{
"chn":"COM1",
"baudRate":9600,
"dataBits":8,
"stopBits":1,
"parity":0
}
}
}
}
2.8 设备调试
{
"id":1234,
"jsonrpc":"2.0",
"method":"debugDevice",
"params":
{
"id":137,
"acqid":101,
"reglen":4,
"expr":"$float($data)",
"rate":1.0,
"template":"协议模板",
"communication":{
"mode":"serial",
"delay":1500,
"addr":{
"chn":"COM1",
"baudRate":9600,
"dataBits":8,
"stopBits":1,
"parity":0
}
}
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"debugDevice",
"result":{"send":"","recv":""}
}
2.9 获取采集参数
{
"id":1234,
"jsonrpc":"2.0",
"method":"getAcquireData",
"params":{"model":137}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getAcquireData",
"result":{
"acquireData":[
{
"acqid":137,
"reglen":4,
"expr":"$float($data)",
"rate":1.0,
"params":"10H;87H 33H"
}
]
"template":""
}
}
3、远程服务
3.1 远程升级
{
"id":1234,
"jsonrpc":"2.0",
"method":"updatePackets",
"params":
{
"url":"http://192.168.0.201:83/leo-das_Ver1.0.tar.gz",
"version":"1.0",
"sign":""
}
}
“返回”:
{
"id":1234,
"jsonrpc":"2.0",
"method":"updatePackets",
"result":{
/*
* 012 安装包下载失败
* 030 正在重启
*/
"stsCode":30, /* 状态码 */
"version":"1.0"
}
}
3.2 执行指令
{
"id":1234,
"jsonrpc":"2.0",
"method":"executeScript",
"params":
{
"mode":1,
"script":"脚本指令"
}
}
4、 时间型温控器
4.1 采集数据
{
"id" : 1000,
"jsonrpc" : "2.0",
"method" : "acquireData",
"params" :
[
{
"data" :
{
"acq510":0x1230,//高档: 510 中档: 511 低档:512,都是BCD码
"acq511":0x1040,
"acq512":0x2030,
"acq503":0/1/2/3, //档位控制状态
"acq502":0/1, // 工作模式: 0-制冷,1-制热
"acq504":22.5, //设置温度
"acq506":22.5, //室内温度
"acq508": 0/1 //锁定方式,0-解锁,1-半锁,2-全锁(含键盘也锁定)
"acq530":0, //阀门开关状态,0-强制关阀(面板显示该缴费),01-开阀(用户可正常使用) 02-暂时故障关阀(面板不显示缴费)
"acq501":0/1 //电源开关状态,0-关 ,1-开
"acq520":0/1 //定时开关状态,0-关 ,1-开
"acq514":1/0 //计时状态,1-关 0-开,
"acq521":0x08301820//bcd,
/* 星期一,开始:时:(0x08301820&0xff000000)>>24,分:(0x08301820&0x00ff0000)>>16; 关闭:时:(0x08301820&0x0000ff00)>>8,分:(0x08301820&0x000000ff)
*/
"acq522":0x08301820//bcd,星期二
。。。直到527
}
"id" : 2883,
"time" : "2018-10-30 16:41:26"
}
]
}
4.2 温控器当前状态
{
"id":1234,
"jsonrpc":"2.0",
"method":"getTMCStatus",
"params":{
"id":2883
}
}
{
"id":1234,
"jsonrpc":"2.0",
"method":"getTMCStatus",
"result":{
"id":2883,
"status":true, //采集状态或通讯状态,如果这个为false,后面的值可能没有
"power":0/1,//开机状态,0-关,1-开
"houseTemp":22.5,//室内温度
"gearPos":0,//档位:0-自动,1-高速,2-中速,3-低速
"lockMode":0 // 0-解锁 1-半锁(不锁开关键) 2-全锁(包括开关键)
"workMode":0 //0-制冷 1-制热
"setTemp":22.5, //设定温度
"valveStatus":1,//阀门状态,0-关机,1-开机
"timingSwitch":1,//定时开关,0-关机,1-开机
"timingStaus":0/1 //计时状态,0-开, 1-关
}
}
4.3 设置定时时间
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCTimer",
"params":{
"id":2883,
"timerSwitch":1/0,//定时开关,1-开,0-关
"timer":[
/* 按顺序分别是星期一到星期日的定时设置 */
{
"week":1/2/3/4/5/6/7
"dayBegin":"10:30",
"dayEnd":"20:45"
//也可以是 undefined, 表示定时时间不设置,延续上一个日期的设置
//dayBegin 设置为undefined 表示延续上一个日期的设置,dayEnd 设置为undefined 表示延迟到下一个日期的设置
}
]
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCTimer",
"result":true/false//设置成功或失败
}
4.4 设置开关控制
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCSwitch",
"params":{
"id":2883,
"switch":0/1 //0-关,1-开
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCSwitch",
"result":true/false //执行成功或失败
}
4.5 设置计时状态
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCTiming",
"params":{
"id":2883,
"switch":0/1 //0-开,1-关
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCTiming",
"result":true/false //执行成功或失败
}
4.6 设置档位
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCGearPos",
"params":{
"id":2883,
"gearPos":0/1/2/3, //0-自动,1-高,2-中, 3-低
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCGearPos",
"result":true/false //执行成功或失败
}
4.7 设置工作模式
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCMode",
"params":{
"id":2883,
"workMode":0/1, //0-制冷,1-制热
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCMode",
"result":true/false //执行成功或失败
}
4.8 设置锁定方式
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCLock",
"params":{
"id":2883,
"lockMode":0/1/2, //0-解锁,1-半锁(不锁开关键),2-全锁(锁定开关键)
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setTMCLock",
"result":true/false //执行成功或失败
}
4.9 控制模块状态
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method" : "acquireData",
"params" :
[
{
"data" :
{
// IO 控制模块有的是8个端口,有的是4个端口,也有可能16个端口,
// 实际使用的按配置来,801开始为第一个端口,其他端口依次增加
"acq801":1,
"acq803":0,
"acq807":1
},
"id" : 2884,
"time" : "2018-10-30 16:41:26"
}
]
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"acquireData",
"result":true/false //执行成功或失败
}
4.10 读取控制模块状态
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method" : "getIOStatus",
"params" :
{
"id":2884,
"type":0/1 //0-DO, 1-DI,
"idx":0~7
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"getIOStatus",
"result":0/1
}
4.11 设置控制模块状态
发送:
{
"id":1234,
"jsonrpc":"2.0",
"method" : "setIOStatus",
"params" :
{
"id":2884,
"type":0/1 //0-DO, 1-DI,DI是不能设置的,如果设置会返回设置失败
"idx":0~7
"value":0/1
}
}
返回:
{
"id":1234,
"jsonrpc":"2.0",
"method":"setIOStatus",
"result":true/false //操作成功或失败
}