A software architecture method for IoT edge gateway based on message coupling

The IoT edge gateway software architecture based on message coupling solves the problems of low scalability and insufficient compatibility in the existing technology, achieves high scalability and multi-device compatibility, supports multiple hardware and communication methods, and improves the IoT Application scenarios and development efficiency of networking gateways.

CN117596094BActive Publication Date: 2024-09-13GUANGXI UNIV FOR NATITIES
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202311541569.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-17
Publication Date
2024-09-13
Estimated Expiration
2043-11-17

AI Technical Summary

Technical Problem

The existing edge computing gateway platform has low scalability, is difficult to deploy, and has insufficient compatibility. It cannot meet the needs of IoT devices in terms of information interaction and unified representation of the physical world, limiting its application scenarios.

Method used

Adopt an IoT edge gateway software architecture method based on message coupling, including a message pump module, an initialization configuration module and an IoT device access module. The message pump performs business logic processing on the message data of the entity manager, initializes the manager and parses the gateway. The configuration file supports the abstract classes of three entities: Businesses, Ports and Devices, and uses reflection technology to realize automatic parameter configuration and automatic assembly of components.

Benefits of technology

It achieves high scalability, low code volume, high development efficiency, convenient management and high device compatibility, supports a variety of hardware systems and communication methods, provides remote control and the development and deployment of distributed artificial intelligence models, and improves the Internet of Things gateway applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117596094B
    Figure CN117596094B
Patent Text Reader

Abstract

The present invention belongs to the technical field of Internet of Things. The software architecture includes a message pump module, an initialization configuration module and an Internet of Things device access module; the message pump module is connected to the initialization configuration module and the Internet of Things device access module respectively; the method includes: first, the message pump module performs business logic processing on the message data of each manager, and the manager includes a message manager, a task manager and an entity manager; then, the initialization configuration module initializes the entity manager and parses the gateway configuration file; finally, the Internet of Things device access module is connected to the Internet of Things gateway; wherein the entity manager includes a Business manager, a Port manager and a Device manager. The present invention's method for the software architecture of an Internet of Things edge gateway based on message coupling can solve the problem that edge computing in the prior art requires customized development and poor scalability, and can meet the requirements for the development of future Internet of Things gateway devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of Internet of Things, and in particular relates to an Internet of Things edge gateway software architecture method based on message coupling. Background Art

[0002] The edge computing gateway platform is a comprehensive device that integrates edge computing, gateways, and application platforms. It can extend cloud functions to local edge computing devices, enabling edge computing devices to respond to local events quickly and autonomously, thereby providing low-latency, low-cost, privacy-secure, and locally autonomous local computing services. With the large-scale application of edge computing, edge gateways face increasingly complex challenges in the edge environment, and the smart Internet of Things brings new challenges such as ubiquitous intelligent perception, context-adaptive communication, distributed group intelligence, and cloud-edge collaborative computing. The research on the basic framework of the smart Internet of Things platform has an increasingly important exploration significance. As a gateway device, the Internet of Things gateway can realize protocol conversion between perception networks and communication networks, as well as between different types of perception networks.

[0003] The patent document with application number CN201910082103.X discloses a design architecture based on the edge computing gateway platform, including an external device layer, a HUB layer, a platform gateway layer, a DSE, a data layer, a service layer, an API and a WEB layer connected in sequence; the device of the external device layer transmits the terminal data to the platform gateway layer through the HUB layer for parsing, and sends it in batches to the database of the data layer through the DSE to realize the data storage function; the API receives the query signal, and retrieves the corresponding data in the database through the service layer to realize the data query function. However, the existing edge computing gateway platform has low scalability and is not easy to deploy. The platform gateway layer has a series of problems such as a single compatible and supported data protocol, a small application scope and insufficient openness. It is necessary to develop the gateway in a targeted manner for the corresponding application scenarios, thereby limiting its applicable scenarios on the edge side. Due to the large number of application fields of the Internet of Things, the characteristics and requirements of various applications are different, and the current technical solutions cannot meet the common needs, especially in terms of information interaction and unified representation in the physical world. The scalability is poor. This is extremely unfavorable to the development of the Internet of Things industry, so a method for the software architecture of the Internet of Things edge gateway based on message coupling is invented to solve the above problems. Summary of the invention

