Method and device for interaction between control interface and Internet of Things device
Through the WebView2 control, cross-platform communication between the operation interface system and the execution processing system is realized, and multi-threaded capabilities are used to interact with IoT devices, solving the application limitations of traditional Web applications in the fields of industrial control and IoT, and achieving efficient multi-threaded task processing and underlying hardware resource access.
Patent Information
- Application Number
- CN202510321275.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-06-27
AI Technical Summary
Traditional Web applications are limited by a single-threaded model in the browser and cannot effectively handle complex multi-threaded tasks. The operating interface system cannot directly access the underlying hardware resources, which limits its application in the fields of industrial control and the Internet of Things.
By using WebView2 controls, cross-platform communication between the operating interface system and the execution processing system, and using the multi-threading capabilities of the execution processing system to achieve interaction with IoT devices, making up for insufficient access to the underlying hardware resources.
It solves the limitation that the single-threaded model of the operating interface system cannot perform complex tasks, and realizes efficient interaction with IoT devices, meeting the requirements of industrial control systems for deterministic response, high reliability and low latency communication.
Smart Images

Figure CN120216581A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for interacting between a control interface and an Internet of Things device. Background Art
[0002] Traditional Web applications mainly run in a browser environment, and their architecture design is limited by the single-threaded execution model of the browser, which shows obvious limitations when dealing with complex multi-threaded tasks. Especially in the field of industrial control, when real-time data interaction with Internet of Things devices such as Modbus TCP industrial protocols is required, the performance bottleneck of this single-threaded model is particularly prominent.
[0003] Due to the security restrictions of the browser sandbox mechanism, the operation interface system and its related technologies cannot directly access underlying hardware resources, such as key I / O devices like network interfaces and serial ports. This severely restricts the application potential of Web applications in scenarios with high requirements for real-time performance and reliability, such as industrial automation and process control. Although technologies such as WebAssembly have brought higher computing performance to Web applications in recent years, there are still significant deficiencies in underlying hardware access and real-time guarantee. This limitation makes it difficult for traditional Web applications to meet the strict requirements of industrial control systems for deterministic response, high reliability, and low-latency communication, thus restricting their in-depth application and promotion in fields such as the Industrial Internet of Things (IIoT). Summary of the Invention
[0004] The main objective of the present invention is to solve the technical problems that traditional Web applications running in a browser are limited by the single-threaded model of the browser and the operation interface system cannot directly access underlying hardware resources.
[0005] In a first aspect of the present invention, a method for interacting between a control interface and an Internet of Things device is provided. The method for interacting between the control interface system and the Internet of Things device is applied to a system for interacting between a control interface and an Internet of Things device. The system for interacting between the control interface and the Internet of Things device includes: an operation interface system, an execution processing system, and an Internet of Things device. The method for interacting between the control interface and the Internet of Things device includes:
[0006] The operation interface system sends a communication message to the execution processing system through a pre-set WebView2 control. The communication message includes: message encoding, IP address, port, operation type, and register address;
[0007] The execution processing system receives and parses the communication message;
[0008] Creates an Internet of Things device data object according to the port using the ModbusFactory function in the pre-set NModbus library;
[0009] Connect to the Internet of Things device;
[0010] Assemble device data according to the operation type and the register address;
[0011] Read and write the device data through the pre-set IModbusMaster interface and send the device data to the Internet of Things device;
[0012] The Internet of Things device sends the device data to the operation interface system;
[0013] The Internet of Things device sends response data to the execution processing system;
[0014] The execution processing system receives the response data and the message encoding, and sends the response data and the message encoding back to the operation interface system through the PostWebMessageAsString function of the WebView2 control;
[0015] The operation interface system receives the response data and the message encoding.
[0016] Optionally, in the first implementation manner of the first aspect of the present invention, the operation interface system sending a communication message to the execution processing system through the pre-set WebView2 control includes:
[0017] In the operation interface system, use the postMessage function to send a communication message to the execution processing system.
[0018] Optionally, in the second implementation manner of the first aspect of the present invention, the execution processing system receiving and parsing the communication message includes:
[0019] The execution processing system listens for the WebMessageReceived event of the WebView2 control and receives the communication message.
[0020] Optionally, in the third implementation manner of the first aspect of the present invention, the reading and writing the device data through the pre-set IModbusMaster interface and sending the device data to the Internet of Things device includes:
[0021] The execution processing system sends the device data to the Internet of Things device at regular intervals according to the timing sending parameter in the preset device parameters.
[0022] Optionally, in the fourth implementation manner of the first aspect of the present invention, the Internet of Things device sending response data to the execution processing system includes:
[0023] The execution processing system sends the communication message to the Internet of Things device;
[0024] Monitor the connection between the port and the Internet of Things device, and wait to receive response data from the Internet of Things device until the response data is received.
[0025] Optionally, in the fifth implementation manner of the first aspect of the present invention, the operation interface system receiving the response data and the message encoding includes:
[0026] The operation interface system listens for the message event through JavaScript;
[0027] When the message event is triggered, receive the response data and the message encoding sent from the execution processing system.
[0028] Optionally, in the sixth implementation manner of the first aspect of the present invention, the receiving the response data and the message encoding sent from the execution processing system when the message event is triggered includes:
[0029] The operation interface system matches the corresponding requests and responses according to the message encoding;
[0030] After successful matching, display the response data in the specified area of the operation interface system or trigger subsequent logic.
[0031] Optionally, in the seventh implementation manner of the first aspect of the present invention, after the Internet of Things device sends the device data to the operation interface system, it further includes:
[0032] The execution processing system calls the close function to close the connection between the port and the Internet of Things device.
[0033] The second aspect of the present invention provides an interactive device between a control interface and an Internet of Things device, including: a memory and at least one processor, instructions are stored in the memory, and the memory and the at least one processor are interconnected through a line; the at least one processor calls the instructions in the memory to enable the interactive device between the control interface and the Internet of Things device to execute the above-mentioned interactive method between the control interface and the Internet of Things device.
[0034] The third aspect of the present invention provides a computer-readable storage medium, instructions are stored in the computer-readable storage medium, and when it runs on a computer, it enables the computer to execute the above-mentioned interactive method between the control interface and the Internet of Things device.
[0035] In the embodiments of the present invention, cross-platform communication between the execution processing systems is achieved by using the WebView2 control, and by leveraging the multi-threading capabilities of the execution processing systems, the limitation that the single-threaded model of the operation interface system cannot execute complex tasks is solved. At the same time, by interacting between the execution processing systems and the Internet of Things devices, the deficiency that the operation interface system cannot directly access the underlying hardware resources is made up for. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 FIG. is a schematic diagram of an embodiment of the method for the control interface to interact with the Internet of Things devices in the embodiments of the present invention;
[0037] Figure 2 FIG. is a schematic diagram of a specific embodiment of step 110;
[0038] Figure 3 FIG. is a schematic diagram of an embodiment of the device for the control interface to interact with the Internet of Things devices in the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0039] The embodiments of the present invention provide a method, a device and a storage medium for the control interface to interact with the Internet of Things devices.
[0040] The embodiments of the present invention disclosed will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present invention disclosed are shown in the drawings, it should be understood that the present invention disclosed can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present invention disclosed are only for exemplary purposes and are not used to limit the protection scope of the present invention disclosed.
[0041] In the description of the embodiments of the present invention disclosed, the term "including" and its like should be understood as an open inclusion, that is, "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects. There may also be other explicit and implicit definitions hereinafter.
[0042] For ease of understanding, the specific process of the embodiments of the present invention will be described below. Please refer to Figure 1 , an embodiment of the method for the control interface to interact with the Internet of Things devices in the embodiments of the present invention includes:
[0043] The method for the control interface system to interact with Internet of Things devices is applied to the control interface and Internet of Things device interaction system. The control interface and Internet of Things device interaction system includes: an operation interface system, an execution processing system, and Internet of Things devices. The method for the control interface to interact with Internet of Things devices includes:
[0044] 101. The operation interface system sends communication messages to the execution processing system through a pre-set WebView2 control. Among them, the communication messages include: message encoding, IP address, port, operation type, and register address;
[0045] In this embodiment, an HTML user interface is constructed using the operation interface system and runs in the WebView2 control; the execution processing system is WPF, which is responsible for business logic, data processing, hardware control, etc.; through the message passing between the WebView2 control and the execution processing system, the decoupling and collaboration between the front-end and the back-end are realized; the WebView2 control can load remote or local Web content, so the HTML page content can be dynamically updated by sending messages without recompiling or deploying the entire application, where the IP address is the IP address of the Internet of Things device.
[0046] For example, after obtaining data from the execution processing system, the WebView2 control is notified by a message to update the HTML page display.
[0047] The HTML page can send messages through the WebView2 control to request the execution processing system to perform certain operations. For example: reading the status of Internet of Things devices. Performing complex calculation tasks. Accessing the local file system or database.
[0048] The execution processing system can send messages through the WebView2 control to transfer the processing results or status information to the HTML page. For example: real-time updating of sensor data. Displaying the task execution progress. Returning the results of user operations.
[0049] The WebView2 control is based on the Chromium kernel and supports modern Web standards, so the same Web technology can be used to build interfaces on different platforms (such as Windows, macOS, Linux). Through the message passing mechanism, the execution processing system can focus on platform-independent logic, while the interface part realizes cross-platform consistency through the WebView2 control.
[0050] The WebView2 control provides a secure sandbox environment to ensure that Web content does not directly access system resources. Through the message passing mechanism, the interaction between the HTML interface and the execution processing system can be strictly controlled to avoid security problems.
[0051] The following steps can be performed in step 101:
[0052] 1011. In the operation interface system, use the postMessage function to send a communication message to the execution processing system.
[0053] In step 1011, the postMessage function is used for cross - domain communication between different windows, iframes, or tab pages, allowing asynchronous communication between documents from different origins and ensuring the secure transmission of messages; the postMessage function allows one window to send a message to another window, regardless of whether they are of the same origin. This mechanism is widely used in modern web applications, especially in the communication between the main page and iframes, pop - up windows, and the server. The message content is passed through the structured clone algorithm to ensure the security and integrity of the message.
[0054] 102. The execution processing system receives and parses the communication message;
[0055] In this embodiment, the execution processing system receiving and parsing the communication message is a key link in the operation of the entire system. Its role is to achieve efficient cooperation between the HTML page (through the WebView2 control) and the execution processing system. The following are the specific roles of this process:
[0056] The execution processing system needs to listen for messages from the WebView2 control to ensure that it can timely obtain requests or data from the HTML page. Ensure that messages between the operation interface system and the execution processing system can be correctly transmitted. Timely receive requests triggered by user operations or interface events. When the user clicks a button on the interface, the WebView2 control sends a message to the execution processing system. The execution processing system receives the message through the listening mechanism.
[0057] The received communication message is usually structured data (such as a JSON string). The execution processing system needs to parse this data to extract specific operation instructions or parameters. Obtain the operation type, parameters, etc. from the communication message and convert the communication message into a format that the execution processing system can understand.
[0058] According to the parsed message content, the execution processing system calls the corresponding business logic or functional module. Perform specific operations, such as reading data, controlling devices, running algorithms, etc. Call underlying resources: access databases, hardware devices, network services, etc. After the execution processing system completes the operation, it encapsulates the result into a message and sends it back to the WebView2 control so that the operation interface system can update the display. Return the processing result to the operation interface system to ensure that the user can see the effect of the operation. Dynamically update the interface content to enhance the user experience. During the process of receiving, parsing, or executing messages, errors may occur (such as invalid parameters, hardware failures, etc.). The execution processing system needs to handle these errors and return error messages to ensure that the system does not crash when errors occur. Return the error message to the operation interface system to prompt the user or record the log. When receiving and parsing messages, the execution processing system needs to perform security verification on the messages to prevent malicious data or illegal operations and ensure that the message format and content meet the expectations.
[0059] The following steps can be executed in step 102:
[0060] 1021. The execution processing system listens for the WebMessageReceived event of the WebView2 control and receives the communication message.
[0061] In step 1021, by listening for the WebMessageReceived event, the execution processing system can establish a stable communication channel with the WebView2 control to ensure that the messages sent by the operation interface system can be captured by the execution processing system in a timely manner, supporting data exchange between the operation interface system and the execution processing system.
[0062] 103. According to the port, use the ModbusFactory function in the preset NModbus library to create an Internet of Things device data object;
[0063] In this embodiment, initialize the tools and objects required for Modbus communication to prepare for subsequent device connection and data operation. Create a Modbus master station object: Use the ModbusFactory function to create an Internet of Things device data object for communicating with the Internet of Things device. Set communication parameters according to the port (such as serial port or network port), such as baud rate, data bits, stop bits, etc.
[0064] 104. Connect to the Internet of Things device;
[0065] In this embodiment, establish a physical connection with the Internet of Things device to ensure a smooth communication channel.
[0066] 105. Assemble device data according to the operation type and the register address;
[0067] In this embodiment, according to the user's operation requirements (such as reading or writing data) and the register address of the device, a Modbus message is assembled and sent to obtain or modify device data. According to the user's operation type (such as reading holding registers, writing coils, etc.), the corresponding Modbus function code is called. According to the register address and data content, a Modbus message is generated. The message is sent to the Internet of Things device, and the response of the device is received. The response data of the device is parsed and returned to the user or the system status is updated.
[0068] 106. Read and write the device data through the preset IModbusMaster interface and send the device data to the Internet of Things device;
[0069] In this embodiment, by reading device data through the IModbusMaster interface, the status information or sensor data of the Internet of Things device can be obtained, the registers, coils, etc. of the Internet of Things device can be read, the current status of the Internet of Things device can be understood, the data in the sensor registers can be read for monitoring environmental parameters (such as temperature, humidity, pressure, etc.), and by regularly reading data, the device status can be updated in real time, facilitating users or the system to make decisions.
[0070] By writing device data through the IModbusMaster interface, the behavior or configuration of the Internet of Things device can be controlled. By writing to coils or registers, the switch, operation mode, etc. of the device can be controlled; by writing to the configuration register, the working parameters of the device (such as thresholds, alarm conditions, etc.) can be set, and through the write operation, remote control of the device can be achieved.
[0071] Send the result of the read-write operation or the control instruction to the Internet of Things device to ensure that the device can correctly execute the operation or update the status, send the control instruction of the user or the system to the device to achieve remote control, write the configuration parameters or operation instructions to the device to ensure that the device works as expected, and return the result of the read-write operation to the user or the system for further processing.
[0072] Through the IModbusMaster interface, the system can achieve two-way communication with the Internet of Things device, that is, it can read data from the Internet of Things device and also send data to the Internet of Things device, realizing data collection and device control under the same communication framework, supporting real-time reading of the status of the Internet of Things device and sending control instructions to meet dynamic requirements.
[0073] In step 106, the following steps can be executed:
[0074] 1061. The execution processing system regularly sends the device data to the Internet of Things device according to the timing sending parameter in the preset device parameters.
[0075] In step 1061, by sending parameters at regular intervals, the system can automatically send data to the Internet of Things devices according to the set time intervals or conditions without manual intervention. Automatically sending data reduces the complexity and error rate of manual operations. The system can efficiently and accurately complete periodic tasks.
[0076] For example: Send configuration parameters to the device once every 5 minutes.
[0077] Send a device status query instruction at 2 am every day.
[0078] The regular sending mechanism can ensure the timely update of device data, avoiding data lag or loss; by sending data regularly, the system can keep track of the device status in real time, ensuring data consistency between the device and the system. By sending data regularly, the system can periodically send control instructions or configuration parameters to the device to ensure that the device operates as expected. According to time or conditions, the working parameters of the device can be dynamically adjusted. Sending control instructions regularly enables remote operation of the device. The regular sending mechanism can be flexibly configured according to business requirements to meet different application scenarios. By setting different regular sending parameters (such as time intervals, trigger conditions, etc.) according to business requirements, configuration data, control instructions, status queries, etc. can be sent regularly. In industrial production, regularly send device operation parameters to ensure the stability of the production line. In smart homes, regularly send environment adjustment instructions to improve living comfort.
[0079] Through the regular sending mechanism, the system can regularly check the device status and promptly detect and handle abnormal situations. Regularly send query instructions to detect whether the device is operating normally. When an abnormality is detected, promptly send repair instructions or alarm messages. Regularly send device status query instructions to detect whether the Internet of Things device is online. When the device is abnormal, regularly send a restart instruction to attempt to restore the device to normal operation.
[0080] The regular sending mechanism can provide a stable data source for data collection and analysis, supporting subsequent data processing and decision-making. Through regular sending, a large amount of device data is accumulated for subsequent analysis. Through periodic data, analyze the device operation trend and optimize device management.
[0081] Through the regular sending mechanism, the system can optimize device operation according to the device status or environmental conditions to achieve energy-saving goals. Send energy-saving instructions regularly during off-peak hours to reduce device energy consumption. Regularly adjust the device operation mode according to demand to optimize resource utilization.
[0082] 107. The Internet of Things device sends the device data to the operation interface system;
[0083] In this embodiment, the visualization of device data and user interaction can be realized to ensure that users can monitor the device status in real time, analyze data and make decisions. The execution processing system does not parse the device data but directly sends the original device data to the operation interface system.
[0084] After step 107, the following steps can be executed:
[0085] 1071. The execution processing system calls the close function to close the connection between the port and the Internet of Things device.
[0086] In step 1071, closing the connection between the port and the Internet of Things device can release resources, ensure communication security and maintain system stability. After closing the port and the connection, the system will release the occupied resources to avoid resource leakage. Releasing the resources that are no longer in use ensures the efficient utilization of system resources. In a system running for a long time (such as a server), unclosed connections may lead to resource exhaustion and then cause the system to crash. In an industrial control system, after closing the connection with a PLC, the serial port or network port resources are released. In an Internet of Things gateway, after closing the connection with a sensor, the network socket resources are released.
[0087] Closing the connection can prevent unauthorized access or data leakage and ensure the security of communication. After closing the connection, the device can no longer send or receive data through this port, avoiding the leakage of sensitive information. Closing unused ports reduces the attack surface exposed by the system. In an industrial control system, after closing the connection with a remote device, malicious attacks are prevented. Timely closing of the connection can avoid system instability caused by excessive connections or abnormal connections. In a system running for a long time (such as a server), unclosed connections may lead to too many connections, affecting system performance. Abnormal connections may cause excessive system resource occupancy or communication anomalies. Closing the connection can restore the normal state of the system. In an Internet of Things gateway, after closing the connection with an abnormal device, the normal operation of the system is restored. In an industrial control system, after closing the connection with a faulty device, the communication of other devices is avoided from being affected.
[0088] After closing the connection, the port can be reused by other devices or application programs, improving resource utilization. Under limited port resources, closing the no-longer-used connections supports the communication needs of other devices. By dynamically closing and opening connections, different communication needs are adapted. In an Internet of Things gateway, after closing the connection with a certain sensor, the same port is used to connect other sensors. In an industrial control system, after closing the connection with a certain PLC, the same port is used to connect other devices.
[0089] 108. The Internet of Things device sends response data to the execution processing system;
[0090] In this embodiment, through the response data, the execution processing system can confirm whether the device has successfully received and processed the request, ensuring that the data is not lost or damaged during transmission. The response data provides feedback information for the execution processing system's operations, facilitating the system to understand the device's status and execution results. The IoT device returns whether the operation is successful, failed, or abnormal. The response data provides a basis for decision-making for the execution processing system. The system can adjust subsequent operations according to the data returned by the device. According to the data returned by the IoT device, the system can dynamically adjust control strategies or parameters. According to the response data, the system can decide whether to continue to execute other operations. The response data is the main way for the execution processing system to obtain device data, supporting data collection and storage. The operating status, sensor data, etc. of the device are obtained through the response data and stored in the database for subsequent analysis and decision-making. The response data can contain error information to help the execution processing system identify and handle communication or device anomalies. Through the error code or message in the response data, the system can identify the specific error type and take corresponding handling measures (such as retrying, alarming, etc.). By receiving and processing the response data, the system can monitor the device status in real time to ensure the reliable operation of the system. Through the response data, the system can understand the operating status of the device in real time. By analyzing the response data, the system can detect device anomalies in a timely manner. In a complex IoT system, multiple IoT devices may need to work together. The response data provides a basis for coordinating the operations of IoT devices. According to the data returned by the IoT device, the system can coordinate the operations of multiple IoT devices.
[0091] In step 108, the following steps can be executed:
[0092] 1081. The execution processing system sends the communication message to the IoT device;
[0093] In step 1081, monitor the connection between the port and the IoT device, wait to receive the response data from the IoT device until the response data is received.
[0094] Ensure that the system can communicate bidirectionally with the device and obtain feedback information from the device. The execution processing system sends communication messages to the Internet of Things device through the port, triggers the corresponding operations of the device, sends configuration information, adjusts the working parameters of the device, triggers the device to return response data by sending messages, the execution processing system listens to the port to ensure that the connection with the Internet of Things device is active and is ready to receive the response data from the device, ensures that the port connection is active, avoids communication interruption, and is always ready to receive the response data returned by the device. After sending the message, the execution processing system waits for the device to return the response data to ensure the integrity of the communication process. Through sending messages and receiving response data, the execution processing system realizes bidirectional communication with the Internet of Things device, ensuring that both parties can interact information. During the process of waiting for the response data, the execution processing system can detect communication anomalies and take corresponding handling measures. By listening to the port and waiting for the response data, the system can monitor the communication status in real time to ensure the reliability of the communication. During the process of waiting for the response data, the system can continue to execute other tasks to improve the concurrent processing ability of the system.
[0095] 109. The execution processing system receives the response data and the message encoding, and sends the response data and the message encoding back to the operation interface system through the PostWebMessageAsString function of the WebView2 control.
[0096] In this embodiment, it is ensured that the operation interface system can obtain device data in real time and update the display. Through the PostWebMessageAsString function, the execution processing system can send the response data and message encoding returned by the device back to the operation interface system to realize data interaction between the operation interface system and the execution processing system. Send the response data (such as sensor readings, device status, etc.) returned by the Internet of Things device to the operation interface system. By sending the response data to the operation interface system, the front end can update the interface content in real time to ensure that users can see the latest device status and data. By sending the message encoding, the operation interface system can perform corresponding logical processing (such as updating the interface, triggering events, etc.) according to the encoding. Through the PostWebMessageAsString function, the execution processing system can quickly send the data to the operation interface system, reducing latency and improving the system response speed.
[0097] 110. The operation interface system receives the response data and the message encoding.
[0098] In this embodiment, after the operation interface system receives the response data and the message encoding, it first needs to parse these data to extract useful information, extract information such as device status and sensor readings from the response data; judge the operation type or data content according to the message encoding.
[0099] As shown Figure 2 in Figure 2 Figure 1, which is a schematic diagram of a specific embodiment of step 110. The following steps may be executed in step 110:
[0100] 1101. The operation interface system listens for the message event through JavaScript;
[0101] 1102. When the message event is triggered, receive the response data and the message encoding sent by the execution processing system.
[0102] 1103. The operation interface system matches the corresponding requests and responses according to the message encoding;
[0103] 1104. After successful matching, display the response data in the designated area of the operation interface system or trigger subsequent logic.
[0104] In steps 1101 - 1104, by listening for the message event, the operation interface system establishes a real-time communication channel with the execution processing system, ensuring that the operation interface system can receive the response data sent by the execution processing system in a timely manner. The success of the operation is confirmed through the response data, and the message encoding is used to ensure that the response data corresponds one-to-one with the request to avoid data confusion.
[0105] In the embodiment of the present invention, the WebView2 control is used to implement cross-platform communication between the execution processing systems, and the multi-threaded capability of the execution processing system is utilized to solve the limitation that the single-threaded model of the operation interface system cannot execute complex tasks. At the same time, by interacting with the Internet of Things devices through the execution processing system, the deficiency that the operation interface system cannot directly access the underlying hardware resources is made up for.
[0106] Figure 3FIG. 0 is a schematic structural diagram of an interaction device between a control interface and an Internet of Things device provided by an embodiment of the present invention. The interaction device 300 between the control interface and the Internet of Things device may vary greatly due to configuration or performance differences, and may include one or more central processing units (CPUs) 310 (for example, one or more processors) and a memory 320, and one or more storage media 330 (for example, one or more mass storage devices) storing application programs 333 or data 332. Among them, the memory 320 and the storage media 330 may be transient storage or persistent storage. The program stored in the storage media 330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the interaction device 300 between the control interface and the Internet of Things device. Further, the processor 310 may be configured to communicate with the storage media 330 and execute a series of instruction operations in the storage media 330 on the interaction device 300 between the control interface and the Internet of Things device.
[0107] Based on the interaction device 300 between the control interface and the Internet of Things device may further include one or more power supplies 340, one or more wired or wireless network interfaces 350, one or more input / output interfaces 360, and / or, one or more operating systems 331, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, and so on. Those skilled in the art can understand that Figure 3 The shown structural diagram of the interaction device between the control interface and the Internet of Things device does not constitute a limitation on the interaction device between the control interface and the Internet of Things device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0108] The present invention also provides a computer-readable storage medium. The computer-readable storage medium may be a non-volatile computer-readable storage medium, and the computer-readable storage medium may also be a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are run on a computer, the computer is caused to execute the steps of the interaction method between the control interface and the Internet of Things device.
[0109] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0110] Moreover, although the operations are depicted in a particular order, this should be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed to achieve the desired result. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single implementation. Conversely, various features that are described in the context of a single implementation can also be implemented separately or in any suitable sub-combination in multiple implementations.
[0111] Although the subject matter has been described in language specific to structural features and / or methodological acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A method for interaction between a control interface and an Internet of Things device, characterized in that: The control interface system and the method for interacting with the Internet of Things device are applied to the control interface and the Internet of Things device interaction system, the control interface and the Internet of Things device interaction system comprises: an operation interface system, an execution processing system, and an Internet of Things device, and the control interface and the Internet of Things device interaction method comprises: The operation interface system sends a communication message to the execution processing system through the preset WebView2 control, and the communication message includes: message code, IP address, port, operation type and register address; The execution processing system receives and parses the communication message; Using the ModbusFactory function in the preset NModbus library to create an IoT device data object according to the port; Connecting the IoT device; Assemble and obtain device data according to the operation type and the register address; Read and write the device data through a preset IModbusMaster interface and send the device data to the IoT device; The Internet of Things device sends the device data to the operation interface system; The IoT device sends response data to the execution processing system; The execution processing system receives the response data and the message code, and sends the response data and the message code back to the operation interface system through the PostWebMessageAsString function of the WebView2 control; The operation interface system receives the response data and the message code.
2. The method for interaction between a control interface and an Internet of Things device according to claim 1, characterized in that: The operation interface system sends a communication message to the execution processing system through the preset WebView2 control, including: In the operation interface system, a postMessage function is used to send a communication message to the execution processing system.
3. The method for interaction between a control interface and an Internet of Things device according to claim 1, characterized in that: The execution processing system receives and analyzes the communication message, including: The execution processing system monitors the WebMessageReceived event of the WebView2 control and receives the communication message.
4. The method for interaction between a control interface and an Internet of Things device according to claim 1, characterized in that: The reading and writing of the device data through the preset IModbusMaster interface and sending the device data to the Internet of Things device includes: The execution processing system sends the device data to the Internet of Things device at a regular time according to the regular sending parameters in the preset device parameters.
5. The method for interaction between a control interface and an Internet of Things device according to any one of claims 1 to 4, characterized in that: The IoT device sending response data to the execution processing system includes: The execution processing system sends the communication message to the Internet of Things device; The connection between the port and the IoT device is monitored, and response data from the IoT device is waited for and received until the response data is received.
6. The method for interaction between a control interface and an Internet of Things device according to claim 1, characterized in that: The operation interface system receiving the response data and the message code includes: The operation interface system monitors message events through JavaScript; When the message event is triggered, the response data and the message code sent from the execution processing system are received.
7. The method for interaction between a control interface and an Internet of Things device according to claim 6, characterized in that: When the message event is triggered, receiving the response data and the message code sent by the execution processing system includes: The operation interface system matches the corresponding request and response according to the message code; After a successful match, the response data is displayed in a designated area of the operation interface system or subsequent logic is triggered.
8. The method for interaction between a control interface and an Internet of Things device according to claim 1, characterized in that: After the Internet of Things device sends the device data to the operation interface system, the method further includes: The execution processing system calls the close function to close the connection between the port and the Internet of Things device.
9. A control interface and Internet of Things device interaction device, characterized in that: The control interface and IoT device interaction device comprises: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instruction in the memory so that the control interface and Internet of Things device interaction device executes the control interface and Internet of Things device interaction method as described in any one of claims 1-8.
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 control interface and Internet of Things device interaction method described in any one of claims 1 to 8 is implemented.