SZWB1L 微型断路器对接文档
模型清单
可使用下列名称或 ID 在 ThinkLink 中搜索对应模型。
| 模型类型 | 名称 | id_name | 平台模型 ID |
|---|---|---|---|
| RPC | [ZW SZWB1] switch | szwb1_22103_switch | 95906553915248645 |
| RPC | [SZWB1 GET] para | szwb1_get_22103 | 95843156968345605 |
| RPC | [SZWB1 SET] para | szwb1_set_para_22103 | 95842872615505925 |
| Template | ZW-SZWB1 | 95843645487321093 | |
| Thing Model | ZW-SZWB1 | szwb1_22103 | 95840195655503877 |
| Thing Model | [ZW-22103-SZWB1L资产] 区域聚合 | szwb1_asset_22103 | 119677174411063315 |
| Parameter Thing Model | [SZWB1-PARA] | szwb1_para_22103 | 95842342686167045 |
1. 传感器简介
SZWB1L 是卓文科技(ZhuoWen)的一款微型断路器设备,可通过 RS-485 接口接入 KC11 采集器,再由 EdgeBus 转换后通过 LoRaWAN 上报至 ThinkLink 平台。该方案支持测量数据周期上报,同时支持告警信息和开关状态触发上报。
2. 产品特点
- 支持微型断路器运行状态、电参量、温度、能量等多种数据采集。
- 支持告警与预警状态采集,包括欠压、过压、过流、超温、漏电、短路、负载不均衡等。
- 支持开关状态采集和远程分合闸控制。
- 上传周期与采集周期分开配置,分别使用 APP 参数地址 70 和 74。
- 上行数据包较长,实际项目中可按业务需求裁剪测点。
3. 适用范围
适用于智慧配电、配电箱监测、用电安全管理、楼宇配电监控、园区配电监测、工业用电监测等场景。
4. 采集器信息
4.1 硬件信息
- 采集器型号:KC11
- 通讯接口:RS-485
- 供电方式:220V / 12V 供电
4.2 接线信息
电源与通讯接口
- KC11 与 SZWB1L 通过 RS-485 连接。
- KC11 供电方式为 220V 或 12V。
- SZWB1L 作为 Modbus 从站接入,默认地址为
0x01(文档中的 EB 配置如此设置;实际部署时可通过参数修改)。
传感器接口
- RS-485 A/B 通讯线。
- 如现场需要远程控制和状态采集,需确保断路器本体支持对应功能并正确接线。
5. 数据采集
本方案中,通过 Modbus 读取以下寄存器:
0x04:读取测量数据(完整上报)0x02:读取离散输入状态(告警/预警变化上报)0x01:读取/配合线圈状态(开关状态相关)
其中:
- 测量数据建议按较长周期采集并上报。
- 告警信息和开关状态采用较短周期或触发方式上报。
- 必须保证采集周期小于上传周期。
5.1 寄存器定义
5.1.1 0x04 只读寄存器(Input Registers)
| 名称 | 地址(十进制) | 地址(十六进制) | 寄存器数量 | 单位 | 字段名 | 说明 |
|---|---|---|---|---|---|---|
| 面板拨码开关 | 3000 | 0BB8 | 1 | - | DIP | 0=断开/锁定,远控无效,漏保有效;1=闭合/解锁,远控有效,漏保无效 |
| 单相两线电流 | 3003 | 0BBB | 2 | 0.001A | I | 32 位,高字在前 |
| 单相电压 | 3005 | 0BBD | 1 | 0.01V | U | |
| 单相两线有功功率/三相合有功功率 | 3006 | 0BBE | 2 | 0.001mW/0.001W | P | 32 位,高字在前 |
| 单相两线无功功率/三相合无功功率 | 3008 | 0BC0 | 2 | 0.001mVar/0.001Var | Q | |
| 单相两线视在功率/三相合视在功率 | 3010 | 0BC2 | 2 | 0.001mVA/0.001VA | S | |
| 单相有功电能/三相合视在电能 | 3012 | 0BC4 | 4 | Wh | E | 64 位,高字在前 |
| 单相L线温 | 3016 | 0BC8 | 1 | 0.1℃ | Ts | |
| 剩余电流 | 3017 | 0BC9 | 1 | mA | Ires | 无符号 |
| A相电流 | 3019 | 0BCB | 2 | 0.001mA | Ia | 32 位,高字在前 |
| B相电流 | 3021 | 0BCD | 2 | 0.001mA | Ib | |
| C相电流 | 3023 | 0BCF | 2 | 0.001mA | Ic | |
| N相电流 | 3025 | 0BD1 | 2 | 0.001mA | In | |
| 额定电流 | 3027 | 0BD3 | 1 | A | Ir | |
| A相电压 | 3029 | 0BD5 | 1 | 0.01V | Ua | |
| B相电压 | 3030 | 0BD6 | 1 | 0.01V | Ub | |
| C相电压 | 3031 | 0BD7 | 1 | 0.01V | Uc | |
| 有功功率A | 3033 | 0BD9 | 2 | 0.001mW/0.001W | Pa | 32 位 |
| 有功功率B | 3035 | 0BDB | 2 | 0.001mW/0.001W | Pb | |
| 有功功率C | 3037 | 0BDD | 2 | 0.001mW/0.001W | Pc | |
| 无功功率A | 3039 | 0BDF | 2 | 0.001mVar/0.001Var | Qa | |
| 无功功率B | 3041 | 0BE1 | 2 | 0.001mVar/0.001Var | Qb | |
| 无功功率C | 3043 | 0BE3 | 2 | 0.001mVar/0.001Var | Qc | |
| 视在功率A | 3045 | 0BE5 | 2 | 0.001mVA/0.001VA | Sa | |
| 视在功率B | 3047 | 0BE7 | 2 | 0.001mVA/0.001VA | Sb | |
| 视在功率C | 3049 | 0BE9 | 2 | 0.001mVA/0.001VA | Sc | |
| 视在能量A | 3051 | 0BEB | 4 | mVAh | Esa | 64 位 |
| 视在能量B | 3055 | 0BEF | 4 | mVAh | Esb | |
| 视在能量C | 3059 | 0BF3 | 4 | mVAh | Esc | |
| 三相合视在能量 | 3063 | 0BF7 | 4 | mVAh | Es | |
| A线温度 | 3067 | 0BFB | 1 | 0.1℃ | Ta | |
| B线温度 | 3068 | 0BFC | 1 | 0.1℃ | Tb | |
| C线温度 | 3069 | 0BFD | 1 | 0.1℃ | Tc | |
| N线温度 | 3070 | 0BFE | 1 | 0.1℃ | Tn | |
| 单相视在能量/三相合有功电能 | 3075 | 0C03 | 4 | mWh | Ep | 64 位 |
| A相有功能量 | 3079 | 0C07 | 4 | mWh | Epa | |
| B相有功能量 | 3083 | 0C0B | 4 | mWh | Epb | |
| C相有功能量 | 3087 | 0C0F | 4 | mWh | Epc | |
| 单相无功能量/三相合无功电能 | 3091 | 0C13 | 4 | mVarh | Eq | |
| A相无功能量 | 3095 | 0C17 | 4 | mVarh | Eqa | |
| B相无功能量 | 3099 | 0C1B | 4 | mVarh | Eqb | |
| C相无功能量 | 3103 | 0C1F | 4 | mVarh | Eqc | |
| 电网频率 | 3107 | 0C23 | 1 | 0.1Hz | Freq |
5.1.2 0x02 状态位(Discrete Inputs)
读取范围:2000 ~ 2054,EB 中按整段读取并转换为告警位图。
5.1.3 0x01 / 0x05 控制线圈(Coil)
| 名称 | 地址 | 字段名 | 说明 |
|---|---|---|---|
| 分合闸 | 0 | switch | 写 1 启动一次合闸动作,写 0 启动一次分闸动作 |
| 漏电测试 | 1 | test | 写 1 启动一次测试动作 |
| 电量全清 | 2 | clear | 写 1 启动一次清零动作 |
5.1.4 0x03 / 0x06 设置寄存器(Holding Registers)
| 名称 | 地址 | 字段名 | 说明 |
|---|---|---|---|
| MODBUS地址 | 4053 | address | 出厂默认 1 |
| 波特率 | 4054 | baud | 0=9600,1=19200,2=38400;推荐统一设为 0 |
| 校验位 | 4055 | parity | 0=NONE,1=ODD,2=EVEN |
| 停止位 | 4056 | stop | 0=1,1=1.2,2=2 |
5.2 状态位定义
| 地址 | 名称 | 字段名 |
|---|---|---|
| 2000 | 单相欠压(报警) | UV_S_ALM |
| 2001 | 单相欠压(预警) | UV_S_WRN |
| 2002 | 单相过压(报警) | OV_S_ALM |
| 2003 | 单相过压(预警) | OV_S_WRN |
| 2004 | 单相过流(报警) | OC_S_ALM |
| 2005 | 单相过流(预警) | OC_S_WRN |
| 2006 | 单相线温(报警) | OT_S_ALM |
| 2007 | 单相线温(预警) | OT_S_WRN |
| 2008 | 漏电(报警) | RCD_ALM |
| 2009 | 漏电(预警) | RCD_WRN |
| 2012 | 过功率报警(报警) | OP_ALM |
| 2013 | 过功率报警(预警) | OP_WRN |
| 2014 | 短路报警(报警) | SC_ALM |
| 2015 | 短路报警(预警) | SC_WRN |
| 2016 | 接地报警 | GND_ALM |
| 2020 | 相序错误报警 | PH_SEQ_ERR |
| 2021 | 欠压(报警)A | UV_A_ALM |
| 2022 | 欠压(预警)A | UV_A_WRN |
| 2023 | 欠压(报警)B | UV_B_ALM |
| 2024 | 欠压(预警)B | UV_B_WRN |
| 2025 | 欠压(报警)C | UV_C_ALM |
| 2026 | 欠压(预警)C | UV_C_WRN |
| 2027 | 过压(报警)A | OV_A_ALM |
| 2028 | 过压(预警)A | OV_A_WRN |
| 2029 | 过压(报警)B | OV_B_ALM |
| 2030 | 过压(预警)B | OV_B_WRN |
| 2031 | 过压(报警)C | OV_C_ALM |
| 2032 | 过压(预警)C | OV_C_WRN |
| 2033 | 过流(报警)A | OC_A_ALM |
| 2034 | 过流(预警)A | OC_A_WRN |
| 2035 | 过流(报警)B | OC_B_ALM |
| 2036 | 过流(预警)B | OC_B_WRN |
| 2037 | 过流(报警)C | OC_C_ALM |
| 2038 | 过流(预警)C | OC_C_WRN |
| 2039 | 温度(报警)A | OT_A_ALM |
| 2040 | 温度(预警)A | OT_A_WRN |
| 2041 | 温度(报警)B | OT_B_ALM |
| 2042 | 温度(预警)B | OT_B_WRN |
| 2043 | 温度(报警)C | OT_C_ALM |
| 2044 | 温度(预警)C | OT_C_WRN |
| 2045 | 温度(报警)N | OT_N_ALM |
| 2046 | 温度(预警)N | OT_N_WRN |
| 2047 | 缺相(报警)A | PH_LOSS_A |
| 2048 | A相漏电识别 | RCD_A_FLG |
| 2049 | 缺相(报警)B | PH_LOSS_B |
| 2050 | B相漏电识别 | RCD_B_FLG |
| 2051 | 缺相(报警)C | PH_LOSS_C |
| 2052 | C相漏电识别 | RCD_C_FLG |
| 2053 | 负载不均衡(报警) | UNB_ALM |
| 2054 | 负载不均衡(预警) | UNB_WRN |
| 2064 | 检修模式 | MAINT_MODE |
| 2073 | 谐波报警 | HARM_ALM |
| 2074 | 特波报警 | SP_HARM_ALM |
| 2075 | N相电流预警 | IN_N_WRN |
| 2076 | N相电流报警 | IN_N_ALM |
| 2077 | N相电压 | UN |
6. EdgeBus 模型
6.1 EB 配置参数
- 采集器:KC21
- 串口参数:9600 / 8N1 / 无校验
Battery: falseConfirmDuty: 60BzType: 22103BzVersion: 13- LoRaWAN 上行端口:22
- 数据类型:
0x86 - 版本:
0x03 - 上传周期参数地址:70
- 采集周期参数地址:74
- Modbus 地址参数映射:150
6.2 EB 代码
typescript
import { Buffer } from "buffer";
import { buildOtaFile } from "@EBSDK/run";
import {
ActionAfertExpr, CalcData,
CrcMode,
CvtRule,
EBBuffer,
EBModel,
ExprCondition,
LoraUpEvent,
QueryEvent, SetUpCovDataType,QuItemBase,
UserConfUPItem, EventInfoItem, QuItemModBus, UserConfQueryItem, EventConfig, Utils
} from "@EBSDK/EBCompiler/all_variable";
import { CheckbitEnum, getOtaConfig, HwTypeEnum, UpgrdTypeEnum } from "@EBSDK/otaConfig";
////////////////////////////////////////////////////////////////////////////////////////
//ZHUOWEN mcb SZWB1L
const eventInfo:UserConfUPItem[]=[
{
name:"mcb",dataType:"0x86", port:22, version:"0x03",upPeriodIndex:70,//upPeriod:"300s",
quInfo:[
{
protocol:"modbus",addr:"0x01",code:"0x04", periodIndex:70,//period:"300s",
indexAPP:150, indexCMD:0, copySize:1,isLast:false,
listVal:[
{ start: "3000", end: "3000"},
{ start: "3003", end: "3017"},
{ start: "3019", end: "3027"},
{ start: "3029", end: "3031"},
{ start: "3033", end: "3070"},
{ start: "3075", end: "3107"},
]
},
{
protocol:"modbus", code:"0x02",periodIndex:74, //period:"30s",
indexAPP:150, indexCMD:0, copySize:1,isLast:false,
listVal:[
{ start: "0x07D0", end: "0x0806",covType:"HEX"}
]
},
{
protocol:"modbus", code:"0x01",periodIndex:74, //period:"30s",
indexAPP:150, indexCMD:0, copySize:1,isLast:false,
listVal:[
{ start: "0", end: "0",covType:"HEX"}
]
}
]
}
]
let otaConfig = getOtaConfig({
SwVersion:31,
BaudRate: 9600,
StopBits: 1,
DataBits: 8,
Checkbit: CheckbitEnum.NONE,
Battery: false,
ConfirmDuty: 60,
BzType: 22103,
BzVersion: 13
})
const MODBUS_TT = (ebModel: EBModel) => {
for (let i=0; i<eventInfo.length; i++){
let event=new EventInfoItem(eventInfo[i]);
event.upEventSetup()
event.eventInstall()
}
return JSON.stringify(ebModel, null, 2)
}
buildOtaFile(import.meta.url, otaConfig, MODBUS_TT)6.3 说明
当前 EB 逻辑说明:
- 使用
0x04读取完整测量数据,作为主数据上报内容。 - 使用
0x02读取告警/预警状态位,作为变化触发依据。 - 使用
0x01读取开关状态。 - 上传周期与采集周期分离:
70用于上传周期,74用于采集周期。 indexAPP:150对应 Modbus 地址参数映射,便于通过参数方式修改从站地址。- 由于 SZWB1L 测点很多,完整上行包较长,项目中建议按场景裁剪测点,避免无效数据占用空口资源。
- 告警信息最终被编码为
warnCode,并在物模型脚本中进一步解析为可读warning文本。 - 透明传输端口
51用于配合远程开关控制结果回传,将透明数据转换为switch状态。
7. 物模型
7.1 物模型基本信息
数据物模型
- 名称:
[ZW-SZWB1] - id Name:
zw_szwb1_22103 - 上行端口:22
- 标签:
0x86 0x03
参数物模型
- 名称:
[SZWB1-PARA] - id Name:
szwb1_para_22103
7.2 上行帧结构
port: 22dataLen: -1rssi: truebattery: truetagList:index:0, tag:0x86index:1, tag:0x03
主要字段如下:
DIPI / U / P / Q / S / ETs / IresIa / Ib / Ic / In / IrUa / Ub / UcPa / Pb / PcQa / Qb / QcSa / Sb / ScEsa / Esb / Esc / EsTa / Tb / Tc / TnEp / Epa / Epb / EpcEq / Eqa / Eqb / EqcFreqwarnCodeswitch- 派生字段:
warning
7.3 物模型脚本
javascript
let frameInfo={
port:22, dataLen:-1,rssi:true,battery:true,
tagList:[{ index:0, tag:0x86}, { index:1, tag:0x03}]
}
const ALARM_MAP = {
// 单相告警
2000: "单相欠压(报警)",
2001: "单相欠压(预警)",
2002: "单相过压(报警)",
2003: "单相过压(预警)",
2004: "单相过流(报警)",
2005: "单相过流(预警)",
2006: "单相线温(报警)",
2007: "单相线温(预警)",
2008: "漏电(报警)",
2009: "漏电(预警)",
// 功率和短路告警
2012: "过功率报警(报警)",
2013: "过功率报警(预警)",
2014: "短路报警(报警)",
2015: "短路报警(预警)",
2016: "接地报警",
// 相序和分相告警
2020: "相序错误报警",
2021: "欠压(报警)A",
2022: "欠压(预警)A",
2023: "欠压(报警)B",
2024: "欠压(预警)B",
2025: "欠压(报警)C",
2026: "欠压(预警)C",
2027: "过压(报警)A",
2028: "过压(预警)A",
2029: "过压(报警)B",
2030: "过压(预警)B",
2031: "过压(报警)C",
2032: "过压(预警)C",
2033: "过流(报警)A",
2034: "过流(预警)A",
2035: "过流(报警)B",
2036: "过流(预警)B",
2037: "过流(报警)C",
2038: "过流(预警)C",
2039: "温度(报警)A",
2040: "温度(预警)A",
2041: "温度(报警)B",
2042: "温度(预警)B",
2043: "温度(报警)C",
2044: "温度(预警)C",
2045: "温度(报警)N",
2046: "温度(预警)N",
2047: "缺相(报警)A",
2048: "A相漏电识别",
2049: "缺相(报警)B",
2050: "B相漏电识别",
2051: "缺相(报警)C",
2052: "C相漏电识别",
2053: "负载不均衡(报警)",
2054: "负载不均衡(预警)"
};
let appInfo = [
{ name: "面板拨码开关", field_name: "DIP", unit: "", index: 6, type: "uint8", coefficient: 1, options: {0: "断开/锁定, 远控无效, 漏保有效", 1: "闭合/解锁, 远控有效, 漏保无效"} },
{ name: "单相两线电流", field_name: "I", unit: "A", index: 8, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "单相电压", field_name: "U", unit: "V", index: 12, type: "int16be", coefficient: 0.01, decimal: 2 },
{ name: "单相两线有功功率/三相合有功功率", field_name: "P", unit: "W", index: 14, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "单相两线无功功率/三相合无功功率", field_name: "Q", unit: "Var", index: 18, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "单相两线视在功率/三相合视在功率", field_name: "S", unit: "VA", index: 22, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "单相有功电能/三相合视在电能", field_name: "E", unit: "kWh", index: 26, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "单相L线温", field_name: "Ts", unit: "℃", index: 34, type: "int16be", coefficient: 0.1, decimal: 1 },
{ name: "剩余电流", field_name: "Ires", unit: "mA", index: 36, type: "uint16be", coefficient: 0.001, decimal: 3 },
{ name: "A相电流", field_name: "Ia", unit: "A", index: 38, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "B相电流", field_name: "Ib", unit: "A", index: 42, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "C相电流", field_name: "Ic", unit: "A", index: 46, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "N相电流", field_name: "In", unit: "A", index: 50, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "额定电流", field_name: "Ir", unit: "A", index: 54, type: "int16be", coefficient: 1, decimal: 0 },
{ name: "A相电压", field_name: "Ua", unit: "V", index: 56, type: "int16be", coefficient: 0.01, decimal: 2 },
{ name: "B相电压", field_name: "Ub", unit: "V", index: 58, type: "int16be", coefficient: 0.01, decimal: 2 },
{ name: "C相电压", field_name: "Uc", unit: "V", index: 60, type: "int16be", coefficient: 0.01, decimal: 2 },
{ name: "有功功率A", field_name: "Pa", unit: "W", index: 62, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "有功功率B", field_name: "Pb", unit: "W", index: 66, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "有功功率C", field_name: "Pc", unit: "W", index: 70, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "无功功率A", field_name: "Qa", unit: "Var", index: 74, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "无功功率B", field_name: "Qb", unit: "Var", index: 78, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "无功功率C", field_name: "Qc", unit: "Var", index: 82, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "视在功率A", field_name: "Sa", unit: "VA", index: 86, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "视在功率B", field_name: "Sb", unit: "VA", index: 90, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "视在功率C", field_name: "Sc", unit: "VA", index: 94, type: "int32be", coefficient: 0.001, decimal: 3 },
{ name: "视在能量A", field_name: "Esa", unit: "VAh", index: 98, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "视在能量B", field_name: "Esb", unit: "VAh", index: 106, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "视在能量C", field_name: "Esc", unit: "VAh", index: 114, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "三相合视在能量", field_name: "Es", unit: "VAh", index: 122, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "A线温度", field_name: "Ta", unit: "℃", index: 130, type: "int16be", coefficient: 0.1, decimal: 1 },
{ name: "B线温度", field_name: "Tb", unit: "℃", index: 132, type: "int16be", coefficient: 0.1, decimal: 1 },
{ name: "C线温度", field_name: "Tc", unit: "℃", index: 134, type: "int16be", coefficient: 0.1, decimal: 1 },
{ name: "N线温度", field_name: "Tn", unit: "℃", index: 136, type: "int16be", coefficient: 0.1, decimal: 1 },
{ name: "单相视在能量/三相合有功电能", field_name: "Ep", unit: "kWh", index: 138, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "A相有功能量", field_name: "Epa", unit: "kWh", index: 146, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "B相有功能量", field_name: "Epb", unit: "kWh", index: 154, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "C相有功能量", field_name: "Epc", unit: "kWh", index: 162, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "单相无功能量/三相合无功电能", field_name: "Eq", unit: "kVarh", index: 170, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "A相无功能量", field_name: "Eqa", unit: "kVarh", index: 178, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "B相无功能量", field_name: "Eqb", unit: "kVarh", index: 186, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "C相无功能量", field_name: "Eqc", unit: "kVarh", index: 194, type: "int64be", coefficient: 1, decimal: 0 },
{ name: "电网频率", field_name: "Freq", unit: "Hz", index: 202, type: "int16be", coefficient: 0.1, decimal: 1 },
{ name: "告警", field_name: "warnCode", unit: "", index: 204, type: "hexbe7" },
{ name: "开关状态", field_name: "switch", unit: "", index: 211, type: "bitle0-0" },
]
let transFrameInfo={ port:51}
let transAppInfo = [
{name: "code", field_name: "code", index: 1, type: "uint8"}
]
let tdata=null
if( port===51) {
let rpcSwitch=device.server_attrs.szwb1_22103_switch
if (rpcSwitch?.ms==undefined) return null
let diff=Date.now()-rpcSwitch.ms
if (diff>5000) return null
let transParser=new PayloadParser({
device:device, msg:msg, frameInfo:transFrameInfo, appInfo:transAppInfo}
)
let transData=transParser.telemetry()
if (transData==undefined) return null
tdata={}
if (transData.code===0x05) {
if (rpcSwitch?.params?.switch===true) {tdata.switch=1
}else { tdata.switch=0 }
}
}else {
let payParser=new PayloadParser({
device:device, msg:msg, frameInfo:frameInfo, appInfo:appInfo}
)
tdata= payParser.telemetry();
if (tdata.warnCode!=undefined) {
let alarmBuffer=new BufferTKL(Buffer.from(tdata.warnCode,"hex"))
let warnInfo="warning: "
let alarmcount=0
for(let i=0;i<55;i++) {
let content=ALARM_MAP[2000 + i]
if (content==undefined) continue
let val =alarmBuffer.read(0,"bitLE"+i.toString(10)+"-"+i.toString(10))
if (val===0) continue
if (alarmcount!==0) {warnInfo+=","}
warnInfo+=content
alarmcount++
}
if (alarmcount===0) { warnInfo="normal"}
tdata.warning=warnInfo;
}
}
return {
telemetry_data: tdata,
server_attrs: null,
shared_attrs: null,
};8. 第三方平台数据订阅
8.1 MQTT Topic
/v32/{Organization Account}/tkl/up/telemetry/{eui}
8.2 上报示例数据
json
{
"eui": "6353012af10a9331",
"active_time": "2026-02-05T08:35:48.000Z",
"thingModelId": "zw_szwb1_22103",
"thingModelIdName": "ZW-SZWB1",
"telemetry_data": {
"DIP": 1,
"I": 12.345,
"U": 220.15,
"P": 2500.123,
"Q": 120.456,
"S": 2520.789,
"Ts": 36.5,
"Ires": 0.012,
"Ia": 12.111,
"Ib": 11.982,
"Ic": 12.204,
"Ua": 220.13,
"Ub": 219.98,
"Uc": 220.42,
"Freq": 50.0,
"warnCode": "00000000000000",
"warning": "normal",
"switch": 1
}
}9. RPC
9.1 RPC 名称
[SZWB1 SET] para- id Name:
szwb1_set_para_22103
- id Name:
[SZWB1 GET] para- id Name:
szwb1_get_22103
- id Name:
9.2 参数定义
| 参数地址 | 参数名 | 字段名 | 类型 | 说明 |
|---|---|---|---|---|
| app_70 | period_up | period_up | uint32le | 上传周期,单位秒 |
| app_74 | period_read | period_read | uint32le | 采集周期,单位秒 |
| app_150 | addr_modbus | addr_modbus | uint8 | Modbus 从站地址 |
9.3 RPC 代码
设置参数
javascript
let classMode = (device && device.shared_attrs && device.shared_attrs.class_mode) || "ClassA";
const rpcName="szwb1_set_para_22103"
let paraDef = {
app_70:{name: "period_up", field_name: "period_up", unit:"S", type: "uint32le"},
app_74:{name: "period_read", field_name: "period_read", unit:"S", type: "uint32le"},
app_150:{name: "addr_modbus", field_name: "addr_modbus", unit:"", type: "uint8"}
}
let frames=RPCHelper.buildFrame({
paraDef:paraDef,
params:params});
let redoBuffer=RPCHelper.redo()
let dnBuffer=Buffer.alloc(frames.writeBuffer.length+frames.readBuffer.length);
frames.writeBuffer.copy(dnBuffer,0)
frames.readBuffer.copy(dnBuffer,frames.writeBuffer.length)
logger.info("set para")
let msgQue=Utils.makeParaSetMSG({
device:device,
classMode:classMode,
rpcName:rpcName,
params:params,
paraDownBuffer:dnBuffer,
extraAppBuffer:redoBuffer
})
if (msgQue.length==0) return null
return msgQue读取参数
javascript
let paraDef = {
app_70:{name: "period_up", field_name: "period_up", unit:"S", type: "uint32le"},
app_74:{name: "period_read", field_name: "period_read", unit:"S", type: "uint32le"},
app_150:{name: "addr_modbus", field_name: "addr_modbus", unit:"", type: "uint8"}
}
let frames=RPCHelper.buildFrame({
paraDef:paraDef,
params:params});
let msg=RPCHelper.makeMSG({
msgType:Utils.msgType.paras,
device:device,
dnBuffer:frames.readBuffer,
sleepTime:0,
})
return [msg]10. 模板选择
在 ThinkLink 平台中搜索模板:
SZWB1
或按业务类型查找:
- 低压配电监测
- 微型断路器
- 用电安全监测
- 配电箱远程监控