[0004] The present invention overcomes the shortcomings of the above-mentioned technical problems and provides an Internet of Things edge gateway software architecture method based on message coupling, which can solve the problem that edge computing in the prior art requires customized development and has poor scalability, and can meet the requirements for the development of future Internet of Things gateway devices.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0006] A method for software architecture of an edge gateway of the Internet of Things based on message coupling, the software architecture comprising a message pump module, an initialization configuration module and an Internet of Things device access module; the message pump module is connected to the initialization configuration module and the Internet of Things device access module respectively; the method comprises: first, the message pump module performs business logic processing on the message data of the entity manager; then, the initialization configuration module initializes each manager and parses out a gateway configuration file, the manager comprising a message manager, a task manager and an entity manager; finally, the Internet of Things device access module is connected to the Internet of Things gateway; wherein, the entity manager comprises a Business manager, a Port manager and a Device manager; specifically:

[0007] The specific method of the message pump module performing business logic processing on the message data of the entity manager is:

[0008] Step 1.1: After the gateway software is started, run the System main program, create the MessageManager message processing thread, create the message subscription mapping, thread pool, message processing context mapping, message processing context object pool, and complete the initialization of the message processing thread;

[0009] Step 1.2: Start the message processing timeout monitoring thread to handle the timeout thread. If a message processor times out, terminate the thread and pass the message to the next message processor for processing;

[0010] Step 1.3: Submit the message to the gateway, MessageManager takes an idle thread from the thread pool as a worker thread, and distributes the message to the worker thread for processing;

[0011] Step 1.4: Identify the message processor list through the message processing thread, obtain a message processing context object from the object pool, and record the message processing start time, message processor list, current message to be processed, and message processor iterator in the message processing context object to complete the initialization of the context object;

[0012] Step 1.5: Use the worker thread to traverse the message processor list in the context, call the message processor according to the list order, execute the processor's MessageHandler message processing method, and update the thread's message processing context object to complete the message processing.

[0013] The specific steps of the initialization configuration module initializing each manager and parsing the gateway configuration file are as follows:

[0014] Step 2.1: Initialize the message manager;

[0015] (1) Instantiate the KL thread, pass in the KL thread callback interface, and create the message subscription mapping required by the message pump and the object pool factory for processing the context as well as the configuration and object pool of its context object pool; at the same time, obtain the idle thread from the thread pool and process the message;

[0016] (2) Start the message processing timeout monitoring thread and process the timed-out thread in a fixed cycle; in each cycle, the gateway pauses and locks the message processing context transaction, then traverses the context object of the message processing thread and terminates the timed-out message processing thread;

[0017] Step 2.2, initialize the task manager;

[0018] (1) Initialize the periodic thread pool.

[0019] (2) Start periodically scanning the task list. If a task times out, stop the worker thread that executes the task and change the state of the task.

[0020] Step 2.3, initialize the entity manager;

[0021] Step 2.4: Read the gateway configuration file through the JSON parser. The configuration file contains three entity modules: Businesses, Ports, and Devices. Convert each module into a corresponding JSON array and send it to the corresponding entity manager. In turn, instantiate the devices and businesses in the above three entity modules through reflection and send them to the corresponding manager thread for management.

[0022] Step 2.5: Instantiate the three entity modules Businesses, Ports, and Devices. The corresponding entity manager obtains the full class name and the class name of the specified class by parsing the JSON array, obtains the constructor of the class with a String type parameter through the constructor, and sets its accessibility; then uses the constructor to call the constructor with parameters, and instantiates the corresponding entity module by passing in the class name of the entity module;

[0023] Step 2.6: After instantiating each configuration in the three entity modules through reflection, a JSON array storing the attribute values ​​of the instantiated class is obtained, and the attributes are assigned values ​​one by one to initialize the instantiation configuration parameters.

[0024] Compared with the prior art, the present invention has the following beneficial effects:

[0025] 1. The present invention provides a method for the software architecture of an edge gateway of the Internet of Things based on message coupling, which uses a message pump as a message coupling mechanism and functional module of a system component, performs task-driven and coupled Internet of Things gateway software architecture through a message pump, and introduces abstract classes of three entities, Businesses, Ports and Devices, and utilizes message coupling to achieve lightweight and high expansion of the framework of the smart Internet of Things gateway. Reflection technology is used to achieve automatic configuration of parameters and automatic assembly of components, improve the efficiency of secondary development, and achieve development framework support at the "class operating system" level.

