[go: up one dir, main page]

CN103916230A - Sensor identification method, host computer, sensor and sensor identification system - Google Patents

Sensor identification method, host computer, sensor and sensor identification system Download PDF

Info

Publication number
CN103916230A
CN103916230A CN201210593313.3A CN201210593313A CN103916230A CN 103916230 A CN103916230 A CN 103916230A CN 201210593313 A CN201210593313 A CN 201210593313A CN 103916230 A CN103916230 A CN 103916230A
Authority
CN
China
Prior art keywords
transducer
sensor
access
connection request
identification
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201210593313.3A
Other languages
Chinese (zh)
Inventor
徐亮
郑辑杰
李虹
庞银生
傅剑
姚国祥
张莹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Group Guangdong Co Ltd
Original Assignee
China Mobile Group Guangdong Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Group Guangdong Co Ltd filed Critical China Mobile Group Guangdong Co Ltd
Priority to CN201210593313.3A priority Critical patent/CN103916230A/en
Publication of CN103916230A publication Critical patent/CN103916230A/en
Pending legal-status Critical Current

Links

Landscapes

  • Arrangements For Transmission Of Measured Signals (AREA)

Abstract

本发明提供了一种传感器识别方法、上位机、传感器及传感器识别系统,通过接收连接请求,该连接请求是传感器接入时发送的并且包括有该传感器的标识信息;对该传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功,从而实现传感器的即插即用,具有准确性较好、反应速度快的特点。并且具有较高的可靠性。

The invention provides a sensor identification method, a host computer, a sensor and a sensor identification system. By receiving a connection request, the connection request is sent when the sensor is connected and includes the identification information of the sensor; identification and verification of the sensor is performed, And based on the identification and verification results, it is determined whether the sensor is connected successfully, so as to realize the plug and play of the sensor, which has the characteristics of good accuracy and fast response speed. And has high reliability.

Description

传感器识别方法、上位机、传感器及传感器识别系统Sensor identification method, upper computer, sensor and sensor identification system

技术领域technical field

本发明涉及通讯技术领域,具体可以涉及一种485半双工连接智能传感器识别方法、上位机、传感器及传感器识别系统。The invention relates to the field of communication technology, and specifically relates to a 485 half-duplex connection intelligent sensor identification method, a host computer, a sensor and a sensor identification system.

背景技术Background technique

在现有工业应用中,存在大量采用485半双工的通信模式,采用485半双工能够支持1000米以内有质量保证的串口通信,以实现低成本高质量的连接。但485半双工的应用一般不会挂接很多的外部设备(如传感器),如何做到在较短时间内发现传感器的接入和拔出并进行通信成为485半双工通信模式的技术难题,并且挂接在总线上的传感器,一般都没有在硬件级别上的接入或者拔掉的识别信号。In existing industrial applications, there are a large number of communication modes using 485 half-duplex, which can support quality-guaranteed serial communication within 1000 meters to achieve low-cost and high-quality connections. However, the application of 485 half-duplex generally does not connect a lot of external devices (such as sensors). How to discover the connection and removal of sensors in a short period of time and communicate has become a technical problem in the 485 half-duplex communication mode. , and the sensors connected to the bus generally do not have identification signals for connecting or unplugging at the hardware level.

现有的接入检测的处理方法是通过串口轮询,不断探察是否有新的传感器接入,有就进行通信尝试,没有再继续轮询。传感器接入后,被动等待上位机来联系,只有上位机发现了新设备并认证接入后,才能够接入到串口总线。The existing processing method of access detection is to continuously check whether there is a new sensor access through the serial port polling, and if there is, a communication attempt is made, and the polling is not continued. After the sensor is connected, it passively waits for the host computer to contact. Only after the host computer discovers the new device and authenticates the access, can it be connected to the serial bus.

现有的拔出检测的处理方法是定期从所有的传感器读数,如果某个传感器没有返回,等待一段时间后,再尝试联系该传感器。进过确定次数的通信,确定无返回,就判断该传感器脱离总线了。Existing handling of unplug detection is to periodically take readings from all sensors, and if a sensor does not return, wait for a period of time before attempting to contact that sensor. After a certain number of communications, it is determined that there is no return, and it is judged that the sensor is off the bus.

因此现有的接入及拔出检测的处理方法存在以下的问题:Therefore, there are the following problems in the existing processing method of access and extraction detection:

(1)、串行处理,等待时间较长。传感器接入的处理,需要等待下一个轮询周期开始,还需要排位等待轮询排位。拔出的处理类似,也需要进行多个轮询周期的处理。(1), serial processing, long waiting time. The processing of sensor access needs to wait for the start of the next polling cycle, and also needs to wait for the polling ranking. The processing of unplugging is similar, and processing of multiple polling cycles is also required.

(2)、数据和控制流不分,开发困难。传感器的识别、升级、重启等是属于控制命令,是对传感器的工作状态进行处理,而连接和读数是数据流,是读取传感器的属性或者工作数据,两者没有区分,读数异常的时候还要考虑是否会突然失去传感器,当传感器拔出后,要若干次读数,看是否有返回值,整个过程都通过数据来判断控制,判断的准确性较差。(2) Data and control flow are not separated, making development difficult. Sensor identification, upgrade, restart, etc. are control commands, which process the working status of the sensor, while connection and reading are data streams, which read the attributes or working data of the sensor. There is no distinction between the two. When the reading is abnormal, the It is necessary to consider whether the sensor will be lost suddenly. When the sensor is pulled out, several readings are required to see if there is a return value. The entire process is judged and controlled by data, and the accuracy of the judgment is poor.

(3)、总线使用效率低。所有的操作都等待上位机的主动处理,总线等待的时间较多,当程序设计不完善或者出现新的场景的时候,上位机无法处理,系统会出现不稳定或者假死现象,导致总线效率低,客户体验差。(3) The bus usage efficiency is low. All operations are waiting for the active processing of the host computer, and the bus waits for a long time. When the program design is not perfect or a new scene appears, the host computer cannot handle it, and the system will be unstable or suspended animation, resulting in low bus efficiency. Poor customer experience.

发明内容Contents of the invention

本发明提供了一种传感器识别方法、上位机、传感器及传感器识别系统,具有即插即用、准确性较好、反应速度快的特点。The invention provides a sensor identification method, a host computer, a sensor and a sensor identification system, which have the characteristics of plug and play, good accuracy and fast response speed.

本发明提供方案如下:The present invention provides scheme as follows:

本发明实施例提供了一种传感器识别方法,包括:An embodiment of the present invention provides a sensor identification method, including:

接收一连接请求,所述连接请求,是当传感器接入时,由传感器所发送的,所述连接请求中包括一传感器标识信息;Receive a connection request, the connection request is sent by the sensor when the sensor is connected, and the connection request includes a sensor identification information;

基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功。Based on the connection request, the sensor is identified and verified, and based on the identification and verified result, it is determined whether the sensor is connected successfully.

优选的,所述基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功包括:Preferably, performing identification verification on the sensor based on the connection request, and determining whether the sensor access is successful based on the identification verification result includes:

判断所述连接请求中包括的传感器标识信息是否有效,获取第一判断结果;Judging whether the sensor identification information included in the connection request is valid, and obtaining a first judgment result;

若所述第一判断结果为所述传感器标识信息有效,则确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入。If the first judgment result is that the sensor identification information is valid, it is determined that the sensor access is a valid access, otherwise, it is determined that the sensor access is an invalid access.

优选的,所述基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功还包括:Preferably, performing identification verification on the sensor based on the connection request, and determining whether the sensor access is successful based on the identification verification result further includes:

在所述第一判断结果为所述传感器标识信息有效之后,向所述传感器发送读属性请求;After the first judgment result is that the sensor identification information is valid, send a read attribute request to the sensor;

