从网站获取值并控制继电器?
今天我从一位客户那里收到了一个非常不寻常的问题。他们提供关键任务服务,在特定事件发生时通知人们非常重要。目前,他们有一个 API,当通过网络浏览器访问时,可以根据警报的状态简单地写出 TRUE 或 FALSE。
他们希望更进一步,因此他们希望拥有一台能够连续从现有 API 获取值的 PC,并根据该值切换继电器,从而打开/关闭警报或警告灯在他们的办公室。
我不知道如何构建这样一个东西,因为我只从事网络应用程序的工作。这听起来不像是一个需要太多脑细胞的项目,但对我来说无疑是一个挑战。我需要学习什么语言才能完成这样的事情?
I got a quite unusual question today from a client. They provide a mission-critical service where it's important that people are notified when a certain event happens. Currently they have an API that simply writes out TRUE or FALSE, when accessed by a web browser, depending on the state of their alert.
They want to take this even further, so they want to have a PC which would fetch the value from their existing API on a continuous basis, and depending on the value, toggle a relay, which would turn on/off an alarm or warning light in their office.
I have no idea of how one could build such a thing, as I work only on web applications. It doesn't sound like a project requiring too many braincells, but certainly a challenge for me. What languages do I need to learn to accomplish something like this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于软件事件将触发物理动作(打开灯),因此需要您与某种电子设备进行交互。
一个好的开始是 Arduino。它是开源硬件,让您可以使用 C++ 的变体与主板进行交互。
Since the software event will trigger a physical action (turning on a light) it will require you to interface with some sort of electronic device.
A good start would be Arduino. It's open-source hardware and let's you interface with the board using a variant of C++.
该项目由两部分组成:
将互联网连接到 PC。例如使用 Perl。
将 PC 连接到某些硬件,例如示例中的
switch_relay
。有几种方法可以做到这一点。对此更有帮助。
This project consists of two parts:
Connect the internet to the PC. For example using Perl.
Connect the PC to some hardware,
switch_relay
in the example. There are a few ways to do this.more helpful with that.
X10 + curl + 任何允许您通过串行端口进行通信的语言:
http://www.smarthome.com/1140/X10-Activehome-CM11A-Computer-Interface-CM11A/p.aspx
http://www.smarthome.com/manuals/protocol.txt
http://curl.haxx.se/
甚至可能只是一个将所有内容结合在一起的批处理文件,包括 http://www.computerhope.com/cttyhlp.htm + 'echo' 用于串行通信
X10 + curl + any language that lets you communicate over a serial port:
http://www.smarthome.com/1140/X10-Activehome-CM11A-Computer-Interface-CM11A/p.aspx
http://www.smarthome.com/manuals/protocol.txt
http://curl.haxx.se/
Perhaps even just a batch file to tie it all together, including http://www.computerhope.com/cttyhlp.htm + 'echo' for serial communication