A dynamic adaptation system, method, device and storage medium for Internet of Things devices
Through the dynamic adaptation system of IoT devices of business modules and adaptation modules, the Groovy language and parameter mapping unit are used to achieve non-differential interaction with devices from multiple manufacturers, solving the problems of bloated code and poor usability in existing technologies and improving the maintainability and stability of the system.
Patent Information
- Application Number
- CN202411561497.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-11-04
AI Technical Summary
The existing IoT device adaptation system has bloated code and poor maintainability due to the wide variety of devices and different manufacturers. In addition, connecting to new devices or modifying protocols requires redeployment, which affects the system's availability and stability.
The dynamic adaptation system for IoT devices, consisting of business modules and adaptation modules, achieves non-differentiated interaction through a unified interface, shields device details using communication templates and parameter mapping units written in Groovy, and maintains state consistency in combination with a state transition unit.
It improves the maintainability and scalability of the system, reduces development workload, improves development efficiency, reduces labor costs, and achieves seamless upgrades through dynamic language features, thereby improving system stability.
Smart Images

Figure CN119363824B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer software application technology, and in particular to a dynamic adaptation system, method, device and storage medium for Internet of Things devices. Background Art
[0002] With the rapid development of the Internet of Things (IoT), more and more applications need to interact with IoT devices. Java, a widely used programming language, is an ideal choice for interfacing with IoT devices due to its cross-platform nature, high efficiency, and rich library support. Currently, the most popular solution for IoT device adaptation and interaction is to use Java to connect to various IoT devices and write the logic code for interacting with them.
[0003] However, due to the wide variety of IoT devices, each type requires unique integration methods, requiring custom integration code for each device type, making it impossible to share code. Furthermore, the same device type is manufactured by different manufacturers, each with its own unique communication protocols. Therefore, each device requires a custom integration code set for each manufacturer, resulting in bloated system code and poor maintainability. Furthermore, integrating new devices or modifying existing device communication protocols requires re-releasing and redeploying the integration system, resulting in poor usability and stability. Summary of the Invention
[0004] Based on this, it is necessary to provide a dynamic adaptation system, method, device and storage medium for IoT devices to address the above technical issues.
[0005] A dynamic adaptation system for IoT devices, the system consisting of a business module and an adaptation module;
[0006] The business module contains several submodules. When interacting with various types of IoT devices from various manufacturers, it calls the unified interface of the adapter module, sends the corresponding operation instructions and related parameters of the IoT device to the adapter module, and receives the return results of the IoT device forwarded by the adapter module. Based on the adapter module, the business module realizes the same adaptive interaction with various types of IoT devices from various manufacturers. The relevant parameters include the manufacturer code, device type and business parameters of the IoT device.
[0007] The adaptation module includes an information storage and query unit, a parameter mapping unit, and a communication template execution unit;
[0008] Among them, the information storage and query unit is used to configure and maintain the corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer before interaction, and send all operation instructions to the business module; during interaction, according to the operation instructions and related parameters sent by the business module, query the communication template, communication information, and input and output parameter templates corresponding to the IoT device;
[0009] The parameter mapping unit is used to map the business parameters sent by the business module to the input parameter template corresponding to the operation instruction of the IoT device, and based on the mapped input parameter template, the business module can call IoT devices of various types from various manufacturers without distinction; and after receiving the return result of the IoT device, it is used to map the return result to the output parameter template corresponding to the operation instruction of the IoT device, and based on the mapped output parameter template, the business module can receive the return result of IoT devices of various types from various manufacturers without distinction;
[0010] The communication template execution unit is used to realize interaction with the IoT device by dynamically executing the communication method in the communication template corresponding to the IoT device, and after receiving the result returned by the IoT device, feed the returned result back to the parameter mapping unit.
[0011] Furthermore, the operation instructions are defined as dictionary values. The communication template, communication information, and the input and output parameter templates corresponding to the operation instructions are maintained in the dictionary table. Once maintained, they are used permanently. When modifications are required, they can be modified and updated using the dynamic loading feature of the Groovy language.
[0012] Furthermore, the communication template is used to configure the communication method used when interacting with IoT devices, including HTTP communication template, SOCKET communication template and MQTT communication template; among them, the HTTP communication template uses the HTTP protocol to interact with IoT devices, the SOCKET communication template uses the SOCKET method to interact with IoT devices, and the MQTT communication template uses the message publishing and subscription method to interact with IoT devices.
[0013] Furthermore, the communication information includes a communication address and port, which are used to bind the communication mode in the communication template to various operation instructions of the IoT device.
[0014] Furthermore, the mapping principles of input parameter templates and output parameter templates include:
[0015] Use the JAVA regular matching mechanism to replace the parameter placeholder mapping of the input template with the business parameters sent by the business module;
[0016] Utilize the JAVA regular matching mechanism to replace the parameter placeholder mapping of the output template with the return result of the IoT device.
[0017] Furthermore, the adaptation module also includes a state conversion unit, which converts the multi-field return results of various types of IoT devices from various manufacturers into fixed-field status codes by maintaining a state conversion template based on an array format, and feeds the fixed-field status codes back to the business module, so as to keep the status codes received by the business module consistent with the status codes of various types of IoT devices from various manufacturers.
[0018] A method for dynamic adaptation of an Internet of Things device, which is applied to the above-mentioned dynamic adaptation system for an Internet of Things device, comprises the following steps:
[0019] Before interaction, the information storage and query unit in the adaptation module configures and maintains corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer, and sends all operation instructions to the business module;
[0020] During interaction, the unified interface of the adaptation module is called according to several sub-modules in the business module, and the operation instructions and related parameters corresponding to the IoT device are sent to the adaptation module. The response results of the IoT device forwarded by the adaptation module are received, and the business module is based on the adaptation module to achieve non-differential adaptation and interaction with various types of IoT devices from various manufacturers.
[0021] Among them, based on the adaptation module, the business module can achieve the same adaptation interaction with various types of IoT devices from various manufacturers, including:
[0022] The information storage and query unit in the adaptation module obtains the operation instructions and related parameters sent by the business module, and queries the communication template, communication information, and input and output parameter templates corresponding to the IoT device based on the operation instructions and related parameters; wherein the relevant parameters include the manufacturer code, device type, and business parameters of the IoT device;
[0023] According to the parameter mapping unit in the adaptation module, the business parameters sent by the business module are mapped to the input parameter template corresponding to the operation instruction of the IoT device. Based on the mapped input parameter template, the business module can call various types of IoT devices from various manufacturers without distinction.
[0024] Then, according to the communication template execution unit in the adaptation module, the communication mode in the communication template corresponding to the IoT device is dynamically executed to realize the interaction with the IoT device, and after receiving the result returned by the IoT device, the returned result is fed back to the parameter mapping unit;
[0025] The return result is further mapped to the output parameter template corresponding to the operation instruction of the IoT device according to the parameter mapping unit. Based on the mapped output parameter template, the business module is enabled to receive the return results of various types of IoT devices from various manufacturers without distinction. After receiving the return result, the business module realizes the non-discriminatory adaptation and interaction between the business module and various types of IoT devices from various manufacturers according to the response processing logic of the return result.
[0026] In one embodiment, before the business module receives the returned result, the method further includes:
[0027] According to the state transition unit in the adaptation module, a state transition template based on the array format is maintained. The state transition template is used to convert the multi-field return results of various types of IoT devices from various manufacturers into status codes with fixed fields, and the status codes with fixed fields are fed back to the business module to keep the status codes received by the business module consistent with the status codes of various types of IoT devices from various manufacturers.
[0028] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0029] Before interaction, the information storage and query unit in the adaptation module configures and maintains corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer, and sends all operation instructions to the business module;
[0030] During interaction, the unified interface of the adaptation module is called according to several sub-modules in the business module, and the operation instructions and related parameters corresponding to the IoT device are sent to the adaptation module. The response results of the IoT device forwarded by the adaptation module are received, and the business module is based on the adaptation module to achieve non-differential adaptation and interaction with various types of IoT devices from various manufacturers.
[0031] Among them, based on the adaptation module, the business module can achieve the same adaptation interaction with various types of IoT devices from various manufacturers, including:
[0032] The information storage and query unit in the adaptation module obtains the operation instructions and related parameters sent by the business module, and queries the communication template, communication information, and input and output parameter templates corresponding to the IoT device based on the operation instructions and related parameters; wherein the relevant parameters include the manufacturer code, device type, and business parameters of the IoT device;
[0033] According to the parameter mapping unit in the adaptation module, the business parameters sent by the business module are mapped to the input parameter template corresponding to the operation instruction of the IoT device. Based on the mapped input parameter template, the business module can call various types of IoT devices from various manufacturers without distinction.
[0034] Then, according to the communication template execution unit in the adaptation module, the communication mode in the communication template corresponding to the IoT device is dynamically executed to realize the interaction with the IoT device, and after receiving the result returned by the IoT device, the returned result is fed back to the parameter mapping unit;
[0035] The return result is further mapped to the output parameter template corresponding to the operation instruction of the IoT device according to the parameter mapping unit. Based on the mapped output parameter template, the business module is enabled to receive the return results of various types of IoT devices from various manufacturers without distinction. After receiving the return result, the business module realizes the non-discriminatory adaptation and interaction between the business module and various types of IoT devices from various manufacturers according to the response processing logic of the return result.
[0036] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0037] Before interaction, the information storage and query unit in the adaptation module configures and maintains corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer, and sends all operation instructions to the business module;
[0038] During interaction, the unified interface of the adaptation module is called according to several sub-modules in the business module, and the operation instructions and related parameters corresponding to the IoT device are sent to the adaptation module. The response results of the IoT device forwarded by the adaptation module are received, and the business module is based on the adaptation module to achieve non-differential adaptation and interaction with various types of IoT devices from various manufacturers.
[0039] Among them, based on the adaptation module, the business module can achieve the same adaptation interaction with various types of IoT devices from various manufacturers, including:
[0040] The information storage and query unit in the adaptation module obtains the operation instructions and related parameters sent by the business module, and queries the communication template, communication information, and input and output parameter templates corresponding to the IoT device based on the operation instructions and related parameters; wherein the relevant parameters include the manufacturer code, device type, and business parameters of the IoT device;
[0041] According to the parameter mapping unit in the adaptation module, the business parameters sent by the business module are mapped to the input parameter template corresponding to the operation instruction of the IoT device. Based on the mapped input parameter template, the business module can call various types of IoT devices from various manufacturers without distinction.
[0042] Then, according to the communication template execution unit in the adaptation module, the communication mode in the communication template corresponding to the IoT device is dynamically executed to realize the interaction with the IoT device, and after receiving the result returned by the IoT device, the returned result is fed back to the parameter mapping unit;
[0043] The return result is further mapped to the output parameter template corresponding to the operation instruction of the IoT device according to the parameter mapping unit. Based on the mapped output parameter template, the business module is enabled to receive the return results of various types of IoT devices from various manufacturers without distinction. After receiving the return result, the business module realizes the non-discriminatory adaptation and interaction between the business module and various types of IoT devices from various manufacturers according to the response processing logic of the return result.
[0044] Compared with the existing technology, the above-mentioned IoT device dynamic adaptation system, method, device and storage medium have the following technical effects:
[0045] 1. The adaptation module provides a unified interface. By calling this unified interface, the business module can efficiently send operation instructions and related parameters to the adaptation module for dynamic adaptation of IoT devices, and receive device feedback forwarded by the adaptation module. The adaptation module can shield the details of the interaction between the business module and various types of IoT devices from various manufacturers, greatly improving the maintainability and scalability of the system.
[0046] 2. Based on the information storage and query unit in the adaptation module, the operation instructions, communication templates, communication information and input and output parameter templates corresponding to the operation instructions of various types of IoT of various manufacturers are configured and maintained. This can greatly reduce the development workload, solve the problem that the docking code cannot be shared when docking various IoT devices, greatly improve development efficiency, and reduce labor costs and system maintenance costs.
[0047] 3. The communication template is written in Groovy. By leveraging the dynamic language features of Groovy, the system can be updated and upgraded without the user's knowledge, solving the problem of poor system availability and stability caused by the need to redeploy after code modification. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 This is a schematic diagram of the structure of a dynamic adaptation system for an Internet of Things device in one embodiment;
[0049] Figure 2A schematic diagram of the principle of achieving uniform adaptive interaction between a business module and various types of IoT devices from various manufacturers based on an adaptation module in one embodiment;
[0050] Figure 3 1 is a flow chart of a method for dynamic adaptation of an Internet of Things device according to an embodiment;
[0051] Figure 4 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0053] In one embodiment, a dynamic adaptation system for IoT devices is provided. The usage scenario of the system is an IoT platform or a platform that needs to connect to various IoT devices (such as access control, parking, cameras, etc.). Based on the dynamic adaptation system for IoT devices, unified management of various types of IoT devices from various manufacturers can be achieved, and relevant remote control of the devices can be performed, and the operating status of the devices can also be monitored.
[0054] like Figure 1 As shown in the figure, the IoT device dynamic adaptation system consists of a business module and an adaptation module;
[0055] The business module contains several submodules. When interacting with various types of IoT devices from various manufacturers, it calls the unified interface process of the adapter module, sends the corresponding operation instructions and related parameters of the IoT device to the adapter module, and receives the return results of the IoT device forwarded by the adapter module. Based on the adapter module, the business module realizes the same adaptive interaction with various types of IoT devices from various manufacturers. The relevant parameters include the manufacturer code, device type and business parameters of the IoT device.
[0056] The adaptation module includes an information storage and query unit, a parameter mapping unit, and a communication template execution unit. The principle of achieving non-differential adaptation and interaction between the business module and various types of IoT devices from various manufacturers based on the adaptation module is as follows: Figure 2 shown.
[0057] Among them, the information storage and query unit is used to configure and maintain corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for various types of IoT devices of various manufacturers before interaction, and send all operation instructions to the business module; during interaction, according to the operation instructions and related parameters sent by the business module, the communication templates, communication information, and input and output parameter templates corresponding to the IoT devices are queried.
[0058] Specifically, the operation instructions are defined as dictionary values and are provided to the business module for use when calling the adapter module. Based on the operation instructions, the business module does not need to pay attention to the manufacturer of the IoT device and the interaction protocol, thereby improving the interaction efficiency between the business module and the IoT device. Specifically, the operation commands defined for access control type devices are: remote door opening, face recognition, and communication record query. The operation commands defined for parking type devices are: channel information query, bar raise, whitelist issuance, and communication record query. The operation commands defined for camera type devices are: obtain real-time playback stream, playback directory query, obtain playback stream, and pan / tilt control.
[0059] Specifically, communication templates, communication information, and the input and output parameter templates corresponding to operation instructions are maintained in a dictionary table. Once maintained, they are permanently used. When modifications are needed, they can be modified and updated using the dynamic loading feature of the Groovy language. All of this information is configured on the page, without the need for code, making it convenient and quick.
[0060] Specifically, communication templates are used to configure the communication methods used when interacting with IoT devices, including HTTP (Hypertext Transfer Protocol) communication templates, SOCKET (socket) communication templates, and MQTT (Message Queuing Telemetry Transport) communication templates.
[0061] The HTTP communication template uses the HTTP protocol to interact with IoT devices, specifically defining HTTP communication methods such as GET, POST, PUT, and DELETE. The GET method is used to obtain resources from the server, the POST method is used to submit data to the server, the PUT method is used to upload or update resources to the server, and the DELETE method is used to delete resources on the server. The OCKET communication template uses the SOCKET method to interact with IoT devices, while the MQTT communication template uses a publish-subscribe messaging method to interact with IoT devices.
[0062] Communication templates written in Groovy are maintained on the page, taking advantage of the dynamic language features of Groovy to complete system updates and upgrades without the user's awareness, solving the problem of poor system availability and stability caused by the need to redeploy after code modification.
[0063] Specifically, communication information includes the communication address and port number, which are used to bind the communication methods in the communication template to various operation commands of the IoT device. For example, if Manufacturer 1's access control device uses the HTTP protocol for interaction, set Manufacturer 1's HTTP communication address and port number, bind the POST method of the HTTP communication template to the access control device's door-opening operation command, and bind the GET method of the HTTP model template to the access control device's communication record query operation command.
[0064] Specifically, the format of the input parameter template corresponding to the operation instruction depends on the specific situation of the IoT device. The front-end page only provides an input box, and no specific format verification is required. Because the interaction parameter formats of various types of IoT devices from different manufacturers vary, in order to allow the business module to use the same business parameters to call various IoT devices without any differences, the business parameters passed by the business module need to be formatted into the actual parameter format of each device according to the input parameter module. For example, for the "remote door opening" operation command, the business parameters passed by the business module to the adapter module are (JSON format):
[0065] {
[0066] "deviceId": "xxxx", / / device ID
[0067] "tagId": "xxxx" / / device tag
[0068] }
[0069] The business parameters for the "remote door opening" operation command of manufacturer 1 only require the device identifier (parameter name is DeviceNo) in JSON format. The definition input template is:
[0070] {
[0071] "deviceNo":"${deviceId}"
[0072] }
[0073] The "remote door opening" operation command from manufacturer 2 requires a device identifier (parameter named deviceNum) and a device tag (tagId) in XML format. Therefore, the parameter template is defined as follows:
[0074] <root>
[0075] <devicenum> ${deviceId}< / devicenum>
[0076] <tagid> ${tagId}< / tagid>
[0077] < / root>
[0078] In the input parameter template, ${} is a parameter placeholder. During mapping, it will be replaced with the business parameter value passed by the business module. In this way, you only need to define the input parameter template for each operation command of each manufacturer's device, and the business module can interact with the IoT device without any difference. The business module does not need to pass parameters in different formats according to different types of IoT devices from different manufacturers, which greatly improves the maintainability of the business module.
[0079] Specifically, since the return results of each type of IoT device from each manufacturer are different, in order to enable the business module to receive the return results of each type of IoT device from each manufacturer without any difference, a parameter template is defined for each operation instruction of each type of IoT device from each manufacturer. For example, for the "remote door opening" operation command, the return result format received by the business module is:
[0080] {
[0081] "code":"",
[0082] "msg":""
[0083] }
[0084] The return result format of the "remote door opening" operation command of manufacturer 1 is:
[0085] {
[0086] "result":"0",
[0087] "msg":"Operation successful"
[0088] }
[0089] The return result format of the "remote door opening" operation command of manufacturer 2 is:
[0090] {
[0091] "code":"0",
[0092] "message":"success"
[0093] }
[0094] The parameter template for the "remote door opening" operation command of manufacturer 1 needs to be defined as follows:
[0095] {
[0096] "code":"${result}",
[0097] "msg":"${msg}"
[0098] }
[0099] The parameter template for the "remote door opening" operation command of manufacturer 2 needs to be defined as follows:
[0100] {
[0101] "code":"${code}",
[0102] "msg":"${message}"
[0103] }
[0104] In the output parameter template, ${} is a parameter placeholder, which will be replaced with the specific corresponding value of the return result of the IoT device during mapping. In this way, the return result format of various types of IoT devices from different manufacturers is the same for the business module. There is no need to write a set of parsing code for the return results of various types of IoT devices from different manufacturers, which greatly improves the maintainability of the system.
[0105] The parameter mapping unit is used to map the business parameters sent by the business module to the input parameter template corresponding to the operation instruction of the Internet of Things device, and based on the mapped input parameter template, the business module can make indiscriminate calls to various types of Internet of Things devices from various manufacturers; and is used to map the return result of the Internet of Things device to the output parameter template corresponding to the operation instruction of the Internet of Things device after receiving the return result, and based on the mapped output parameter template, the business module can receive the return result of various types of Internet of Things devices from various manufacturers indiscriminately.
[0106] Specifically, the mapping principles of input parameter templates and output parameter templates include:
[0107] The JAVA regular matching mechanism is used to map and replace the parameter placeholders of the input template with the business parameters sent by the business module. Specifically, for business parameters in JSON format, the string in the parameter placeholder of the input template corresponds to the key in the business parameter in JSON format. The JAVA regular matching method is used to extract the value corresponding to the key in the business parameter and replace it with the parameter placeholder of the input template to obtain the mapped input template.
[0108] Utilize the JAVA regular matching mechanism to replace the parameter placeholder mapping of the output template with the return result of the IoT device.
[0109] The communication template execution unit is used to interact with IoT devices by dynamically executing the communication methods specified in the communication templates corresponding to the IoT devices. Upon receiving the results returned by the IoT devices, the unit feeds the results back to the parameter mapping unit. Specifically, the communication template execution unit first uses Java reflection to instantiate the Groovy object defined in the communication template, and then interacts with the IoT devices by executing the corresponding communication methods in the communication template.
[0110] Furthermore, the adaptation module also includes a state conversion unit. The state conversion unit converts the multi-field return results of various types of IoT devices from various manufacturers into fixed-field status codes by maintaining a state conversion template based on an array format, and feeds the fixed-field status codes back to the business module, so as to keep the status codes received by the business module consistent with the status codes of various types of IoT devices from various manufacturers. The state conversion template is stored in the information storage and query unit. Specifically, if the IoT device returns 100 to represent success, it can be converted to 1 through the state conversion template and then returned to the business module through the unified interface of the adaptation module. The state conversion template is defined as follows:
[0111] [{
[0112] "sourceKey":"code"
[0113] "sourceValue":"100"
[0114] "targetValue":"1"
[0115] }]
[0116] Among them, the state conversion template can define the dynamic conversion of multiple fields, sourceKey is the field name to be converted, sourceValue is the original field value, and targetValue is the converted value.
[0117] In one embodiment, Figure 3 As shown, a method for dynamic adaptation of an Internet of Things device is provided, which is applied to the above-mentioned dynamic adaptation system for an Internet of Things device, and includes the following steps:
[0118] Before interaction, the information storage and query unit in the adaptation module configures and maintains corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer, and sends all operation instructions to the business module;
[0119] During interaction, the unified interface of the adaptation module is called according to several sub-modules in the business module, and the operation instructions and related parameters corresponding to the IoT device are sent to the adaptation module. The response results of the IoT device forwarded by the adaptation module are received, and the business module is based on the adaptation module to achieve non-differential adaptation and interaction with various types of IoT devices from various manufacturers.
[0120] Among them, based on the adaptation module, the business module can achieve the same adaptation interaction with various types of IoT devices from various manufacturers, including:
[0121] The information storage and query unit in the adaptation module obtains the operation instructions and related parameters sent by the business module, and queries the communication template, communication information, and input and output parameter templates corresponding to the IoT device based on the operation instructions and related parameters; wherein the relevant parameters include the manufacturer code, device type, and business parameters of the IoT device;
[0122] When communication information exists, the parameter mapping unit in the adaptation module maps the service parameters sent by the service module to the input parameter template corresponding to the operation instruction of the IoT device. Based on the mapped input parameter template, the service module can call various types of IoT devices from various manufacturers without distinction.
[0123] Then, according to the communication template execution unit in the adaptation module, the communication mode in the communication template corresponding to the IoT device is dynamically executed to realize the interaction with the IoT device, and after receiving the result returned by the IoT device, the returned result is fed back to the parameter mapping unit;
[0124] The return result is further mapped to the output parameter template corresponding to the operation instruction of the IoT device according to the parameter mapping unit. Based on the mapped output parameter template, the business module is enabled to receive the return results of various types of IoT devices from various manufacturers without distinction. After receiving the return result, the business module realizes the non-discriminatory adaptation and interaction between the business module and various types of IoT devices from various manufacturers according to the response processing logic of the return result.
[0125] In one embodiment, before the business module receives the returned result, the method further includes:
[0126] According to the state transition unit in the adaptation module, a state transition template based on the array format is maintained. The state transition template is used to convert the multi-field return results of various types of IoT devices from various manufacturers into status codes with fixed fields, and the status codes with fixed fields are fed back to the business module to keep the status codes received by the business module consistent with the status codes of various types of IoT devices from various manufacturers.
[0127] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4As shown. The computer device includes a processor, memory, network interface, display screen and input device connected via a system bus. 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 and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a dynamic adaptation method for an Internet of Things device is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.
[0128] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0129] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0130] Before interaction, the information storage and query unit in the adaptation module configures and maintains corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer, and sends all operation instructions to the business module;
[0131] During interaction, the unified interface of the adaptation module is called according to several sub-modules in the business module, and the operation instructions and related parameters corresponding to the IoT device are sent to the adaptation module. The response results of the IoT device forwarded by the adaptation module are received, and the business module is based on the adaptation module to achieve non-differential adaptation and interaction with various types of IoT devices from various manufacturers.
[0132] Among them, based on the adaptation module, the business module can achieve the same adaptation interaction with various types of IoT devices from various manufacturers, including:
[0133] The information storage and query unit in the adaptation module obtains the operation instructions and related parameters sent by the business module, and queries the communication template, communication information, and input and output parameter templates corresponding to the IoT device based on the operation instructions and related parameters; wherein the relevant parameters include the manufacturer code, device type, and business parameters of the IoT device;
[0134] According to the parameter mapping unit in the adaptation module, the business parameters sent by the business module are mapped to the input parameter template corresponding to the operation instruction of the IoT device. Based on the mapped input parameter template, the business module can call various types of IoT devices from various manufacturers without distinction.
[0135] Then, according to the communication template execution unit in the adaptation module, the communication mode in the communication template corresponding to the IoT device is dynamically executed to realize the interaction with the IoT device, and after receiving the result returned by the IoT device, the returned result is fed back to the parameter mapping unit;
[0136] The return result is further mapped to the output parameter template corresponding to the operation instruction of the IoT device according to the parameter mapping unit. Based on the mapped output parameter template, the business module is enabled to receive the return results of various types of IoT devices from various manufacturers without distinction. After receiving the return result, the business module realizes the non-discriminatory adaptation and interaction between the business module and various types of IoT devices from various manufacturers according to the response processing logic of the return result.
[0137] 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 following steps are implemented:
[0138] Before interaction, the information storage and query unit in the adaptation module configures and maintains corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer, and sends all operation instructions to the business module;
[0139] During interaction, the unified interface of the adaptation module is called according to several sub-modules in the business module, and the operation instructions and related parameters corresponding to the IoT device are sent to the adaptation module. The response results of the IoT device forwarded by the adaptation module are received, and the business module is based on the adaptation module to achieve non-differential adaptation and interaction with various types of IoT devices from various manufacturers.
[0140] Among them, based on the adaptation module, the business module can achieve the same adaptation interaction with various types of IoT devices from various manufacturers, including:
[0141] The information storage and query unit in the adaptation module obtains the operation instructions and related parameters sent by the business module, and queries the communication template, communication information, and input and output parameter templates corresponding to the IoT device based on the operation instructions and related parameters; wherein the relevant parameters include the manufacturer code, device type, and business parameters of the IoT device;
[0142] According to the parameter mapping unit in the adaptation module, the business parameters sent by the business module are mapped to the input parameter template corresponding to the operation instruction of the IoT device. Based on the mapped input parameter template, the business module can call various types of IoT devices from various manufacturers without distinction.
[0143] Then, according to the communication template execution unit in the adaptation module, the communication mode in the communication template corresponding to the IoT device is dynamically executed to realize the interaction with the IoT device, and after receiving the result returned by the IoT device, the returned result is fed back to the parameter mapping unit;
[0144] The return result is further mapped to the output parameter template corresponding to the operation instruction of the IoT device according to the parameter mapping unit. Based on the mapped output parameter template, the business module is enabled to receive the return results of various types of IoT devices from various manufacturers without distinction. After receiving the return result, the business module realizes the non-discriminatory adaptation and interaction between the business module and various types of IoT devices from various manufacturers according to the response processing logic of the return result.
[0145] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the 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-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0146] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, 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, they should be considered to be within the scope of this specification.
[0147] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A dynamic adaptation system for Internet of Things devices, characterized in that: The system consists of a business module and an adaptation module; The business module includes multiple submodules, which are used to call the unified interface of the adaptation module to send the corresponding operation instructions and related parameters of the IoT device to the adaptation module when interacting with various types of IoT devices from various manufacturers, and receive the return results of the IoT device forwarded by the adaptation module. Based on the adaptation module, the business module can achieve non-differential adaptive interaction with various types of IoT devices from various manufacturers; wherein the related parameters include the manufacturer code, device type and business parameters of the IoT device; The adaptation module includes an information storage and query unit, a parameter mapping unit and a communication template execution unit; Among them, the information storage and query unit is used to configure and maintain corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer before interaction, and send all operation instructions to the business module; during interaction, according to the operation instructions and related parameters sent by the business module, query the communication template, communication information, and input and output parameter templates corresponding to the IoT device; The parameter mapping unit is used to map the business parameters sent by the business module to the input parameter template corresponding to the operation instruction of the Internet of Things device, and based on the mapped input parameter template, the business module can call the various types of Internet of Things devices of various manufacturers without distinction; and is used to map the return result of the Internet of Things device to the output parameter template corresponding to the operation instruction of the Internet of Things device after receiving the return result, and based on the mapped output parameter template, the business module can receive the return result of the various types of Internet of Things devices of various manufacturers without distinction; The communication template execution unit is used to realize interaction with the Internet of Things device by dynamically executing the communication method in the communication template corresponding to the Internet of Things device, and after receiving the result returned by the Internet of Things device, feed back the returned result to the parameter mapping unit.
2. The Internet of Things device dynamic adaptation system according to claim 1, characterized in that: The operation instruction is defined as a dictionary value, and the communication template, communication information, and the input parameter template and output parameter template corresponding to the operation instruction are maintained in the dictionary table. Once maintained, they are used permanently. When modification is required, the dynamic loading feature of the Groovy language can be used to modify and update them.
3. The Internet of Things device dynamic adaptation system according to claim 2, characterized in that: The communication template is used to configure the communication method used when interacting with IoT devices, including HTTP communication template, SOCKET communication template and MQTT communication template; wherein, the HTTP communication template uses the HTTP protocol to interact with IoT devices, the SOCKET communication template uses the SOCKET method to interact with IoT devices, and the MQTT communication template uses the message publishing and subscription method to interact with IoT devices.
4. The Internet of Things device dynamic adaptation system according to claim 2, characterized in that: The communication information includes a communication address and a port, which are used to bind the communication mode in the communication template to various operation instructions of the IoT device.
5. The Internet of Things device dynamic adaptation system according to claim 2, characterized in that: The mapping principles of the input parameter template and the output parameter template include: Using the JAVA regular matching mechanism, the parameter placeholder mapping of the input template is replaced with the business parameters sent by the business module; Utilize the JAVA regular matching mechanism to replace the parameter placeholder mapping of the output template with the return result of the IoT device.
6. The Internet of Things device dynamic adaptation system according to claim 1, characterized in that: The adaptation module also includes a state conversion unit, which converts the multi-field return results of various types of IoT devices from various manufacturers into fixed-field status codes by maintaining a state conversion template based on an array format, and feeds the fixed-field status codes back to the business module, keeping the status codes received by the business module consistent with the status codes of various types of IoT devices from various manufacturers.
7. A method for dynamic adaptation of an Internet of Things device, the method being applied to the dynamic adaptation system for an Internet of Things device according to any one of claims 1 to 6, characterized in that: The method comprises the following steps: Before interaction, the information storage and query unit in the adaptation module configures and maintains corresponding operation instructions, communication templates written in Groovy language, communication information of each manufacturer, and input and output parameter templates corresponding to the operation instructions for each type of IoT device of each manufacturer, and sends all operation instructions to the business module; During interaction, the unified interface of the adaptation module is called according to the multiple submodules in the business module, the operation instructions and related parameters corresponding to the IoT device are sent to the adaptation module, and the return results of the IoT device forwarded by the adaptation module are received. Based on the adaptation module, the business module is adapted to interact with various types of IoT devices from various manufacturers without any difference; The adaptation module is used to implement the same adaptation interaction between the business module and various types of IoT devices from various manufacturers, including: Obtaining the operation instructions and related parameters sent by the business module according to the information storage and query unit in the adaptation module, and querying the communication template and communication information corresponding to the IoT device and the input parameter template and output parameter template corresponding to the operation instruction according to the operation instruction and related parameters; wherein the related parameters include the manufacturer code, device type and business parameters of the IoT device; According to the parameter mapping unit in the adaptation module, the service parameters sent by the service module are mapped to the input parameter template corresponding to the operation instruction of the Internet of Things device, and based on the mapped input parameter template, the service module can call various types of Internet of Things devices of various manufacturers without distinction; Then, according to the communication template execution unit in the adaptation module, the communication mode in the communication template corresponding to the IoT device is dynamically executed to realize the interaction with the IoT device, and after receiving the result returned by the IoT device, the returned result is fed back to the parameter mapping unit; The return result is further mapped to the output parameter template corresponding to the operation instruction of the Internet of Things device according to the parameter mapping unit, and the business module is enabled to receive the return results of various types of Internet of Things devices from various manufacturers without distinction based on the mapped output parameter template. After receiving the return result, the business module realizes the non-differential adaptation interaction between the business module and various types of Internet of Things devices from various manufacturers according to the response processing logic of the return result.
8. The method for dynamic adaptation of IoT devices according to claim 7, wherein: Before the business module receives the returned result, the method further includes: According to the state conversion unit in the adaptation module, a state conversion template based on an array format is maintained, and the state conversion template is used to convert the multi-field return results of various types of IoT devices of various manufacturers into status codes of fixed fields, and the status codes of the fixed fields are fed back to the business module to keep the status codes received by the business module consistent with the status codes of various types of IoT devices of various manufacturers.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 7 to 8 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 7 to 8 are implemented.
Citation Information
Patent Citations
Internet of Things equipment integration system based on mapping file
CN114281787A
Visual editing generation and dynamic analysis system for internet-of-things equipment model
CN118034673A