根据所述传感器基于所述读属性请求而返回的属性信息,判断是否能够识别所述传感器,获取第二判断结果;judging whether the sensor can be identified according to the attribute information returned by the sensor based on the read attribute request, and obtaining a second judgment result;

若所述第二判断结果为能够识别所述传感器,则确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入。If the second determination result is that the sensor can be identified, it is determined that the sensor access is a valid access, otherwise, it is determined that the sensor access is an invalid access.

优选的,所述基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功还包括:Preferably, performing identification verification on the sensor based on the connection request, and determining whether the sensor access is successful based on the identification verification result further includes:

在确定所述传感器接入为有效接入之后,向所述传感器发送确认信息;After determining that the sensor access is a valid access, sending confirmation information to the sensor;

根据所述传感器基于所述确认信息而返回的连接验证信息,确定所述传感器接入是否成功。According to the connection verification information returned by the sensor based on the confirmation information, it is determined whether the access of the sensor is successful.

优选的,所述方法在确定所述传感器接入成功之后还包括:Preferably, after determining that the sensor access is successful, the method further includes:

将所述传感器加入到当前被监控的传感器数组中;adding the sensor to the currently monitored sensor array;

按第一预设时间间隔向传感器数组中的传感器发送监控信号,所述监控信号用于监控传感器是否存在于所述传感器数组中。A monitoring signal is sent to the sensors in the sensor array at a first preset time interval, and the monitoring signal is used to monitor whether a sensor exists in the sensor array.

优选的,所述方法还包括:Preferably, the method also includes:

按第二预设时间间隔轮询传感器数组中各传感器的数值,并记录传感器每一次被轮询的时间。The value of each sensor in the sensor array is polled at a second preset time interval, and the time at which the sensor is polled each time is recorded.

优选的,所述方法还包括:Preferably, the method also includes:

若系统当前时间与传感器最后一次被轮询的时间之间的差值,大于预设的失效阈值时,判定所述传感器失效。If the difference between the current time of the system and the last polled time of the sensor is greater than a preset failure threshold, it is determined that the sensor is invalid.

优选的,所述方法还包括:Preferably, the method also includes:

若在第三预设时间间隔内没有收到传感器返回的所述监控信号,和/或判定所述传感器失效,则判断所述传感器已被拔出;If the monitoring signal returned by the sensor is not received within the third preset time interval, and/or it is determined that the sensor is invalid, it is determined that the sensor has been pulled out;

将被拨出传感器从当前被监控的传感器数组中移除并发出传感器拨出信号。Removes the dialed out sensor from the currently monitored array of sensors and signals a sensor dialed out.

优选的,所述方法还包括:Preferably, the method also includes:

当轮询获取的传感器的数值高于预设的告警阈值时,启动告警线程。When the value of the sensor obtained by polling is higher than the preset alarm threshold, an alarm thread is started.

优选的,所述启动告警线程包括:Preferably, the starting alarm thread includes:

根据告警等级和告警设置,触发对应的告警动作。According to the alarm level and alarm settings, trigger the corresponding alarm action.

本发明实施例还提供了一种上位机,其特征在于,包括:The embodiment of the present invention also provides a host computer, which is characterized in that it includes:

接收模块,用于接收一连接请求,所述连接请求,是当传感器接入时,由传感器所发送的,所述连接请求中包括一传感器标识信息;The receiving module is configured to receive a connection request, the connection request is sent by the sensor when the sensor is connected, and the connection request includes a sensor identification information;

识别验证模块,用于基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功。The identification verification module is configured to perform identification verification on the sensor based on the connection request, and determine whether the sensor access is successful based on the identification verification result.

优选的,所述识别验证模块包括:Preferably, the identification verification module includes:

第一判断单元,用于判断所述连接请求中包括的传感器标识信息是否有效;A first judging unit, configured to judge whether the sensor identification information included in the connection request is valid;

确定单元,用于在所述第一判断单元判断所述传感器标识信息有效时,确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入。The determination unit is configured to determine that the sensor access is valid when the first determination unit determines that the sensor identification information is valid, or determine that the sensor access is invalid.

优选的,所述识别验证模块还包括:Preferably, the identification verification module also includes:

发送单元,用于在所述第一判断单元判断所述传感器标识信息有效时,向所述传感器发送读属性请求;A sending unit, configured to send an attribute read request to the sensor when the first judging unit judges that the sensor identification information is valid;

第二判断单元,用于根据所述传感器基于所述读属性请求而返回的属性信息,判断是否能够识别所述传感器;A second judging unit, configured to judge whether the sensor can be identified according to the attribute information returned by the sensor based on the attribute read request;

所述确定模块还用于在所述第二判断单元判断能够识别所述传感器时,确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入。The determining module is further configured to determine that the sensor access is valid when the second judging unit determines that the sensor can be identified, or determine that the sensor access is invalid.

优选的,所述发送单元还用于在所述确定模块确定所述传感器接入有效时,向所述传感器发送确认信息;Preferably, the sending unit is further configured to send confirmation information to the sensor when the determining module determines that the sensor access is valid;

所述确定单元,还用于基于所述传感器基于所述确认信息而返回的连接验证信息,确定所述传感器连接是否成功。The determining unit is further configured to determine whether the connection of the sensor is successful based on the connection verification information returned by the sensor based on the confirmation information.

优选的,所述上位机还包括:Preferably, the host computer also includes:

加入模块,用于在所述识别验证模块确定所述传感器接入成功后,将所述传感器加入到当前被监控的传感器数组中;An adding module, configured to add the sensor to the currently monitored sensor array after the identification and verification module determines that the sensor is successfully connected;

监控模块,用于按第一预设时间间隔向传感器数组中的传感器发送监控信号,所述监控信号用于监控传感器是否存在于所述传感器数组中。A monitoring module, configured to send a monitoring signal to the sensors in the sensor array at a first preset time interval, and the monitoring signal is used to monitor whether a sensor exists in the sensor array.

优选的,所述上位机还包括:Preferably, the host computer also includes:

轮询模块,用于按第二预设时间间隔轮询传感器数组中各传感器的数值,并记录传感器每一次被轮询的时间。The polling module is configured to poll the values of the sensors in the sensor array at a second preset time interval, and record the time when the sensors are polled each time.

优选的,所述上位机还包括:Preferably, the host computer also includes:

失效判断模块,用于若系统当前时间与传感器最后一次被轮询的时间之间的差值,大于预设的失效阈值时,判定所述传感器失效。The failure judging module is used to judge that the sensor is invalid if the difference between the current time of the system and the time when the sensor was last polled is greater than a preset failure threshold.

优选的,所述上位机还包括:Preferably, the host computer also includes:

拨出判断模块,用于若在第三预设时间间隔内没有收到传感器返回的所述监控信号,和/或所述失效判断模块判定所述传感器失效,则判断所述传感器已被拔出;The dialing out judging module is used to judge that the sensor has been pulled out if the monitoring signal returned by the sensor is not received within the third preset time interval, and/or the failure judging module judges that the sensor is invalid ;

拨出处理模块,用于将被拨出传感器从当前被监控的传感器数组中移除并发出传感器拨出信号。The dial-out processing module is configured to remove the dial-out sensor from the currently monitored sensor array and send a sensor dial-out signal.

优选的,所述上位机还包括:Preferably, the host computer also includes:

告警模块,用于当轮询模块获取的传感器的数值高于预设的告警阈值时,启动告警线程。The alarm module is configured to start an alarm thread when the value of the sensor acquired by the polling module is higher than a preset alarm threshold.

本发明实施例还提供了一种传感器,包括:The embodiment of the present invention also provides a sensor, including:

