A data processing method, device, equipment, storage medium and system
By receiving subscription cancel messages in the proxy device of the industrial security monitoring system and switching the working state of the sensor, the problem of fast power consumption when the sensor is not required is solved, and the effect of extending battery life and reducing production costs is achieved.
Patent Information
- Application Number
- CN202210610499.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-05-31
AI Technical Summary
In the existing industrial safety monitoring system, the sensors are still in the working state without monitoring, resulting in rapid battery power consumption and increasing industrial production costs.
By implementing the data processing method in the proxy device, receiving a subscription cancel message, determining a target sensor, and sending it a second working state switching instruction, the sensor switches to an operating state with a longer measurement period or stops measurement.
It extends the battery life of the sensor, reduces industrial production costs, and improves the energy efficiency of the sensor.
Smart Images

Figure CN117201525B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of industrial safety monitoring, and specifically to a data processing method, device, equipment, storage medium and system. Background Art
[0002] In industrial production, safety issues guarantee the foundation of industrial production. In order to ensure the safety of production, it is usually necessary to monitor the production environment and production parameters during industrial production. When monitoring the production environment, you can monitor parameters such as temperature, concentration of harmful gases, wind speed, etc. in the environment. When monitoring the production process, you can monitor the operating status of the equipment, production parameters in each production link, etc. for detection. For example, when conducting coal mine safety monitoring, on the one hand, it is necessary to monitor the concentration, temperature, wind speed, temperature and other environmental parameters of various toxic gases underground in the coal mine. On the other hand, it is also necessary to detect production parameters such as coal level in the coal bunker, water level in the water bunker, and operating status of the coal mining machine.
[0003] At present, the existing safety monitoring systems usually include various sensors and substations. Among them, various sensors are respectively set at the locations where parameter monitoring is required to monitor the corresponding environmental parameters and production parameters. For example, the temperature in the production environment is monitored by a temperature sensor, the concentration of methane in the production environment is monitored by a methane sensor, and the wind speed in the production environment is monitored by a wind speed sensor. After monitoring the data, different sensors can transmit the monitored data to the substation, and the substation sends the monitored data to other devices for subsequent processing. In some technologies, the sensor is powered by a battery, and the sensor is always in working condition after it is turned on. When the equipment to be tested by the sensor stops running and is in an inoperative state, the sensor is still in a normal working state, consuming more power, reducing the working time of the battery and increasing the cost of industrial production. Summary of the invention
[0004] In view of this, the present application provides a data processing method, device, equipment, storage medium and system to help solve the problem of high industrial production costs in the prior art.
[0005] In a first aspect, an embodiment of the present application provides a data processing method, which is applied to a proxy device, and the method includes:
[0006] receiving a subscription cancellation message; the subscription cancellation message carries identification information of the target sensor;
[0007] Determining a target sensor according to the subscription cancellation message;
[0008] A second working state switching instruction is sent to the target sensor; the second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state in which the target sensor stops data measurement or performs data measurement in a second measurement cycle; wherein the second measurement cycle is greater than the first measurement cycle.
[0009] In a possible implementation manner of the first aspect, before sending the second working state switching instruction to the target sensor, the method further includes:
[0010] Acquire the subscription quantity of the target sensor, and reduce the subscription quantity of the target sensor by a first preset value;
[0011] When the subscription quantity of the target sensor is equal to or less than a preset threshold, acquiring the subscription state of the target sensor, and updating the subscription state of the target sensor from a subscribed state to an unsubscribed state;
[0012] The sending of the second working state switching instruction to the target sensor comprises:
[0013] When the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state, a second working state switching instruction is sent to the target sensor.
[0014] A possible implementation of the first aspect also includes:
[0015] Receiving a subscription message; the subscription message carries identification information of the target sensor;
[0016] Determining the target sensor according to the subscription message;
[0017] Obtaining the subscription status of the target sensor;
[0018] When the subscription state of the target sensor is an unsubscribed state, the subscription state of the target sensor is updated from an unsubscribed state to a subscribed state, the subscription quantity of the target sensor is increased by a second preset value, and a first working state switching instruction is sent to the target sensor; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
[0019] A possible implementation of the first aspect also includes:
[0020] When the subscription state of the target sensor is subscribed, the subscription quantity of the target sensor is increased by a second preset value.
[0021] A possible implementation of the first aspect also includes:
[0022] Obtain measurement data of target sensors;
[0023] Acquire identification information of the target sensor, and determine at least one subscription device of the target sensor according to the identification information of the target sensor;
[0024] The measurement data is sent to at least one subscribing device of the target sensor.
[0025] A possible implementation manner of the first aspect is to send a working state switching instruction to the target sensor, wherein the working state switching instruction includes a first working state switching instruction or a second working state switching instruction, including:
[0026] When there are at least two target sensors, determining a connection mode of each target sensor;
[0027] According to the connection mode of each target sensor, a working state switching instruction is sent to the target sensor respectively.
[0028] In a possible implementation of the first aspect, sending a working state switching instruction to each target sensor according to a connection mode of the target sensor includes:
[0029] When the target sensor is connected to the proxy device via a field bus, a working state switching instruction is sent to the target sensor via the field bus; or,
[0030] When the target sensor is connected to the proxy device via a network, a working state switching instruction is sent to the target sensor via the network connection.
[0031] In a possible implementation manner of the first aspect, obtaining measurement data of the target sensor includes:
[0032] When the target sensor is connected to the proxy device via a field bus, the proxy device queries the target sensor via the field bus to obtain measurement data of the target sensor; or
[0033] When the target sensor is connected to the proxy device via a network, the measurement data sent by the target sensor is received via the network connection.
[0034] In a possible implementation manner of the first aspect, the network connection includes: an Ethernet connection or a wireless network connection.
[0035] In a second aspect, an embodiment of the present application provides a data processing method, which is applied to a sensor, and the method includes:
[0036] receiving a second working state switching instruction; the second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle; wherein the second measurement cycle is greater than the first measurement cycle;
[0037] According to the second working state switching instruction, the current working state is switched to the second working state, and when the second working state is a working state for performing data measurement in a second measurement cycle, data measurement is performed according to the second measurement cycle.
[0038] A possible implementation of the second aspect also includes:
[0039] Receiving a first working state switching instruction; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state;
[0040] According to the first working state switching instruction, the current working state is switched to the first working state, and when the first working state is a working state for performing data measurement in a first measurement cycle, data measurement is performed according to the first measurement cycle.
[0041] A possible implementation of the second aspect also includes:
[0042] Sends measurement data to the proxy device.
[0043] In a third aspect, an embodiment of the present application provides a proxy device, including:
[0044] The subscription publishing service module is used to receive a subscription cancellation message and send the subscription cancellation message to the subscription management module; the subscription cancellation message carries the identification information of the target sensor;
[0045] A subscription management module, used to determine a target sensor according to the subscription cancellation message;
[0046] A second working state switching instruction is sent to the target sensor; the second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle; wherein the second measurement cycle is greater than the first measurement cycle.
[0047] In a possible implementation manner of the third aspect, the subscription management module is used to obtain the subscription quantity of the target sensor and reduce the subscription quantity of the target sensor by a first preset value;
[0048] When the subscription quantity of the target sensor is equal to or less than a preset threshold, acquiring the subscription state of the target sensor, and updating the subscription state of the target sensor from a subscribed state to an unsubscribed state;
[0049] The subscription management module is used to send a second working state switching instruction to the target sensor when the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state.
[0050] In a possible implementation manner of the third aspect, the subscription publishing service module is used to receive a subscription message and send the subscription message to a subscription management module; the subscription message carries identification information of the target sensor;
[0051] The subscription management module is used to determine the target sensor according to the subscription message;
[0052] Obtaining the subscription status of the target sensor;
[0053] When the subscription state of the target sensor is an unsubscribed state, the subscription state of the target sensor is updated from an unsubscribed state to a subscribed state, the subscription quantity of the target sensor is increased by a second preset value, and a first working state switching instruction is sent to the target sensor; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
[0054] In a possible implementation manner of the third aspect, the subscription management module is configured to increase the subscription quantity of the target sensor by a second preset value when the subscription status of the target sensor is subscribed.
[0055] A possible implementation of the third aspect also includes:
[0056] The subscription and publishing client module is used to obtain the measurement data of the target sensor and send the measurement data sent by the target sensor to the subscription and publishing service module;
[0057] The subscription and publishing service module is used to obtain the identification information of the target sensor and determine at least one subscription device of the target sensor according to the identification information of the target sensor;
[0058] The measurement data is sent to at least one subscribing device of the target sensor.
[0059] In a possible implementation manner of the third aspect, the subscription management module is configured to determine a connection mode of each target sensor when there are at least two target sensors;
[0060] According to the connection mode of each target sensor, a working state switching instruction is sent to the target sensor respectively; the working state switching instruction includes: a first working state switching instruction or a second working state switching instruction.
[0061] In a possible implementation of the third aspect, the subscription management module is configured to send a working state switching instruction to the target sensor through the field bus when the target sensor is connected to the proxy device through the field bus; or
[0062] When the target sensor is connected to the proxy device via a network, a working state switching instruction is sent to the target sensor via the network connection.
[0063] In a possible implementation of the third aspect, the subscription and publishing client module is used to query the target sensor through the field bus to obtain the measurement data of the target sensor when the target sensor is connected to the proxy device through the field bus; or
[0064] When the target sensor is connected to the proxy device via a network, the measurement data sent by the target sensor is received via the network connection.
[0065] In a possible implementation of the third aspect, the subscription and publishing client module is used to query the target sensor through the field bus to obtain the measurement data of the target sensor when the target sensor is connected to the proxy device through the field bus; or
[0066] When the target sensor is connected to the proxy device via a network, the measurement data sent by the target sensor is received via the network connection.
[0067] In a possible implementation manner of the third aspect, the network connection includes: an Ethernet connection or a wireless network connection.
[0068] In a fourth aspect, an embodiment of the present application provides a sensor, including:
[0069] A receiving module, configured to receive a second working state switching instruction; the second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle; wherein the second measurement cycle is greater than the first measurement cycle;
[0070] The processing module is used to switch the current working state to the second working state according to the second working state switching instruction, and when the second working state is a working state for performing data measurement in a second measurement cycle, perform data measurement according to the second measurement cycle.
[0071] In a possible implementation manner of the fourth aspect, the receiving module is used to receive a first working state switching instruction; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state;
[0072] The processing module is used to switch the current working state to the first working state according to the first working state switching instruction, and perform data measurement according to the first measurement cycle when the first working state is a working state for performing data measurement in a first measurement cycle.
[0073] A possible implementation of the fourth aspect also includes:
[0074] The sending module is used to send the measurement data to the proxy device.
[0075] In a fifth aspect, an embodiment of the present application provides a data processing system, including: an agent device, at least one sensor and at least one subscription device;
[0076] wherein the proxy device is connected to at least one sensor and at least one subscription device;
[0077] At least one subscription device, used to send a subscription cancellation message to the proxy device; the subscription cancellation message carries identification information of the target sensor;
[0078] The proxy device includes the proxy device described in any one of the third aspects above; the at least one sensor includes the sensor described in any one of the fourth aspects above.
[0079] In a sixth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed, the electronic device executes the method described in any one of the first aspect above, or executes the method described in any one of the second aspect above.
[0080] In the seventh aspect, an embodiment of the present application provides a storage medium, which includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the method described in any one of the first aspect above, or execute the method described in any one of the second aspect above.
[0081] Adopt the scheme provided by the embodiment of the present application, receive a subscription cancellation message; the subscription cancellation message carries the identification information of the target sensor; determine the target sensor according to the subscription cancellation message; send a second working state switching instruction to the target sensor. In this way, when the subscription device suspends obtaining the measurement data of the target sensor, a subscription cancellation message is sent to the first device. After the first device receives the subscription cancellation message, it can determine the target sensor according to the subscription cancellation message, and send a second working state switching instruction to the target sensor, so that the target sensor switches from the first working state to the second working state. The data measurement frequency of the target sensor in the second working state is lower than the data measurement frequency of the target sensor in the first working state. That is, when the subscription cancellation message is received, the target sensor can be controlled to switch to the second working state with a longer measurement cycle, so that when the target sensor is not needed for monitoring, the monitoring cycle of the target sensor can be extended, or data measurement can be stopped, thereby reducing the power consumption of the target sensor when data monitoring is not required, extending the battery life of the target sensor, and reducing industrial production costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0083] Figure 1 A schematic diagram of a scenario in which a sensor and a substation are connected according to an embodiment of the present application;
[0084] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application;
[0085] Figure 3 A flowchart of another data processing method provided in an embodiment of the present application;
[0086] Figure 4 A flowchart of another data processing method provided in an embodiment of the present application;
[0087] Figure 5a A schematic diagram of a scenario of a data processing method provided in an embodiment of the present application;
[0088] Figure 5b A schematic diagram of another data processing method provided in an embodiment of the present application;
[0089] Figure 6 A flowchart of another data processing method provided in an embodiment of the present application;
[0090] Figure 7 A schematic diagram of another data processing method provided in an embodiment of the present application;
[0091] Figure 8 A flowchart of another data processing method provided in an embodiment of the present application;
[0092] Fig. 9 A schematic diagram of the structure of a proxy device provided in an embodiment of the present application;
[0093] Fig.10 A schematic diagram of the structure of another proxy device provided in an embodiment of the present application;
[0094] Fig.11 A schematic diagram of the structure of a sensor provided in an embodiment of the present application;
[0095] Fig.12 A schematic diagram of the structure of another sensor provided in an embodiment of the present application;
[0096] Fig.13 A schematic diagram of the structure of a data processing system provided in an embodiment of the present application;
[0097] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0098] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0099] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0100] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0101] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0102] Before a detailed introduction to the embodiments of the present application, the terms that are applied or may be applied to the embodiments of the present application are first explained.
[0103] A sensor (English name: transducer / sensor) is a detection device that can sense the information being measured and convert the sensed information into electrical signals or other required forms of information output according to certain rules to meet the requirements of information transmission, processing, storage, display, recording and control.
[0104] At present, the existing security monitoring system usually includes various sensors, substations and data service equipment, such as Figure 1 As shown. Among them, various sensors are respectively set at the positions where parameters need to be monitored to monitor the corresponding environmental parameters and production parameters. For example, the temperature in the production environment is monitored by a temperature sensor, the concentration of methane in the production environment is monitored by a methane sensor, and the wind speed in the production environment is monitored by a wind speed sensor. After monitoring the data, different sensors can transmit the monitored data to the substation, and the substation sends the monitored data to the data service equipment for subsequent processing. In some technologies, the sensor is powered by a battery, and the sensor is always in working condition after it is turned on. When the measurement data of the sensor is not subscribed, the sensor is still in normal working condition, consuming more power, reducing the working time of the battery and increasing the industrial production cost.
[0105] In addition, the data transmission methods between different sensors and substations are not exactly the same. Figure 1 As shown, some sensors and substations are connected via fieldbus to achieve data transmission, for example, temperature sensors and substations are connected via fieldbus. Some sensors and substations are connected via Ethernet or wireless network to achieve data transmission, such as the methane sensor and substation are connected via Ethernet, and the wind speed sensor and substation are connected via wireless network. In some technologies, a substation with a corresponding connection method is set for each sensor with each connection method, so that the sensor can transmit data to the substation through the connection method it supports. In this way, a large number of substations need to be set up, further increasing the cost of industrial production.
[0106] In view of the above problems, the embodiment of the present application provides a data processing method, device, equipment, storage medium and system, receiving a subscription cancellation message; the subscription cancellation message carries the identification information of the target sensor; according to the subscription cancellation message, the target sensor is determined; and a second working state switching instruction is sent to the target sensor. In this way, when the subscription device suspends obtaining the measurement data of the target sensor, a subscription cancellation message is sent to the first device. After the first device receives the subscription cancellation message, the target sensor can be determined according to the subscription cancellation message, and a second working state switching instruction is sent to the target sensor, so that the target sensor switches from the first working state to the second working state. The data measurement frequency of the target sensor in the second working state is lower than the data measurement frequency of the target sensor in the first working state. That is, when the subscription cancellation message is received, the target sensor can be controlled to switch to the second working state with a longer measurement cycle, so that when the target sensor is not required to monitor, the monitoring cycle of the target sensor can be extended, or data measurement can be stopped, the power consumption of the target sensor when data monitoring is not required can be reduced, the battery life of the target sensor can be extended, and the industrial production cost can be reduced. The following is a detailed description.
[0107] See also Figure 2 , is a flow chart of a data processing method provided in an embodiment of the present application. The method is applied to a proxy device, such as Figure 2 As shown, the method includes:
[0108] Step S201: Receive a subscription cancellation message.
[0109] The subscription cancellation message carries the identification information of the target sensor.
[0110] In an embodiment of the present application, in the industrial production process, in order to improve the safety of industrial production, it is necessary to periodically measure the parameters of the operating status of the surrounding environment or important equipment in the production process through sensors. Due to the simple structure of the sensor, its function is single, its computing power is poor, and it generally does not have a storage function. Therefore, it is necessary to transfer the measurement data of the periodic measurement to other devices for processing. In an embodiment of the present application, the proxy device establishes a connection with different sensors, so that the sensor can transmit its periodic measurement data to the proxy device. Other data service devices can subscribe to the measurement data of the sensor required by the proxy device, and at this time, the other data service device can be called a subscription device. When the proxy device obtains the measurement data of the periodic measurement of different sensors, it can send the measurement data of the corresponding sensor periodic measurement to each subscription device according to the measurement data of the required sensor subscribed by each subscription device. If it is necessary to stop the operation of certain equipment or no longer pay attention to certain parameters in the environment due to production needs, the relevant subscription device can stop obtaining the measurement data measured by the relevant sensor, and at this time the subscription device can send a subscription cancellation message to the proxy device. The subscription cancellation message carries the identification information of the target sensor. The target sensor is a sensor whose measurement data is no longer obtained by the subscription device. The proxy device may receive a subscription cancellation message sent by the subscribing device.
[0111] The identification information of the target sensor is information used to identify the target sensor, such as the identity document (ID) of the target sensor, or the name of the target sensor, or other information that has a mapping relationship with the sensor, for example, when there is a mapping relationship between the subscription topic information and the sensor, the identification information of the target sensor can also be the subscription topic information, etc. The mapping relationship between other information and the sensor can be pre-set, and this application does not limit the identification information of the target sensor.
[0112] For example, in the coal mine production process, a temperature sensor, a methane sensor and a wind speed sensor are provided. Subscriber device 1 needs to obtain the ambient temperature in the coal mine production process in order to monitor whether the temperature is too high or too low in the coal mine production process. Subscriber device 2 needs to obtain the methane concentration in the coal mine production process in order to monitor whether the methane content in the air in the coal mine production process exceeds the standard. Subscriber device 3 needs to obtain the wind speed in the coal mine production process in order to monitor whether the wind speed is too large or too small in the coal mine production process. Based on this, subscriber device 1 can subscribe to the measurement data of the temperature sensor from the proxy device. Subscriber device 2 can subscribe to the measurement data of the methane sensor from the proxy device. Subscriber device 3 can subscribe to the measurement data of the wind speed sensor from the proxy device. In this way, after the temperature sensor periodically measures the temperature of the environment in the coal mine production process, it can transmit the measurement data measured by it to the proxy device, and the proxy device can send the measurement data transmitted by the temperature sensor to the subscriber device 1. Similarly, after the methane sensor periodically measures the methane concentration in the air during the coal mine production process, it can transmit the measured data to the proxy device, and the proxy device can send the measured data transmitted by the temperature sensor to the subscription device 2. After the wind speed sensor periodically measures the wind speed of the environment during the coal mine production process, it can transmit the measured data to the proxy device, and the proxy device can send the measured data transmitted by the temperature sensor to the subscription device 3. If due to improvements in the production environment or other reasons, it is assumed that the subscription device 3 no longer needs to monitor the wind speed in the environment. At this time, the subscription device 3 can send a subscription cancellation message to the proxy device, and the subscription cancellation message carries the identification information of the wind speed sensor. The proxy device receives the subscription cancellation message sent by the subscription device 3.
[0113] Step S202: Determine the target sensor according to the subscription cancellation message.
[0114] In an embodiment of the present application, after obtaining the subscription cancellation message, the proxy device can parse the subscription cancellation message to obtain the identification information of the target sensor carried therein, thereby determining the target sensor corresponding to the subscribing device according to the identification information of the target sensor.
[0115] Step S203: Send a second working state switching instruction to the target sensor.
[0116] The second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state. The first working state is a working state in which the target sensor performs data measurement in a first measurement cycle. The second working state is a working state in which the target sensor stops data measurement or performs data measurement in a second measurement cycle. The second measurement cycle is greater than the first measurement cycle.
[0117] In an embodiment of the present application, after the proxy device receives the subscription cancellation message sent by the subscription device and determines the target sensor, since the subscription device cancels the subscription to the target sensor, it means that the measurement data measured by the target sensor does not need to be transmitted to other devices. At this time, the cycle of the measurement data of the target sensor can be extended or the target sensor can be controlled to stop measuring data. A first working state and a second working state are pre-set in the target sensor. Among them, the first working state is a working state in which data is measured in a first measurement cycle. When the target sensor is normally measuring data, it usually works in the first working state. The second working state is a working state in which the target sensor stops measuring data or measures data in a second measurement cycle. When the subscription device stops subscribing to the measurement data measured by the target sensor, the target sensor can switch to the second working state to stop data measurement or extend the cycle of data measurement to reduce battery loss and extend the working time of the battery in the target sensor. Based on this, the proxy device can send a second working state switching instruction to the target sensor so that the target sensor can switch from the first working state to the second working state after receiving the second working state switching instruction.
[0118] It should be noted that in an embodiment of the present application, a first working state and a second working state can be pre-set in the sensor. And, when setting the second working state, it can be set according to whether the sensor needs to work for a long time. If the sensor needs to work for a long time, the second working state of this type of sensor can be set to a working state in which data is measured in a second measurement cycle. That is, even if there is no subscription device for data subscription, this type of sensor must monitor parameters for a long time to ensure the safety of industrial production. For example, a methane concentration sensor, when there is no subscription device that needs to obtain the methane concentration, in order to improve the life safety of workers in industrial production, the methane concentration in the production environment must also be monitored. The methane sensor is a type that needs to work for a long time. At this time, the second working state of the methane sensor can be set to a working state in which data is measured in a second measurement cycle.
[0119] If the sensor does not need to work for a long time, the second working state of this type of sensor can be set to a working state that stops data measurement. That is, when there is no subscribing device to subscribe to data, this type of sensor does not need to monitor parameters. For example, the target sensor is a sensor that detects the operating status of the device. In some embodiments, when the device stops running, the relevant subscribing device stops obtaining data on the operating status of the device. Since the device has stopped running, the target sensor does not need to continue to monitor the relevant parameters of its working status. Therefore, its second working state can be set to a working state that stops data measurement.
[0120] It should be understood that whether the target sensor is of a type that requires long-term operation can be set by relevant personnel according to actual needs, and based on whether it is of a type that requires long-term operation, its second working state can be set.
[0121] It should be noted that the first measurement period and the second measurement period can be set by technical personnel in this field based on actual experience, or obtained based on the results of big data analysis, and the embodiments of the present application are not limited to this.
[0122] In some embodiments, the proxy device may support multiple connection modes to connect to the sensor. For sensors that need to be connected via a field bus, the proxy device may be connected to such sensors via the field bus. For sensors that need to be connected via a network, the proxy device may be connected to such sensors via a network connection. The network connection includes an Ethernet connection or a wireless network connection. The proxy device sending a second working state switching instruction to the target sensor includes: determining the connection mode of the target sensor; and sending a second working state switching instruction to the target sensor according to the connection mode of the target sensor.
[0123] That is to say, the target sensor and the proxy device may be connected by a field bus or a network connection. Before sending the second working state switching instruction to the target sensor, the proxy device determines the connection mode of the target sensor, and sends the second working state switching instruction to the target sensor according to the connection mode of the target sensor. For example, when the target sensor and the proxy device are connected by a network, assuming that it is an Ethernet network connection, the second working state switching instruction can be sent to the target sensor through the Ethernet network connection. When the target sensor and the proxy device are connected by a field bus, the proxy device can send the second working state switching instruction of the target sensor through the field bus. At this time, all devices connected to the field bus can receive the second working state switching instruction. After receiving the second working state switching instruction, other devices except the target sensor detect that the instruction is not sent to themselves and do not respond to the instruction. After receiving the second working state switching instruction, the target sensor can perform the corresponding working state switching.
[0124] In some embodiments, the proxy device may receive at least two subscription cancellation messages, and the identification information of the target sensors carried in the at least two subscription cancellation messages may be the same or different. At this time, the proxy device can determine at least two target sensors based on the received subscription cancellation messages, and the proxy device needs to send a second working state switching instruction to the at least two target sensors. Based on this, the proxy device sends the second working state switching instruction to the target sensor, including: when there are at least two target sensors, determining the connection mode of each target sensor; and sending the second working state switching instruction to the target sensor according to the connection mode of each target sensor.
[0125] That is, when the proxy device determines that there are at least two target sensors, the proxy device may determine a connection mode with each target sensor, and send a second working state switching instruction to each target sensor according to the connection mode with each target sensor.
[0126] In this way, when the subscription device suspends obtaining the measurement data of the target sensor, a subscription cancellation message is sent to the proxy device. After receiving the subscription cancellation message, the proxy device can determine the target sensor according to the subscription cancellation message, and send a second working state switching instruction to the target sensor, so that the target sensor switches from the first working state to the second working state. The data measurement frequency of the target sensor in the second working state is lower than the data measurement frequency of the target sensor in the first working state. That is, when the subscription cancellation message is received, the target sensor can be controlled to switch to the second working state with a longer measurement cycle, so that when the target sensor is not needed for monitoring, the monitoring cycle of the target sensor can be extended, or data measurement can be stopped, thereby reducing the power consumption of the target sensor when data monitoring is not required, extending the battery life of the target sensor, and reducing industrial production costs.
[0127] See also Figure 3 , is a flow chart of a data processing method provided in an embodiment of the present application. The method is applied to sensors, such as Figure 3 As shown, the method includes:
[0128] Step S301: receiving a second working state switching instruction.
[0129] The second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state. The first working state is a working state in which the target sensor performs data measurement in a first measurement cycle. The second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle. The second measurement cycle is greater than the first measurement cycle.
[0130] In the embodiment of the present application, the target sensor can transmit measurement data through the connection with the proxy device. And can receive the instruction sent by the proxy device to the target sensor through the connection between it and the proxy device. When the proxy device sends the second working state switching instruction to the target sensor through the connection between it and the target sensor, the target sensor can receive the second working state switching instruction sent by the proxy device.
[0131] Step S302: according to the second working state switching instruction, switch the current working state to the second working state, and when the second working state is a working state for performing data measurement in a second measurement cycle, perform data measurement in accordance with the second measurement cycle.
[0132] In an embodiment of the present application, after the target sensor receives the second working state switching instruction, when its current working state is the first working state, the current working state can be switched from the first working state to the second working state. That is, after the target sensor receives the second working state, it is learned that the measurement cycle needs to be extended. At this time, if the target sensor performs data measurement in the first measurement cycle, the current working state can be switched to the second working state when the second working state switching instruction is received. For example, when the second working state is a working state for stopping data measurement, the target sensor stops data measurement when receiving the second working state switching instruction. When the second working state is for performing data measurement in the second measurement cycle, the target sensor switches the measurement cycle from the first measurement cycle to the second measurement cycle when receiving the second working state switching instruction, and performs data measurement with the second measurement cycle as a cycle. Since the second measurement cycle is greater than the first measurement cycle, when the target sensor switches the current working state to the second working state, the measurement cycle of data measurement is extended, and the frequency of data measurement is reduced, thereby reducing the power consumption of the target sensor and increasing production costs.
[0133] It should be noted that when the target sensor measures data in the second measurement period, the measurement data measured by the target sensor may no longer be transmitted to the proxy device because no subscribing device obtains the measurement data measured by the target sensor, or the measurement data measured in the second measurement period may continue to be transmitted to the proxy device. At this time, after the proxy device receives the measurement data transmitted by the target sensor, since no subscribing device needs to obtain the measurement data measured by the target sensor, the proxy device may store the received measurement data in the storage device or delete the received measurement data, and the proxy device no longer sends the measurement data transmitted by the target sensor to the subscribing device.
[0134] See also Figure 4, is a flow chart of another data processing method provided by an embodiment of the present application. This embodiment is described for the scenario where a subscribing device subscribes to a sensor from a proxy device. Figure 4 As shown, the method includes:
[0135] Step S401: The subscription device sends a subscription message to the proxy device, and the proxy device receives the subscription message.
[0136] The subscription message carries the identification information of the target sensor.
[0137] In an embodiment of the present application, when a subscribing device needs to obtain measurement data measured by a sensor, it can inform the proxy device of the measurement data of the sensor that it needs to obtain. At this time, the subscribing device sends a subscription message to the proxy device, and the subscription message includes identification information of the target sensor, wherein the measurement data measured by the target sensor is the measurement data that the subscribing device needs to obtain.
[0138] For example, if the subscription device 1 needs to obtain the measurement data measured by sensor 1 and sensor 2, and the subscription device 2 needs to obtain the measurement data measured by sensor 3, the subscription device 1 sends a subscription message to the proxy device, and the subscription message sent by the subscription device 1 carries the identification information of sensor 1 and the identification information of sensor 2. The subscription device 2 sends a subscription message to the proxy device, and the subscription message sent by the subscription device carries the identification information of sensor 3. The proxy device can receive the subscription message sent by the subscription device 1 and the subscription message sent by the subscription device 2.
[0139] Step S402: The proxy device determines the target sensor according to the subscription message.
[0140] In an embodiment of the present application, after receiving a subscription message, the proxy device may parse the subscription message to obtain identification information of the target sensor carried therein, and determine the target sensor corresponding to the subscribing device based on the obtained identification information of the target sensor.
[0141] As a possible implementation method, the proxy device can record the correspondence between the subscribing device and the target sensor. In this way, the proxy device can know which target sensor's measurement data the subscribing device needs to obtain based on the recorded correspondence. When the measurement data transmitted by the target sensor is obtained, the subscribing device corresponding to the target sensor can be determined by recording information, and the measurement data can be sent to the subscribing device. For example, the proxy device can be set with a subscription list of the sensor for each sensor. The subscription list records the identification information of the subscribing device that has subscribed to the sensor. In this way, after receiving the subscription message sent by the subscribing device and parsing the identification information of the target sensor, the subscription list of the target sensor can be found based on the identification information of the target sensor, and the identification information of the subscribing device can be added to the subscription list of the target sensor. Of course, the proxy device can also record the correspondence between the sensor and the subscribing device in other ways, and this application does not limit this.
[0142] As in the above example, after receiving the subscription message sent by the subscription device 1, the proxy device can parse the subscription message sent by the subscription device 1 and obtain the identification information of sensor 1 and sensor 2 carried therein. The proxy device can determine sensor 1 and sensor 2 as the target sensors corresponding to the subscription device 1 based on the identification information of sensor 1 and the identification information of sensor 2. The proxy device can determine sensor 3 as the target sensor corresponding to the subscription device 2 based on the identification information of sensor 3.
[0143] Step S403: The proxy device obtains the subscription status of the target sensor.
[0144] In an embodiment of the present application, after receiving the subscription message sent by the subscription device, the proxy device can determine the target sensor through the identification information of the target sensor carried in the subscription message, so as to know that the subscription device needs to subscribe to the measurement data measured by the target sensor, that is, to know that the subscription device needs to obtain the measurement data measured by the target sensor. Since the data of a sensor can be subscribed and obtained by multiple subscription devices; when the sensor is not subscribed by any subscription device, the proxy device records the subscription state of the sensor as the unsubscribed state, and needs to control the sensor to work in the second working state, so that the sensor stops measuring data or reduces the frequency of measuring data. When the sensor is subscribed by at least one subscription device, the proxy device records the subscription state of the sensor as the subscribed state, and the proxy device controls the sensor to work in the first working state, so that the sensor can measure data normally. Therefore, when the proxy device receives the subscription message and determines the target sensor, it needs to detect the current subscription state of the target sensor, so as to control the target sensor to switch the working state when the current subscription state is the unsubscribed state. Based on this, when the proxy device determines the target sensor, the recorded current subscription state of the target sensor can be checked to know whether the target sensor is in the unsubscribed state.
[0145] It should be noted that the subscription status is the status information recorded by the proxy device whether the sensor is subscribed by the subscription device, and is recorded by the proxy device according to whether each sensor is subscribed by the subscription device to obtain measurement data. For example, when the sensor is not subscribed by any subscription device to obtain measurement data, the subscription status of the sensor is recorded as the unsubscribed status. When the sensor is subscribed by at least one subscription device to obtain measurement data, the subscription status of the sensor is recorded as the subscribed status.
[0146] As a possible implementation, the proxy device may determine one or more target sensors based on the subscription message. For example, the subscription message received by the proxy device may carry identification information of at least one target sensor. The proxy device may determine at least one target sensor based on the subscription message. Alternatively, the proxy device receives a subscription message sent by at least one subscribing device. The proxy device may determine at least one target sensor based on the received at least one subscription message. The proxy device needs to obtain the subscription status of each target sensor in the at least one target sensor.
[0147] For example, subscribing device 1 needs to obtain measurement data measured by sensor 1, and subscribing device 2 needs to obtain measurement data measured by sensor 2. Figure 5a and Figure 5bAs shown, the subscription device 1 and the subscription device 2 send subscription messages to the proxy device. Among them, the subscription message sent by the subscription device 1 to the proxy device carries the identification information of sensor 1. The subscription message sent by the subscription device 2 to the proxy device carries the identification information of sensor 2. After the proxy device receives the subscription message sent by the subscription device 1, it can obtain the identification information of sensor 1 by parsing the subscription message, and then determine that the subscription device 1 needs to obtain the measurement data measured by sensor 1. The proxy device can determine that the target sensor is sensor 1 based on the identification information of sensor 1. The proxy device can obtain the recorded subscription status of sensor 1. Similarly, after the proxy device receives the subscription message sent by the subscription device 2, it can obtain the identification information of sensor 2 by parsing the subscription message, and then determine that the subscription device 2 needs to obtain the measurement data measured by sensor 2. The proxy device determines that the target sensor is sensor 2 based on the identification information of sensor 2, and can obtain the recorded subscription status of sensor 2.
[0148] It should be understood that since the subscription state includes two states, the subscribed state and the unsubscribed state, the proxy device performs different steps according to the different subscription states of the acquired target sensor. When the proxy device determines that the subscription state of the target sensor is the unsubscribed state, the following steps S404a-S405a and steps S406-S408 are performed. When the proxy device determines that the subscription state of the target sensor is the subscribed state, the following steps S404b and steps S406-S408 are performed.
[0149] Step S404a: When the proxy device detects that the subscription state of the target sensor is unsubscribed, it updates the subscription state of the target sensor from unsubscribed to subscribed, increases the subscription quantity of the target sensor by a second preset value, and sends a first working state switching instruction to the target sensor. The target sensor receives the first working state switching instruction.
[0150] The first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
[0151] In an embodiment of the present application, when the proxy device obtains the subscription status of the target sensor, it can detect the subscription status of the target sensor. When it is detected that the subscription status of the target sensor is unsubscribed, it means that the target sensor has not been subscribed by other subscribing devices to obtain measurement data, and its working state is the second working state. Since the subscribing device needs to obtain the measurement data measured by the target sensor, the proxy device can update the subscription status of the target sensor from the unsubscribed state to the subscribed state, and increase the subscription number of the target sensor by the second preset value, so as to record how many subscribing devices have subscribed to obtain the measurement data measured by the target sensor. The proxy device can send a first working state switching instruction to the target sensor, so that the working state of the target sensor is switched from the second working state to the first working state, so that the target sensor is in a normal data measurement cycle and performs corresponding data measurement. At this time, the target sensor can receive the first working state switching instruction sent by the proxy device.
[0152] It should be noted that the second preset value is a preset change amount for each change in the number of subscriptions. The second preset value can be set by a person skilled in the art based on actual experience, or obtained based on the results of big data analysis, and the embodiment of the present application does not limit this. As a possible implementation, the second preset value is 1.
[0153] As a possible implementation manner, when the proxy device sends the first working state switching instruction to the target sensor, the proxy device sends the working state switching instruction to the target sensor according to the connection mode between the proxy device and the target sensor.
[0154] That is, the connection method between the proxy device and the target sensor can be a field bus connection, a network connection, or other connection methods. When the proxy device sends the first working state switching instruction to the target sensor, it can send the first working state switching instruction according to the connection method between the proxy device and the target sensor. For example, when the proxy device and the target sensor are connected through a field bus, the proxy device sends the first working state switching instruction of the target sensor to the field bus, and the target sensor can receive the first working state switching instruction through the field bus. When the proxy device is connected through a network between target sensors, such as an Ethernet connection or a wireless network connection, the proxy device can send the first working state switching instruction to the target sensor through an Ethernet connection or a wireless network connection.
[0155] It should be noted that when the proxy device is connected to the target sensor through a field bus, when the proxy device sends the first working state switching instruction of the target sensor through the field bus, other devices connected to the field bus can also receive the instruction. Since the first working state switching instruction is sent to the target sensor, other devices do not perform corresponding processing when they receive the first working state switching instruction.
[0156] As a possible implementation manner, after determining at least one target sensor, the proxy device needs to obtain the subscription status of the at least one target sensor, and then send a first working state switching instruction to the at least one target sensor when the subscription status of the at least one target sensor is unsubscribed.
[0157] As a possible implementation method, when there are at least two target sensors, the proxy device sends a first working state switching instruction to the target sensor, including: when there are at least two target sensors, determining a connection mode of each target sensor; and sending a first working state switching instruction to each target sensor according to the connection mode of each target sensor.
[0158] That is, when there are at least two target sensors, the connection mode between each target sensor and the proxy device may be different. At this time, the proxy device may send a first working state switching instruction to each target sensor according to the connection mode of each target sensor.
[0159] As shown in the example above, reference Figure 5a As shown, after the proxy device obtains the subscription status of sensor 1, assuming that the proxy device detects that the subscription status of sensor 1 is unsubscribed, and sensor 1 and the proxy device are connected via a field bus, the proxy device can send a first working state switching instruction to sensor 1 via the field bus. Sensor 1 receives the first working state switching instruction via the field bus. Similarly, after the proxy device obtains the subscription status of sensor 2, assuming that the proxy device detects that the subscription status of sensor 2 is unsubscribed, and sensor 2 and the proxy device are connected via an Ethernet network, the proxy device can send a first working state switching instruction to sensor 2 via the Ethernet network. Sensor 2 receives the first working state switching instruction via the Ethernet network.
[0160] Step S404b: When the subscription status of the target sensor is subscribed, the proxy device increases the subscription quantity of the target sensor by a second preset value.
[0161] In the embodiment of the present application, when the proxy device obtains the subscription status of the target sensor, it can detect the subscription status of the target sensor. When it is detected that the subscription status of the target sensor is the subscribed status, it means that the target sensor has been subscribed by other subscribing devices to obtain measurement data, and its working status is the first working status. At this time, the proxy device does not need to send the first working status switching instruction to the target sensor, but only needs to increase the subscription quantity of the target sensor by the second preset value.
[0162] As shown in the example above, reference Figure 5bAs shown, after the proxy device obtains the subscription status of sensor 1, assuming that the proxy device detects that the subscription status of sensor 1 is unsubscribed, and sensor 1 and the proxy device are connected via a field bus, the proxy device can send a first working state switching instruction to sensor 1 via the field bus. Sensor 1 receives the first working state switching instruction via the field bus. After the proxy device obtains the subscription status of sensor 2, assuming that the proxy device detects that the subscription status of sensor 2 is subscribed, and sensor 2 and the proxy device are connected via an Ethernet network, the proxy device does not need to send the first working state switching instruction to sensor 2. Assuming that the second preset value is 1, the proxy device increases the subscription quantity of sensor 2 by 1.
[0163] Step S405a: The target sensor switches the current working state to the first working state according to the first working state switching instruction, and performs data measurement according to the first measurement cycle when the first working state is a working state for performing data measurement in the first measurement cycle.
[0164] In the embodiment of the present application, after the target sensor receives the first working state switching instruction, when it is working in the second working state, that is, when the target sensor stops measuring data or measures data in the second measurement cycle, after the target sensor receives the first working state switching instruction, it is known that the working state needs to be switched from the second working state to the first working state. At this time, the target sensor can switch its working state to the first working state. That is, the target sensor adjusts its working state to a working state that measures data in the first measurement cycle, and measures data according to the first measurement cycle.
[0165] For example, after receiving the first working state switching instruction sent by the proxy device, sensor 1 switches its working state from the second working state to the first working state. Assuming that the second working state of sensor 1 is to stop data measurement, after receiving the first working state switching instruction, sensor 1 switches from stopping data measurement to the working state of measuring data with the first measurement cycle as a period, and periodically performs data measurement according to the first measurement cycle.
[0166] Step S406: The proxy device obtains measurement data of the target sensor.
[0167] In an embodiment of the present application, after the target sensor periodically performs data measurement in a first measurement period, the target sensor may transmit the measured data to the proxy device, so that the proxy device transmits the measured data to the corresponding subscribing device. For example, the target sensor may send the measured data directly to the proxy device, and the proxy device may obtain the measured data of the target sensor from the target sensor.
[0168] As a possible implementation manner, when the target sensor sends the measurement data to the proxy device, the identification information of the target sensor may be added to the measurement data and sent to the proxy device.
[0169] As a possible implementation method, the proxy device obtains measurement data in different ways according to the different connection methods between the proxy device and the target sensor. Specifically, the proxy device obtains the measurement data sent by the target sensor in the following ways:
[0170] When the target sensor and the proxy device are connected via a fieldbus, the proxy device queries the target sensor via the fieldbus to obtain the measurement data sent by the target sensor. Alternatively, when the target sensor and the proxy device are connected via a network, the proxy device receives the measurement data sent by the target sensor via the network connection.
[0171] That is, the target sensor and the proxy device are connected via a field bus or a network, so when the target sensor sends measurement data to the proxy device, if the target sensor and the proxy device are connected via a field bus, the proxy device queries the measurement data of the target sensor via the field bus to obtain the measurement data of the target sensor. At this time, the proxy device can determine the identification information of the target sensor while querying the measurement data of the target sensor.
[0172] When the target sensor and the proxy device are connected via a network, the target sensor sends measurement data to the proxy device via the network connection, and the proxy device receives the measurement data sent by the target sensor via the network connection.
[0173] As described in the above example, the proxy device needs to query the measurement data of sensor 1 through the fieldbus. At this time, sensor 1 can transmit its measured data to the proxy device through the fieldbus. Sensor 2 can transmit its acquired measurement data to the proxy device through the Ethernet connection. The proxy device can receive the measurement data sent by sensor 1 through the fieldbus between it and sensor 1, and receive the measurement data sent by sensor 2 through the Ethernet connection between it and sensor 2.
[0174] Step S407: The proxy device obtains identification information of the target sensor, and determines at least one subscribing device of the target sensor according to the identification information of the target sensor.
[0175] In an embodiment of the present application, when the proxy device receives the subscription message sent by the subscription device, it can record the corresponding relationship between the subscription device and the target sensor when determining the target sensor corresponding to the subscription device. After acquiring the measurement data of the target sensor, the proxy device can determine the identification information of the target sensor according to the received measurement data, and thus can search for the recorded corresponding relationship between the subscription device and the target sensor according to the identification information of the target sensor, and determine at least one subscription device corresponding to the target sensor.
[0176] As a possible implementation manner, the measurement data carries identification information of the target sensor. In this case, after receiving the measurement data, the proxy device may parse the measurement data to obtain the identification information of the target sensor.
[0177] Of course, the proxy device can also obtain the identification information of the target sensor in other ways. For example, when the proxy device establishes a connection with the sensor, it can simultaneously record the identification information of the sensor corresponding to the connection. At this time, when the proxy device receives measurement data through the connection with the target sensor, it can record the identification information of the sensor corresponding to the connection and determine the identification information of the target sensor. Of course, the identification information of the target sensor can also be obtained in other ways, and this application does not limit this.
[0178] Step S408: The proxy device sends the measurement data to at least one subscribing device of the target sensor. The at least one subscribing device receives the measurement data.
[0179] In an embodiment of the present application, when the proxy device determines at least one subscribing device of the target sensor, it can send the measurement data of the target sensor to the at least one subscribing device, so that the at least one subscribing device obtains the measurement data of the target sensor and performs corresponding processing.
[0180] Thus, in the embodiment of the present application, the subscription device can send a subscription message to the proxy device, and the proxy device can determine the target sensor according to the subscription message, and control the target sensor to measure data in the first working state. In addition, the proxy device can support multiple connection modes at the same time to achieve connection with sensors with different connection modes, so as to obtain measurement data of sensors with multiple connection modes, reduce the number of substations used, and greatly reduce industrial costs.
[0181] See also Figure 6 , is a flow chart of another data processing method provided in an embodiment of the present application. Figure 4 The embodiment described adds the relevant steps of canceling the subscription of the sensor. Figure 6 As shown, the method includes:
[0182] Step S601: The subscription device sends a subscription message to the proxy device, and the proxy device receives the subscription message.
[0183] For details, please refer to step S401 and no further details will be given here.
[0184] Step S602: The proxy device determines the target sensor according to the subscription message.
[0185] For details, please refer to step S402 and no further details will be given here.
[0186] Step S603: The proxy device obtains the subscription status of the target sensor.
[0187] For details, please refer to step S403 and no further details will be given here.
[0188] It should be understood that since the subscription state includes two states, the subscribed state and the unsubscribed state, the proxy device performs different steps according to the different subscription states of the acquired target sensor. When the proxy device determines that the subscription state of the target sensor is the unsubscribed state, the following steps S604a-S605a and steps S606-S608 are performed. When the proxy device determines that the subscription state of the target sensor is the subscribed state, the following steps S604b and steps S606-S608 are performed.
[0189] Step S604a: when the subscription state of the target sensor is unsubscribed, update the subscription state of the target sensor from unsubscribed to subscribed, increase the subscription quantity of the target sensor by a second preset value, and send a first working state switching instruction to the target sensor. The target sensor receives the first working state switching instruction.
[0190] The first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
[0191] For details, please refer to step S404a and no further details will be given here.
[0192] Step S604b: when the subscription status of the target sensor is subscribed, increase the subscription quantity of the target sensor by a second preset value.
[0193] For details, please refer to step S404b and no further details will be given here.
[0194] Step S605a: The target sensor switches the current working state to the first working state according to the first working state switching instruction, and performs data measurement according to the first measurement cycle when the first working state is a working state for performing data measurement in the first measurement cycle.
[0195] For details, please refer to step S405a and no further details will be given here.
[0196] Step S606: The proxy device obtains measurement data of the target sensor.
[0197] For details, please refer to step S406 and no further details will be given here.
[0198] Step S607: The proxy device obtains identification information of the target sensor, and determines at least one subscribing device of the target sensor according to the identification information of the target sensor.
[0199] For details, please refer to step S407 and no further details will be given here.
[0200] Step S608: The proxy device sends the measurement data to at least one subscribing device of the target sensor. The at least one subscribing device receives the measurement data.
[0201] For details, please refer to step S408 and no further details will be given here.
[0202] Step S609: The subscription device sends a subscription cancellation message to the proxy device. The proxy device receives the subscription cancellation message.
[0203] The subscription cancellation message carries the identification information of the target sensor.
[0204] For details, please refer to step S201 and no further details will be given here.
[0205] Step S610: The proxy device determines the target sensor according to the subscription cancellation message.
[0206] For details, please refer to step S202 and no further details will be given here.
[0207] As a possible implementation, when the proxy device determines the target sensor, since the subscribing device no longer needs to obtain the measurement data of the target sensor, the proxy device can delete the recorded correspondence between the subscribing device and the target sensor, thereby no longer sending the measurement data of the target sensor to the subscribing device. For example, the identification information of the subscribing device recorded in the subscription list of the target sensor is deleted.
[0208] Step S611: The proxy device obtains the subscription quantity of the target sensor, and reduces the subscription quantity of the target sensor by a first preset value.
[0209] In an embodiment of the present application, after receiving a subscription cancellation message, the proxy device can parse the subscription message to obtain the identification information of the target sensor carried therein, and then determine the target sensor whose measurement data the subscribing device needs to cancel. Since the target sensor may be subscribed by multiple subscribing devices at the same time, that is, multiple subscribing devices need to obtain the measurement data of the target sensor at the same time, when one of the subscribing devices cancels the subscription to the measurement data of the target sensor, there are still other subscribing devices that need to subscribe to the measurement data of the target sensor, so the target sensor still works in the first working state. When the target sensor is subscribed by only one subscribing device, when the subscribing device cancels the subscription to the measurement data of the target sensor, that is, when no subscribing device subscribes to the measurement data of the target sensor, it is necessary to switch the working state of the target sensor to the second working state to reduce the power consumption of the target sensor. Therefore, it is necessary to record the subscription number of the target sensor, and when each additional subscription device subscribes to the test data of the target sensor, the subscription number increases by the second preset value, and when each reduced subscription device subscribes to the test data of the target sensor, the subscription number decreases by the first preset value. Based on this, after receiving the subscription cancellation message sent by the subscription device and determining the target sensor, the proxy device can obtain the subscription quantity of the target sensor and reduce the subscription quantity of the target sensor by a first preset value.
[0210] As a possible implementation manner, the first preset value is equal to the second preset value.
[0211] As a possible implementation manner, the first preset value is 1.
[0212] Step S612: When the subscription quantity of the target sensor is equal to or less than a preset threshold, the proxy device obtains the subscription state of the target sensor and updates the subscription state of the target sensor from the subscribed state to the unsubscribed state.
[0213] In the embodiment of the present application, after the proxy device reduces the subscription number of the target sensor by the first threshold value, that is, updates the subscription number of the target sensor, it can compare the updated subscription number of the target sensor with the preset threshold value. When the subscription number of the target sensor is less than or equal to the preset threshold value, it means that no subscribing device has subscribed to the measurement data of the target sensor. At this time, the proxy device can obtain the recorded subscription status of the target sensor and update the subscription status of the target sensor from the subscribed state to the unsubscribed state.
[0214] It should be noted that when the number of subscription data of the target sensor is greater than the preset threshold, it means that there are other subscription devices that need to obtain the measurement data of the target sensor. At this time, step S607 can be re-executed until the subscription data of the target sensor is less than or equal to the preset threshold.
[0215] It should be understood that the preset threshold is a preset threshold for determining whether no subscribing device has subscribed to the measurement data of the target sensor. When the number of subscriptions to the target sensor is greater than the preset threshold, it is considered that a subscribing device has subscribed to the measurement data of the target sensor. When the number of subscriptions to the target sensor is less than or equal to the preset threshold, it is considered that no subscribing device has subscribed to the measurement data of the target sensor. As a possible implementation, the preset threshold is 0.
[0216] Step S613: When the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state, the proxy device sends a second working state switching instruction to the target sensor. The target sensor receives the second working state switching instruction.
[0217] The second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state. The first working state is a working state in which the target sensor performs data measurement in a first measurement cycle. The second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle. The second measurement cycle is greater than the first measurement cycle.
[0218] In an embodiment of the present application, when the number of subscriptions of the updated target sensor is less than or equal to a preset threshold, the subscription state of the target sensor is updated from a subscribed state to an unsubscribed state. At this time, since the subscription device cancels the subscription of the measurement data of the target sensor, and no other subscription device subscribes to the measurement data of the target sensor, the proxy device can send a second working state switching instruction to the target sensor, so that the target sensor switches from the first working state to the second working state. The target sensor receives the second working state switching instruction. For details, please refer to step S203 and step S301, which will not be repeated here.
[0219] Step S614: The target sensor switches the current working state to the second working state according to the second working state switching instruction, and performs data measurement according to the second measurement cycle when the second working state is a working state for performing data measurement in the second measurement cycle.
[0220] For details, please refer to step S302 and no further details will be given here.
[0221] Exemplarily, subscribing device 1 needs to obtain the measurement data of sensor 1, and subscribing device 2 needs to obtain the measurement data of sensor 1 and sensor 2. Subscribing device 3 has subscribed to the measurement data of sensor 3 and needs to unsubscribe from the measurement data of sensor 3. At this time, subscribing device 1 sends a subscription message to the proxy device, and the subscription message carries the identification information of sensor 1. After receiving the subscription message, the proxy device can parse the identification information of sensor 1 according to the subscription message, and determine that subscribing device 1 needs to subscribe to the measurement data of sensor 1. At this time, the proxy device can record the correspondence between subscribing device 1 and its target sensor. That is, record the correspondence between subscribing device 1 and sensor 1. The proxy device obtains the subscription status of sensor 1. Assuming that the subscription status of sensor 1 is unsubscribed at this time, when the proxy device detects that the subscription status of sensor 1 is unsubscribed, it updates the subscription status of sensor 1 from unsubscribed to subscribed, increases the subscription quantity of sensor 1 by 1, and sends a first working state switching instruction to sensor 1 at the same time, such as Figure 7 As shown. Assuming that in this example, sensor 1 and the proxy device are connected via a fieldbus, when the proxy device sends the first working state switching instruction to sensor 1, it can be sent via the fieldbus. Sensor 1 receives the first working state switching instruction via the fieldbus. After receiving the first working state switching instruction, sensor 1 learns that the working state needs to be switched to the first working state. At this time, sensor 1 can switch the second working state to the first working state, that is, sensor 1 switches the measurement cycle to the first measurement cycle, and starts to measure data with the first measurement cycle as the cycle. The proxy device can query the measurement data of sensor 1 through the fieldbus to obtain the measurement data of sensor 1. Since the proxy device queries the measurement data of sensor 1 through the fieldbus, it can be learned that the identification information of the target sensor corresponding to the measurement data is the identification information of sensor 1. The proxy device can find the corresponding relationship between sensor 1 and the subscribing device recorded according to the identification information of sensor 1, and determine that the subscribing device of sensor 1 is subscribing device 1. At this time, the proxy device can send the measurement data of sensor 1 to subscribing device 1.
[0222] Similarly, the subscribing device 2 sends a subscription message to the proxy device. The subscription message carries the identification information of sensor 1 and sensor 2. After receiving the subscription message, the proxy device can parse the identification information of sensor 1 and sensor 2 according to the subscription message, and determine that the subscribing device 2 needs to subscribe to the measurement data of sensor 1 and sensor 2. At this time, the proxy device can record the correspondence between the subscribing device 2 and its target sensor. That is, record the correspondence between the subscribing device 2 and sensor 1 and sensor 2. The proxy device obtains the subscription status of sensor 1 and sensor 2. At this time, the subscription status of sensor 1 is subscribed. When the proxy device detects that the subscription status of sensor 1 is subscribed, it increases the subscription number of sensor 1 by 1. Assuming that the subscription status of sensor 2 is unsubscribed, when the proxy device detects that the subscription status of sensor 2 is unsubscribed, it updates the subscription status of sensor 2 from unsubscribed to subscribed, increases the subscription number of sensor 2 by 1, and sends a first working state switching instruction to sensor 2 at the same time, refer to Figure 7 As shown. Assuming that in this example, sensor 2 and the proxy device are connected via a wireless network, when the proxy device sends the first working state switching instruction to sensor 2, it can be sent via the wireless network connection. Sensor 2 receives the first working state switching instruction via the wireless network connection. After receiving the first working state switching instruction, sensor 2 learns that the working state needs to be switched to the first working state. At this time, sensor 2 can switch the second working state to the first working state, that is, sensor 2 switches the measurement cycle to the first measurement cycle, and starts to measure data with the first measurement cycle as the cycle. The proxy device can query the measurement data measured by sensor 1 through the field bus, obtain the measurement data of sensor 1, and determine the identification information of sensor 1. Sensor 2 uploads the measurement data it measures to the proxy device via the wireless network connection. At this time, the measurement data sent by sensor 2 can carry the identification information of sensor 2. The proxy device can parse the measurement data sent by sensor 2 to obtain the identification information of sensor 2. The proxy device searches for the correspondence between sensor 1 and the subscribing device, and the correspondence between sensor 2 and the subscribing device according to the identification information of sensor 1 and the identification information of sensor 2, and determines that the subscribing device of sensor 1 is subscribing device 1 and subscribing device 2, and the subscribing device of sensor 2 is subscribing device 2. At this time, the proxy device can send the measurement data of sensor 1 to subscribing device 1 and subscribing device 2, and send the measurement data of sensor 2 to subscribing device 2.
[0223] Since the subscription device 3 has subscribed to the measurement data of the target sensor 3, the proxy device can send the measurement data of the subscription device 3 to the subscription device 3 when it obtains the measurement data of the subscription device 3. When the subscription device 3 does not need to obtain the measurement data of the sensor 3, a subscription cancellation message is sent to the proxy device. At this time, the proxy device receives the subscription cancellation message, wherein the subscription cancellation message carries the identification information of the sensor 3. The proxy device can obtain the identification information of the sensor 3 by parsing the subscription cancellation message, that is, to determine that the subscription device 3 needs to cancel the subscription of the test data of the sensor 3. The proxy device can delete the recorded correspondence between the sensor 3 and the subscription device 3. Obtain the subscription number of the sensor 3. Assuming that the subscription number of the sensor 3 is 1, the proxy device reduces the subscription number of the sensor 3 by 1. At this time, the subscription number of the sensor 3 is 0. After detecting that the subscription number of the sensor 3 is 0, the proxy device knows that the sensor 3 has no subscription device subscribed to its measurement data. At this time, the subscription state of the sensor 3 is updated from the subscribed state to the unsubscribed state, and the second working state switching instruction is sent to the sensor 3. After receiving the second working state switching instruction, the sensor 3 can switch its working state to the second working state, that is, stop data measurement.
[0224] It should be noted that in all embodiments of the present application, the first measurement periods of different sensors may be different or the same, and the present application does not limit this. The second measurement periods of different sensors may be the same or different, and the present application does not limit this.
[0225] In this way, when the subscription device suspends obtaining the measurement data of the target sensor, a subscription cancellation message is sent to the first device. After receiving the subscription cancellation message, the first device can determine the target sensor according to the subscription cancellation message, change the subscription state of the target sensor from the subscribed state to the unsubscribed state, and send a second working state switching instruction to the target sensor, so that the target sensor switches from the first working state to the second working state. The data measurement frequency of the target sensor in the second working state is lower than the data measurement frequency of the target sensor in the first working state. That is, when the subscription cancellation message is received, the target sensor can be controlled to switch to the second working state with a longer measurement cycle, so that when the target sensor is not needed for monitoring, the monitoring cycle of the target sensor can be extended, or data measurement can be stopped, thereby reducing the power consumption of the target sensor when data monitoring is not required, extending the battery life of the target sensor, and reducing industrial production costs.
[0226] Furthermore, in the present application, the proxy device supports multiple connection modes to connect to the sensor, and there is no need to set up multiple proxy devices for sensors with different connection modes, thereby greatly reducing the number of proxy devices used and further reducing industrial production costs.
[0227] See also Figure 8, which is a flow chart of another data processing method provided in an embodiment of the present application. This embodiment describes a scenario in which a subscription device and a proxy device use MQTT (Message Queuing Telemetry Transport) to implement message subscription and publishing. Of course, the subscription device and the proxy device can also implement message subscription and publishing in other ways, and this application does not limit this. In the embodiment of the present application, only the use of MQTT to implement message subscription and publishing is used as an example. Figure 8 As shown, the method includes:
[0228] Step S801: The subscription device sends a subscription message in MQTT format to the proxy device, and the proxy device receives the subscription message in MQTT format.
[0229] In an embodiment of the present application, the subscribing device can send a subscription message to the proxy device to subscribe to the measurement data of the sensor. At this time, the subscription message sent by the subscribing device to the proxy device is a message in MQTT format. Among them, the identification information of the target sensor carried in the subscription message is the target subscription topic information.
[0230] It should be noted that the corresponding relationship between each sensor and the subscription topic information can be preset on the subscription device side, so that the subscription device can determine the corresponding subscription topic information when it needs to obtain the measurement data of a sensor.
[0231] For details, please refer to step S401 and no further details will be given here.
[0232] Step S802: The proxy device determines the target sensor according to the subscription message in the MQTT format.
[0233] In the embodiment of the present application, the subscription message received by the proxy device is a message in the MQTT format. At this time, the identification information of the target sensor carried in the subscription message is the target subscription topic information of the subscribing device. At this time, the proxy device obtains the mapping information between the preset sensor and the subscription topic information; according to the target subscription topic information and the mapping information between the preset sensor and the subscription topic information, the target sensor is determined.
[0234] That is, mapping information between sensors and subscription topic information is pre-set in the proxy device. After obtaining the target subscription topic information, the proxy device can search for mapping information between preset sensors and subscription topic information, thereby determining the target sensor corresponding to the target subscription topic information.
[0235] As a possible implementation manner, after parsing the target subscription topic information from the subscription message, the proxy device may record the correspondence between the subscription device carrying the target subscription topic information in the sent subscription message and the target subscription topic information.
[0236] It should be noted that each sensor is provided with corresponding subscription topic information, which may be the same or different and may be set according to actual needs, and this application does not impose any restrictions on this.
[0237] Step S803: The proxy device obtains the subscription status of the target sensor.
[0238] For details, please refer to step S403 and no further details will be given here.
[0239] It should be understood that since the subscription state includes two states, the subscribed state and the unsubscribed state, the proxy device performs different steps according to the different subscription states of the acquired target sensor. When the proxy device determines that the subscription state of the target sensor is the unsubscribed state, the following steps S604a-S605a and steps S606-S608 are performed. When the proxy device determines that the subscription state of the target sensor is the subscribed state, the following steps S604b and steps S606-S608 are performed.
[0240] Step S804a: when the subscription state of the target sensor is unsubscribed, update the subscription state of the target sensor from unsubscribed to subscribed, increase the subscription quantity of the target sensor by a second preset value, and send a first working state switching instruction to the target sensor. The target sensor receives the first working state switching instruction.
[0241] The first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
[0242] For details, please refer to step S404a and no further details will be given here.
[0243] Step S804b: when the subscription status of the target sensor is subscribed, increase the subscription quantity of the target sensor by a second preset value.
[0244] For details, please refer to step S404b and no further details will be given here.
[0245] Step S805a: The target sensor switches the current working state to the first working state according to the first working state switching instruction, and performs data measurement according to the first measurement cycle when the first working state is a working state for performing data measurement in the first measurement cycle.
[0246] For details, please refer to step S405a and no further details will be given here.
[0247] Step S806: The proxy device obtains measurement data of the target sensor.
[0248] For details, please refer to step S406 and no further details will be given here.
[0249] Step S807: The proxy device obtains identification information of the target sensor, and determines at least one subscribing device of the target sensor according to the identification information of the target sensor.
[0250] In the embodiment of the present application, after receiving the measurement data sent by the target sensor, the proxy device needs to send the measurement data to the corresponding subscription device. At this time, the proxy device determines the target subscription topic information according to the mapping information between the target sensor and the preset sensor and the subscription topic information; and determines at least one subscription device according to the target subscription topic information.
[0251] That is, after receiving the measurement data, the proxy device can know which target sensor sent the measurement data, find the mapping information between the preset sensor and the subscription subject information, and thus determine the target subscription subject information corresponding to the target sensor. The proxy device can determine at least one subscription device corresponding to the target subscription subject information based on the correspondence between the recorded subscription subject information and the subscription device.
[0252] Step S808: The proxy device sends the measurement data to at least one subscribing device of the target sensor. The at least one subscribing device receives the measurement data.
[0253] In an embodiment of the present application, after determining at least one subscriber device corresponding to the target subscription topic information, the proxy device may convert the received measurement data of the target sensor into a message in MQTT format and send it to the at least one subscriber device.
[0254] As a possible implementation manner, the proxy device sends measurement data to at least one subscriber device of the target sensor, including: generating a target publishing message according to target subscription topic information and the measurement data sent by the target sensor; and sending the target publishing message to the at least one subscriber device.
[0255] That is, after determining at least one subscriber device corresponding to the target subscription topic information, the proxy device can generate a target publishing message with the target subscription topic information and the measurement data sent by the target sensor, and the target publishing message is a message in the MQTT format. The target publishing message is sent to at least one subscriber device. After receiving the target publishing message, at least one subscriber device can parse the target publishing message to obtain the target subscription topic information and measurement data therein, so as to know which target subscription topic information the received measurement data belongs to, and then perform corresponding processing.
[0256] Step S809: The subscription device sends a subscription cancellation message in MQTT format to the proxy device. The proxy device receives the subscription cancellation message in MQTT format.
[0257] The subscription cancellation message carries the identification information of the target sensor.
[0258] In the embodiment of the present application, the subscription cancellation message is a message in the MQTT format, and the identification information of the target sensor is the target subscription topic information. That is, when the subscribing device does not need to obtain the relevant data of the target subscription topic information, it sends a subscription cancellation message to the proxy device. The subscription cancellation message carries the target subscription topic information. The proxy device receives the subscription cancellation message.
[0259] Step S810: The proxy device determines the target sensor according to the subscription cancellation message in the MQTT format.
[0260] In the embodiment of the present application, after receiving the subscription cancellation message, the proxy device can parse the subscription cancellation message and then obtain the target subscription topic information. The proxy device can obtain the mapping information between the preset sensor and the subscription topic information, search for the mapping information between the preset sensor and the subscription topic information according to the target subscription topic information, and determine the target sensor corresponding to the target subscription topic information.
[0261] As a possible implementation method, when the proxy device determines the target sensor, since the subscribing device no longer needs to obtain the measurement data of the target sensor, the proxy device can delete the recorded correspondence between the subscribing device and the target subscription topic information, thereby no longer sending the measurement data of the target sensor to the subscribing device.
[0262] Step S811: The proxy device obtains the subscription quantity of the target sensor, and reduces the subscription quantity of the target sensor by a first preset value.
[0263] For details, please refer to step S611 and no further details will be given here.
[0264] Step S812: When the subscription quantity of the target sensor is equal to or less than the preset threshold, the proxy device obtains the subscription state of the target sensor and updates the subscription state of the target sensor from the subscribed state to the unsubscribed state.
[0265] For details, please refer to step S612 and no further details will be given here.
[0266] Step S813: When the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state, the proxy device sends a second working state switching instruction to the target sensor. The target sensor receives the second working state switching instruction.
[0267] For details, please refer to step S613 and no further details will be given here.
[0268] Step S814: The target sensor switches the current working state to the second working state according to the second working state switching instruction, and performs data measurement according to the second measurement cycle when the second working state is a working state for performing data measurement in the second measurement cycle.
[0269] For details, please refer to step S302 and no further details will be given here.
[0270] Fig. 9 FIG. 1 is a schematic diagram of the structure of a proxy device provided in an embodiment of the present application. Fig. 9 As shown, the proxy device includes:
[0271] The subscription publishing service module 901 is used to receive a subscription cancellation message and send the subscription cancellation message to the subscription management module 902 .
[0272] The subscription cancellation message carries the identification information of the target sensor;
[0273] The subscription management module 902 is used to determine the target sensor according to the subscription cancellation message; and send a second working state switching instruction to the target sensor.
[0274] The second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state. The first working state is a working state in which the target sensor performs data measurement in a first measurement cycle. The second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle. The second measurement cycle is greater than the first measurement cycle.
[0275] As a possible implementation manner, the subscription management module 902 is used to determine the connection mode of each target sensor when there are at least two target sensors; and send a second working state switching instruction to each target sensor according to the connection mode of each target sensor.
[0276] Wherein, sending a working state switching instruction to each target sensor respectively according to the connection mode of each target sensor includes:
[0277] When the target sensor and the proxy device are connected via a field bus, a working state switching instruction is sent to the target sensor via the field bus; or, when the target sensor and the proxy device are connected via a network, a working state switching instruction is sent to the target sensor via a network connection.
[0278] As a possible implementation manner, the network connection includes an Ethernet connection or a wireless network connection.
[0279] As a possible implementation, the subscription management module 902 is used to obtain the subscription number of the target sensor and reduce the subscription number of the target sensor by a first preset value; when the subscription number of the target sensor is equal to or less than a preset threshold, the subscription state of the target sensor is obtained, and the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state. When the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state, a second working state switching instruction is sent to the target sensor.
[0280] As a possible implementation, the subscription publishing service module 901 is used to receive a subscription message and send the subscription message to the subscription management module 902 .
[0281] The subscription message carries the identification information of the target sensor.
[0282] The subscription management module 902 is used to determine the target sensor according to the subscription message, obtain the subscription status of the target sensor, update the subscription status of the target sensor from the unsubscribed state to the subscribed state when the subscription status of the target sensor is the unsubscribed state, increase the subscription quantity of the target sensor by a second preset value, and send a first working state switching instruction to the target sensor.
[0283] The first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
[0284] As a possible implementation manner, the subscription management module 902 is used to determine the connection mode of each target sensor when there are at least two target sensors; and send a first working state switching instruction to each target sensor according to the connection mode of each target sensor.
[0285] Wherein, sending a working state switching instruction to each target sensor respectively according to the connection mode of each target sensor includes:
[0286] When the target sensor and the proxy device are connected via a field bus, a working state switching instruction is sent to the target sensor via the field bus; or, when the target sensor and the proxy device are connected via a network, a working state switching instruction is sent to the target sensor via a network connection.
[0287] As a possible implementation manner, the subscription management module 902 is configured to increase the subscription quantity of the target sensor by a second preset value when the subscription status of the target sensor is subscribed.
[0288] As a possible implementation, Fig.10 As shown, the above-mentioned proxy device also includes:
[0289] The subscription and publishing client module 903 is used to obtain the measurement data of the target sensor and send the measurement data to the subscription and publishing service module 901 .
[0290] The subscription and publishing service module 901 is used to obtain identification information of a target sensor, determine at least one subscription device of the target sensor according to the identification information of the target sensor, and send measurement data to at least one subscription device of the target sensor.
[0291] As a possible implementation method, the subscription and publishing client module 903 is used to query the target sensor through the field bus to obtain the measurement data of the target sensor when the target sensor and the proxy device are connected through the field bus; or, when the target sensor and the proxy device are connected through the network, receive the measurement data sent by the target sensor through the network connection.
[0292] As a possible implementation method, the proxy device implements the subscription function of the subscribing device to the sensor measurement data through the MQTT protocol. At this time, the subscription and publishing service module 901 integrates the function of the MQTT server. The subscription and publishing client module 903 integrates the function of the MQTT client. The identification information of the target sensor includes the target subscription topic information.
[0293] The above subscription messages and subscription cancellation messages are both in MQTT format.
[0294] At this time, the subscription management module 902 is used to obtain the mapping information between the preset sensor and the subscription subject information; and determine the target sensor according to the target subscription subject information and the mapping information between the preset sensor and the subscription subject information.
[0295] As a possible implementation method, the subscription and publishing service module 901 is used to determine the target subscription topic information based on the mapping information between the target sensor and the preset sensor and the subscription topic information; determine at least one subscription device based on the target subscription topic information; generate a target publishing message based on the target subscription topic information and the measurement data sent by the target sensor; and send the target publishing message to at least one subscription device.
[0296] The target published message includes a message in the message queue telemetry transmission MQTT format.
[0297] Fig.11 FIG. 1 is a schematic diagram of the structure of a sensor provided in an embodiment of the present application. Fig.11 As shown, the sensor comprises:
[0298] The receiving module 1101 is used to receive a second working state switching instruction.
[0299] The second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state. The first working state is a working state in which the target sensor performs data measurement in a first measurement cycle. The second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle. The second measurement cycle is greater than the first measurement cycle.
[0300] The processing module 1102 is used to switch the current working state to the second working state according to the second working state switching instruction, and perform data measurement according to the second measurement cycle when the second working state is a working state for performing data measurement in a second measurement cycle.
[0301] As a possible implementation manner, the receiving module 1101 is configured to receive a first working state switching instruction.
[0302] The first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
[0303] The processing module 1102 is configured to switch the current working state to the first working state according to the first working state switching instruction, and perform data measurement according to the first measurement cycle when the first working state is a working state for performing data measurement in the first measurement cycle.
[0304] As a possible implementation, Fig.12 As shown, the above sensor also includes:
[0305] The sending module 1103 is used to send the measurement data to the proxy device.
[0306] Fig.13 FIG. 1 is a schematic diagram of a data processing system provided in an embodiment of the present application. Fig.13 As shown, the data processing system includes an agent device 1301 , at least one sensor 1302 and at least one subscription device 1303 .
[0307] The proxy device 1301 is connected to at least one sensor 1302 and at least one subscription device 1303 .
[0308] At least one subscription device 1303 is configured to send a subscription cancellation message to the proxy device 1301. The subscription cancellation message carries identification information of the target sensor.
[0309] The proxy device 1301 includes the proxy device described in the above embodiment; and the at least one sensor includes the sensor described in the above embodiment.
[0310] As a possible implementation, at least one subscription device 1303 is further configured to send a subscription request message to the proxy device 1301. The subscription message carries identification information of the target sensor.
[0311] Corresponding to the above embodiments, the present application also provides an electronic device. Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, the electronic device 1400 may include: a processor 1401, a memory 1402 and a communication unit 1403. These components communicate through one or more buses, and those skilled in the art can understand that the structure of the server shown in the figure does not constitute a limitation on the embodiment of the present invention, it can be a bus structure or a star structure, and can also include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0312] The communication unit 1403 is used to establish a communication channel so that the storage device can communicate with other devices, receive user data sent by other devices or send user data to other devices.
[0313] The processor 1401 is the control center of the storage device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 1402, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 1401 can only include a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.
[0314] The memory 1402 is used to store the execution instructions of the processor 1401. The memory 1402 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0315] When the execution instructions in the memory 1402 are executed by the processor 1401, the electronic device 1400 can execute Figure 2 or Figure 3 Some or all of the steps in the illustrated embodiments.
[0316] In a specific implementation, the present invention further provides a storage medium, wherein the storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment of the data processing method provided by the present invention. The storage medium may be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0317] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention or some parts of the embodiments.
[0318] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the device embodiment and the terminal embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.
Claims
1. A data processing method, characterized in that: Applied to a proxy device, the method comprises: receiving a subscription cancellation message; the subscription cancellation message carries identification information of a target sensor; Determining the target sensor according to the subscription cancellation message; Obtain the subscription quantity of the target sensor, and reduce the subscription quantity of the target sensor by 1; When the subscription quantity of the target sensor is equal to 0, the subscription state of the target sensor is acquired, and the subscription state of the target sensor is updated from a subscribed state to an unsubscribed state; When the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state, a second working state switching instruction is sent to the target sensor; the second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state set according to whether the target sensor needs to work for a long time, wherein when the target sensor does not need to work for a long time, the second working state of the target sensor is set to a working state in which data measurement is stopped, and when the target sensor needs to work for a long time, the second working state of the target sensor is set to a working state in which data measurement is performed in a second measurement cycle, and the second measurement cycle is greater than the first measurement cycle.
2. The method according to claim 1, characterized in that Also includes: Receive subscription messages; The subscription message carries the identification information of the target sensor; Determining the target sensor according to the subscription message; Obtaining the subscription status of the target sensor; When the subscription state of the target sensor is an unsubscribed state, the subscription state of the target sensor is updated from an unsubscribed state to a subscribed state, the subscription quantity of the target sensor is increased by a second preset value, and a first working state switching instruction is sent to the target sensor; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
3. The method according to claim 2, characterized in that Also includes: When the subscription state of the target sensor is subscribed, the subscription quantity of the target sensor is increased by a second preset value.
4. The method according to claim 3, characterized in that Also includes: Obtain measurement data of target sensors; Acquire identification information of the target sensor, and determine at least one subscription device of the target sensor according to the identification information of the target sensor; The measurement data is sent to at least one subscribing device of the target sensor.
5. The method according to claim 4, characterized in that Sending a working state switching instruction to the target sensor, wherein the working state switching instruction includes a first working state switching instruction or a second working state switching instruction, includes: When there are at least two target sensors, determining a connection mode of each target sensor; According to the connection mode of each target sensor, a working state switching instruction is sent to the target sensor respectively.
6. The method according to claim 5, characterized in that The sending of the working state switching instruction to each target sensor according to the connection mode of each target sensor comprises: When the target sensor is connected to the proxy device via a field bus, a working state switching instruction is sent to the target sensor via the field bus; or, When the target sensor is connected to the proxy device via a network, a working state switching instruction is sent to the target sensor via the network connection.
7. The method according to claim 6, characterized in that The obtaining of the measurement data of the target sensor comprises: When the target sensor is connected to the proxy device via a field bus, the proxy device queries the target sensor via the field bus to obtain measurement data of the target sensor; or When the target sensor is connected to the proxy device via a network, the measurement data sent by the target sensor is received via the network connection.
8. The method according to claim 6 or 7, characterized in that: The network connection includes: Ethernet connection or wireless network connection.
9. A data processing method, characterized in that: Applied to a sensor, the method comprises: Receiving a second working state switching instruction generated by a proxy device according to the method according to any one of claims 1 to 8; the second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle; wherein the second measurement cycle is greater than the first measurement cycle; According to the second working state switching instruction, the current working state is switched to the second working state, and when the second working state is a working state for performing data measurement in a second measurement cycle, data measurement is performed according to the second measurement cycle.
10. The method according to claim 9, characterized in that Also includes: Receiving a first working state switching instruction; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state; According to the first working state switching instruction, the current working state is switched to the first working state, and when the first working state is a working state for performing data measurement in a first measurement cycle, data measurement is performed according to the first measurement cycle.
11. The method according to claim 9 or 10, characterized in that: Also includes: Sends measurement data to the proxy device.
12. A proxy device, characterized in that: include: The subscription publishing service module is used to receive a subscription cancellation message and send the subscription cancellation message to the subscription management module; The subscription cancellation message carries identification information of the target sensor; A subscription management module, configured to determine a target sensor according to the subscription cancellation message; obtain the subscription quantity of the target sensor, and reduce the subscription quantity of the target sensor by 1; When the subscription quantity of the target sensor is equal to 0, the subscription state of the target sensor is acquired, and the subscription state of the target sensor is updated from a subscribed state to an unsubscribed state; When the subscription state of the target sensor is updated from the subscribed state to the unsubscribed state, a second working state switching instruction is sent to the target sensor; the second working state switching instruction is used to instruct the target sensor to switch from the first working state to the second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state set according to whether the target sensor needs to work for a long time, wherein when the target sensor does not need to work for a long time, the second working state of the target sensor is set to a working state in which data measurement is stopped, and when the target sensor needs to work for a long time, the second working state of the target sensor is set to a working state in which data measurement is performed in a second measurement cycle, and the second measurement cycle is greater than the first measurement cycle.
13. The proxy device according to claim 12, characterized in that: The subscription publishing service module is used to receive subscription messages and send the subscription messages to the subscription management module; the subscription messages carry the identification information of the target sensor; The subscription management module is used to determine the target sensor according to the subscription message; Obtaining the subscription status of the target sensor; When the subscription state of the target sensor is an unsubscribed state, the subscription state of the target sensor is updated from an unsubscribed state to a subscribed state, the subscription quantity of the target sensor is increased by a second preset value, and a first working state switching instruction is sent to the target sensor; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state.
14. The proxy device according to claim 13, characterized in that: The subscription management module is configured to increase the subscription quantity of the target sensor by a second preset value when the subscription status of the target sensor is subscribed.
15. The proxy device according to claim 14, characterized in that: Also includes: The subscription and publishing client module is used to obtain the measurement data of the target sensor and send the measurement data sent by the target sensor to the subscription and publishing service module; The subscription and publishing service module is used to obtain the identification information of the target sensor and determine at least one subscription device of the target sensor according to the identification information of the target sensor; The measurement data is sent to at least one subscribing device of the target sensor.
16. The proxy device according to claim 15, characterized in that: The subscription management module is used to determine the connection mode of each target sensor when there are at least two target sensors; According to the connection mode of each target sensor, a working state switching instruction is sent to the target sensor respectively; The working state switching instruction includes: a first working state switching instruction or a second working state switching instruction.
17. The proxy device according to claim 16, characterized in that: The subscription management module is used to send a working state switching instruction to the target sensor through the field bus when the target sensor is connected to the proxy device through the field bus; or When the target sensor is connected to the proxy device via a network, a working state switching instruction is sent to the target sensor via the network connection.
18. The proxy device according to claim 17, characterized in that: The subscription and publishing client module is used to query the target sensor through the field bus to obtain the measurement data of the target sensor when the target sensor is connected to the proxy device through the field bus; or When the target sensor is connected to the proxy device via a network, the measurement data sent by the target sensor is received via the network connection.
19. The proxy device according to claim 17 or 18, characterized in that: The network connection includes: Ethernet connection or wireless network connection.
20. A sensor, characterized in that: include: A receiving module, configured to receive a second working state switching instruction sent by a proxy device according to any one of claims 12 to 19; the second working state switching instruction is used to instruct a target sensor to switch from a first working state to a second working state; the first working state is a working state in which the target sensor performs data measurement in a first measurement cycle; the second working state is a working state in which the target sensor does not perform data measurement or performs data measurement in a second measurement cycle; wherein the second measurement cycle is greater than the first measurement cycle; The processing module is used to switch the current working state to the second working state according to the second working state switching instruction, and when the second working state is a working state for performing data measurement in a second measurement cycle, perform data measurement according to the second measurement cycle.
21. The sensor according to claim 20, characterized in that The receiving module is used to receive a first working state switching instruction; the first working state switching instruction is used to instruct the target sensor to switch from the second working state to the first working state; The processing module is used to switch the current working state to the first working state according to the first working state switching instruction, and perform data measurement according to the first measurement cycle when the first working state is a working state for performing data measurement in a first measurement cycle.
22. The sensor according to claim 20 or 21, characterized in that Also includes: The sending module is used to send the measurement data to the proxy device.
23. A data processing system, characterized in that: include: an agent device, at least one sensor and at least one subscriber device; wherein the proxy device is connected to at least one sensor and at least one subscription device; At least one subscription device, used to send a subscription cancellation message to the proxy device; the subscription cancellation message carries identification information of the target sensor; The proxy device comprises the proxy device according to any one of claims 12-19; the at least one sensor comprises the sensor according to any one of claims 20-22.
24. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores a computer program. When the computer program is executed, the electronic device executes the method according to any one of claims 1 to 8 or executes the method according to any one of claims 9 to 11.
25. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 8 or the method according to any one of claims 9 to 11.
Citation Information
Patent Citations
Multi-sensor detection method and device, and computer readable storage medium
CN107340014A
Detection system based on lora Internet of Things gateway
CN112910833A
Control method and device and storage medium
CN113971045A