在RaspberryPi和Windows IoT上介绍AllJoyn平台-额外提供美食式南方风味烹饪(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/pi/introduction-to-alljoyn-platform-on-raspberrypi-an-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 19 分钟阅读 - 9365 个词 阅读量 0在RaspberryPi和Windows IoT上介绍AllJoyn平台-额外提供美食式南方风味烹饪(译文)
原文地址:https://www.codeproject.com/Articles/1117035/Introduction-to-AllJoyn-platform-on-RaspberryPi-an
原文作者:Mikolaj Barwicki
译文由本站 robot-v1.0 翻译
前言
How I built a sous-vide cooking device on Raspberry PI with Windows IoT controlled via AllJoyn protocol from Android smartphone.
我如何在Raspberry PI上构建具有sous-vide的烹饪设备,并通过Windows IoT通过Android智能手机的AllJoyn协议控制Windows IoT.
介绍(Introduction)
我最初的想法实质上是构建一个可用于低温烹饪的可编程加热设备.我在抽屉中有几个RaspberryPi设备,我认为这可能是一个有趣且有用的项目.随着微软凭借RPi版本的Windows 10 IoT进入Raspberry Pi的世界,作为专注于Mcrosoft平台的开发人员,“设备"世界对我而言变得更加可访问.(My original idea was essentially to build a programmable heating device that could be used for low-temperature cooking. Having a couple of RaspberryPi devices in a drawer I thought this could be an interesting and useful project. With Microsoft entering the world of Raspberry Pi with a RPi edition of Windows 10 IoT, the ‘device’ world became more accessible to me as a developer focused on Mcrosoft platform.) 我最初不知道的是如何解决设备控制问题(因为我不想购买会使整个设备成本翻倍的触摸屏),而这正是我运行的目的进入AllJoyn.在巨头们努力建立强大的IoT设备通信标准的时代,开源AllJoyn框架可能是第一个或多或少的IoT连接完整标准之一.(What I didn’t know originally was how to solve the problem of controlling the device (as I didn’t want to buy a touch-screen which would double the cost of the whole device) - and that was the point at which I ran into AllJoyn. In the times when the giants struggle to establish strong standards of communication of IoT devices, the opensource AllJoyn framework was probably one of the first more-or-less complete standards for IoT connectivity.) AllJoyn获得了Microsoft的支持,并且已内置到第一个Windows IoT SDK中,因此,它是我继续进行项目的理想平台.尽管当前的前途不明朗,但随着新的OpenConnectivity Foundation(由Microsoft共同组建)的出现,在AllJoyn框架中实现的构想及其性能使其成为任何工程师和制造商的有趣研究点.如果AllJoyn被OpenConnectivity取代,自然应该将项目移植到此不同的连接平台.(AllJoyn has had support from Microsoft and it was built into the first Windows IoT SDK, therefore it was a perfect platform for me to jump on with my project. While its future is currently vague, with emergence of new OpenConnectivity Foundation (co-formed by Microsoft), the ideas implemented in AllJoyn framework and its performance make it an interesting point of study for any engineer and maker. If AllJoyn becomes superseded by OpenConnectivity, it should be natural to port the project to this different connectivity platform.)
背景(Background)
下面列出了该项目引用的一些基本概念.(Some essential concepts referenced by this project are listed below.)
烹饪(Sous-vide cooking)
Sous-vide是基于将水煮产品(主要是肉类)加热到严格控制的温度的烹饪技术.实际上,可以获得均匀加工的,风味丰富的食物(因为所有汁液和风味都与产品一起放在真空密封袋中保存),从而可以进行精确且可重复的烹饪(例如,肉类不能做得过分) .(Sous-vide is a cooking technique based on heating poached products (mainly meats) to strictly controlled temperatures. In effect, uniformly processed, flavour-rich food is obtained (as all the juices and flavours are kept with the product in a vacuum-sealed bag), allowing for precise and repeatable cooking (eg. meat cannot be ‘over-done’).)
维基百科提供了相当全面的sous-vide((Wikipedia provides a fairly comprehensive monography of sous-vide () https://zh.wikipedia.org/wiki/苏维德(https://en.wikipedia.org/wiki/Sous-vide) ).().) 由于通常将sous-vide视为经典的美食式烹饪技术,因此商用的sous-vide加热设备大多是专业的上架(阅读:昂贵).但是,制造这样的设备并不是火箭科学,对于"制造商"来说似乎是一个迫在眉睫的挑战.(As sous-vide is generally perceived as classy, gourmet-style cooking technique, mostly professional, upper-shelf (read: expensive) sous-vide heating appliances are available commercially. However, building such a device is not rocket science and seems to be a compelling challenge for a ‘maker’.)
AllJoyn框架(AllJoyn framework)
AllJoyn是Allseen Alliance((AllJoyn is an opensource framework designed by Allseen Alliance () https://allseenalliance.org(https://allseenalliance.org) ),以便为物联网设备的连接提出一个统一的平台.它涵盖以下方面(以及其他方面):() in order to propose a unified platform for connectivity of IoT devices. It covers following aspects (among others):)
- 设备通信-通过提供框架来定义包括属性,操作和事件的接口(Device communication - by providing framework to define interfaces comprising Properties, Actions and Events)
- 设备广告和发现-通过设备服务总线的概念(Device advertisement and discovery - via a concept of a device service bus)
- 设备入门-即如何将新设备插入网络(Device onboarding - ie. how do I plug a new device into my network)
- 安全(Security) AllSeen Alliance门户网站上提供了相当全面的文档((A fairly comprehensive documentation is provided on AllSeen Alliance portal () https://allseenalliance.org/framework/documentation(https://allseenalliance.org/framework/documentation) ),并由AllJoyn SDK中包含的示例进行了补充.() and is supplemented by samples included in AllJoyn SDKs.)
它是如何建造的(How it was built)
概念(Concept)
蒸煮过程中的挑战是通过在受控温度下长时间将水煮食物浸入水中来加热水煮食物.烹饪设备实际上是以下各项的简单组合:(The challenge in sous-vide cooking is to heat poached food via immersing it in water for a prolonged time in a controlled temperature. The cooking device is actually a simple combination of:)
- 电暖器(Heater)
- 温度感应器(Temperature Sensor)
- **设备控制单元(Device Control Unit)**实施(implementing a)PID控制器(PID controller)-根据温度传感器的输入,控制器设置加热器组件的功率输出(PID控制器是最典型的,因此是该问题的默认解决方案,PID控制器的专题图也可以在Wikipedia上找到-(- based on input from Temperature Sensor, the controller sets the power output by Heater component (a PID controller is the most typical and therefore default solution to this problem, a monography of a PID controller can also be found on Wikipedia -) https://zh.wikipedia.org/wiki/PID_controller(https://en.wikipedia.org/wiki/PID_controller) )())
- 水泵(Water pump)-为了使热量在水中的分布均匀,水需要保持恒定的循环.(- in order to achieve uniform distribution of heat in the water, water needs to maintain constant circulation.)
- 用户控制单元(User control unit)-允许对加热模式进行编程的UI设备(- a UI device allowing to program the heating patterns) 注意:用于烹饪的产品的真空密封可使用廉价的现成设备实现,因此不在本文范围之内.(Note: vacuum-sealing of products for cooking can be achieved using cheap off-the-shelf appliances and is out-of-scope of this article.)
AllJoyn框架-它有什么作用?(AllJoyn framework - what does it give?)
我在该项目中面临的主要挑战之一是从外部移动控制器连接到加热设备.我确实假设我会使用基于TCP的连接,即.我的RPi需要通过WiFi连接到网络,我也可以将移动设备(智能手机或平板电脑)连接到该网络.因此,我确实需要构建供加热设备使用的某种API,以便控制器UI可以连接到该设备并发送"订单"以及收集状态(至少通过轮询).我想到了某种Web服务(可能是HTTP,REST-ful),我的控制器可以连接到该服务.这将需要使用服务URL配置我的控制器. MS示例确实演示了将设备的API发布到Azure(显然是:)),但这对我来说似乎不合适.然后我开始阅读有关AllJoyn的文章…(One of my main challenges in this project was to connect to the heating device from an external, mobile controller. I did assume I would use TCP-based connectivity, ie. my RPi would need to be connected to the network via WiFi, and I could have a mobile device (smartphone or tablet) connected to that network as well. So I did need to build some sort of an API exposed by the heating device, so that the controller UI could connect to it and send ‘orders’ as well as collect state (at least via polling). I had in mind some sort of a web-service (probably HTTP, REST-ful), which my controller would connect to. This would require configuring my controller with the service URL. MS samples do demonstrate publishing the device’s API into Azure (obviously :) ), but that seemed inappropriate to me. Then I started reading about AllJoyn…) 事实证明,AllJoyn引入了设备服务总线的概念,该设备服务总线实际上是由一个或多个AllJoyn路由器节点组装并在网络中公开的.任何AllJoyn"生产者"设备(一种设备)都可以动态定位总线并发布其接口.另一方面,任何AllJoyn"消费者”(控制面板设备)都可以连接到总线并向其查询可用设备.(It turns out AllJoyn introduces the concept of a Device Service Bus, virtually assembled and exposed in the network by one or more AllJoyn Router nodes. Any AllJoyn “producer” device (an appliance) can dynamically locate the bus and publish it’s interface to it. On the other hand, any AllJoyn “consumer” (a control panel device) can connect to the bus and query it for available devices.) Windows IoT带有AllJoyn支持,这意味着任何Windows IoT设备都可以充当AllJoyn路由器.因此,我的RPi烹饪设备还可以发布Alloyn总线,并且可以使用为Android编写的控制面板连接到它.(Windows IoT comes with AllJoyn support, which means any Windows IoT device can serve as an AllJoyn Router. So my RPi cooking device can also publish the Alloyn Bus, and I can connect to it using a control panel written for Android.) 实际上,这意味着,只要我的加热设备与我的控制设备位于同一个WiFi网络中,它们便会立即相互看到并连接-此项目演示了这种情况.不需要用户提供的API URL配置,等等.(In reality this means, as long as my heating device is in the same WiFi network as my control device is, they will instantly see each other and connect - and this project demonstrates such scenario. No user-provided API URL configuration is needed, etc.) 注意:(Note:)RPi设备仍然需要插入WiFi网络,这意味着它需要进行初步设置(提供WiFi SSID和密钥).这使加热设备的初始设置更加麻烦-如果要在自己的WiFi外部演示设备,则需要屏幕,键盘和鼠标,或者至少需要以太网电缆和远程PowerShell会话才能将设备插入WiFi .(the RPi device still needs to be plugged into WiFi network, which means it requires preliminary setup (provision of WiFi SSID and Key). This makes the initial setup of the heating device more cumbersome - if I want to demo my device outside my own WiFi, I need either a screen, keyboard and mouse or at least an ethernet cable and remote PowerShell session to plug my device into the WiFi.) AllJoyn框架定义了WiFi入门场景,在该场景中,使用启用了UI的" onboarder"设备将WiFi设置传递到"无界面"无UI的" onboardee"设备中,但是我在这个项目中没有做得那么深入.(AllJoyn framework defines WiFi onboarding scenarios, where a UI-enabled ‘onboarder’ device is used to pass WiFi settings into a ‘blind’ UI-less ‘onboardee’ device, but I have not gone that far in this project.)
硬件(Hardware)
每个概念的组件已使用通用设备实现,如下所述.(Each of concept’s components have been implemented using commonly available devices, as summarized below.)
电暖器(Heater)
使用了一个简单的便携式浸入式500瓦加热器(“行进加热器”).可以找到类似的器具,例如.在eBay上((A simple portable immersion 500Watt heater (“travel heater”) has been used. A similar appliance can be found eg. on eBay () http://www.ebay.co.uk/itm/500W-Electric-Water-Heater-Liquids-Immersion-Travel-Portable-Boiler-Element-Hot-/351790910762?hash=item51e85f4d2a:g:O64AAOSwARZXk0gW(http://www.ebay.co.uk/itm/500W-Electric-Water-Heater-Liquids-Immersion-Travel-Portable-Boiler-Element-Hot-/351790910762?hash=item51e85f4d2a:g:O64AAOSwARZXk0gW) )())
温度感应器(Temperature Sensor)
使用了流行的水密包装DS18B20数字温度传感器.由于此传感器通过OneWire协议进行通信,因此无法直接将其作为RPi的输入插入(RPI中没有对OneWire的硬件支持).因此,需要一个OneWire-2-I2C桥接器(如下所列).(A popular DS18B20 digital temperature sensor in water-tight wrapping has been used. As this sensor communicates via OneWire protocol, plugging it directly as RPi’s input is not feasible (no hardware support for OneWire in RPi). Therefore a OneWire-2-I2C bridge is required (as listed below).)
设备控制单元(Device control unit)
运行Windows IoT的Raspberry Pi 2和实现伪PID控制器算法和基于AllJoyn的连接性的软件(SoViAgent).使用官方RPi WiFi加密狗将RPi插入网络.(Raspberry Pi 2 running Windows IoT and a software (SoViAgent) implementing a pseudo-PID controller algorithm and AllJoyn-based connectivity. The RPi is plugged into network using an official RPi WiFi dongle.)
水泵(Water pump)
使用了一个简单的水族箱泵.由于使用的温度不超过70摄氏度,因此一个简单的鱼缸设备可以可靠地工作,并且似乎不受热量的影响.(A simple aquarium pump has been used. As temperatures used do not exceed 70 C, a simple fish-tank device works reliably and seems to remain unaffected by heat.)
其他设备(Other devices)
- 两个大电流继电器开关可通过Raspberry Pi的引脚输出控制大功率设备(加热器和泵).(Two high-current relay switches to control the high-power devices (heater and pump) from Raspberry Pi’s pin outputs.)
- OneWire-2-I2C桥接器-基于DS2482芯片.必须将温度传感器连接到WPi的I2C接口.(OneWire-2-I2C bridge device - based on DS2482 chip. Necessary to connect the Temperature Sensor to the WPi’s I2C interface.)
用户控制单元(User control unit)
定制的SoVi Controller应用程序在Android智能手机或平板电脑上运行,如本文中进一步所述.(A bespoke SoVi Controller application running on an Android smartphone or tablet, as described further in the article.)
组装好的设备(SoViAgent部件)在下面可见:(An assembled device (SoViAgent part) is visible below:)
SoViAgent-Windows IoT应用程序(SoViAgent - Windows IoT app)
先决条件(Prerequisites)
- 具有Visual C ++和C#,通用Windows平台和ARM编译器的VisualStudio 2015 Update 1或2(基本上是为Raspberry Pi开发项目所需的安装程序,如(VisualStudio 2015 Update 1 or 2 with Visual C++ and C#, Universal Windows Platform and ARM compilers (basically a setup required to develop projects for Raspberry Pi as described on) https://developer.microsoft.com/zh-CN/windows/iot(https://developer.microsoft.com/en-us/windows/iot) )())
- AllJoyn Studio((AllJoyn Studio () https://visualstudiogallery.msdn.microsoft.com/064e58a7-fb56-464b-bed5-f85914c89286(https://visualstudiogallery.msdn.microsoft.com/064e58a7-fb56-464b-bed5-f85914c89286) )())
总览(Overview)
该解决方案的SoViAgent部分已汇总到SoViAgent.slnVisualStudio解决方案中.它包含以下组件:(The SoViAgent part of the solution is aggregated into SoViAgent.sln VisualStudio solution. It has the following components:)
SoViAgent.UI
-SoViAgent应用程序项目实现为WinIoT Headed应用程序(即,具有UI).该应用程序实例化了SoViAgentService类,该类可整理AllJoyn Bus与设备``引擎'‘之间的所有通信.(- SoViAgent application project implemented as WinIoT Headed application (ie. with a UI). This application instantializes the SoViAgentService class which marshalls all communication between AllJoyn Bus and the device ‘engine’.)SoViAgent.Headless
-用于无头实施SoViAgent的占位符.(- Placeholder for headless implementation of the SoViAgent.)SoViAgent.AllJoyn
-具有PID控制器实现和AllJoyn设备包装程序类的主应用程序"引擎".(- The main application ‘engine’ with PID controller implementation and AllJoyn device wrapper classes.)SoViAgent.Devices
-实现特定于硬件的输入和输出(例如,DS18B20温度传感器通信包装器).(- Implementation of hardware-specific input and output (eg. DS18B20 temp sensor communication wrapper).)org.stranger80.SoViAgent
-由AllJoyn代码生成工具生成的AllJoyn连接影响.(- AllJoyn connectivity impementation as generated by AllJoyn code generation tools.)SoViAgent.Test
-一些基本的UnitTest类.(- Some rudimentary UnitTest classes.) AllJoyn Studio软件包中提供的工具支持为Windows IoT构建支持AllJoyn的应用程序.该过程将根据获得或创建的接口定义(自省XML)生成代理代码.代码生成器用于生成处理AllJoyn通信详细信息的C ++本机代码.这遵循典型的"合同至上"整合方法.(Building an AllJoyn-enabled application for Windows IoT is supported by tooling provided in AllJoyn Studio package. The procedure is to generate proxy code based on an obtained or created interface definition - the Introspection XML. Code generator is used to generate C++ native code handling the AllJoyn communication details. This follows a typical ‘contract-first’ integration approach.) 注意:(Note:)可以在这里找到有关为Windows IoT构建支持AllJoyn的应用程序的良好分步指南:(a good step-by-step tutorial on building an AllJoyn-enabled application for Windows IoT can be found here:) https://channel9.msdn.com/Blogs/Internet-of-Things-Blog/Using-the-AllJoyn–Studio-Extension(https://channel9.msdn.com/Blogs/Internet-of-Things-Blog/Using-the-AllJoyn–Studio-Extension)
AllJoyn接口"合同"-内省XML(AllJoyn Interface ‘contract’ - Introspection XML)
内省XML是一种定义设备在AllJoyn设备总线上公开的" API"的方法.(The Introspection XML is a way to define the ‘API’ exposed by the device on the AllJoyn device bus.)
的(The) SoViAgent.xml
在SoViAgent.AllJoyn项目中定义了我的烹饪设备的API. XML必须遵循(in SoViAgent.AllJoyn project is defining the API for my cooking device. The XML must follow the) D-Bus规格(D-Bus specification) ,并定义了接口的以下基本元素:(, and defines following fundamental elements of the interface:)
- 方法(Methods)-设备发布的端点,可用于将"订单"发送到设备.例如:(- endpoints published by the device which can be used to send ‘orders’ into the device. For example:)
<method name="ExecuteHeatPattern">
<description language="en">
Programs the device to start executing a heat pattern defined via array of 'heat points'.
</description>
<arg name="heatPointArray" type="a(di)" direction="in">
<description language="en">
Array of heat points.
A 'heat point' is a single order to set a given temperature to T and maintain it for S seconds.
Thus it is a struct of 2 integers:
- Target temperature (degrees Celsius)
- Temperature sustain period (seconds)
</description>
</arg>
<arg name="success" type="b" direction="out">
<description language="en">
Result of operation (success = true/false).
</description>
</arg>
</method>
注意输入和输出参数如何((Note how input and output arguments () <arg>
元素)指定为值的序列和模式.(elements) are specified as sequences and patterns of values.)
- 物产(Properties)-客户端可以读取和/或设置的设备属性.例如:(- attributes of a device which can be read and/or set by a client. For example:)
<property name="Temperature" type="d" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<description language="en">
Current temperature measured by device (degrees Celsius).
</description>
</property>
请注意,属性可能会发出信号通知其值的更改,并且客户端应用程序可能会侦听此类信号,而不是反复轮询设备.(Note that a property may signal changes in its value, and client application may listen for such signals rather then poll the device repeatedly.)
- 大事记(Events)-由设备主动发出信号,以便客户端应用程序可以被动地侦听事件信号:(- actively signalled by the device, so that client applications may listen for event signals passively:)
<signal name="DeviceErrorOccurred" sessioncast="true">
<description>
Signal to notify the controller about a device error.
</description>
<arg name="errorDescription" type="(is)" direction="out">
Error description struct:
- error code (integer)
- error description (string)
</arg>
</signal>
从自省XML生成AllJoyn管道代码后,(Once the AllJoyn plumbing code is generated from the Introspection XML, the) org.stranger80.SoViAgent
包含处理上述元素的代码.然后,C#包装器可以引用此代码((contains the code handling the above elements. This code can then be referenced by C# wrappers () SoViAgentService
类)以展示设备功能.(class) to expose the device functionality.)
DS18B20温度传感器-输入(DS18B20 Temperature sensor - input)
SoViAgent参考(SoViAgent references) Rinsen.OneWire
图书馆 ((library () https://github.com/Rinsen/OneWire(https://github.com/Rinsen/OneWire) )与温度传感器通讯.包装此内容的代码位于() to communicate with the temperature sensor. The code which wraps this is located in) OneWireDevice
类.(class.)
加热器和水泵-输出(Heater and Water pump - output)
加热器和水泵都是开/关设备,因此可以通过RPi的输出引脚进行控制.来自引脚的信号传递到为实际设备供电的大电流继电器.这是在处理(Both Heater and Water pump are on/off devices so can be controlled from RPi’s output pins. The signal from the pins is passed into high-current relays which power the actual devices. This is handled in) SimpleRelayOutputDevice
类.(class.)
PID控制器实现(PID Controller implementation)
温度控制器的"大脑"是(The ‘brain’ of temperature controller is the) DefaultController
类,适用于"滴答声".每个刻度都测量来自输入传感器的输入,根据硬编码的PID设置执行输出计算,并将更新的输出设置发送到输出设备.(class, which works in ‘ticks’. Each tick measures inputs from the input sensor, performs the output calculation according to hardcoded PID settings and sends updated output setting to the output device.)
头对头(Headed vs. Headless)
尽管此原型仅被实现为嵌入式应用程序,但值得注意的是,无头实现将更加轻巧,并可能增加设备启动时间.无论如何,将应用程序配置为在RPi启动时自动运行很有用.(While this prototype has been implemented as a headed app only, it is worth noting a headless implementation would be more lightweight, and would possible increase device startup time. In any case, it is useful to configure the app to run automtically on RPi boot.)
- 对于有头脑的应用程序,可以使其成为一种(For a headed app, one can make it a)**默认应用(default app)**通过Windows IoT的App Manager控制台.如果设置为默认默认模式,则应用程序将在启动时启动.(via Windows IoT’s App Manager console. The application will start at boot if set to headed default mode.)
- 对于无头应用程序,可以在无头启动模式下将其设置为默认值,或者在有头模式下将其添加到启动列表中-这将使其作为"服务"运行:(For a headless app it is possible to either set it as default in headless boot mode, or add to startup list in headed mode - this will make it run as a ‘service’:)
- 用这个 ((Use this () https://ms-iot.github.io/content/zh-CN/win10/samples/PowerShell.htm(https://ms-iot.github.io/content/en-US/win10/samples/PowerShell.htm) )以从Powershell连接到设备,以及() to connect to device from Powershell, and)
- 这个 ((this () https://ms-iot.github.io/content/zh-CN/win10/tools/CommandLineUtils.htm(https://ms-iot.github.io/content/en-US/win10/tools/CommandLineUtils.htm) )以使用IoTStartup命令将您的应用添加到"无头启动"列表中.() to use IoTStartup command to add your app to ‘startup headless’ list.)
SoViController-Android应用(SoViController - Android app)
先决条件(Prerequisites)
- Android Studio(AndroidStudio)
- AllJoyn SDK 15.09((AllJoyn SDK 15.09 () https://allseenalliance.org/releases/alljoyn/15.09/alljoyn-15.09.00a-android-sdk-rel.zip(https://allseenalliance.org/releases/alljoyn/15.09/alljoyn-15.09.00a-android-sdk-rel.zip) )())
总览(Overview)
该代码是基于适用于Android的AllJoyn SDK中的"观察者"示例编写的.(The code was written based on the ‘Observer’ example included in AllJoyn SDK for Android.) Android应用程序包含以下组件:(The Android application consists of following components:)
SoViAgent
接口和(interface and)org.stranger80.sovicontroller.model
名称空间-处理设备协定的类的定义.这些都是手工编写的-我没有花太多时间试图找到合适的gode生成工具,幸运的是,除了许多特定于AllJoyn的注释之外,这里没有太多要写的东西了.(namespace - definition of the classes handling the device contract. These were written by hand - I didn’t spend much time on trying to find a suitable gode generation tool, fortunately there isn’t much to write here apart from a number of AllJoyn-specific annotations.)AllJoynBusHandler
-负责与AllJoyn总线的所有通信.(- responsible for all communication with the AllJoyn bus.)BusHandlerService
-一个Android Service类,负责将SoVi设备通信嵌入到与UI活动分离的后台线程中.(- an Android Service class responsible for embedding the SoVi device communication in a background thread, detached from the UI activities.)DevicePanelActivity
-显示设备控制面板.(- displays the device control panel.)MainActivity
-主要应用程序活动,负责搜索可用设备并将用户重定向到实际的SoViAgent实例的控制面板.(- main app activity, responsible for searching for available devices and redirecting the user to actual SoViAgent instance’s control panel.)
操作方式(Operation)
SoVi控制器连接到SoVi代理设备后,将显示控制面板:(Once the SoVi Controller connects to a SoVi Agent device, the control panel gets displayed:)
用户可以转动"旋钮"控件来设置目标温度,然后点击"旋钮"以打开或关闭设备.就如此容易… :)(A user may turn the ‘knob’ control to set the target temperature and then tap the ‘knob’ to switch the device on or off. As simple as that… :)) 面板会随着设备属性的所有更改而更新,温度会绘制在图表上以说明加热曲线.可以观察到PID控制器实现的效果-通过编程将温度控制器保持在固定温度T,kontroller设法将温度保持在+ -0.5 C范围内,这可能与使用简单的开/关加热器所获得的效果一样好.(The panel gets updated with all changes of device properties, and the temperature gets plotted on a graph for illustration of the heating curve. It is possible to observe the effect of the PID Controller implementation - whe programmed to maintain a fixed temperature T the kontroller manages to keep the temperature within +-0.5 C range, which probably is as good as it get’s with a simple on/off heater.) 注意:目前,控制器应用程序无法处理设备通知.(Note: at the moment the controller app does not handle the device notifications.)
SoVi代理在行动(SoVi Agent in action)
最后,可以将整个设备投入使用!以下是一小段带酱的牛柳烹饪图.(Finally it is possible to put the whole device into action! Below is a small pictorial of a sous-vide beef fillet cooking.)
切一小块牛肉片并调味:(A small chunk of beef fillet is cut and seasoned:)
使用SoVi Agent设备在52摄氏度下将真空密封的水煮1小时:(Vacuum-sealed poaches are cooked using the SoVi Agent device in 52 degrees Celsius for 1 hour:)
然后将每片放在烤盘上烤熟,以获得脆皮和风味:(Each piece is then seared on a grilling pan for crispy skin and flavour:)
…并切成可食用的切片:(…and cut into tasty-looking slices for serving:)
请享用!(Enjoy!)
概要(Summary)
总而言之,我真的很喜欢构建这个原型.可以从该计划中学到一些想法:(All in all, I really enjoyed building this prototype. Several thoughts can be highlighted as lessons learned from this initiative:)
- AllJoyn似乎是一个非常强大的框架,并且它提供的解决方案确实是连贯和完整的.虽然我没有探索安全性和设备入门领域,但框架涵盖了这些领域,并且有可能进行探索.(AllJoyn seems a really powerful framework, and the solution it provides does seem coherent and complete. While I didn’t explore the areas of security and device onboarding, the framework covers them and exploring them is possible.)
- 我所处理的AllJoyn实现(Windows和Android)似乎确实表现出色,当观察控制器中用户操作与设备对其做出反应之间的延迟时可以看到这一点-轻按控制旋钮可触发加热器的开/关(AllJoyn implementations I dealt with (Windows and Android) seem really performant, which could be seen when observing delay between user actions in the controller and device reacting to them - a tap on the control knob triggers the heater on/off)立即(immediately).令人印象深刻.(. Impressive.)
- 开始时,AllJoyn似乎相当复杂,并且其支持是有限的.(AllJoyn seems fairly complicated to start with, and its support is limited.)
- 当然,我不是一名专业的Android开发人员,因此编写控制器应用程序时需要维持一个持续连接的后台服务来处理AllJoyn Bus交通,这对我来说是一项艰巨的任务.我最终得到了一个蜘蛛网的处理程序和侦听器,它们似乎可以工作(或多或少),但是我一直在问自己一个问题-是否可以用更简单的方式编写它,还是Android的编程模型如此复杂设计?(Granted I am not a specialist Android developer, writing the controller app with a requirement to maintain a constantly connected background service to handle the AllJoyn Bus traffic was a big struggle for me. I ended up with a spider’s web of handlers and listeners, which seem to work (more-or-less) but I keep asking myself a question - is it possible to write it in a simpler way, or is Android’s programming model so convoluted by design?)
- 通用Windows平台是一个使我大开眼界的框架.例如,我无法使用我最喜欢的模拟框架将单元测试作为UWP程序集编写-FakeItEasy没有可在UWP API上运行的兼容版本(我相信主要原因是缺乏反射和代码发出API )-我最终自己从头开始编写了模拟类,这有点令人失望.(The Universal Windows Platform is a framework which makes me raise eye brows. For example I wasn’t able to write Unit Tests as a UWP assembly using my favourite mocking frameworks - FakeItEasy didn’t have a compliant version to run on the UWP API (I believe the main reason is the lack of Reflection and code emitting APIs) - I ended up writing mocking classes myself from scratch, which was slightly disappointing.)
- 所发布的代码实际上是"原型",即.不稳定(尤其是Android部分).(The code published is really ‘prototype’, ie. unstable (esp. the Android part).)
- 一旦微软踏上OpenConnectivity Foundation之路,AllJoyn的未来就变得模糊不清.至少我们可以期望在将来的Windows IoT版本中支持OpenConnectivity.(Future of AllJoyn is vague once Microsoft stepped on the OpenConnectivity Foundation boat. At least we can expect support for OpenConnectivity support in future Windows IoT versions.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C# .NET Mobile Android Raspberry Windows Design Dev 新闻 翻译