发送模块,用于当传感器接入时,发送连接请求,以用于上位机基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否有效,所述连接请求中包括一传感器标识信息。The sending module is used to send a connection request when the sensor is connected, so that the upper computer can identify and verify the sensor based on the connection request, and determine whether the sensor access is valid based on the result of the recognition and verification. The connection request includes a sensor identification information.

优选的,所述发送模块还用于在所述上位机对所述传感器识别验证时,发送传感器属性信息以及连接验证信息中的至少一项。Preferably, the sending module is further configured to send at least one of sensor attribute information and connection verification information when the host computer identifies and verifies the sensor.

本发明实施例还提供了一种传感器识别系统,包括传感器和上位机,其中:The embodiment of the present invention also provides a sensor recognition system, including a sensor and a host computer, wherein:

传感器,用于当传感器接入时,发送连接请求,所述连接请求中包括一传感器标识信息;The sensor is configured to send a connection request when the sensor is connected, and the connection request includes sensor identification information;

上位机,用于接收所述传感器发送的连接请求,并基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功。The upper computer is configured to receive the connection request sent by the sensor, and based on the connection request, perform identification verification on the sensor, and based on the identification verification result, determine whether the sensor access is successful.

从以上所述可以看出,本发明实施例提供的传感器识别方法、上位机、传感器及传感器识别系统,通过接收连接请求,该连接请求是传感器接入时发送的并且包括有该传感器的标识信息,对该传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功,从而实现传感器的即插即用,具有准确性较好、反应速度快的特点。并且具有较高的可靠性。It can be seen from the above that the sensor identification method, host computer, sensor and sensor identification system provided by the embodiments of the present invention receive a connection request, which is sent when the sensor is connected and includes the identification information of the sensor , identify and verify the sensor, and determine whether the sensor is connected successfully based on the result of the identification and verification, so as to realize the plug and play of the sensor, which has the characteristics of good accuracy and fast response speed. And has high reliability.

附图说明Description of drawings

图1为本发明实施例提供的传感器识别方法的流程示意图一;FIG. 1 is a schematic flow diagram of a sensor identification method provided by an embodiment of the present invention;

图2为本发明实施例提供的传感器识别方法中传感器识别验证过程示意图;2 is a schematic diagram of the sensor identification verification process in the sensor identification method provided by the embodiment of the present invention;

图3为本发明实施例提供的传感器识别方法的流程示意图二;FIG. 3 is a schematic flow diagram II of a sensor identification method provided by an embodiment of the present invention;

图4为本发明实施例提供的传感器识别系统结构示意图;Fig. 4 is a schematic structural diagram of a sensor identification system provided by an embodiment of the present invention;

图5为本发明实施例提供的上位机结构示意图。FIG. 5 is a schematic structural diagram of a host computer provided by an embodiment of the present invention.

具体实施方式Detailed ways

本发明实施例提供了一种传感器识别方法,如图1所示,包括:An embodiment of the present invention provides a sensor identification method, as shown in Figure 1, including:

步骤11,接收一连接请求,所述连接请求,是当传感器接入时,由传感器所发送的,所述连接请求中包括一传感器标识信息;Step 11, receiving a connection request, the connection request is sent by the sensor when the sensor is connected, and the connection request includes a sensor identification information;

步骤12,基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功。Step 12: Perform identification verification on the sensor based on the connection request, and determine whether the sensor access is successful based on the identification verification result.

本发明实施例提供的传感器识别方法,可以实现传感器的即插即用,具有较高的可靠性。The sensor identification method provided by the embodiment of the present invention can realize the plug-and-play of the sensor, and has high reliability.

本发明实施例提供的技术方案中,采用中断方式实现上位机对传感器接入处理,主要包括两部分内容,第一个是传感器挂接到485总线后,能够主动发出信息,第二个是总线能够及时接收和处理接入请求,否则总线就会发生数据碰撞而难以通信。通过实现即插即用的方式,使传感器接入就能够被上位机发现和应用,将主从方式改为双主方式,将串行方式改为中断方式。In the technical solution provided by the embodiment of the present invention, the interrupt method is used to realize the access processing of the host computer to the sensor, which mainly includes two parts. The first one is that the sensor can actively send information after it is connected to the 485 bus, and the second is the bus. Access requests can be received and processed in a timely manner, otherwise data collisions will occur on the bus and communication will be difficult. By realizing the plug-and-play method, the sensor access can be discovered and applied by the host computer, the master-slave mode is changed to a dual-master mode, and the serial mode is changed to an interrupt mode.

本发明实施例所涉及的中断方式,具体是指传感器主动发出消息,中断上位机的当前处理,即上位机暂停其它工作,与传感器通信,将其纳入系统,再恢复继续之前的工作。The interruption method involved in the embodiment of the present invention specifically means that the sensor actively sends a message to interrupt the current processing of the upper computer, that is, the upper computer suspends other work, communicates with the sensor, incorporates it into the system, and resumes the previous work.

485总线是异步半双工的通信总线,在某一个时刻,总线只可能呈现一种状态,一般适用于主机对分机的查询方式通信,总线上必然有一台始终处于主机地位的设备在巡检其它的分机,通过制定合理的通信协议来协调总线的分时共用。在485总线中的通信数据是成帧成包发送的,每包数据都有引导码、长度码、地址码、命令码、内容、校验码等部分组成。其中引导码是用于同步每一包数据的引导头;长度码是这一包数据的总长度;命令码是主机对分机(或分机应答主机)的控制命令;地址码是分机的本机地址号;“内容”是这一包数据里的各种信息;校验码是这一包数据的校验标志,可以采用奇偶校验等不同的方式。The 485 bus is an asynchronous half-duplex communication bus. At a certain moment, the bus can only show one state. Generally, it is suitable for the master to communicate with the extension. The extensions coordinate the time-sharing of the bus by formulating a reasonable communication protocol. The communication data in the 485 bus is sent in frames and packets, and each packet of data consists of boot code, length code, address code, command code, content, check code and other parts. The boot code is the boot header used to synchronize each packet of data; the length code is the total length of this packet of data; the command code is the control command from the host to the extension (or the extension answers the host); the address code is the local address of the extension No.; "Content" is the various information in this packet of data; the check code is the check mark of this packet of data, and different methods such as parity check can be used.

在本具体实施方式中,当一个新传感器接入的时候,该传感器是主端口,不断发出接入请求,一直到上位机做出了应答。In this specific embodiment, when a new sensor is connected, the sensor is the main port, which continuously sends access requests until the upper computer responds.

上位机应答接入传感器后,除第一个接入的传感器外,其它端口就从主端口变回从端口,切换回传统的主从方式通信。After the upper computer responds to access the sensor, except for the first connected sensor, the other ports will change from the master port to the slave port, and switch back to the traditional master-slave communication.

在本发明一可选实施例中,所述基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功过程具体还可以包括:In an optional embodiment of the present invention, the process of identifying and verifying the sensor based on the connection request, and determining whether the sensor access is successful based on the result of the identification verification may further include:

判断所述连接请求中包括的传感器标识信息是否有效,获取第一判断结果;Judging whether the sensor identification information included in the connection request is valid, and obtaining a first judgment result;

若所述第一判断结果为所述传感器标识信息有效,则确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入即传感器接入失败。If the first judgment result is that the sensor identification information is valid, it is determined that the sensor access is valid; otherwise, it is determined that the sensor access is invalid, that is, the sensor access fails.

在本发明一可选实施例中,所述基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功的过程具体还可以包括:In an optional embodiment of the present invention, the process of performing identification verification on the sensor based on the connection request, and determining whether the sensor access is successful based on the identification verification result may further include:

在所述第一判断结果为所述传感器标识信息有效之后,向所述传感器发送读属性请求;After the first judgment result is that the sensor identification information is valid, send a read attribute request to the sensor;

