当前位置:网站首页>Internet of things development practice 06 things model: how to define intelligent lights? (study notes)
Internet of things development practice 06 things model: how to define intelligent lights? (study notes)
2022-04-21 13:15:00 【Xiao Hui_ Super】
Learn only as yourself 《 The development of the Internet of things 》 Learning notes of , Link to the original course : Geek time 《 The development of the Internet of things 》—— Guo Chaobin
In the Internet of things , How to provide the control interface information of the underlying hardware ? How does the platform application match with devices of different brands ( Development )?
We need to solve this problem , By adding an intermediate protocol layer , For example, browse different files in the browser ( Text 、 Audio and video etc. ) Through HTML( Hypertext markup language ) To express , The Internet of things has a similar protocol layer ——Thing Specification Language, abbreviation TSL.
Use TSL Describe the entity model in the Internet of things , Namely ” Models of things , Or called “ product model ”, It's also called “ Data panel ” Of .
What is the relationship between IOT model and equipment ?
The object model is an abstraction of the physical world , After digital description , A digital model for the digital world . Direct point , Object model is a language that can be understood by computer , Make it clear what this product is 、 What can be done , And what information can be provided .
In turn, , The object model also specifies the function of the equipment . New equipment , If it's the same type , In the design 、 Under development , Will follow the same functional definition , Have the same characteristics , Implement the same service .
How to define the object model
We usually use attributes 、 Event and action are three functional elements to define .
attribute (Property): Describe a certain state when the product is running , Property can be read and written , For example, the two properties of temperature and humidity of environmental detection equipment .
event (Event): Summarize the information generated during the operation of the equipment 、 Warnings and faults, etc , It's an event. . The event is reported by the equipment , Cannot be set by app .
action (Action): Also known as services , The action is sent to the device by the application , The device can return results to the application . Actions can be further divided into synchronous and asynchronous .
Data type of object model
There are six types of object models :
- Boolean type (Bool): Non true or false binary variables .
- Integer type (Int): Linearly adjustable integer variables .
- String type (String): A variable expressed as a string .
- floating-point (Float): Variables with floating-point precision .
- enum (Enum): Custom finite set values .
- Time type (Timestamp):String Type of UTC Time stamp .
Physical type is generally used JSON Format to express model elements .JSON yes Web In development , Frequently used data formats .
Define the IOT model of intelligent electric lamp
Intelligent electric switch attribute Corresponding JSON Say as follows :
{
"id": "power_switch", // The identification of the property
"name": " Light switch ", // name
"desc": " Light switch control ", // Description of the property
"required": true, // Indicates whether this property must contain
"mode": "rw", // Attribute mode , Set to read and write
"define": {
// The numeric definition of the property
"type": "bool", // Type of value , Boolean type
"mapping": {
// The meaning of specific values
"0": " Turn off ",
"1": " open "
}
}
}
Intelligent electric lamp event , The voltage of the light needs to be monitored , When the voltage is too low , You can report this event ( The voltage is too low ), The data type is floating point , Corresponding JSON The format is described below :
{
"id": "voltage_too_low", // Identification of the event
"name": " The light is too low ", // name
"desc": " The voltage is too low ", // Description of the event
"required": false, // Indicates whether this property must contain
"params": [ // Parameters of the event
{
"id": "voltage", // Identification of event parameters
"name": " voltage ", // name
"desc": " The current voltage ", // Description of parameters
"define": {
// Numerical definition of parameters
"type": "float", // Type of value , floating-point
"unit": "V", // The unit of value , Volt
"step": "1", // The change step of the value
"min": "0.0", // The minimum value of the value
"max": "24.0", // The maximum value of the value
"start": "1", // The starting value of the event
}
}
]
}
action Definition and properties of 、 The process of defining events is similar to .
Should each model be defined from scratch ?
When creating a model , Yes Copy and Inherit Two modes , Their differences are reflected in the model relationship .
Copy mode is similar to value copy in programming , The new model has exactly the same elements as the copied model , The two models are independent of each other , Model changes do not affect each other .
Inheritance pattern is the concept of inheritance in programming , The new model is defined as “ Submodels ”, The inherited model is defined as “ Parent model ”.
Extended application of object model
Device shadow
Device shadow is used for Cache device status . The application can directly obtain the last updated attribute value of the device through the device shadow , Without having to access the device every time . When the device is online , Application instructions can be obtained directly ; When the device is offline , When you go online again, you can actively pull application instructions .
such as , The switching state of the smart light is a property , You can change... Locally through physical switches , If the network is unstable , Then the state on the platform may not be synchronized with the real state . Device shadow can be synchronized in both directions , Realize the consistency between the server and the device , To solve this problem .
Number twin (Digital Twin)
Object model is the digital model of physical entity , But it is mainly aimed at the development of applications and equipment interoperability in the Internet of things . This model integrates all kinds of data of physical entities , These data will evolve with the physical entity in the life cycle of the physical entity , Accumulate all kinds of information and knowledge , And promote the optimization of physical entities . Such a model is the digital twin of physical entities .
版权声明
本文为[Xiao Hui_ Super]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211313538749.html
边栏推荐
- 【数字信号处理】线性常系数差分方程 ( 使用 matlab 求解 “ 线性常系数差分方程 “ 示例 | A 向量分析 | B 向量分析 | 输入序列分析 | matlab 代码 )
- Revit二次开发——创建墙体(1)(第十期)
- S TYLE N E RF: A S TYLE - BASED 3D-A WARE G ENERA - TOR FOR H IGH - RESOLUTION I MAGE S YNTHESIS
- S: Unit gain compensation
- Baidu map development custom information window openinfowindow style
- 【数字信号处理】相关系数 ( 相关系数概念解析 | 信号能量常数 | 共轭序列 | 序列在相同时刻的相关性 )
- Blazor 的 NavLink 的 NavLinkMatch.Prefix 有啥作用
- leetcode:无数个面额的硬币得到amount的选法(dp)
- MySQL uses PIP and binlog2sql to install
- Qfileinfo file and folder operations
猜你喜欢