[0026] 2. Low operating environment, the software operation has low hardware requirements and can support a variety of mainstream embedded hardware systems on the market;

[0027] 3. Low code volume and high development efficiency. Various device control components, port communication components, and protocol parsing components can be provided in the form of libraries. With the help of the open source community, they are constantly improved. The framework software is automatically assembled, and the code reuse rate is high.

[0028] 4. Convenient management: The platform is easy to manage. By formulating the development and launch process of functional modules, it provides coarse-grained authorization management at the functional module level and fine-grained access authentication at the API (Application Program Interface) level in accordance with the SaaS (Software as a Service) and multi-tenant software service model.

[0029] 5. High device compatibility. This framework can be compatible with sensor devices of different manufacturers, different models, different communication methods, and different data formats;

[0030] 6. High business compatibility. This framework can provide remote control, telemetry data upload, distributed artificial intelligence model evolution and distribution, and easily realize the development and deployment of customized cloud and edge businesses. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a framework hierarchical structure diagram in a message coupling-based Internet of Things edge gateway software architecture method of the present invention;

[0032] Figure 2 It is a schematic diagram of the software architecture structure in a message coupling-based Internet of Things edge gateway software architecture method of the present invention;

[0033] Figure 3 This is an application example diagram of an Internet of Things edge gateway software architecture method based on message coupling of the present invention. DETAILED DESCRIPTION

[0034] The present invention is further described below in conjunction with the accompanying drawings and embodiments. It should be noted that the specific embodiments of the present invention are only for the purpose of more clearly describing the technical solution and cannot be used as a limitation on the protection scope of the present invention.

[0035] The present invention establishes an object model for the IoT gateway software system and designs a lightweight and highly scalable software framework to provide developers with secondary development support at the "operating system-like" level. The software architecture design structure diagram is shown in the figure below. Figure 1 , Figure 2 shown.

[0036] See also Figure 3 , a method for software architecture of an IoT edge gateway based on message coupling, the software architecture includes a message pump module, an initialization configuration module and an IoT device access module; the message pump module is connected to the initialization configuration module and the IoT device access module respectively; the method includes: first, the message pump module performs business logic processing on the message data of the entity manager; then, the initialization configuration module initializes each manager and parses the gateway configuration file, the manager includes a message manager, a task manager and an entity manager; finally, the IoT device access module is connected to the IoT gateway IoT cloud platform to realize the mutual connection and data sharing of different IoT devices; wherein, the entity manager includes a Business manager, a Port manager and a Device manager. Figure 2 and Figure 3 As shown, the figure also includes an IoT cloud platform. In a specific application, the IoT cloud platform is connected to the IoT gateway via WAN; the IoT cloud platform and the IoT device access module are connected to the IoT gateway via the HTTP protocol; the IoT device access module is connected to the IoT cloud platform signal via WIFI or other communication methods;

[0037] The message pump is the core part of the gateway software architecture, which is mainly responsible for the business logic processing of message data. The main part of the gateway is regarded as a large message pump, in which each component is abstracted as a virtual entity (Entity) with message processing function, and unified management of all components. Through the inheritance of interfaces and abstract parent classes, the communication and management of various message processors such as Business, Device, Port, etc. Port includes Modbus serial port, Websocket, Bluetooth, GPIO, etc. If there are new business components that need to be added to the framework, you only need to initialize a new message processor, inherit the highest abstract class of Entity, and implement the MessageHandler message processing interface, clarify the attributes of the message processor such as subscription message type and the specific business logic of message processing. The specific method for the message pump module to perform business logic processing on the message data of the entity manager is:

[0038] Step 1.1: After the gateway software is started, run the System main program, create the MessageManager message processing thread, create the message subscription mapping, thread pool, message processing context mapping, message processing context object pool, and complete the initialization of the message processing thread;

[0039] Step 1.2: Start the message processing timeout monitoring thread to handle the timeout thread. If a message processor times out, terminate the thread and pass the message to the next message processor for processing;

[0040] Step 1.3: Submit the message to the gateway, MessageManager takes an idle thread from the thread pool as a worker thread, and distributes the message to the worker thread for processing;

[0041] Step 1.4: Identify the message processor list through the message processing thread, obtain a message processing context object from the object pool, and record the message processing start time, message processor list, current message to be processed, and message processor iterator in the message processing context object to complete the initialization of the context object;