根据所述传感器基于所述读属性请求而返回的属性信息,判断是否能够识别所述传感器,获取第二判断结果;judging whether the sensor can be identified according to the attribute information returned by the sensor based on the read attribute request, and obtaining a second judgment result;

若所述第二判断结果为能够识别所述传感器,则确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入。If the second determination result is that the sensor can be identified, it is determined that the sensor access is a valid access, otherwise, it is determined that the sensor access is an invalid access.

在本发明一可选实施例中,所述基于所述连接请求,对所述传感器进行识别验证,并基于识别验证结果,确定所述传感器接入是否成功过程具体还可以包括:In an optional embodiment of the present invention, the process of identifying and verifying the sensor based on the connection request, and determining whether the sensor access is successful based on the result of the identification verification may further include:

在确定所述传感器接入为有效接入之后,向所述传感器发送确认信息;After determining that the sensor access is a valid access, sending confirmation information to the sensor;

根据所述传感器基于所述确认信息而返回的连接验证信息,确定所述传感器接入是否成功。According to the connection verification information returned by the sensor based on the confirmation information, it is determined whether the access of the sensor is successful.

在本发明一具体实施例中,也可以按如附图2所示流程实现传感器的识别验证过程,包括:In a specific embodiment of the present invention, the identification and verification process of the sensor can also be realized according to the process shown in Figure 2, including:

步骤21,传感器发送连接请求,所述连接请求携带的传感器标识信息;Step 21, the sensor sends a connection request, the sensor identification information carried by the connection request;

步骤22,上位机收连接请求,当所述连接请求携带的传感器标识信息有效时发送读属性请求;Step 22, the host computer receives the connection request, and sends a read attribute request when the sensor identification information carried by the connection request is valid;

步骤23,传感器根据接收的发送读属性请求,发送传感器属性信息;Step 23, the sensor sends the sensor attribute information according to the received attribute read request;

步骤24,上位机根据接收的传感器属性信息判断是否能够识别相应的传感器,若能够识别,则发送确认信息;Step 24, the host computer judges whether the corresponding sensor can be identified according to the received sensor attribute information, and if it can be identified, then sends a confirmation message;

步骤25,传感器根据接收的确认信息,发送连接验证;Step 25, the sensor sends connection verification according to the received confirmation information;

步骤26,上位机根据接收的连接验证确定相应的传感器连接成功。Step 26, the host computer determines that the corresponding sensor is successfully connected according to the received connection verification.

经过上述传感器与上位机的交互,上位机已经能够识别传感器并调用传感器的相应功能,但是在调用传感器的相应功能时,还需要对传感器的状态和读数进行管理,具体通过控制流线程和数据流线程实现。After the above-mentioned interaction between the sensor and the host computer, the host computer has been able to identify the sensor and call the corresponding function of the sensor, but when calling the corresponding function of the sensor, it also needs to manage the state and reading of the sensor, specifically through the control flow thread and data flow Thread implementation.

相应的控制流线程具体可以包括:监控线程和失效线程。Corresponding control flow threads may specifically include: monitoring threads and failure threads.

相应的数据流线程具体可以包括:读数线程和告警线程。The corresponding data flow thread may specifically include: a reading thread and an alarm thread.

本发明实施例中,通过控制流线程和数据流线程能够实现传感器的接入识别、数据读取、告警处理和拔出识别,以完成整个监控过程的核心处理流程。其中监控线程、读数线程和失效检测线程共同维护一个信号量(当前被监控的传感器数组)。In the embodiment of the present invention, the access identification, data reading, alarm processing and extraction identification of the sensor can be realized through the control flow thread and the data flow thread, so as to complete the core processing flow of the entire monitoring process. The monitoring thread, the reading thread and the failure detection thread jointly maintain a semaphore (an array of sensors currently being monitored).

本发明所涉及的监控线程,具体可以理解为对已接入成功的传感器所采取的实时监控操作,该监控操作可以用于确认传感器是否发生拨出事件。The monitoring thread involved in the present invention can specifically be understood as a real-time monitoring operation on a sensor that has been successfully connected, and the monitoring operation can be used to confirm whether a dial-out event occurs in the sensor.

那么,在本发明一可选实施例中,当上位机确定传感器接入成功之后,具体还可以包括以下处理步骤:Then, in an optional embodiment of the present invention, after the host computer determines that the sensor is connected successfully, it may specifically include the following processing steps:

将所述传感器加入到当前被监控的传感器数组中;adding the sensor to the currently monitored sensor array;

按第一预设时间间隔向传感器数组中的传感器发送监控信号,所述监控信号用于监控传感器是否存在于所述传感器数组中。A monitoring signal is sent to the sensors in the sensor array at a first preset time interval, and the monitoring signal is used to monitor whether a sensor exists in the sensor array.

为了确保尽快发现传感器是否发生拨出事件,本发明实施例所涉及的第一预设时间间隔可以设置的比较小,例如0.1秒等,即监控信号的发送频率可以为0.1秒等。以及时确定传感器数组中的传感器是否还存在于传感器数组中,即传感器是否发生拨出事件。In order to ensure that whether a dial-out event occurs in the sensor is detected as soon as possible, the first preset time interval involved in the embodiment of the present invention can be set relatively small, such as 0.1 second, that is, the sending frequency of the monitoring signal can be 0.1 second. To timely determine whether the sensor in the sensor array still exists in the sensor array, that is, whether the sensor has a dial-out event.

这里需要说明的是,本发明实施例所涉及的传感器在接收到上述监控信号后,可直接返回该监控信号,以便上位机接收确认传感器是否还存在于传感器数组中。It should be noted here that the sensor involved in the embodiment of the present invention may directly return the monitoring signal after receiving the monitoring signal, so that the host computer can receive and confirm whether the sensor still exists in the sensor array.

另外,当上位机在第三预设时间间隔内,没有收到传感器返回的监控信号,则可以确定传感器发生拨出事件,即传感器被拨出。而且,第三预设的时间间隔可以稍大于第一预设时间间隔,例如0.3秒等等。In addition, when the host computer does not receive the monitoring signal returned by the sensor within the third preset time interval, it can be determined that the sensor is dialed out, that is, the sensor is dialed out. Moreover, the third preset time interval may be slightly longer than the first preset time interval, such as 0.3 seconds and so on.

本发明实施例所涉及的读数线程,具体可以理解为上位机与传感器交互的过程。The reading thread involved in the embodiment of the present invention can be specifically understood as the process of interaction between the upper computer and the sensor.

即在本发明一可选实施例中,当传感器加入传感器数组即传感器处于监控线程的监控后,具体还可以包括以下处理步骤:That is, in an optional embodiment of the present invention, after the sensor is added to the sensor array, that is, the sensor is under the monitoring of the monitoring thread, the following processing steps may be specifically included:

按第二预设时间间隔轮询传感器数组中各传感器的数值,并记录传感器每一次被轮询的时间。The value of each sensor in the sensor array is polled at a second preset time interval, and the time at which the sensor is polled each time is recorded.

具体的,读数线程可以按预设的时间间隔(具体可大于监控信号的发送间隔),轮询当前被监控的传感器数组中的传感器,发送读数请求,一次一个,每个传感器间隔可以1秒等,而轮询周期具体可为15秒等。Specifically, the reading thread can poll the sensors in the currently monitored sensor array at a preset time interval (specifically greater than the sending interval of the monitoring signal), and send reading requests, one at a time, and each sensor interval can be 1 second, etc. , and the polling period may specifically be 15 seconds or the like.

