跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
Wiki首页
Domoticz 中文站
Domoticz 论坛
Domoticz Github
随机页面
特殊页面
特殊页面
所有页面
分类
最近更改
Domoticz
搜索
搜索
登录
个人工具
登录
查看“Developing a hardware plugin”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
←
Developing a hardware plugin
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
=我应该创建一个 C++ 硬件插件吗?= 可能不需要.<br><br>Domoticz 支持 Python 插件框架,无论从保证 Domoticz 核心系统更小还是更专注等方面都应该使用 Python. 细节请参考这里: [[Developing a Python plugin]] 只有不能被 Python 框架很好兼容的硬件才需要增加 C++ 插件.<br> =在硬件目录创建一个 .cpp 和一个 .h 文件= 通过查看其他插件作为一个好的例子,重命名这些文件和这些文件中的类和定义。例如:Sonos 硬件插件,我修改了这些文件: * hardware/SonosPlugin.cpp * hardware/SonosPlugin.h =在适当的全局文件中增加新的硬件= 接下来我们需要使 domotic 检测到新的插件存在。 '''main/RFXNames.h''' 增加 HTYPE_SonosPlugin 到 _eHardwareTypes '''main/RFXNames.cpp''' 增加 HTYPE_SonosPlugin 到 Hardware_Type_Desc '''main/mainworker.cpp''' 为硬件增加 #include "../hardware/SonosPlugin.h" 到 includes 文件末尾。 为 AddHardwareFromParams 方法添加 CSonosPlugin 的实例化(new)。 '''main/WebServer.cpp''' 通过 Cmd_UpdateHardware 增加 HTYPE_SonosPlugin 的操作,确保所有所需的硬件设置都有值。 在添加串行设备时,将HTYPE添加到 main/RFXNames.cpp 中的 IsSerialDevice 中。 =Add the UI to create the new hardware in the Hardware tab= '''www/app/HardwareController.js''' Add the Hardware to the field verifications in UpdateHardware and AddHardware (look for text.indexOf("YourModelPlugin")). Don't forget to also edit the RefreshHardwareTable function, where the hardware items are referred by numeric id!!! I'm assuming here that no extra configuration data for hardware is needed. If you need it, other plugins reuse the hardware available fields from the database: Address VARCHAR(20), Port INTEGER, Username VARCHAR(100), Password VARCHAR(100), Mode1 - Mode5 CHAR If you need to let the user edit this fields, create the corresponding Edit* function in HardwareController.js (use available ones as inspiration). '''www/html5.appcache''' Increment the ref number on the second line so that the browser knows the js file has been updated and to force a refresh of the hardware list. =Change the makefile= '''CMakeLists.txt''' Add hardware/SonosPlugin.cpp to Target - Trick: While debugging, add it close to the top (issues will arrive earlier); later add it as the last hardware code target. Add the needed specific libraries for linking. In this case (in gcc you would use the -llibname syntax): pthread gupnp-1.0 gssdp-1.0 gupnp-av-1.0 glib-2.0 gobject-2.0 gthread-2.0 Add the needed specific headers/includes. '''Build Makefile''' You change that modifying the CMakeLists.txt and then creating a makefile <nowiki> cmake CMakeLists.txt (raspberry) or cmake -DCMAKE_BUILD_TYPE=Release . (cubieboard) </nowiki> You have to add to the makefile all the libraries and includes needed for your specific plugin. And maybe other compiler/linker options. (The syntax for CMake is tricky. I've just added what I needed in a quick and dirty way. There's for sure a better way to do that.) =Install any prerequisite packages= for raspbian: sudo apt-get install sometimes you need the -dev version, you never know!. In this case I had to install this libraries. Check the name of the latest available version using "apt-cache search". libgupnp-1.0-dev libgupnp-av-1.0-dev libgssdp-1.0-dev libsoup2.4-dev libxml2 // libg glib =Compile and have fun=
返回
Developing a hardware plugin
。
开关有限宽度模式