[0042] Step 1.5: Use the worker thread to traverse the message processor list in the context, call the message processor according to the list order, execute the processor's MessageHandler message processing method, and update the thread's message processing context object to complete the message processing.

[0043] Furthermore, the specific steps of the initialization configuration module initializing each manager and parsing the gateway configuration file are as follows:

[0044] Step 2.1: Initialize the message manager;

[0045] (1) Instantiate the KL thread, pass in the KL thread callback interface, and create the message subscription mapping required by the message pump and the object pool factory for processing the context and the configuration and object pool of its context object pool; at the same time, obtain the idle thread from the thread pool and process the message. The process of KL thread processing the message is as follows:

[0046] ①Get the processor list of this message;

[0047] ②Get the message processing object from the object pool;

[0048] ③Initialize the message processing object;

[0049] ④Message processing;

[0050] ⑤Return the message processing object.

[0051] (2) Start the message processing timeout monitoring thread and process the timeout thread in a fixed cycle; in each cycle, suspend the gateway's processing of the message processing context transaction and lock it, then traverse the context object of the message processing thread and terminate the timeout message processing thread; there are two situations when the message thread operation timeout occurs:

[0052] ① The preset message processing time has been exceeded;

[0053] ② Exceeding the maximum operation time specified by the gateway for each internal message processing thread;

[0054] When a message processor times out, the monitoring thread starts to terminate thread processing and passes the message to the next message processor. At the same time, the thread pool runs subsequent message processors and returns the message processing context object when the message processing is completed successfully.

[0055] (3) Instantiate a delayed message processing thread to delay some special demand messages that have a lower priority.

[0056] Step 2.2, initialize the task manager;

[0057] (1) Initialize the periodic thread pool.

[0058] (2) Start periodic execution (execution cycle is 1 second) to scan the task list. If a task execution times out, stop the working thread executing the task and change the status of the task;

[0059] Step 2.3, initialize the entity manager;

[0060] The entity manager includes the Business manager, Port manager and Device manager. All three managers inherit from the abstract class EntityManager and are initialized using the parent class's constructor (through the type specified by the enumeration class EntityType).

[0061] Step 2.4: Use the JAVA compiler to develop and read the gateway configuration file through the JSON parser. The configuration file contains three entity modules: Businesses, Ports, and Devices. Each module is converted into a corresponding JSON array and sent to the corresponding entity manager that has been initialized using the singleton mode. The devices and businesses in the above three entity modules are instantiated in turn through reflection and sent to the corresponding manager thread for management;

[0062] Step 2.5: Instantiate the Businesses module, Ports module, and Devices module respectively. Taking the business in Businesses as an example, the corresponding business manager obtains the full class name of the specified class name and its class name by parsing the JSON array, obtains the constructor of the class with a String type parameter through the constructor, and sets its accessibility; then uses the constructor to call the constructor with parameters and instantiates it by passing in its class name; the instantiation of Ports and Devices is the same as the instantiation process of the above Business.

[0063] Step 2.6: After instantiating each configuration in the three entity modules through reflection, a JSON array storing the attribute values ​​of the instantiated class is obtained, and the attributes are assigned one by one to initialize the instantiation configuration parameters. There are two cases of assignment:

[0064] (1) Non-remote subclass: Use the setFieldValue(Object o, String fieldName, Object value) interface provided by the JDK's built-in reflection tool ClassUtil to assign the value of the attribute in the configuration file to the corresponding instance in the form of a key-value pair.

[0065] (2) Remote subclass: Based on the parameters of the file provided by the instance in the configuration file, the remote subclass is instantiated through reflection, and the attributes of the remote subclass are assigned values ​​according to the process in (1).

[0066] In order to make the IoT gateway more scalable and standardized, a remote class Remote, a remote callback interface IRemoteCallback and a self-injection parameter interface KLInitParam are introduced in the embodiment of the present invention. The remote class defines a series of properties required by the cloud IoT platform, such as: IoT cloud access token, device number, MQTT connection and remote callback interface, etc., and the remote class also defines relevant default data collection and data upload rules.

[0067] Connecting the IoT device access module to the IoT gateway mainly involves matching the Businesses, Ports, and Devices classes to the Businesse, Port, and Device entities of the IoT devices. These three classes inherit from the top-level abstract class Entity. The gateway uses the principle of convention over configuration for IoT device access. Entity regulates the access to IoT devices and defines a series of abstract entities and methods to enable edge devices in the IoT to quickly access the IoT gateway and connect to the cloud.