由于目前使用的都是温度、湿度等非经常剧烈变化的传感器,而对于急速变化的传感器,可以将周期设置为几秒。在实际应用时,根据不同的传感器性能,不同的成熟度等情况,以上的时间都可以配置,实现总体的平衡和用户的良好的体验。Since the sensors that are currently used are non-frequent and drastic changes such as temperature and humidity, and for sensors that change rapidly, the cycle can be set to a few seconds. In actual application, according to different sensor performances and different maturity levels, the above time can be configured to achieve overall balance and a good user experience.

读数线程在获取传感器的值后,分析该值,根据功能码进行下一步通信。After the reading thread obtains the value of the sensor, it analyzes the value and performs the next communication according to the function code.

基于以上描述可以看出,本发明实施例所提供的传感器识别方法中,读数线程的启动时刻即为传感器插入时,关闭时刻即为传感器拔出时。读数线程以固定周期读取各个传感器数据,如果发现有监控线程中断事件,就停止读数,转向新加入的传感器交互认证,将传感器纳入网络。如果读数线程无法读取某个传感器,将信息传入失效线程,该线程处理失效问题。正常读数后,将信息转给告警线程。继续循环读数,一直运行。Based on the above description, it can be seen that in the sensor identification method provided by the embodiment of the present invention, the start time of the reading thread is when the sensor is inserted, and the close time is when the sensor is pulled out. The reading thread reads the data of each sensor in a fixed period. If it finds that there is a monitoring thread interruption event, it stops reading, turns to the interactive authentication of the newly added sensor, and incorporates the sensor into the network. If the reading thread fails to read a sensor, it passes the information to the invalidation thread, which handles the invalidation. After a normal reading, forward the information to the alarm thread. Continue to cycle through the readings, running all the time.

由于电子产品可能存在虚焊或接触不良等情况,在这种不良情况下,上位机可能也无法获取传感器的数值,或者无法接收传感器返回的监控信号。但在这种不良的情况下,实质上传感器并未发生拨出事件,因此,本发明实施例中引入了实效线程,以用于判断传感器是否实效。Due to the fact that the electronic product may have weak soldering or poor contact, in such a bad situation, the host computer may not be able to obtain the value of the sensor, or may not be able to receive the monitoring signal returned by the sensor. However, in such a bad situation, the sensor does not actually have a dial-out event. Therefore, the embodiment of the present invention introduces an invalidation thread to determine whether the sensor is invalidated.

具体的,实效线程可以通过判断系统当前时间与传感器最后一次被轮询的时间之间的差值,是否大于预设的失效阈值,从而判定传感器是否失效。Specifically, the effectiveness thread can determine whether the sensor is invalid by judging whether the difference between the current time of the system and the last polled time of the sensor is greater than a preset failure threshold.

在具体应用时,失效阈值具体可为传感器读数轮询周期的2倍。In a specific application, the failure threshold may specifically be twice the polling period for sensor readings.

由于传感器失效也可以理解为传感器发生拨出事件,因此,本发明实施例中,也可以基于判断传感器是否失效,来判断传感器是否发生拨出事件。Since the failure of the sensor can also be understood as a dial-out event occurring on the sensor, in the embodiment of the present invention, it may also be determined whether a dial-out event occurs on the sensor based on whether the sensor fails.

可见,本发明实施例中,可以基于监控线程以及失效线程两者中的至少一项,及时确认传感器是否发生拨出事件。It can be seen that, in the embodiment of the present invention, based on at least one of the monitoring thread and the failure thread, it can be confirmed in time whether the sensor has a dial-out event.

即本发明一可选实施例中,具体还可以涉及以下步骤:That is, in an optional embodiment of the present invention, the following steps may also be specifically involved:

若在第三预设时间间隔内没有收到传感器返回的所述监控信号,和/或判定所述传感器失效,则判断传感器已被拔出。If the monitoring signal returned by the sensor is not received within the third preset time interval, and/or it is determined that the sensor is invalid, it is determined that the sensor has been pulled out.

本发明实施例中,当确定传感器已被拔出后,还可以涉及以下操作:In the embodiment of the present invention, after it is determined that the sensor has been pulled out, the following operations may also be involved:

将被拨出传感器从当前被监控的传感器数组中移除并发出传感器拨出信号。Removes the dialed out sensor from the currently monitored array of sensors and signals a sensor dialed out.

而本发明所涉及的告警线程,具体是指当读数线程经轮询获取的传感器的数值高于预设的告警阈值时,而启动的告警流程。The alarm thread involved in the present invention specifically refers to the alarm process that is started when the value of the sensor acquired by the reading thread through polling is higher than the preset alarm threshold.

在启动告警线程后,可根据告警级别和告警设置触发不同的告警,包括发光、震动、发声、短信等。After starting the alarm thread, different alarms can be triggered according to the alarm level and alarm settings, including lighting, vibration, sound, text messages, etc.

同时,本发明实施例中,可保存告警记录等待处理。At the same time, in the embodiment of the present invention, the alarm record may be saved for processing.

通过采用上述技术方案,本发明实施例提出了一种双主端口的方式来解决传感器主动发出请求的中断方式,变被动为主动,为传感网优化提出新的思路;提出中断方式来进行通信,只有中断方式才能实现基于事件的处理,才能实现从串行处理到分时的并行处理,就有了新的实现方法的可能;提出将控制和数据分开管理,理顺系统处理的架构,提升系统的拓展性。同时提高处理的速度,也为后续的系统的升级维护打下了基础。By adopting the above-mentioned technical solution, the embodiment of the present invention proposes a dual-master port method to solve the interrupt mode in which the sensor actively sends out a request, changing from passive to active, and proposing a new idea for sensor network optimization; proposing an interrupt mode for communication , only the interrupt method can realize event-based processing, and can realize parallel processing from serial processing to time-sharing, and there is a possibility of a new implementation method; it is proposed to manage control and data separately, straighten out the architecture of system processing, and improve System scalability. At the same time, the processing speed is improved, which also lays the foundation for the subsequent system upgrade and maintenance.

下面,对本发明实施例提供的传感器识别方法的一个实现传感器的识别验证及控制过程进行详细的描述。In the following, a detailed description will be given of a sensor identification verification and control process of a sensor identification method provided by an embodiment of the present invention.

如附图3所示,该过程具体可以包括:As shown in Figure 3, the process specifically may include:

步骤31,当传感器接入时,传感器发送连接请求,所述连接请求携带的传感器标识信息。Step 31, when the sensor is connected, the sensor sends a connection request, and the connection request carries the sensor identification information.

步骤32,上位机接收连接请求后,判断连接请求携带的传感器标识信息是否有效,若判断结果为有效,则执行步骤34,否则执行步骤33,即上位机确定传感器接入为无效接入。Step 32, after receiving the connection request, the host computer judges whether the sensor identification information carried in the connection request is valid, if the judgment result is valid, then executes step 34, otherwise executes step 33, that is, the host computer determines that the sensor access is invalid.

步骤34,上位机向传感器发送读属性请求。Step 34, the host computer sends a request to read attributes to the sensor.

步骤35,传感器向上位机发送自身属性信息。Step 35, the sensor sends its own attribute information to the host computer.

本发明实施例所涉及的传感器属性信息,具体可以包括传感器的厂家、类型、开发时间、版本、单位等属性信息。The sensor attribute information involved in the embodiments of the present invention may specifically include attribute information such as the manufacturer, type, development time, version, and unit of the sensor.

步骤36,上位机判断是否能够识别传感器属性信息,并当判断结果为能够识别时,后续执行步骤37,否则执行步骤33,即上位机确定传感器接入为无效接入。Step 36, the host computer judges whether the sensor attribute information can be identified, and if the judgment result is yes, then executes step 37, otherwise executes step 33, that is, the host computer determines that the sensor access is invalid.

