Filter stick detection method and device based on MQTT protocol and computer equipment
Through the filter rod detection method based on the MQTT protocol, data transfer and processing are used by the MQTT server, the problem of insufficient real-time detection of traditional filter rod detection equipment is solved, real-time and reliability of filter rod detection is realized, and production quality and efficiency are improved.
Patent Information
- Application Number
- CN202510643151.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-07-25
AI Technical Summary
Traditional filter rod detection equipment has the problem of low real-time detection, which is difficult to meet the real-time quality monitoring needs in complex production environments, and the lag in fault response may affect production efficiency and quality.
The filter rod detection method based on the MQTT protocol is adopted, and the communication between the filter rod detection device and the MQTT server and the web server is detected. The MQTT protocol is used to realize data transmission, generate JSON data packets and perform data processing, ensuring the real-time and reliability of the detection data.
Real-time and reliability of filter rod detection is realized, production quality and efficiency are improved, equipment status and alarm information are promptly responded to, intuitive data display and control instructions are provided, and the reliability and practicality of the production process is improved.
Smart Images

Figure CN120378516A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of filter rod detection, and particularly to a filter rod detection method, device, computer device, computer-readable storage medium, and computer program product based on the MQTT protocol. Background Art
[0002] During the production process of filter rods, the quality of filter rods directly affects the overall performance of cigarettes and the user experience. Traditional filter rod detection devices usually adopt an independent structure or a local area network communication mode.
[0003] However, this method has the problem of low detection real-time performance. Summary of the Invention
[0004] Based on this, it is necessary to provide a filter rod detection method, device, computer device, computer-readable storage medium, and computer program product based on the MQTT protocol that can improve the detection real-time performance for the above technical problems.
[0005] In a first aspect, this application provides a filter rod detection method based on the MQTT protocol, which is applied to a web server and includes:
[0006] Receiving a JSON data packet forwarded by an MQTT server; the MQTT server is used to receive JSON data packets uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated based on an XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and the MAC address, and the MAC address is the device address of the filter rod detection device;
[0007] Performing data processing on the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0008] In combination with the first aspect, in one embodiment, performing data processing on the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information includes:
[0009] Parsing the JSON data packet based on a pre-set parsing library to obtain the parsed data;
[0010] Classifying the parsed data according to a predefined format or field name to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information and storing them.
[0011] In combination with the first aspect, in one embodiment, the method further includes:
[0012] Generate a data table based on the numerical data and categorical data in the detection data, and generate a data chart according to the numerical data, categorical data and ordinal data in the detection data, and return it to the user terminal; the user terminal is used to display the data table and the data chart through a visualization interface.
[0013] In combination with the first aspect, in an exemplary embodiment, the method further includes:
[0014] Return the status information of the filter rod detection device to the user terminal; the user terminal is used to display the status information through a visualization interface;
[0015] Generate a pop-up prompt message or a visual prompt message based on the alarm information, and return it to the user terminal; the user terminal is used to display the pop-up prompt message or the visual prompt message through a visualization interface.
[0016] In combination with the first aspect, in one of the embodiments, the method further includes:
[0017] Judge whether the detection data is within a preset qualified range;
[0018] Generate a control instruction based on the judgment result and send it. The filter rod detection device receives the control instruction sent by the web server by subscribing to the topic including the device address of the filter rod detection device.
[0019] In a second aspect, the present application further provides a filter rod detection method based on the MQTT protocol, which is applied to a filter rod detection device and includes:
[0020] Obtain the detection data of the detected target cigarette filter rod;
[0021] Generate an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulate a JSON data packet with the theme format of platformTopic and the MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device;
[0022] Upload the JSON data packet to the MQTT server through the MQTT protocol; the MQTT server is used to receive each JSON data packet and forward the JSON data packet to the web server subscribing to the topic including platformTopic;
[0023] The web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device and the alarm information.
[0024] In a third aspect, the present application also provides a filter rod detection system based on the MQTT protocol. The system includes a filter rod detection device, an MQTT server, and a web server;
[0025] The filter rod detection device is used to obtain the detection data of the target cigarette filter rod to be detected; generate an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulate a JSON data packet with the topic format of platformTopic or MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device;
[0026] The filter rod detection device is also used to upload the JSON data packet to the MQTT server through the MQTT protocol;
[0027] The MQTT server is used to receive each JSON data packet and forward the JSON data packet to the web server whose subscribed topic includes platformTopic;
[0028] The web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0029] In a fourth aspect, the present application also provides a filter rod detection device based on the MQTT protocol, which is applied to the web server and includes:
[0030] A forwarded data packet receiving module, which is used to receive the JSON data packet forwarded by the MQTT server; the MQTT server is used to receive the JSON data packet uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated and generated based on the XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and MAC address, and the MAC address is the device address of the filter rod detection device;
[0031] A data packet processing module, which is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0032] In a fourth aspect, the present application also provides a filter rod detection device based on the MQTT protocol, which is applied to the filter rod detection device and includes:
[0033] A detection data acquisition module, which is used to obtain the detection data of the target cigarette filter rod to be detected;
[0034] A data packet encapsulation module, which is used to generate an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulate a JSON data packet with the topic format of platformTopic and the MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device;
[0035] A data packet upload module, which is used to upload the JSON data packet to the MQTT server through the MQTT protocol; the MQTT server is used to receive each JSON data packet and forward the JSON data packet to a web server whose subscribed topic includes platformTopic;
[0036] The web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information and alarm information of the filter rod detection device.
[0037] In a sixth aspect, the present application further provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0038] Receiving the JSON data packet forwarded by the MQTT server; the MQTT server is used to receive the JSON data packets uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated and generated based on the XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and the MAC address, and the MAC address is the device address of the filter rod detection device;
[0039] Processing the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information and alarm information of the filter rod detection device.
[0040] In a seventh aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0041] Receiving the JSON data packet forwarded by the MQTT server; the MQTT server is used to receive the JSON data packets uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated and generated based on the XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and the MAC address, and the MAC address is the device address of the filter rod detection device;
[0042] Process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0043] In an eighth aspect, the present application also provides a computer program product, including a computer program, which when executed by a processor implements the following steps:
[0044] Receive the JSON data packet forwarded by the MQTT server; the MQTT server is used to receive the JSON data packets uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated based on the XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and the MAC address, and the MAC address is the device address of the filter rod detection device;
[0045] Process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0046] For the above filter rod detection method, device, computer device, computer-readable storage medium, and computer program product based on the MQTT protocol, the filter rod detection device detects the target cigarette filter rod, generates an XML data string based on the operation of the device itself and the detection data obtained, encapsulates it into a JSON data packet with the topic format of platformTopic and the MAC address based on the XML data string and the identification information of the device, and uploads it to the MQTT server based on the MQTT protocol. The MQTT server forwards the JSON data packet to the web server, and the web server processes the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information. By introducing the MQTT server as a relay server for realizing the detection of the target cigarette filter rod and using the MQTT protocol to realize data transmission between multiple terminals, the real-time performance of data transmission is realized, and thus the timeliness of filter rod detection is ensured. Description of the Drawings
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for the description of the embodiments of the present application or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0048] Figure 1Application environment diagram of a filter rod detection method based on the MQTT protocol in an embodiment;
[0049] Figure 2 Schematic flowchart of a filter rod detection method based on the MQTT protocol in an embodiment;
[0050] Figure 3 Schematic flowchart of a filter rod detection method based on the MQTT protocol in another embodiment;
[0051] Figure 4 Schematic diagram of a filter rod detection system based on the MQTT protocol in an embodiment;
[0052] Figure 5 Schematic flowchart of a filter rod detection method based on the MQTT protocol in yet another embodiment;
[0053] Figure 6 MQTT protocol data packet format diagram in an embodiment;
[0054] Figure 7 Structural block diagram of a filter rod detection device based on the MQTT protocol in an embodiment;
[0055] Figure 8 Structural block diagram of a filter rod detection device based on the MQTT protocol in another embodiment;
[0056] Figure 9 Internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0057] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0058] During the production process of filter rods, the quality of filter rods directly affects the overall performance of cigarettes and the user experience. Traditional filter rod detection devices usually adopt an independent structure or a local area network communication mode, and this method has the following limitations:
[0059] Insufficient real-time performance: The data transmission delay between the detection device and the monitoring system is relatively large, making it difficult to meet the real-time quality monitoring requirements in a complex production environment.
[0060] Lag in fault response: The existing system has a slow response speed to equipment abnormalities, which may affect production efficiency, pose quality risks, and even cause greater economic losses.
[0061] In recent years, the Internet of Things technology has developed rapidly. In particular, the MQTT protocol (Message Queuing Telemetry Transport) has been widely used in the industrial Internet of Things scenarios due to its lightweight, efficient, and low-bandwidth environment support characteristics. The MQTT protocol realizes efficient data transmission and collaborative work among devices through the publish / subscribe mechanism. However, most of the existing solutions based on the MQTT protocol are highly general and lack specialized optimization for the monitoring requirements of filter rod detection devices in the filter rod industry. For example, there are still deficiencies in supporting high-frequency data acquisition, real-time anomaly alerts, and multi-device collaborative management.
[0062] Therefore, developing a monitoring system for cigarette filter rod detection devices based on the MQTT protocol can not only significantly improve the real-time performance and reliability of data transmission but also meet the requirements of multi-device efficient collaboration and centralized management, providing intelligent and digital support for the filter rod production process.
[0063] The filter rod detection method based on the MQTT protocol provided in the embodiments of this application can be applied to an application environment as Figure 1 shown. Among them, the filter rod detection device 102 communicates with the web server 106 through the relay server MQTT server 104. The data storage system can store the data that the server 106 needs to process. The data storage system can be integrated on the web server 106, or placed in the cloud or other network servers.
[0064] The filter rod detection device 102 performs detection on the target cigarette filter rod to obtain corresponding detection data, generates an XML data string based on the detection data and the operating information of the filter rod detection device 102, and then encapsulates a JSON data packet according to the XML data string and the device identifier of the filter rod detection device 102. The topic format of the JSON data packet is platformTopic (platform topic) and MAC address. Here, the MAC address is the device address of the filter rod detection device 102. The filter rod detection device 102 uploads the JSON data packet to the MATT server 104 through the MQTT protocol. The MATT server 104 forwards the JSON data packet to the web server 106. After receiving it, the web server 106 processes the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information, and the alarm information of the filter rod detection device 102. Among them, the server 104 can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0065] In an exemplary embodiment, as Figure 2 shown, a filter rod detection method based on the MQTT protocol is provided. This method is applied toFigure 1 Taking the web server 106 in as an example, the following steps S201 and S202 are included. Among them:
[0066] Step S201: Receive the JSON data packet forwarded by the MQTT server. The MQTT server is used to receive the JSON data packets uploaded by each filter rod detection device through the MQTT protocol. The JSON data packet is encapsulated based on the XML data string and the identification information of the filter rod detection device. The XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device. The topic format of the JSON data packet is platformTopic and the MAC address, and the MAC address is the device address of the filter rod detection device.
[0067] Among them, the MQTT server can be understood as a data transmission transfer station. The data transmitted into the MQTT server can only be through the MQTT protocol. The MQTT protocol can be understood as a lightweight message transmission protocol based on the publish-subscribe mode. The JSON data packet can be understood as a lightweight data exchange format. The XML data string can be understood as a data document composed of elements, attributes, text, etc., with strict format requirements. The operation information can be understood as the status information, timestamp, etc. of the filter rod detection device.
[0068] Optionally, when the filter rod detection device 102 detects the target cigarette filter rod, it collects the detection data once for each detected sample. The collected detection data includes but is not limited to parameters such as filter rod length, diameter, and draw resistance. An XML data string is generated according to the collected detection data and the operation information of the filter rod detection device 102. Then, a JSON data packet with the topic format of platformTopic and the MAC address is encapsulated based on the XML data string and the device identification of the filter rod detection device, and the JSON data packet is reported to the MQTT server 104 through the MQTT protocol. The MQTT server 104 forwards the JSON data packet to the web server.
[0069] Based on the above implementation, by introducing the MQTT server as a transfer station for relevant detection data packets, it is ensured that the detection data detected by the filter rod detection device can be transmitted to the web server completely and effectively. And using the MQTT protocol to achieve data transmission also ensures the high efficiency of data transmission, thereby ensuring the timeliness of the data received by the web server.
[0070] Step S202: Process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0071] Among them, data processing can be understood as steps such as data packet parsing, data classification, and comprehensive analysis of the classified data. Status information can be understood as the device status information of the filter rod detection device, including device online, device offline, and maintenance status, etc. Alarm information can be understood as alarm information for the device and / or alarm information for the data.
[0072] Exemplarily, the web server 106 uses a pre-set parsing library to parse the JSON data packet to obtain the parsed data, and then classifies the parsed data according to a predefined format or field name to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information, and returns the detection data, status information, and alarm information to the user terminal. The user terminal displays the detection data, status information, and alarm information through a visual interface.
[0073] According to the above embodiments, through the data processing and data analysis of the web server, the detection results for the filter rod detection device can be quickly obtained, including the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information, and are returned to the user terminal for display through a visual interface, ensuring the timeliness of detection, enabling timely response to equipment abnormalities, and thus ensuring production quality and efficiency.
[0074] In the above filter rod detection method based on the MQTT protocol, the filter rod detection device detects the target cigarette filter rod, generates an XML data string based on the detection data obtained from its own operation and detection, encapsulates the XML data string and the device identification information into a JSON data packet with the topic format of platformTopic and the MAC address, and uploads it to the MQTT server based on the MQTT protocol. The MQTT server forwards the JSON data packet to the web server, and the web server processes the JSON data packet (JavaScript Object Notation) to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information. By introducing the MQTT server as a relay server for realizing the detection of the target cigarette filter rod and using the MQTT protocol to realize data transmission between multiple terminals, the real-time nature of data transmission is achieved, and thus the timeliness of filter rod detection is ensured.
[0075] In one embodiment, data processing is performed on the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information, including: parsing the JSON data packet based on a pre-set parsing library to obtain the parsed data; classifying the parsed data according to a predefined format or field name to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information and storing them.
[0076] Optionally, the web server 106 parses the JSON data packet based on a pre-set parsing library to obtain the parsed data, and then classifies the parsed data according to a predefined format or field name to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information and stores them in the database. For example, classifying the data according to the field names: Detection data: the values in the "data" field, such as "weight", "circumference", "length". Status information: the values in the "status" field, such as "normal" or "error". Alarm information: the values in the "alert" field, such as "code" and "message".
[0077] According to the above embodiment, the web server parses the JSON data packet by using a pre-set parsing library, and classifies the parsed data by using a predefined format and field name to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information. Performing the above data processing on the JSON data packet and storing it in the database ensures the reduction of the original data and speeds up the detection progress, ensuring the reliability and real-time nature of the detection results, and storing them in the database for historical data query and analysis.
[0078] In one of the embodiments, the method further includes: generating a data table based on the numerical data and categorical data in the detection data, and generating a data chart based on the numerical data, categorical data, and ordinal data in the detection data, and returning them to the user terminal; the user terminal is used to display the data table and the data chart through a visualization interface.
[0079] Among them, the numerical data can be understood as data composed of clear Arabic numerals, such as length, weight, mixing ratio, etc., which can be subjected to mathematical operations and analysis. The categorical data can be understood as data used to describe the categories and attributes of things, such as the category of cigarette filter rods, regional classification attribute data, etc. The ordinal data can be understood as data with an inherent order, such as grade, ranking, etc.
[0080] Exemplarily, the web server 106 generates a data table based on the numerical data and categorical data in the detection data, and generates a data chart based on the numerical data, categorical data, and sequential data in the detection data. There may or may not be a corresponding relationship between the data table and the data chart. The generated data table and data chart are returned to the user terminal, and the user terminal displays the data table and data chart through a visualization interface.
[0081] Based on the above embodiments, by generating a data table according to the numerical data and categorical data in the detection data, and generating a data chart based on the numerical data, categorical data, and sequential data in the detection data, and returning them to the user terminal for display through a visualization interface, data tables and data charts with more intuitive and clear expression ways are generated using the detection data, which helps users improve the acquisition speed of the detection data and facilitates the control of the production efficiency and quality of the product.
[0082] In an exemplary embodiment, the method further includes: returning the status information of the filter rod detection device to the user terminal; the user terminal is used to display the status information through a visualization interface; generating a pop-up prompt message or a visual prompt message based on the alarm information, and returning it to the user terminal; the user terminal is used to display the pop-up prompt message or the visual prompt message through the visualization interface.
[0083] Among them, the visual prompt message can be understood as the alarm information processed by highlighting, bolding, or using a conspicuous color such as red.
[0084] Optionally, the web server 106 returns the status information of the filter rod detection device to the user terminal, and the user terminal displays the status information through a visualization interface, including displaying the online, offline, and maintenance status of the filter rod detection device, and generating a pop-up prompt message or a visual prompt message based on the alarm information, and returning it to the user terminal, and the user terminal displays the pop-up prompt message or the visual prompt message through the visualization interface.
[0085] According to the foregoing embodiments, the web server generates a pop-up prompt message or a visual prompt message based on the alarm information, and returns the generated pop-up prompt message or visual prompt message and the status information of the filter rod detection device to the user terminal. The user terminal realizes the display of the status information, pop-up prompt message, or visual prompt message through the visualization interface. By displaying the status information of the filter rod detection device, users can monitor the online status of the device in real time, control the detection process, and avoid the ineffective increase in costs. Secondly, generating a pop-up prompt message or a visual prompt message based on the alarm information and returning it to the user terminal, and also displaying it through the visualization interface, improves the technical effect of realizing the alarm of the alarm information, thereby helping users respond quickly to the failure, and further improving the reliability and practicality of the filter rod detection process.
[0086] In one embodiment, the method further includes: determining whether the detection data is within a preset qualified range; generating a control instruction based on the determination result and sending it. The filter rod detection device receives the control instruction sent by the web server by subscribing to a topic including the device address of the filter rod detection device.
[0087] Exemplarily, the web server 106 performs a quality judgment on the detection data, determines whether the detection data is within a preset qualified range, generates a control instruction based on the determination result and broadcasts it. The filter rod detection device 102 receives the control instruction sent by the web server by subscribing to a topic including the device of the filter rod detection device 102.
[0088] Based on the above embodiments, by performing a quality judgment on the detection data, generating a control instruction based on the judgment result, and broadcasting the control instruction, the filter rod detection device needs to subscribe to a topic including its own device address in order to successfully receive the corresponding control instruction, thereby realizing the smooth control of the detection process, avoiding the wrong control of the control instruction, and achieving the technical effects of improving production efficiency and product quality.
[0089] In an exemplary embodiment, as Figure 3 shown, a filter rod detection method based on the MQTT protocol is provided. Taking the method applied to the filter rod detection device 102 in Figure 1 as an example, it includes the following steps S301 to S303. Wherein:
[0090] Step S301, obtaining the detection data of the detected target cigarette filter rod.
[0091] Step S302, generating an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulating a JSON data packet with the theme format of platformTopic and the MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device.
[0092] Optionally, when the filter rod detection device 102 detects the target cigarette filter rod, it collects the detection data once for each detected sample. The collected detection data includes but is not limited to parameters such as the length, diameter, and draw resistance of the filter rod. The filter rod detection device 102 processes the operation information (device status information, timestamp, etc.) and detection data of the filter rod detection device 102 to form an XML format data string, and encapsulates a JSON data packet according to the XML data string and the device identification of the filter rod detection device. The theme format of the JSON data packet is platformTopic / MAC address, where the MAC address is the unique identification of the filter rod detection device.
[0093] Based on the above embodiments, the filter rod detection device encapsulates the collected data into a unified data format including device identification, timestamp, detection items and values, preparing data for subsequent data reporting. By means of data encapsulation, the independence of various types of data is ensured, and at the same time, compression and encapsulation also ensure the security and integrity of the data itself during the transmission process.
[0094] Step 303, upload the JSON data packet to the MQTT server through the MQTT protocol; the MQTT server is used to receive each JSON data packet and forward the JSON data packet to the web server whose subscribed topic includes platformTopic; the web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information and alarm information of the filter rod detection device.
[0095] Exemplarily, the filter rod detection device 102 uploads the JSON data packet to the MQTT server 104 through the MQTT protocol. The MQTT server 104 receives each JSON data packet and forwards the JSON data packet to the web server 106 whose subscribed topic includes platformTopic. The web server 106 processes the JSON data packet to obtain the detection device of the target cigarette filter rod, the status information and alarm information of the filter rod detection device.
[0096] Based on the above embodiments, the JSON data packet is uploaded to the MQTT server through the MQTT protocol. The MQTT server forwards the JSON data packet to the web server, and the web server performs data processing to achieve detection. Through the MQTT protocol, low-latency and highly reliable data transmission is achieved, ensuring the real-time performance and stability of the monitoring system.
[0097] In one of the embodiments, as Figure 4 shown, a filter rod detection system based on the MQTT protocol is provided. The system includes a filter rod detection device, an MQTT server and a web server;
[0098] The filter rod detection device is used to obtain the detection data of the detected target cigarette filter rod; generate an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulate a JSON data packet with the topic format of platformTopic or MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device;
[0099] The filter rod detection device is also used to upload the JSON data packet to the MQTT server through the MQTT protocol;
[0100] An MQTT server, which is used to receive each JSON data packet and forward the JSON data packet to a web server whose subscribed topic includes platformTopic;
[0101] A web server, which is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0102] Exemplarily, the filter rod detection device acquires the detection data of the detected target cigarette filter rod, generates an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulates a JSON data packet with a topic format of platformTopic or MAC address according to the XML digital string and the identification information of the filter rod detection device, where the MAC address is the device identification of the current filter rod detection device, uploads the JSON data packet to the MQTT server through the MQTT protocol, the MQTT server receives each JSON data packet, and forwards the JSON data packet to a web server whose subscribed topic includes platformTopic, and the web server processes the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information. Through the MQTT protocol, low-latency and high-reliability data transmission is achieved, ensuring the real-time performance and stability of the monitoring system, effectively monitoring the operation status of the filter rod detection device, promptly responding to device anomalies, and improving production efficiency and product quality.
[0103] In an exemplary embodiment, as Figure 5 shown, a specific implementation manner of a filter rod detection method based on the MQTT protocol is provided, where:
[0104] System composition:
[0105] Filter rod detection device: It has a data acquisition function, can collect various detection data of the cigarette filter rod in real time, and after encapsulating the data in a preset unified format, synchronously send it to the local control terminal and the MQTT server.
[0106] Local control terminal: Responsible for receiving the data of the filter rod detection device and performing preliminary data processing and device control.
[0107] MQTT server: As a data transmission transfer station, it communicates with the filter rod detection device using the MQTT protocol, receives and forwards the device data to the Web server.
[0108] Web server: Communicates with the MQTT server through the MQTT protocol, subscribes to relevant topics to receive the data of the filter rod detection device, and performs operations such as classification, processing, analysis, and storage of the data.
[0109] Visualization Interface: Provide an intuitive display platform for real-time display of the operating status, sampling status, detection data, statistical data, and alarm information of the filter rod detection device.
[0110] System Functions:
[0111] Data Communication: The filter rod detection device and the MQTT server perform efficient and stable data communication through the MQTT protocol.
[0112] Data Encapsulation: The filter rod detection device encapsulates the collected data into a unified data format containing device identification, timestamp, detection items, and values.
[0113] Data Subscription and Forwarding: The Web server subscribes to specific topics and receives the filter rod detection device data forwarded by the MQTT server.
[0114] Data Processing and Analysis: The Web server classifies, processes, and analyzes the received data and sends control instructions or messages based on the analysis results.
[0115] Remote Control and Notification: The filter rod detection device subscribes to topics based on its own MAC address and receives remote control instructions and message notifications from the Web server.
[0116] Real-time Monitoring and Display: The visualization interface real-time displays the device status, detection data, statistical data, and alarm information in various forms such as tables, line charts, and pop-up windows.
[0117] The specific steps are as follows:
[0118] 1. Data Collection and Sending:
[0119] 1.1. When the filter rod detection device detects a cigarette filter rod, it collects detection data once for each detected sample.
[0120] 1.2. The collected detection data includes but is not limited to parameters such as filter rod length, diameter, and draw resistance.
[0121] 1.3. The filter rod detection device processes the collected detection data with other relevant information (such as device status, timestamp, etc.) to form an XML format data string.
[0122] 1.4. The filter rod detection device encapsulates the XML data string and a unique message number (i.e., the device identification of the aforementioned filter rod detection device) into a JSON format data packet and sends it to the MQTT server through the MQTT protocol. The message sending format is as Figure 6 shown, and the topic format of the message is platformTopic / MAC address, where the MAC address is the unique identifier of the filter rod detection device.
[0123] 2. Message Receiving and Processing:
[0124] 2.1. The Web server listens to the topic platformTopic / # to obtain messages sent by all filter rod detection devices.
[0125] 2.2. After receiving the message, the Web server processes the message as follows:
[0126] Classification: Distinguish detection data, device status messages, and alarm messages.
[0127] Analysis: Judge the quality of the detection data to determine whether the data is within the preset qualified range.
[0128] Storage: Save the processed detection data and device status messages to the database for historical data query and analysis.
[0129] Push: Save the alarm message to the database and push it to the visualization interface in real time for alarm prompt.
[0130] 3. Visualization Interface Display:
[0131] The visualization interface provides the following functions:
[0132] 3.1. Real-time display of the detection data of the filter rod detection device, including but not limited to table and chart forms.
[0133] 3.2. Display device status messages, such as device online, offline, maintenance status, etc.
[0134] 3.3. Real-time prompt of alarm messages, and inform the operator of device abnormalities through pop-up windows or other visual prompt methods.
[0135] Compared with the prior art, the present application has the following technical advantages:
[0136] 1. It can monitor the online status, measurement data, and error alarms of the filter rod detection device in real time, effectively improving the monitoring efficiency.
[0137] 2. Through data processing and analysis of the Web server, the system can respond to device abnormalities in a timely manner, ensuring production quality and efficiency.
[0138] 3. The visualization interface provides intuitive data display, facilitating the operator to quickly understand the device status and detection results.
[0139] 4. It effectively solves the deficiencies of traditional data acquisition systems in terms of real-time performance and fault response, improving the reliability and practicality of the entire target cigarette filter rod detection.
[0140] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0141] Based on the same inventive concept, an embodiment of the present application further provides a filter rod detection device based on the MQTT protocol for implementing the above-mentioned filter rod detection method based on the MQTT protocol. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the filter rod detection device based on the MQTT protocol provided below can refer to the limitations on the filter rod detection method based on the MQTT protocol in the above text, and will not be repeated here.
[0142] In an exemplary embodiment, as Figure 7 shown, a filter rod detection device based on the MQTT protocol is provided, which is applied to a web server and includes: a forwarding data packet receiving module 701 and a data packet processing module 702, where:
[0143] The forwarding data packet receiving module 701 is used to receive the JSON data packet forwarded by the MQTT server; the MQTT server is used to receive the JSON data packets uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated based on the XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and the MAC address, and the MAC address is the device address of the filter rod detection device.
[0144] The data packet processing module 702 is used to perform data processing on the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0145] In an embodiment, the data packet processing module 702 further includes a parsing sub-module and a classification module, where:
[0146] A parsing sub-module, configured to parse the JSON data packet based on a pre-set parsing library to obtain the parsed data.
[0147] A classification sub-module, configured to classify the parsed data according to a predefined format or field name, obtain the detection data of the target cigarette filter rod, the status information and alarm information of the filter rod detection device, and store them.
[0148] In one embodiment, the data packet processing module 702 is further configured to generate a data table based on the numerical data and classification data in the detection data, and generate a data chart according to the numerical data, classification data and sequential data in the detection data, and return them to the user terminal; the user terminal is configured to display the data table and data chart through a visualization interface.
[0149] In an exemplary embodiment, the data packet processing module 702 is further configured to return the status information of the filter rod detection device to the user terminal; the user terminal is configured to display the status information through a visualization interface; generate a pop-up prompt message or a visual prompt message based on the alarm information, and return them to the user terminal; the user terminal is configured to display the pop-up prompt message or the visual prompt message through a visualization interface.
[0150] In one embodiment, the classification sub-module is further configured to determine whether the detection data is within a preset qualified range; generate a control instruction based on the determination result and send it. The filter rod detection device receives the control instruction sent by the web server by subscribing to a topic including the device address of the filter rod detection device.
[0151] In an exemplary embodiment, as Figure 8 shown, a filter rod detection device based on the MQTT protocol is provided, which is applied to a filter rod detection device, and includes: a detection data acquisition module 801, a data packet encapsulation module 802, and a data packet upload module 803, where:
[0152] The detection data acquisition module 801 is configured to acquire the detection data of the detected target cigarette filter rod;
[0153] The data packet encapsulation module 802 is configured to generate an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulate a JSON data packet with the theme format of platformTopic and the MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device;
[0154] The data packet uploading module 803 is used to upload JSON data packets to the MQTT server through the MQTT protocol; the MQTT server is used to receive each JSON data packet and forward the JSON data packet to the web server whose subscribed topic includes platformTopic; the web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
[0155] Each module in the above filter rod detection device based on the MQTT protocol can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in hardware form or independent of it, or stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0156] In an exemplary embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 9 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store JSON data packets, the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through a network connection. When the computer program is executed by the processor, it implements a filter rod detection method based on the MQTT protocol.
[0157] Those skilled in the art can understand that Figure 9 the structure shown in
[0158] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements. In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, it implements the filter rod detection method based on the MQTT protocol in the above embodiment.
[0159] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the filter rod detection method based on the MQTT protocol in the above embodiment is implemented.
[0160] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the filter rod detection method based on the MQTT protocol in the above embodiment is implemented.
[0161] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0162] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., and are not limited thereto. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., and are not limited thereto.
[0163] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope recorded in the present application.
[0164] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A filter rod detection method based on the MQTT protocol, characterized in that, Applied to a web server, the method includes: Receiving a JSON data packet forwarded by an MQTT server; the MQTT server is used to receive JSON data packets uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated based on an XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and the MAC address, and the MAC address is the device address of the filter rod detection device; Performing data processing on the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and alarm information.
2. The method according to claim 1, wherein The performing data processing on the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and alarm information includes: Parsing the JSON data packet based on a pre-set parsing library to obtain the parsed data; Classifying the parsed data according to a predefined format or field name to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and alarm information and storing them.
3. The method according to claim 2, wherein The method further includes: Generating a data table based on the numerical data and categorical data in the detection data, and generating a data chart based on the numerical data, categorical data, and sequential data in the detection data, and returning them to the user terminal; the user terminal is used to display the data table and the data chart through a visualization interface.
4. The method according to claim 3, wherein The method further includes: Returning the status information of the filter rod detection device to the user terminal; the user terminal is used to display the status information through the visualization interface; Generating a pop-up prompt message or a visual prompt message based on the alarm information, and returning it to the user terminal; the user terminal is used to display the pop-up prompt message or the visual prompt message through the visualization interface.
5. The method according to claim 2, wherein The method further includes: Judging whether the detection data is within a preset qualified range; Generating a control instruction based on the judgment result and sending it. The filter rod detection device receives the control instruction sent by the web server by subscribing to a topic including the device address of the filter rod detection device.
6. A filter rod detection method based on the MQTT protocol, characterized in that, Applied to a filter rod detection device, the method includes: Obtaining the detection data of the detected target cigarette filter rod; Generating an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulating a JSON data packet with a topic format of platformTopic and MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device; Upload the JSON data packet to the MQTT server through the MQTT protocol; the MQTT server is used to receive each JSON data packet and forward the JSON data packet to a web server whose subscribed topic includes platformTopic; The web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
7. A filter rod detection system based on the MQTT protocol, characterized in that, The system includes a filter rod detection device, an MQTT server, and a web server; The filter rod detection device is used to obtain the detection data of the detected target cigarette filter rod; Generate an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulate a JSON data packet with the topic format of platformTopic or MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device; The filter rod detection device is also used to upload the JSON data packet to the MQTT server through the MQTT protocol; The MQTT server is used to receive each JSON data packet and forward the JSON data packet to a web server whose subscribed topic includes platformTopic; The web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
8. A filter rod detection device based on the MQTT protocol, characterized in that, Applied to a web server, the device includes: A forwarded data packet receiving module, used to receive the JSON data packet forwarded by the MQTT server; the MQTT server is used to receive the JSON data packets uploaded by each filter rod detection device through the MQTT protocol; the JSON data packet is encapsulated and generated based on the XML data string and the identification information of the filter rod detection device, and the XML data string is generated according to the operation information of the filter rod detection device and the detection data of the target cigarette filter rod detected by the filter rod detection device; the topic format of the JSON data packet is platformTopic and MAC address, and the MAC address is the device address of the filter rod detection device; A data packet processing module, used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
9. A filter rod detection device based on the MQTT protocol, characterized in that, Applied to a filter rod detection device, the device includes: A detection data acquisition module, used to obtain the detection data of the detected target cigarette filter rod; A data packet encapsulation module, used to generate an XML data string based on the operation information and detection data of the filter rod detection device, and encapsulate a JSON data packet with the topic format of platformTopic and MAC address according to the XML data string and the identification information of the filter rod detection device; the MAC address is the device address of the filter rod detection device; A data packet upload module for uploading the JSON data packet to an MQTT server via the MQTT protocol; the MQTT server is used to receive each of the JSON data packets and forward the JSON data packet to a web server whose subscribed topic includes platformTopic; The web server is used to process the JSON data packet to obtain the detection data of the target cigarette filter rod, the status information of the filter rod detection device, and the alarm information.
10. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.