摘要
针对环保物联网实时双向通信要求,提出并实现了一种基于Netty的现场机和上位机实时双向通信的设计模型。利用Netty构建数据监听服务程序,首先建立基于设备唯一标识的线程安全的客户端连接缓冲,其次采用正则解析HJ/T212-2005格式数据实现污染源在线自动监控系统数据传输通讯协议,运用生产者消费者模式将接收到的消息推送线程安全的消息队列,业务处理线程从消息队列拉取消息进行处理,最后下发线程则从消息服务器拉取其他异构系统推送的消息,从客户端连接缓冲选择正确的客户端连接进行下发,解决了异构系统间的数据传输问题。实际应用结果表明,数据监听服务程序的实时性和数据接收率都满足工业使用的要求。
To meet the requirement of real-time bidirectional communication for environmental protection of Internet of Things,this paper proposes a communication model for spot controller and host computer model based on Netty. Firstly,the connection map with thread safety and equipment identification key is established and the custom protocol in HJ/T212-2005 format is implemented by using regular expression. Meanwhile,the message received by the server is pushed to thread safety message queue and the message is processed by business processing thread. And then,the message pushed by other heterogeneous system is polled by the issue thread and issued by the correct client connection,and finally the problem of data transmission between heterogeneous systems is solved. Results show that the real-time feature and data receiving rate of the communication server can meet the demand for industrial application.
引文
[1]陈海明,崔莉,谢开斌.物联网体系结构与实现方法的比较研究[J].计算机学报,2013,36(1):168-188.
[2]丁浩,管致锦,沈兵,等.环保物联网中远程设备实时控制问题研究[J].计算机测量与控制,2014,22(6):1786-1789.
[3]于旭耀,余辉,徐可欣,等.恶臭自动在线监控体系设计与实现[J].安全与环境学报,2013,13(6):152-157.
[4]中华人民共和国环境保护行业标准(HJ/T212-2005):污染源在线自动监控(监测)系统数据传输标准[S].北京:国家环境保护总局,2006.
[5]王堃,于悦,张玉华,等.面向物联网应用平台的Socket设计与优化[J].吉林大学学报:工学版,2012,42(S1):290-294.
[6]The Netty Project.The Proven Approach to Rapid Network Application Development[EB/OL].(2013-11-7)[2017-02-09].http://netty.io/3.8/guide/.
[7]MAURER N.Netty in Action[M].American:Manning Publications,2013:100-102.