步骤37,上位机向传感器发送确认信息。Step 37, the upper computer sends confirmation information to the sensor.

步骤38,传感器基于上述确认信息,向上位机返回连接验证信息。In step 38, the sensor returns connection verification information to the host computer based on the above confirmation information.

步骤39,上位机基于连接验证信息,确认传感器接入是否成功。In step 39, the host computer confirms whether the sensor access is successful based on the connection verification information.

若传感器接入成功,则后续执行步骤310,否则可执行步骤33,上位机确定传感器接入为无效接入,即等同于宣告传感器接入识别。If the sensor access is successful, step 310 is subsequently performed, otherwise step 33 can be performed, and the host computer determines that the sensor access is invalid, which is equivalent to declaring sensor access identification.

步骤310,上位机将接入成功的传感器加入到当前被监控的传感器数组中。Step 310, the host computer adds the successfully connected sensors to the currently monitored sensor array.

步骤311,上位机按照第一预设时间间隔向传感器数组中的传感器发送监控信号,以确定传感器是否发生拨出事件。Step 311 , the host computer sends monitoring signals to the sensors in the sensor array according to a first preset time interval, so as to determine whether a dial-out event occurs in the sensors.

后续上位机可分别执行步骤312和步骤313。The subsequent host computer can execute step 312 and step 313 respectively.

其中,步骤312,上位机判断在第二预设时间间隔内,是否接收到传感器返回的监控信号,并当超过第二预设时间间隔后,仍然没有收到传感器返回的监控信号,则执行步骤316。Wherein, in step 312, the upper computer judges whether the monitoring signal returned by the sensor is received within the second preset time interval, and when the monitoring signal returned by the sensor is still not received after exceeding the second preset time interval, then the step 316.

步骤313,上位机按第三预设时间间隔轮询传感器数组中各传感器的数值,并记录传感器每一次被轮询的时间。Step 313 , the host computer polls the values of the sensors in the sensor array at a third preset time interval, and records the time when the sensors are polled each time.

若上位机轮询获取的传感器的数值高于预设的告警阈值时,执行步骤314,即启动告警线程,并根据告警等级和告警设置,触发对应的告警动作。If the value of the sensor polled by the host computer is higher than the preset alarm threshold, step 314 is executed, that is, an alarm thread is started, and a corresponding alarm action is triggered according to the alarm level and alarm settings.

若系统当前时间与传感器最后一次被轮询的时间之间的差值,大于预设的失效阈值时,执行步骤315,即判定传感器失效。If the difference between the current time of the system and the last polled time of the sensor is greater than the preset failure threshold, step 315 is executed, that is, it is determined that the sensor is invalid.

那么,当步骤312或315中的至少一项产生触发条件时,即超过第二预设时间间隔后,仍然没有收到传感器返回的监控信号,和/或判定传感器失效,则后续可执行步骤316,确定传感器已经发送拨出事件,将被拨出的传感器从当前被监控的传感器数组中移除并发出传感器拨出信号。Then, when at least one of step 312 or 315 generates a trigger condition, that is, after the second preset time interval is exceeded, the monitoring signal returned by the sensor is still not received, and/or the sensor is determined to be invalid, then step 316 can be subsequently performed , to determine that the sensor has sent a dialout event, remove the dialed out sensor from the array of currently monitored sensors and signal a sensor dialout.

上述本发明实施例提供的传感器识别方法的实现,可以实现传感器的即插即用,具有准确性较好、反应速度快的特点,并且具有较高的可靠性。同时,当传感器被拨出时,可以及时发现拨出事件,为新的传感器接入提供处理的空间。The implementation of the sensor identification method provided by the above embodiments of the present invention can realize the plug-and-play of the sensor, has the characteristics of good accuracy, fast response speed, and high reliability. At the same time, when the sensor is dialed out, the dial-out event can be detected in time to provide processing space for new sensor access.

本发明实施例还提供了一种传感器识别系统,如附图4所示,该系统具体可以包括传感器41以及上位机42。其中:The embodiment of the present invention also provides a sensor recognition system, as shown in FIG. 4 , the system may specifically include a sensor 41 and a host computer 42 . in:

传感器41,用于当接入网络时,发送连接请求,所述连接请求中包括一传感器标识信息。The sensor 41 is configured to send a connection request when accessing the network, where the connection request includes sensor identification information.

上位机42,用于接收传感器41发送的连接请求,并基于所述连接请求,对传感器41进行识别验证,并基于识别验证结果,确定传感器41接入是否成功。The host computer 42 is configured to receive the connection request sent by the sensor 41, and based on the connection request, perform identification verification on the sensor 41, and based on the identification verification result, determine whether the connection of the sensor 41 is successful.

本发明实施例所涉及的传感器41内,具体可包括一发送模块,用于当传感器接入例如采用485半双工通信模式的网络时,向网络侧中的一设备,例如上位机发送连接请求。The sensor 41 involved in the embodiment of the present invention may specifically include a sending module, which is used to send a connection request to a device on the network side, such as a host computer, when the sensor is connected to a network using, for example, a 485 half-duplex communication mode .

该连接请求中,具体可以包括传感器标识等信息。The connection request may specifically include information such as sensor identification.

另外,传感器41中所包括的发送模块,具体还可以用于在网络侧对传感器进行识别验证过程中,发送传感器属性信息、连接验证信息中的至少一项。In addition, the sending module included in the sensor 41 may specifically be used to send at least one item of sensor attribute information and connection verification information during the process of identifying and verifying the sensor on the network side.

而本发明实施例所涉及的上位机42,如附图5所示,具体可以包括:And the upper computer 42 involved in the embodiment of the present invention, as shown in accompanying drawing 5, specifically can comprise:

接收模块421,用于接收一连接请求。The receiving module 421 is configured to receive a connection request.

具体的该连接请求可以是当传感器41接入网络时,由传感器41所发送的,所述连接请求中具体可以包括传感器标识等信息。Specifically, the connection request may be sent by the sensor 41 when the sensor 41 accesses the network, and the connection request may specifically include information such as a sensor identification.

识别验证模块422,用于基于所述连接请求,对传感器41进行识别验证,并基于识别验证结果,确定传感器41接入是否成功。The identification verification module 422 is configured to perform identification verification on the sensor 41 based on the connection request, and determine whether the access of the sensor 41 is successful based on the identification verification result.

在本发明一可选实施例中,识别验证模块422具体可以包括:In an optional embodiment of the present invention, the identification verification module 422 may specifically include:

第一判断单元,用于判断连接请求中包括的传感器标识信息是否有效;A first judging unit, configured to judge whether the sensor identification information included in the connection request is valid;

确定单元,用于在第一判断单元判断所述传感器标识信息有效时,确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入。The determining unit is configured to determine that the sensor access is valid when the first judging unit determines that the sensor identification information is valid, otherwise determine that the sensor access is invalid.

在本发明一可选实施例中,识别验证模块422具体还可以包括:In an optional embodiment of the present invention, the identification verification module 422 may specifically include:

发送单元,用于在第一判断单元判断传感器标识信息有效时,向传感器发送读属性请求;A sending unit, configured to send a read attribute request to the sensor when the first judging unit judges that the sensor identification information is valid;

第二判断单元,用于根据述传感器基于读属性请求而返回的属性信息,判断是否能够识别所述传感器;A second judging unit, configured to judge whether the sensor can be identified according to the attribute information returned by the sensor based on the attribute read request;

所述确定模块还用于在所述第二判断单元判断能够识别所述传感器时,确定所述传感器接入为有效接入,否者确定所述传感器接入为无效接入。The determining module is further configured to determine that the sensor access is valid when the second judging unit determines that the sensor can be identified, or determine that the sensor access is invalid.

