什么是物模型
物模型這個概念好像也是阿里先提出來的,定義iot中的設備具有三個緯度
屬性---上報數據時各個狀態;功能---提供給外部調用的接口;事件---主動上報出來的事件,如心跳,告警等
A Thing 基於aliyunJAVASDK做的優化的項目,目前可能還不會仔細學習,先放着,2021.7.20
https://github.com/athingx/athing
數據格式
這篇主要描寫了物模型的一些數據格式
下圖貼了一個阿里標准定義的路燈的物模型JSON.
{ "schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json", "profile": { "version": "1.0", "productKey": "a1wuKiOVolu" }, "properties": [ { "identifier": "LightStatus", "name": "工作狀態", "accessMode": "rw", "required": true, "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LightAdjustLevel", "name": "調光等級", "accessMode": "rw", "desc": "調光等級采用百分比表示", "required": true, "dataType": { "type": "int", "specs": { "min": "0", "max": "100", "unit": "%", "unitName": "百分比", "step": "1" } } }, { "identifier": "LightVolt", "name": "工作電壓", "accessMode": "r", "desc": "顯示設備電壓;電參數采用4個字節浮點型數據", "required": true, "dataType": { "type": "float", "specs": { "min": "0", "max": "4", "unit": "V", "unitName": "伏特", "step": "0.1" } } }, { "identifier": "LightCurrent", "name": "工作電流", "accessMode": "r", "desc": "電參數采用4個字節浮點型數據", "required": true, "dataType": { "type": "float", "specs": { "min": "0", "max": "9", "unit": "A", "unitName": "安培", "step": "0.1" } } }, { "identifier": "ActivePower", "name": "有功功率值", "accessMode": "r", "desc": "電參數采用4個字節浮點型數據", "required": true, "dataType": { "type": "float", "specs": { "min": "0", "max": "1000", "unit": "W", "unitName": "瓦特", "step": "0.1" } } }, { "identifier": "PowerRatio", "name": "功率因數", "accessMode": "r", "desc": "電參數采用4個字節浮點型數據", "required": true, "dataType": { "type": "float", "specs": { "min": "0.01", "max": "1", "unit": "pF", "unitName": "皮法", "step": "0.1" } } }, { "identifier": "PowerConsumption", "name": "用電量", "accessMode": "r", "desc": "耗電量;電參數采用4個字節浮點型數據", "required": true, "dataType": { "type": "float", "specs": { "min": "0", "max": "2147483647", "unit": "kW·h", "unitName": "千瓦·時", "step": "0.1" } } }, { "identifier": "DrainVoltage", "name": "漏電壓", "accessMode": "r", "desc": "電參數采用4個字節浮點型數據", "required": true, "dataType": { "type": "float", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "0.1" } } }, { "identifier": "TiltValue", "name": "傾斜角度值", "accessMode": "r", "desc": "路燈的傾斜角度;采用1個字節16進制數", "required": true, "dataType": { "type": "int", "specs": { "min": "0", "max": "90", "unit": "°", "unitName": "度", "step": "1" } } }, { "identifier": "ErrorPowerThreshold", "name": "故障功率門限", "accessMode": "rw", "desc": "故障功率門限", "required": true, "dataType": { "type": "int", "specs": { "min": "0", "max": "1000", "unit": "W", "unitName": "瓦特", "step": "1" } } }, { "identifier": "ErrorCurrentThreshold", "name": "故障電流門限", "accessMode": "rw", "required": true, "dataType": { "type": "float", "specs": { "min": "0.1", "max": "9", "unit": "A", "unitName": "安培", "step": "0.1" } } }, { "identifier": "TiltThreshold", "name": "傾斜閾值", "accessMode": "rw", "required": true, "dataType": { "type": "int", "specs": { "min": "0", "max": "90", "unit": "°", "unitName": "度", "step": "1" } } }, { "identifier": "UnderVoltThreshold", "name": "欠壓閾值", "accessMode": "rw", "required": true, "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "OverCurrentThreshold", "name": "過流閾值", "accessMode": "rw", "required": true, "dataType": { "type": "int", "specs": { "min": "0", "max": "9", "unit": "A", "unitName": "安培", "step": "1" } } }, { "identifier": "OverVoltThreshold", "name": "過壓閾值", "accessMode": "rw", "required": true, "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "LightErrorEnable", "name": "燈具故障使能", "accessMode": "rw", "desc": "1:打開,0:關閉", "required": true, "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverCurrentEnable", "name": "過流告警使能", "accessMode": "rw", "desc": "1:打開,0:關閉", "required": true, "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverVoltEnable", "name": "過壓告警使能", "accessMode": "rw", "desc": "1:打開,0:關閉", "required": true, "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "UnderVoltEnable", "name": "欠壓告警使能", "accessMode": "rw", "desc": "1:打開,0:關閉", "required": true, "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LeakageEnable", "name": "漏電告警使能", "accessMode": "rw", "desc": "1:打開,0:關閉", "required": true, "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverTiltEnable", "name": "傾斜告警使能", "accessMode": "rw", "desc": "1:打開,0:關閉", "required": true, "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LampError", "name": "燈具故障告警", "accessMode": "r", "desc": "1-告警;0-正常", "required": true, "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverCurrentError", "name": "過流告警", "accessMode": "r", "desc": "1-告警;0-正常", "required": true, "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverVoltError", "name": "過壓告警", "accessMode": "r", "desc": "1-告警;0-正常", "required": true, "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "UnderVoltError", "name": "欠壓告警", "accessMode": "r", "desc": "1-告警;0-正常", "required": true, "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverTiltError", "name": "傾斜告警", "accessMode": "r", "desc": "1-告警;0-正常", "required": true, "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "LeakageError", "name": "漏電告警", "accessMode": "r", "desc": "1-告警;0-正常", "required": true, "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "GeoLocation", "name": "地理位置", "accessMode": "rw", "required": true, "dataType": { "type": "struct", "specs": [ { "identifier": "longitude", "name": "經度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "latitude", "name": "緯度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "altitude", "name": "高度", "dataType": { "type": "double", "specs": { "min": "0", "max": "9999", "unit": "m", "unitName": "米", "step": "0.01" } } }, { "identifier": "CoordinateSystem", "name": "坐標系統", "dataType": { "type": "enum", "specs": { "1": "WGS_84", "2": "GCJ_02" } } } ] } } ], "events": [ { "identifier": "post", "name": "post", "type": "info", "required": true, "desc": "屬性上報", "method": "thing.event.property.post", "outputData": [ { "identifier": "LightStatus", "name": "工作狀態", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LightAdjustLevel", "name": "調光等級", "dataType": { "type": "int", "specs": { "min": "0", "max": "100", "unit": "%", "unitName": "百分比", "step": "1" } } }, { "identifier": "LightVolt", "name": "工作電壓", "dataType": { "type": "float", "specs": { "min": "0", "max": "4", "unit": "V", "unitName": "伏特", "step": "0.1" } } }, { "identifier": "LightCurrent", "name": "工作電流", "dataType": { "type": "float", "specs": { "min": "0", "max": "9", "unit": "A", "unitName": "安培", "step": "0.1" } } }, { "identifier": "ActivePower", "name": "有功功率值", "dataType": { "type": "float", "specs": { "min": "0", "max": "1000", "unit": "W", "unitName": "瓦特", "step": "0.1" } } }, { "identifier": "PowerRatio", "name": "功率因數", "dataType": { "type": "float", "specs": { "min": "0.01", "max": "1", "unit": "pF", "unitName": "皮法", "step": "0.1" } } }, { "identifier": "PowerConsumption", "name": "用電量", "dataType": { "type": "float", "specs": { "min": "0", "max": "2147483647", "unit": "kW·h", "unitName": "千瓦·時", "step": "0.1" } } }, { "identifier": "DrainVoltage", "name": "漏電壓", "dataType": { "type": "float", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "0.1" } } }, { "identifier": "TiltValue", "name": "傾斜角度值", "dataType": { "type": "int", "specs": { "min": "0", "max": "90", "unit": "°", "unitName": "度", "step": "1" } } }, { "identifier": "ErrorPowerThreshold", "name": "故障功率門限", "dataType": { "type": "int", "specs": { "min": "0", "max": "1000", "unit": "W", "unitName": "瓦特", "step": "1" } } }, { "identifier": "ErrorCurrentThreshold", "name": "故障電流門限", "dataType": { "type": "float", "specs": { "min": "0.1", "max": "9", "unit": "A", "unitName": "安培", "step": "0.1" } } }, { "identifier": "TiltThreshold", "name": "傾斜閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "90", "unit": "°", "unitName": "度", "step": "1" } } }, { "identifier": "UnderVoltThreshold", "name": "欠壓閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "OverCurrentThreshold", "name": "過流閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "9", "unit": "A", "unitName": "安培", "step": "1" } } }, { "identifier": "OverVoltThreshold", "name": "過壓閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "LightErrorEnable", "name": "燈具故障使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverCurrentEnable", "name": "過流告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverVoltEnable", "name": "過壓告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "UnderVoltEnable", "name": "欠壓告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LeakageEnable", "name": "漏電告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverTiltEnable", "name": "傾斜告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LampError", "name": "燈具故障告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverCurrentError", "name": "過流告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverVoltError", "name": "過壓告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "UnderVoltError", "name": "欠壓告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverTiltError", "name": "傾斜告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "LeakageError", "name": "漏電告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "GeoLocation", "name": "地理位置", "dataType": { "type": "struct", "specs": [ { "identifier": "longitude", "name": "經度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "latitude", "name": "緯度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "altitude", "name": "高度", "dataType": { "type": "double", "specs": { "min": "0", "max": "9999", "unit": "m", "unitName": "米", "step": "0.01" } } }, { "identifier": "CoordinateSystem", "name": "坐標系統", "dataType": { "type": "enum", "specs": { "1": "WGS_84", "2": "GCJ_02" } } } ] } } ] } ], "services": [ { "identifier": "set", "name": "set", "required": true, "callType": "async", "desc": "屬性設置", "method": "thing.service.property.set", "inputData": [ { "identifier": "LightStatus", "name": "工作狀態", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LightAdjustLevel", "name": "調光等級", "dataType": { "type": "int", "specs": { "min": "0", "max": "100", "unit": "%", "unitName": "百分比", "step": "1" } } }, { "identifier": "ErrorPowerThreshold", "name": "故障功率門限", "dataType": { "type": "int", "specs": { "min": "0", "max": "1000", "unit": "W", "unitName": "瓦特", "step": "1" } } }, { "identifier": "ErrorCurrentThreshold", "name": "故障電流門限", "dataType": { "type": "float", "specs": { "min": "0.1", "max": "9", "unit": "A", "unitName": "安培", "step": "0.1" } } }, { "identifier": "TiltThreshold", "name": "傾斜閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "90", "unit": "°", "unitName": "度", "step": "1" } } }, { "identifier": "UnderVoltThreshold", "name": "欠壓閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "OverCurrentThreshold", "name": "過流閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "9", "unit": "A", "unitName": "安培", "step": "1" } } }, { "identifier": "OverVoltThreshold", "name": "過壓閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "LightErrorEnable", "name": "燈具故障使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverCurrentEnable", "name": "過流告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverVoltEnable", "name": "過壓告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "UnderVoltEnable", "name": "欠壓告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LeakageEnable", "name": "漏電告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverTiltEnable", "name": "傾斜告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "GeoLocation", "name": "地理位置", "dataType": { "type": "struct", "specs": [ { "identifier": "longitude", "name": "經度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "latitude", "name": "緯度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "altitude", "name": "高度", "dataType": { "type": "double", "specs": { "min": "0", "max": "9999", "unit": "m", "unitName": "米", "step": "0.01" } } }, { "identifier": "CoordinateSystem", "name": "坐標系統", "dataType": { "type": "enum", "specs": { "1": "WGS_84", "2": "GCJ_02" } } } ] } } ], "outputData": [] }, { "identifier": "get", "name": "get", "required": true, "callType": "async", "desc": "屬性獲取", "method": "thing.service.property.get", "inputData": [ "LightStatus", "LightAdjustLevel", "LightVolt", "LightCurrent", "ActivePower", "PowerRatio", "PowerConsumption", "DrainVoltage", "TiltValue", "ErrorPowerThreshold", "ErrorCurrentThreshold", "TiltThreshold", "UnderVoltThreshold", "OverCurrentThreshold", "OverVoltThreshold", "LightErrorEnable", "OverCurrentEnable", "OverVoltEnable", "UnderVoltEnable", "LeakageEnable", "OverTiltEnable", "LampError", "OverCurrentError", "OverVoltError", "UnderVoltError", "OverTiltError", "LeakageError", "GeoLocation" ], "outputData": [ { "identifier": "LightStatus", "name": "工作狀態", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LightAdjustLevel", "name": "調光等級", "dataType": { "type": "int", "specs": { "min": "0", "max": "100", "unit": "%", "unitName": "百分比", "step": "1" } } }, { "identifier": "LightVolt", "name": "工作電壓", "dataType": { "type": "float", "specs": { "min": "0", "max": "4", "unit": "V", "unitName": "伏特", "step": "0.1" } } }, { "identifier": "LightCurrent", "name": "工作電流", "dataType": { "type": "float", "specs": { "min": "0", "max": "9", "unit": "A", "unitName": "安培", "step": "0.1" } } }, { "identifier": "ActivePower", "name": "有功功率值", "dataType": { "type": "float", "specs": { "min": "0", "max": "1000", "unit": "W", "unitName": "瓦特", "step": "0.1" } } }, { "identifier": "PowerRatio", "name": "功率因數", "dataType": { "type": "float", "specs": { "min": "0.01", "max": "1", "unit": "pF", "unitName": "皮法", "step": "0.1" } } }, { "identifier": "PowerConsumption", "name": "用電量", "dataType": { "type": "float", "specs": { "min": "0", "max": "2147483647", "unit": "kW·h", "unitName": "千瓦·時", "step": "0.1" } } }, { "identifier": "DrainVoltage", "name": "漏電壓", "dataType": { "type": "float", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "0.1" } } }, { "identifier": "TiltValue", "name": "傾斜角度值", "dataType": { "type": "int", "specs": { "min": "0", "max": "90", "unit": "°", "unitName": "度", "step": "1" } } }, { "identifier": "ErrorPowerThreshold", "name": "故障功率門限", "dataType": { "type": "int", "specs": { "min": "0", "max": "1000", "unit": "W", "unitName": "瓦特", "step": "1" } } }, { "identifier": "ErrorCurrentThreshold", "name": "故障電流門限", "dataType": { "type": "float", "specs": { "min": "0.1", "max": "9", "unit": "A", "unitName": "安培", "step": "0.1" } } }, { "identifier": "TiltThreshold", "name": "傾斜閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "90", "unit": "°", "unitName": "度", "step": "1" } } }, { "identifier": "UnderVoltThreshold", "name": "欠壓閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "OverCurrentThreshold", "name": "過流閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "9", "unit": "A", "unitName": "安培", "step": "1" } } }, { "identifier": "OverVoltThreshold", "name": "過壓閾值", "dataType": { "type": "int", "specs": { "min": "0", "max": "400", "unit": "V", "unitName": "伏特", "step": "1" } } }, { "identifier": "LightErrorEnable", "name": "燈具故障使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverCurrentEnable", "name": "過流告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverVoltEnable", "name": "過壓告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "UnderVoltEnable", "name": "欠壓告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LeakageEnable", "name": "漏電告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "OverTiltEnable", "name": "傾斜告警使能", "dataType": { "type": "bool", "specs": { "0": "關閉", "1": "打開" } } }, { "identifier": "LampError", "name": "燈具故障告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverCurrentError", "name": "過流告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverVoltError", "name": "過壓告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "UnderVoltError", "name": "欠壓告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "OverTiltError", "name": "傾斜告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "LeakageError", "name": "漏電告警", "dataType": { "type": "bool", "specs": { "0": "正常", "1": "告警" } } }, { "identifier": "GeoLocation", "name": "地理位置", "dataType": { "type": "struct", "specs": [ { "identifier": "longitude", "name": "經度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "latitude", "name": "緯度", "dataType": { "type": "double", "specs": { "min": "-180", "max": "180", "unit": "°", "unitName": "度", "step": "0.01" } } }, { "identifier": "altitude", "name": "高度", "dataType": { "type": "double", "specs": { "min": "0", "max": "9999", "unit": "m", "unitName": "米", "step": "0.01" } } }, { "identifier": "CoordinateSystem", "name": "坐標系統", "dataType": { "type": "enum", "specs": { "1": "WGS_84", "2": "GCJ_02" } } } ] } } ] } ] }