[0068] The invention discloses a method for software architecture of an edge gateway of the Internet of Things based on message coupling, which uses a message pump as a message coupling mechanism and a functional module of a system component, performs task driving and coupling on the software architecture of the Internet of Things gateway through the message pump, and introduces three abstract classes of entities and two accessories to achieve lightweight and high expansion of a smart Internet of Things gateway framework by means of message coupling.

[0069] The above description is a detailed description of the preferred feasible embodiments of the present invention, but the embodiments are not intended to limit the scope of the patent application of the present invention. All equivalent changes or modified changes completed under the technical spirit suggested by the present invention should fall within the patent scope covered by the present invention.

Claims

1. A method for software architecture of an IoT edge gateway based on message coupling, characterized in that: The software architecture includes a message pump module, an initialization configuration module and an IoT device access module; the message pump module is connected to the initialization configuration module and the IoT device access module respectively; the method includes: first, the message pump module performs business logic processing on the message data of the entity manager; then, the initialization configuration module initializes each manager and parses the gateway configuration file, the manager includes a message manager, a task manager and an entity manager; finally, the IoT device access module is connected to the IoT gateway; wherein the entity manager includes a Business manager, a Port manager and a Device manager; specifically: The specific method of the message pump module performing business logic processing on the message data of the entity manager is: Step 1.1: After the gateway software is started, run the System main program, create the MessageManager message processing thread, create the message subscription mapping, thread pool, message processing context mapping, message processing context object pool, and complete the initialization of the message processing thread; Step 1.2: Start the message processing timeout monitoring thread to handle the timeout thread. If a message processor times out, terminate the thread and pass the message to the next message processor for processing; Step 1.3: Submit the message to the gateway, MessageManager takes an idle thread from the thread pool as a worker thread, and distributes the message to the worker thread for processing; Step 1.4: Identify the message processor list through the message processing thread, obtain a message processing context object from the object pool, and record the message processing start time, message processor list, current message to be processed, and message processor iterator in the message processing context object to complete the initialization of the context object; Step 1.5: Use the worker thread to traverse the message processor list in the context, call the message processor according to the list order, execute the MessageHandler message processing method of the processor, and update the message processing context object of the thread to complete the message processing; The specific steps of the initialization configuration module initializing each manager and parsing the gateway configuration file are as follows: Step 2.1: Initialize the message manager; (1) Instantiate the KL thread, pass in the KL thread callback interface, and create the message subscription mapping required by the message pump and the object pool factory for processing the context as well as the configuration and object pool of its context object pool; at the same time, obtain the idle thread from the thread pool and process the message; (2) Start the message processing timeout monitoring thread and process the timed-out thread in a fixed cycle; in each cycle, the gateway pauses and locks the message processing context transaction, then traverses the context object of the message processing thread and terminates the timed-out message processing thread; Step 2.2, initialize the task manager; (1) Initialize the periodic thread pool; (2) Start periodically scanning the task list. If a task times out, stop the worker thread that executes the task and change the state of the task. Step 2.3, initialize the entity manager; Step 2.4: Read the gateway configuration file through the JSON parser. The configuration file contains three entity modules: Businesses, Ports, and Devices. Convert each module into a corresponding JSON array and send it to the corresponding entity manager. In turn, instantiate the devices and businesses in the above three entity modules through reflection and send them to the corresponding manager thread for management. Step 2.5: Instantiate the three entity modules Businesses, Ports, and Devices. The corresponding entity manager obtains the full class name and the class name of the specified class by parsing the JSON array, obtains the constructor of the class with a String type parameter through the constructor, and sets its accessibility; then uses the constructor to call the constructor with parameters, and instantiates the corresponding entity module by passing in the class name of the entity module; Step 2.6: After instantiating each configuration in the three entity modules through reflection, a JSON array storing the attribute values ​​of the instantiated class is obtained, and the attributes are assigned values ​​one by one to initialize the instantiation configuration parameters.

Citation Information

Patent Citations

  • Dynamic pluggable component based-Internet of things middleware system

    CN103218220A

  • Business function implementation method, device and equipment of Internet of Things terminal and storage medium

    CN114221865A

  • Access method and device of Internet of Things equipment

    CN116320077A

  • Software appliance framework

    US20090249279A1