在本发明一可选实施例中,发送单元还可以用于在确定模块确定所述传感器接入有效时,向所述传感器发送确认信息;In an optional embodiment of the present invention, the sending unit may also be configured to send confirmation information to the sensor when the determining module determines that the sensor access is valid;

所述确定单元,还用于基于所述传感器基于所述确认信息而返回的连接验证信息,确定所述传感器连接是否成功。The determining unit is further configured to determine whether the connection of the sensor is successful based on the connection verification information returned by the sensor based on the confirmation information.

在本发明一可选实施例中,上位机42具体还可以包括:In an optional embodiment of the present invention, the upper computer 42 may specifically include:

加入模块,用于在所述识别验证模块422确定所述传感器接入成功后,将所述传感器加入到当前被监控的传感器数组中;A adding module, configured to add the sensor to the currently monitored sensor array after the identification verification module 422 determines that the sensor is successfully connected;

监控模块,用于按第一预设时间间隔向传感器数组中的传感器发送监控信号,所述监控信号用于监控传感器是否存在于所述传感器数组中。A monitoring module, configured to send a monitoring signal to the sensors in the sensor array at a first preset time interval, and the monitoring signal is used to monitor whether a sensor exists in the sensor array.

在本发明一可选实施例中,上位机42具体还可以包括:In an optional embodiment of the present invention, the upper computer 42 may specifically include:

轮询模块,用于按第二预设时间间隔轮询传感器数组中各传感器的数值,并记录传感器每一次被轮询的时间。The polling module is configured to poll the values of the sensors in the sensor array at a second preset time interval, and record the time when the sensors are polled each time.

在本发明一可选实施例中,上位机42具体还可以包括:In an optional embodiment of the present invention, the upper computer 42 may specifically include:

失效判断模块,用于若系统当前时间与传感器最后一次被轮询的时间之间的差值,大于预设的失效阈值时,判定所述传感器失效。The failure judging module is used to judge that the sensor is invalid if the difference between the current time of the system and the time when the sensor was last polled is greater than a preset failure threshold.

在本发明一可选实施例中,上位机42具体还可以包括:In an optional embodiment of the present invention, the upper computer 42 may specifically include:

拨出判断模块,用于若在第三预设时间间隔内没有收到传感器返回的所述监控信号,和/或所述失效判断模块判定所述传感器失效,则判断所述传感器已被拔出;The dialing out judging module is used to judge that the sensor has been pulled out if the monitoring signal returned by the sensor is not received within the third preset time interval, and/or the failure judging module judges that the sensor is invalid ;

拨出处理模块,用于将被拨出传感器从当前被监控的传感器数组中移除并发出传感器拨出信号。The dial-out processing module is configured to remove the dial-out sensor from the currently monitored sensor array and send a sensor dial-out signal.

在本发明一可选实施例中,上位机42具体还可以包括:In an optional embodiment of the present invention, the upper computer 42 may specifically include:

告警模块,用于当轮询模块获取的传感器的数值高于预设的告警阈值时,启动告警线程。The alarm module is configured to start an alarm thread when the value of the sensor acquired by the polling module is higher than a preset alarm threshold.

采用本发明实施例提供的传感器识别方法、系统,以及传感器和上位机,在485半双工通信模式下,所有的传感器接入的时候都是采用主端口方式,不是整个总线上只有一个主端口,其余都是从端口;传感器发出连接请求,上位机读取配置,传感器发送配置,上位机确认配置,传感器回复确认的五个步骤。之后传感器进入等待读数的方式,减少了对总线的占用,实现了从传统传感器向智能传感器转换的一种方法;采用多线程进行传感器的识别和管理,通过接入线程和失效线程两个控制线程,读数线程和告警线程两个数据线程,实现整个过程的协调有序的管理。Using the sensor identification method and system provided by the embodiment of the present invention, as well as the sensor and the upper computer, in the 485 half-duplex communication mode, all the sensors are connected using the master port mode, not only one master port on the entire bus , and the rest are slave ports; the sensor sends a connection request, the host computer reads the configuration, the sensor sends the configuration, the host computer confirms the configuration, and the sensor replies to confirm the five steps. After that, the sensor enters the mode of waiting for readings, which reduces the occupation of the bus and realizes a method of converting from traditional sensors to smart sensors; multi-threading is used to identify and manage sensors, and two control threads are used to access the thread and the invalid thread , two data threads, the reading thread and the alarm thread, realize the coordinated and orderly management of the whole process.

以上所述仅是本发明的实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以作出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。The above is only the embodiment of the present invention, it should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present invention, some improvements and modifications can also be made, and these improvements and modifications should also be regarded as Be the protection scope of the present invention.

Claims (22)

