Update 适配器.md

This commit is contained in:
钟进 2018-09-23 21:12:01 +08:00
parent b3fbf926bc
commit d6d4fdec06

View File

@ -28,7 +28,7 @@
- [Functions](#functions)
- [How to create instance](#how-to-create-instance)
- [如何创建实例](#如何创建实例)
- [How to debug](#how-to-debug)
- [admin.html](#adminhtml)
- [最佳实践](#best-practice)
@ -786,15 +786,15 @@ adapter.getObject('myObject', function (err, obj) {
});
```
Functions are always asynchronous.
函数始终是异步的。
Objects of adapter must be organized in devices, channels and states.
See: getForeignObjects, findForeignObject, getForeignObject, getDevices, getChannels, getStatesOf
#### How to write object
To write the objects generally two functions can be used: setObject, setForeignObject.
But there are many help functions to modify objects:
#### 写对象
要编写对象通常可以使用两个函数setObjectsetForeignObject。但是有许多帮助函数来修改对象
- extendObject, extendForeignObject,
- delObject, delForeignObject,
@ -804,11 +804,12 @@ But there are many help functions to modify objects:
- createState, deleteState
- addStateToEnum, deleteStateFromEnum
extendObject只是读取对象与给定对象合并并将对象写回。
extendObject is just reads object, merges with given one and write object back.
Difference between xxxObject and xxxForeignObject is that xxxObject automatically extends the object id with "adapter.instance." text.
Functions are always asynchronous.
函数始终是异步的。
```
adapter.getForeignObject('otherAdapter.X.someState', function (err, obj) {
@ -825,6 +826,10 @@ adapter.getForeignObject('otherAdapter.X.someState', function (err, obj) {
```
#### info.connection
如果适配器建立并监视某些连接例如对受控设备则应创建并维护info.connection变量。
如果发生这种情况连接状态将显示在“admin”的实例列表中如果需要将根据连接状态设置状态质量。
If the adapter establishes and monitors some connection (e.g. to controlled device), it should create and maintenance **info.connection** variable.
If it happens, the status of connection will be shown in the instance's list in "admin" and if desired, the quality of states will be set up depends on the connection status.
@ -915,7 +920,9 @@ EVENTS:
- stateChange(id, state) (Warning state can be null if deleted)
- unload
## How to create instance
## 如何创建实例
在发布到npm之前复制到ioBroker / node_modules转到“admin”并添加实例在npm发布后转到ioBroker /并写入“npm install iobroker.xxx --production”转到“admin”并添加实例
Before published to npm: copy into ioBroker/node_modules, go to "admin" and add instance
After published at npm: go to ioBroker/ and write "npm install iobroker.xxx --production", go to "admin" and add instance
@ -946,5 +953,5 @@ After published at npm: go to ioBroker/ and write "npm install iobroker.xxx --pr
- function getTableResult(tabId, cols)
## Best practice
## 最佳实践
...