2021-08-10

Wanzi dry goods! Help you master the knowledge of "light and shadow" in design

Netease cloud - Mobile authentication code login

动手篇 | 如何在麒麟v10 SP2安装达梦8版本数据库

3、 Label preparation

36 day assault Tencent finally took the offer! Redis, high concurrency

S TYLE N E RF: A S TYLE - BASED 3D-A WARE G ENERA - TOR FOR H IGH - RESOLUTION I MAGE S YNTHESIS

Go语言 文件操作

万字干货!帮你深度掌握设计中的「光影」知识点 (下)

Network communication protocol model
随机推荐
PostgreSQL 15 will soon support merge statements in the SQL standard
S TYLE N E RF: A S TYLE - BASED 3D-A WARE G ENERA - TOR FOR H IGH - RESOLUTION I MAGE S YNTHESIS
网易数帆王佰平:我的 Envoy Maintainer 之路
[C#]给地球来点光
Technology giants compete to enter, who can become the "number one player" of the meta universe?
让你的代码更优秀的 14 条建议
Revit secondary development - creating elevation (phase 8)
The return value of [SV] function is a parameterized function of variable matrix
Wang Baiping: my way to envoy maintainer
How to open a securities account for goucai? Is it safer to open an account in a securities firm?
SSM高校实验室安全培训系统设计与实现.docx
Netease cloud - Mobile authentication code login
Qfileinfo file and folder operations
2021-08-10
Installing and configuring canal
【数字信号处理】线性常系数差分方程 ( 使用 matlab 求解 “ 线性常系数差分方程 “ 示例 | A 向量分析 | B 向量分析 | 输入序列分析 | matlab 代码 )
通过Ffmpeg把M3u8格式转换成Mp4
[digital signal processing] correlation function (energy signal | cross correlation function of energy signal | autocorrelation function of energy signal)
Convert m3u8 format to MP4 through fmpeg
乡村vlog收割8000w+播放,又一个流量天花板?