1. an identification method of sensor, is characterized in that, comprising:
Receive a connection request, described connection request, is in the time that transducer accesses, and is sent by transducer, and described connection request comprises a sensor identification information;
Based on described connection request, described transducer is identified to checking, and based on identification the result, determine that whether described transducer access is successful.
2. the method for claim 1, is characterized in that, described based on described connection request, and described transducer is identified to checking, and based on identification the result, determines whether described transducer access successfully comprises:
Judge that whether the sensor identification information that described connection request comprises is effective, obtain the first judged result;
If described the first judged result is that described sensor identification information is effective, determine that described transducer access is for effectively access, no person determines that described transducer access is invalid access.
3. method as claimed in claim 2, is characterized in that, described based on described connection request, and described transducer is identified to checking, and based on identification the result, determines whether described transducer access successfully also comprises:
Described the first judged result be described sensor identification information effectively after, send and read attribute request to described transducer;
Read based on described the attribute information that attribute request is returned according to described transducer, judge whether to identify described transducer, obtain the second judged result;
If described the second judged result for can identify described transducer, determines that described transducer access is for effectively access, no person determines that described transducer access is invalid access.
4. method as claimed in claim 2 or claim 3, is characterized in that, described based on described connection request, and described transducer is identified to checking, and based on identification the result, determines whether described transducer access successfully also comprises:
After determining that described transducer access is for effective access, send confirmation to described transducer;
The connectivity verification information of returning based on described confirmation according to described transducer, determines that whether described transducer access is successful.
5. the method for claim 1, is characterized in that, described method also comprises after definite described transducer accesses successfully:
Described transducer is joined in current monitored transducer array;
Send pilot signal by the first Preset Time interval to the transducer in transducer array, whether described pilot signal is present in described transducer array for monitoring sensor.
6. method as claimed in claim 5, is characterized in that, described method also comprises:
By the numerical value of each transducer in the second Preset Time interval poll transducer array, and record transducer polled time each time.
7. method as claimed in claim 6, is characterized in that, described method also comprises:
If the difference between the last polled time of current time in system and transducer, while being greater than default failure threshold, judges described sensor failure.
8. method as claimed in claim 7, is characterized in that, described method also comprises:
If do not receive the described pilot signal that transducer returns in the 3rd Preset Time interval, and/or judge described sensor failure, judge that described transducer is pulled out;
Transferred to signal by transfering to transducer to remove and send transducer from current monitored transducer array.
9. method as claimed in claim 6, is characterized in that, described method also comprises:
The numerical value of the transducer obtaining when poll during higher than default alarm threshold, starts alarm thread.
10. method as claimed in claim 9, is characterized in that, described startup alarm thread comprises:
According to alarm grade and alarm setting, trigger corresponding alarm action.
11. 1 kinds of host computers, is characterized in that, comprising:
Receiver module, for receiving a connection request, described connection request, is in the time that transducer accesses, and is sent by transducer, described connection request comprises a sensor identification information;
Identification authentication module, for based on described connection request, identifies checking to described transducer, and based on identification the result, determines that whether described transducer access is successful.
12. host computers as claimed in claim 11, is characterized in that, described identification authentication module comprises:
The first judging unit, whether effective for judging the sensor identification information that described connection request comprises;
Determining unit, in the time that described the first judging unit judges that described sensor identification information is effective, determines that described transducer access is for effectively access, and no person determines that described transducer access is invalid access.
13. host computers as claimed in claim 12, is characterized in that, described identification authentication module also comprises:
Transmitting element, in the time that described the first judging unit judges that described sensor identification information is effective, sends and reads attribute request to described transducer;
The second judging unit, for reading based on described the attribute information that attribute request is returned according to described transducer, judges whether to identify described transducer;
Described determination module also, in the time that described the second judging unit judgement can be identified described transducer, determines that described transducer access is for effectively access, and no person determines that described transducer access is invalid access.
14. host computers as described in claim 12 or 13, is characterized in that, described transmitting element is also for determining that at described determination module described transducer accesses when effective, sends confirmation to described transducer;
Described determining unit, the also connectivity verification information for returning based on described confirmation based on described transducer, determines whether described transducer connects successful.
15. host computers as claimed in claim 11, is characterized in that, also comprise:
Add module, after determining that at described identification authentication module described transducer accesses successfully, described transducer is joined in current monitored transducer array;
Monitoring module, for sending pilot signal by the first Preset Time interval to the transducer of transducer array, whether described pilot signal is present in described transducer array for monitoring sensor.
16. host computers as claimed in claim 15, is characterized in that, also comprise:
Poll module, for by the numerical value of the each transducer of the second Preset Time interval poll transducer array, and records transducer polled time each time.
17. host computers as claimed in claim 16, is characterized in that, also comprise:
Inefficacy judge module, if for the difference between current time in system and last polled time of transducer, while being greater than default failure threshold, judge described sensor failure.
18. host computers as claimed in claim 17, is characterized in that, also comprise:
Transfer to judge module, if for do not receive the described pilot signal that transducer returns in the 3rd Preset Time interval, and/or described inefficacy judge module judges described sensor failure, judges that described transducer is pulled out;
Transfer to processing module, for being transferred to signal by transfering to transducer to remove and send transducer from current monitored transducer array.
19. host computers as claimed in claim 16, is characterized in that, also comprise:
Alarm module, during higher than default alarm threshold, starts alarm thread for the numerical value of the transducer that obtains when poll module.
20. 1 kinds of transducers, is characterized in that, comprising:
Sending module, in the time that transducer accesses, sends connection request, based on described connection request, described transducer is identified to checking for host computer, and based on identification the result, determine whether described transducer access is effective, and described connection request comprises a sensor identification information.
21. transducers as claimed in claim 20, is characterized in that, described sending module also, in the time that described host computer is verified described transducer identification, sends at least one in attribute sensor information and connectivity verification information.
22. 1 kinds of transducer recognition systems, is characterized in that, comprise transducer and host computer, wherein:
Described transducer, in the time that transducer accesses, sends connection request, and described connection request comprises a sensor identification information;
Host computer, the connection request sending for receiving described transducer, and based on described connection request, described transducer is identified to checking, and based on identification the result, determine that whether described transducer access is successful.
CN201210593313.3A 2012-12-31 2012-12-31 Sensor identification method, host computer, sensor and sensor identification system Pending CN103916230A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210593313.3A CN103916230A (en) 2012-12-31 2012-12-31 Sensor identification method, host computer, sensor and sensor identification system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210593313.3A CN103916230A (en) 2012-12-31 2012-12-31 Sensor identification method, host computer, sensor and sensor identification system

Publications (1)

Publication Number Publication Date
CN103916230A true CN103916230A (en) 2014-07-09

Family

ID=51041651

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210593313.3A Pending CN103916230A (en) 2012-12-31 2012-12-31 Sensor identification method, host computer, sensor and sensor identification system

Country Status (1)

Country Link
CN (1) CN103916230A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111090265A (en) * 2019-03-28 2020-05-01 惠州市奇思创想科技有限公司 Industrial monitoring system based on big data and work flow thereof
CN112954641A (en) * 2021-02-24 2021-06-11 深圳市中电软件有限公司 Novel dual-channel wireless communication system, control method and control system
CN113378150A (en) * 2021-06-22 2021-09-10 疯壳(深圳)科技有限公司 Autonomous identification and connection method and system for serial port terminal equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007010175A1 (en) * 2005-07-22 2007-01-25 Laurence Carolan Remote activation system
CN101136131A (en) * 2006-08-30 2008-03-05 株式会社日立制作所 Sensor network system and data management method of sensor network system
CN102333388A (en) * 2011-09-16 2012-01-25 浙江双友物流器械股份有限公司 Method and system for grouping wireless sensor networks, as well as sensor and data sink node
CN102487505A (en) * 2010-12-06 2012-06-06 中国移动通信集团河南有限公司 A sensor node access authentication method, device and system
CN103457786A (en) * 2012-06-05 2013-12-18 中国移动通信集团公司 Sensor access detection method, device and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007010175A1 (en) * 2005-07-22 2007-01-25 Laurence Carolan Remote activation system
CN101136131A (en) * 2006-08-30 2008-03-05 株式会社日立制作所 Sensor network system and data management method of sensor network system
CN102487505A (en) * 2010-12-06 2012-06-06 中国移动通信集团河南有限公司 A sensor node access authentication method, device and system
CN102333388A (en) * 2011-09-16 2012-01-25 浙江双友物流器械股份有限公司 Method and system for grouping wireless sensor networks, as well as sensor and data sink node
CN103457786A (en) * 2012-06-05 2013-12-18 中国移动通信集团公司 Sensor access detection method, device and system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111090265A (en) * 2019-03-28 2020-05-01 惠州市奇思创想科技有限公司 Industrial monitoring system based on big data and work flow thereof
CN112954641A (en) * 2021-02-24 2021-06-11 深圳市中电软件有限公司 Novel dual-channel wireless communication system, control method and control system
CN113378150A (en) * 2021-06-22 2021-09-10 疯壳(深圳)科技有限公司 Autonomous identification and connection method and system for serial port terminal equipment

Similar Documents

Publication Publication Date Title
CN102625171B (en) Remote control method, system and corresponding equipment for smart television
TW201944236A (en) Task processing method, apparatus, and system
EP3404872B1 (en) Device control method, network device, and network system
CN106100939B (en) The network equipment starts time test method and test console
CN110069288B (en) USB equipment sharing method, device and system
CN108924064B (en) Switch quick start method, switch and medium
CN101980171A (en) Failure self-recovery method for software system and software watchdog system used by same
CN112559146B (en) Communication method between client and data terminal server
CN103916230A (en) Sensor identification method, host computer, sensor and sensor identification system
CN102882708A (en) Operation and maintenance auditing method, device and system
US7990886B2 (en) Network device and connection detection method thereof
CN115865743A (en) Device and method for realizing network connectivity detection of fusion type set top box
CN101951327B (en) iSCSI network system and network fault detection method
CN101136756B (en) Electric self-checking method, system and BMC chip on network long-range control host machine
JP5770815B2 (en) Wireless monitoring control method and apparatus
CN118075278B (en) Data transmission method, device, equipment and medium
CN202035000U (en) Control host for internet of things and internet of things provided with same
CN109240844B (en) Log obtaining method and system
CN208999999U (en) Data processing equipment
CN103457786A (en) Sensor access detection method, device and system
CN109542812A (en) Data communication control method, device and terminal device
CN113819587B (en) Method and device for air conditioning control, and air conditioner
CN112637370B (en) Data processing method, device, equipment and storage medium
CN109561168B (en) MAC address synchronization method
CN107733702A (en) The method and apparatus that operational state of mainframe is managed in group system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20140709