Communication method, device and storage medium based on EXCEL file

By recording the communication information between the main controller and the remote terminal device in the EXCEL sample file, the command message is automatically generated and sent to the remote terminal device, which solves the problems of low communication efficiency and high development threshold in the traditional solution, and realizes the remote terminal device Fast communication and efficient protocol development with management devices.

CN118509500BActive Publication Date: 2024-10-18HANGZHOU HUASU TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410969206.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-10-18
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

In industrial automation systems, traditional solutions require professional coders to manually write protocol development codes, resulting in low efficiency of data point communication between remote terminal equipment and management equipment and high development threshold.

Method used

By recording the serial channel communication information between the main controller and the remote terminal device in the EXCEL sample file, the command message is automatically generated and sent to the remote terminal device, and the reply message is received and forwarded to the management device to achieve automatic protocol adaptation and reduce development costs. threshold and improve communication efficiency.

Benefits of technology

It realizes fast communication between remote terminal equipment and management equipment, improves protocol development efficiency, lowers the development threshold, and eliminates the need to manually write targeted protocol development code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118509500B_ABST
    Figure CN118509500B_ABST
Patent Text Reader

Abstract

The present application discloses a communication method, device and storage medium based on EXCEL file. The method is applied to a master controller. The master controller is connected to a remote terminal device through a first protocol, and the master controller is connected to a management device through a second protocol. The remote terminal device includes multiple data points. The method includes: obtaining a target worksheet in an EXCEL sample file; determining an instruction processing list based on the target worksheet; the read instruction list is determined according to a read point information table; generating an instruction message according to a preset format according to the instruction processing list; periodically sending an instruction message to the remote terminal device; receiving a reply message sent by the remote terminal device and processing it, and sending the processed reply message to the management device. The present application can quickly realize the communication between the data points of the remote terminal device and the management device, thereby improving the efficiency of protocol development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular, relates to a communication method, device and storage medium based on EXCEL files. Background Art

[0002] With the promotion and application of Internet of Things technology in industrial automation systems, Modbus protocol, as an open serial port protocol, is widely used. In modern factories and automation systems, upper-level management systems such as or cloud platforms usually use Ethernet-based communication protocols, such as Modbus TCP protocol, to achieve remote monitoring and data analysis. However, many underlying devices such as sensors and inverters use serial communication, such as Modbus RTU protocol. In order to achieve seamless integration of remote terminal devices with upper-level systems, protocol conversion is required. Remote terminal devices are devices that support Modbus RTU protocol. For example, in the energy storage industry, in the Energy Management System (EMS), it is necessary to connect remote terminal devices to the management equipment of the control center to achieve remote data acquisition, control and communication functions.

[0003] In practical applications, taking energy management systems as an example, the same type of remote terminal protocol equipment has different data points in different projects. In traditional solutions, the Modbus protocol needs to be re-encoded and developed each time the data collected on-site is accessed to ensure that the data points can communicate normally with the management equipment. This process requires the use of professional coders, and the amount of code development is large, and the development efficiency is low.

[0004] Therefore, how to quickly realize the communication between the data points of the remote terminal equipment and the management equipment and improve the efficiency of protocol development is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The present application provides a communication method, device and storage medium based on EXCEL files, which can quickly realize the communication between the data points of the remote terminal equipment and the management equipment, and improve the efficiency of protocol development.

[0006] On the one hand, an embodiment of the present application provides a communication method based on an EXCEL file, the method is applied to a master controller, the master controller is connected to a remote terminal device through a first protocol, the master controller is connected to a management device through a second protocol, the remote terminal device includes a plurality of data points, and the method includes:

[0007] Obtain a target worksheet in the EXCEL sample file; the target worksheet includes communication information between a target serial port channel of the master controller and a plurality of the data points, the target serial port channel being any one of the plurality of serial port channels of the master controller;

[0008] Based on the target work table, determining an instruction processing list; the instruction processing list includes at least one item of a read instruction list and a write instruction list; the read instruction list is determined according to a read point information table; the write instruction list and the read point information table are obtained by parsing the target work table;

[0009] Generate a command message in a preset format according to the command processing list;

[0010] Periodically sending the command message to the remote terminal device;

[0011] Receive and process the reply message sent by the remote terminal device, and send the processed reply message to the management device.

[0012] In an exemplary embodiment, the read point information table includes a plurality of point information, each of which includes a device type number of a remote terminal device corresponding to the data point, a first function code of the data point, and a first read register address; the method further includes:

[0013] Determine a first read register address set according to a preset difference; the first read register address set is a set of register addresses that can be read continuously in one instruction message; the preset difference represents a difference threshold between two first read register addresses that can be read continuously;

[0014] Determining a first first read register address of the first read register set as a starting address of the first read register address set;

[0015] Determine the number of registers corresponding to the first read register address set according to the starting address and the last first read register address in the first read register address set;

[0016] The starting address of the first read register address set, the number of registers corresponding to the first read register address set, and the device type number of the remote terminal device where the first read register address set is located are determined as a read instruction and added to the read instruction list.

[0017] In an exemplary embodiment, determining the first read register address set according to the preset difference includes:

[0018] Sorting the plurality of point information according to a preset strategy to obtain a sorted point information table;

[0019] In the sorted point information table, when the difference between two first read register addresses in two adjacent rows of point information is less than or equal to the preset difference, the two first read register addresses in the two adjacent rows of point information are added to the first read register address set.

[0020] In an exemplary embodiment, the plurality of point information are sorted according to a preset strategy to obtain a sorted point information table, including:

[0021] Sorting the plurality of pieces of point information in order according to the equipment type numbers;

[0022] When the device type numbers are the same, the plurality of point information are sequentially sorted according to the first read register address to obtain the sorted point information table.

[0023] In an exemplary embodiment, the command message includes at least one of a write command message and a read command message; and generating the command message according to the command processing list in a preset format includes:

[0024] Initializing the target serial port channel according to initialization information; the initialization information is obtained by parsing the target worksheet; the initialization information includes the type number, starting address, number of devices and serial port protocol type of multiple remote terminal devices connected to the target serial port channel;

[0025] Based on the read point information table and the write point information table, determine the first function code and the first register address corresponding to each of the data points, the second function code and the second register address of each of the data points on the management device, and the precision and offset of each of the data points during data conversion, and obtain a point correspondence table;

[0026] Based on the serial port protocol type, according to the write instruction list and the point position correspondence table, a write instruction message is generated according to the preset format; the preset format corresponds to the serial port protocol type; or,

[0027] Based on the serial port protocol type, according to the read instruction list and the point position correspondence table, a read instruction message is generated according to the preset format.

[0028] In an exemplary embodiment, the method further comprises:

[0029] Receiving a single setting instruction sent by the management device;

[0030] Determining a target remote terminal device according to the single setting instruction;

[0031] According to the preset format, the single setting instruction is converted into the instruction message, and the instruction message is sent to the target remote terminal device.

[0032] In an exemplary embodiment, the method further comprises:

[0033] Acquire a target number of times the command message is sent to the remote terminal device;

[0034] When the target number of times is greater than a preset number threshold, and no reply message sent by the remote terminal device is received within the target number of times, an alarm interface is called to record alarm information.

[0035] On the other hand, the present application also provides a communication device based on an EXCEL file, the device comprising:

[0036] An acquisition module is used to acquire a target worksheet in an EXCEL sample file; the target worksheet includes communication information between a target serial port channel of the master controller and a plurality of data points, and the target serial port channel is any one of the plurality of serial port channels of the master controller;

[0037] An instruction processing list determination module is used to determine an instruction processing list based on the target work table; the instruction processing list includes at least one of a read instruction list and a write instruction list; the read instruction list is determined according to a read point information table; the write instruction list and the read point information table are obtained by parsing the target work table;

[0038] An instruction message generation module, used to generate an instruction message according to a preset format based on the instruction processing list;

[0039] A sending module, used for periodically sending the command message to the remote terminal device;

[0040] The receiving module is used to receive and process the reply message sent by the remote terminal device, and send the processed reply message to the management device.

[0041] On the other hand, the present application also provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the communication method based on EXCEL file as described above.

[0042] On the other hand, the present application also provides a computer storage medium, which stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement the communication method based on EXCEL file as described above.

[0043] On the other hand, the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes to implement the communication method based on the EXCEL file as described above.

[0044] The communication method based on EXCEL file provided in this application has the following technical effects:

[0045] In the embodiment of the present application, by recording the communication information of the data point connected to the serial port channel of the master controller in the EXCEL sample file, determining the read instruction list and the write instruction list, and then automatically generating the instruction message according to the instruction list and sending it to the remote terminal device, and receiving the reply message of the remote terminal device and forwarding it to the management device, the remote terminal device and the management device can quickly establish communication. For technical personnel, when deploying the project, they only need to record the communication information of the data point between the remote terminal device and the management device in the EXCEL sample file, and then automatically perform unified processing, so that the protocol can automatically adapt to the data point, without the need to manually write the protocol development code in a targeted manner, which reduces the development threshold, and quickly realizes the communication between the data point of the remote terminal device and the management device, and improves the efficiency of protocol development. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0047] Figure 1 It is an application environment diagram of an EXCEL file-based communication method provided in an embodiment of the present application.

[0048] Figure 2 It is a flow chart of a communication method based on an EXCEL file provided in an embodiment of the present application.

[0049] Figure 3 Schematic diagram of the target worksheet provided in the embodiment of the present application.

[0050] Figure 4 It is a flowchart of generating a read instruction list provided in an embodiment of the present application.

[0051] Figure 5 It is a flowchart of generating instruction messages provided in an embodiment of the present application.

[0052] Figure 6 It is a structural diagram of an EXCEL file-based communication method device provided in an embodiment of the present application.

[0053] Figure 7 It is a hardware structure block diagram of a server of an EXCEL file-based communication method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0055] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0056] Figure 1 It is an application environment diagram of an EXCEL file-based communication method provided in an embodiment of the present application.

[0057] With the promotion and application of Internet of Things technology in industrial automation systems, Modbus protocol, as an open serial port protocol, is widely used. In modern factories and automation systems, upper-level management systems such as or cloud platforms usually use Ethernet-based communication protocols, such as Modbus Transmission Control Protocol (TCP), to achieve remote monitoring and data analysis. However, many underlying devices such as sensors, inverters, programmable logic controllers (PLCs), etc. use serial communication, such as Modbus Remote Terminal Unit (RTU). In order to achieve seamless integration of remote terminal devices with upper-level systems, protocol conversion is required. Remote terminal devices are devices that support the Modbus RTU protocol. For example, in the energy storage industry, in the energy management system (EMS), it is necessary to connect remote terminal devices to the management equipment of the control center to achieve remote data acquisition, control and communication functions.

[0058] With the development of the Internet of Things, in existing industrial networks, remote monitoring of field equipment is mainly achieved through the Internet of Things management platform. The connection between remote terminal equipment and the Internet of Things management platform needs to be communicated through an intermediate medium. The intermediate medium converts the Modbus RTU protocol to the Modbus TCP protocol, thereby realizing the two-way conversion of serial port data and network data packets. Specifically, Figure 1 As shown, Figure 1 The remote terminal device 100, the main controller 110 and the management device 120 are included. Specifically, the remote terminal device 100 may include multiple devices, for example, the remote terminal device 101, the remote terminal device 102, the remote terminal device 103, etc. The main controller 110 is connected to the remote terminal device 100 through a first protocol, and the main controller 110 is connected to the management device 120 through a second protocol. The first protocol may be a Modbus RTU protocol, and the second protocol may be a Modbus TCP protocol.

[0059] It should be noted that the Modbus RTU protocol uses the master / slave mode to communicate between devices. Figure 1In the example, the remote terminal device 100 can be regarded as a slave station, and the master controller 110 can be regarded as a master station. When reading data, the remote terminal device 100 contains multiple data points. After reading the data of the data points of the remote terminal device 100, the master controller 110 uploads the reading results to the management device 120 and performs data visualization; in addition, the master controller 110 can also receive the setting instructions of the control interface of the management device and forward the setting instructions to the corresponding remote terminal device.

[0060] However, in actual applications, taking the energy management system as an example, the same type of remote terminal equipment has different data points in different projects. In the traditional solution, the Modbus protocol needs to be re-encoded and developed each time the data collected on-site is accessed to ensure that the data at the data point can be normally transmitted with the management device. This process needs to rely on professional coders, and the amount of code development is large, and the development efficiency is low. Therefore, the present application provides a communication method, device and storage medium based on EXCEL files, which can quickly realize the communication between the data points of the remote terminal equipment and the management equipment, and improve the development efficiency.

[0061] Figure 2 It is a flow chart of a communication method based on an EXCEL file provided in an embodiment of the present application.

[0062] S201: Obtain a target worksheet in an EXCEL sample file; the target worksheet includes communication information between a target serial port channel of the master controller and a plurality of data points, and the target serial port channel is any one of a plurality of serial port channels of the master controller.

[0063] The EXCEL sample file includes multiple worksheets; each worksheet corresponds to a serial port channel of the master controller. Take the target worksheet as an example, the target worksheet records the communication information between the target serial port channel and multiple data points. In actual applications, the master controller is connected to multiple remote terminal devices, which can be 1 serial port channel connected to 1 remote terminal device or 1 serial port channel connected to multiple remote terminal devices. Therefore, the target worksheet records the situation where multiple remote terminal devices are connected to the same serial port channel.

[0064] It should be noted that the EXCEL sample file is an EXCEL file obtained by filling in the communication information according to a preset format after the communication information between the data of the remote terminal device and the management device is determined.

[0065] Specifically, the communication information may include the starting address of the remote terminal device connected to the current serial port channel, the number of devices, the function codes and register addresses corresponding to different data points, data accuracy and point data offset, etc. Based on the above information, data interaction between the remote terminal device and the master controller can be achieved. On this basis, the management device function code and management device register address corresponding to the corresponding data point can be determined, and data interaction between the master controller and the management device can be achieved.

[0066] S203: Determine an instruction processing list based on the target worksheet.

[0067] The instruction processing list includes at least one item of a read instruction list and a write instruction list; the instruction processing list is used to determine relevant setting information of a read or write register in an instruction message.

[0068] The read instruction list is determined according to the read point information table; the write instruction list and the read point information table are obtained by parsing the target worksheet.

[0069] Specifically, the read point information table and the write instruction list can be obtained by parsing the target worksheet; in one implementation, the read point information table and the write instruction list can be obtained by parsing the name of the title column in the target worksheet. In another implementation, it can also be parsed according to the row number, and the data in the preset row number is determined as the corresponding read point information table or write instruction list; and then the read instruction list is generated according to the read point information table. In one implementation, the generation of the read instruction list can be automatically executed by the main controller after determining that the data in the target worksheet has been entered; in another implementation, a control for generating a read instruction list can also be set in the target worksheet, and the main controller executes the generation of the read instruction list in response to the operation instruction based on the control for generating the instruction list. In addition, the write point information table can also be obtained by parsing the target worksheet.

[0070] It should be noted that this step can be achieved by executing a preset VBA (Visual Basic for Applications) code in an EXCEL file. The preset VBA code is pre-written and can automatically generate an instruction processing list based on the information in the target worksheet.

[0071] S205: Generate a command message according to the command processing list and in a preset format.

[0072] Since the instruction processing list records the relevant instruction settings of the instruction read or write register, the instruction message can be automatically generated according to the instruction processing list, and the message format of the instruction message matches the message format of the first protocol, so as to apply the first protocol to transmit the instruction message to the remote terminal device.

[0073] The command message can be divided into a write command message and a read command message according to different functions, wherein the write command message is determined according to the write command list; the read command message is determined according to the read command list.

[0074] It should be noted that for each instruction in the instruction processing list, a corresponding instruction message will be generated.

[0075] S207: Periodically sending the instruction message to the remote terminal device.

[0076] Since the remote terminal device will not actively send data to the main controller, it will respond only after the main controller initiates a request. In actual applications, it is necessary to read or write data at regular intervals. Therefore, the data points recorded in the target worksheet in this application are the data points that need to be written or read regularly; then the main controller periodically sends the generated command message to the remote terminal device to improve communication efficiency.

[0077] S209: receiving and processing the reply message sent by the remote terminal device, and sending the processed reply message to the management device.

[0078] After the remote terminal device receives the command message sent by the main controller, it responds and sends a reply message to the main controller. After the main controller receives the reply message sent by the remote terminal device, it is necessary to convert the message format. The converted message format matches the message format of the second protocol, so that the second protocol can be used to send the format-converted reply message to the management device.

[0079] It should be noted that step S207 and step S209 can be implemented by preset VBA codes in the EXCEL file. For example, corresponding interfaces can be written or relevant interfaces can be called in the preset VBA code to realize the communication between the data point and the controller and between the controller and the management device.

[0080] In the embodiment of the present application, by recording the communication information of the data point connected to the serial port channel of the master controller in the EXCEL sample file, determining the read instruction list and the write instruction list, and then automatically generating the instruction message according to the instruction list and sending it to the remote terminal device, and receiving the reply message of the remote terminal device and forwarding it to the management device, the remote terminal device and the management device can quickly establish communication. For technical personnel, when deploying the project, they only need to record the communication information of the data point between the remote terminal device and the management device in the EXCEL sample file, and then automatically perform unified processing, so that the protocol can automatically adapt to the data point, without the need to manually write the protocol development code in a targeted manner, which reduces the development threshold, and quickly realizes the communication between the data point of the remote terminal device and the management device, improving the development efficiency.

[0081] Figure 3 Schematic diagram of the target worksheet provided in the embodiment of the present application.

[0082] like Figure 3 As shown in the figure, taking the management device equipped with an energy management system and the master controller including two serial port channels as an example, the target worksheet corresponding to the serial port channel 1 of the master controller includes initialization information, read point information table, write point information table, read instruction list and write instruction list. Among them, the initialization information includes the following title columns: device type number, device starting address and device quantity. The following title columns of the read point information table: device type number, point function description, function code, read register address, point data accuracy, point data offset, EMS function code and EMS register address; correspondingly, the write point information includes write register address, etc. If the master controller needs to forward the data sent by the remote terminal device to the management device, it needs both the function code and register address of the remote terminal device and the master controller, and the function code and register address of the master controller and the management device. For the data that needs to be forwarded from the remote terminal device to the management device, after obtaining the function code and register address of both parties, the corresponding relationship between this data point on the remote terminal device and the management device can be known.

[0083] The read point information table includes multiple point information, each of which includes data items such as the device type number of the remote terminal device corresponding to the data point, the first function code of the data point, and the first read register address. Figure 3 In the worksheet, the point information of row number 7 indicates that the corresponding data point is on the remote terminal device with device type number 1. The data point indicates the high-order data of the first concentration value of H2 detected internally. The first function code corresponding to the data point is 0x03, and the first read register address is 0x0003, indicating reading the holding register, specifically, reading 2 bytes of data in the specified register address 0x0003. For another example, the point information of row number 25 in the worksheet indicates that the corresponding data point is on the remote terminal device with device type number 2. The data point indicates the battery cell temperature. The first function code corresponding to the data point is 0x06, and the first write register address is 0x000F, indicating writing a single holding register, specifically, writing 2 bytes of data to the specified register 0x000F.

[0084] In addition, the target worksheet also includes a custom configuration value for the maximum difference in register addresses allowed when automatically generating a read instruction list. The custom configuration value is used to determine the number of registers that can be read continuously by a single instruction message.

[0085] Figure 3The target worksheet shown also includes an automatic read instruction list control and a generated code file control. In response to a click operation based on the automatic generation of the read instruction control, the device type number and register address can be automatically extracted from the read point information table to generate a read instruction list. The read instruction list includes the device type number, the read register starting address, and the number of registers read continuously in a single message. When the difference between the two read register addresses of devices with the same device type number is less than or equal to the maximum difference, it means that the two registers can be read continuously. In addition, in response to a click operation of the generated code file control, a preset VBA code can be executed to realize data interaction between the remote terminal device and the master controller and between the master controller and the management device.

[0086] Figure 4 It is a flowchart of generating a read instruction list provided in an embodiment of the present application. Figure 4 It can be regarded as a specific example of step S203.

[0087] S401: Determine a first read register address set according to a preset difference.

[0088] The first read register address set is a set of register addresses that can be read continuously in one instruction message; the preset difference value represents a difference threshold between two first read register addresses that can be read continuously.

[0089] In one implementation, determining the first read register address set based on the preset difference includes: sorting the multiple point information according to a preset strategy to obtain a sorted point information table; in the sorted point information table, when the difference between two of the first read register addresses in two adjacent rows of point information is less than or equal to the preset difference, adding the two first read register addresses in the two adjacent rows of point information to the first read register address set.

[0090] In one implementation, the multiple pieces of point information are sorted according to a preset strategy to obtain a sorted point information table, including: sorting the multiple pieces of point information in sequence according to the device type number; when the device type numbers are the same, sorting the multiple pieces of point information in sequence according to the first read register address to obtain the sorted point information table.

[0091] The preset difference can be Figure 3 The maximum difference in register addresses allowed when automatically generating a read instruction list in the custom configuration value.

[0092] In the above implementation, all device type numbers in the read point information table are first traversed from small to large, and then the rows with the same device type number are reordered from small to large according to the first read register address to obtain the sorted point information table. For rows with the same device type number, if the difference in the read register address of two adjacent rows is not greater than the preset difference, then the two first read registers can be read in one instruction message and added to the first read register address set. In one example, the preset difference can be 1 or 2 or other values. Figure 3 Taking the preset difference value of 2 as an example, when the first read register address in one point information is 0x0005, and the first read register address in another point information is 0x0007, and the difference is 2, the two first read registers can be read in one instruction message, and the two first read register addresses 0x0005 and 0x0007 are added to the first read register address set.

[0093] S403: Determine the first first read register address of the first read register set as the start address of the first read register address set.

[0094] The first first read register address is the first read register address with the smallest address in the first read register set, and is recorded as the starting address F of the first read register address set. For example, if the first read register addresses included in the first read register set are 0x0003, 0x0004, 0x0005, and 0x0007, then the starting address F of the first read register set is 0x0003.

[0095] S405: Determine the number of registers corresponding to the first read register address set according to the starting address and the last first read register address in the first read register address set; it should be noted that the last first read register address is the first read register address with the largest address in the first read register set. The number of registers M corresponding to the first read register address set can be obtained by the following formula.

[0096]

[0097] Wherein, M represents the number of registers corresponding to the first read register address set, L represents the last first read register address in the first read register address set, and F represents the starting address of the first read register set.

[0098] Still taking the example in step S403, the last first read register address L in the first read register address set is 0x0007, and the starting address F is 0x0003. Therefore, it can be determined that the number of registers M corresponding to the first read register address set is equal to 5. That is to say, in an instruction message, with 0x0003 as the starting address, data stored in 5 registers can be read continuously.

[0099] S407: Determine the starting address of the first read register address set, the number of registers corresponding to the first read register address set, and the device type number of the remote terminal device where the first read register address set is located as a read instruction, and add it to the read instruction list.

[0100] In this step, the read instruction list can be Figure 3 The data table with row numbers 28 to 31. It should be noted that there can be multiple first read register address sets, and each first read register address set corresponds to a read instruction. In each first read register address set, the device type number corresponding to the data point bit is the same.

[0101] In an embodiment of the present application, a read instruction list is generated according to a first read register set. When a read instruction message is subsequently generated, only the starting address and the number of registers in the read instruction list need to be read and used as components of the instruction message. By determining the starting address and the number of registers in the instruction message in advance according to the first read register set, the data processing flow of instruction message generation in the traditional scheme is reduced.

[0102] Figure 5 It is a flowchart of generating instruction messages provided in an embodiment of the present application. Figure 5 This can be regarded as a specific example of step S205. The step of generating a command message according to the command processing list and in a preset format includes:

[0103] S501: Initialize the target serial port channel according to initialization information; the initialization information is obtained by parsing the target worksheet; the initialization information includes the type number, starting address, number of devices and serial port protocol type of multiple remote terminal devices connected to the target serial port channel.

[0104] Figure 5 The method shown can be implemented by a pre-written VBA code. The VBA code includes an initialization interface and a task scheduling interface. The initialization interface is used to initialize the target serial port channel according to the initialization information, and the initialization information includes the type number, device start address, device quantity, and serial port protocol type of all remote terminal devices. While executing step S501, the read point information table and the write point information table as well as the cache read instruction list and the write instruction list are used as the basis for subsequent generation of instruction messages.

[0105] S503: Based on the read point information table and the write point information table, determine the first function code and the first register address corresponding to each of the data points, the second function code and the second register address of each of the data points on the management device, and the precision and offset of each of the data points during data conversion, and obtain a point correspondence table.

[0106] It should be noted that step S503 can be executed before step S205, that is, after parsing the read point information table and the write point information table, or after obtaining the read instruction list. After generating the point correspondence table, the point correspondence table can be stored for subsequent forwarding data use, avoiding multiple generation, thereby saving computing resources.

[0107] The VBA code generates a correspondence table between the data point positions in the remote terminal device and the management device based on the read point position information table and the write point position information table. The point position correspondence table records the first function code and the first register address of the data point position on the remote terminal device, the second function code and the second register address on the management device, and the precision and offset that need to be converted when forwarding the data of the data point position. The main controller can forward the read and write instructions of the management device to the remote terminal device through the point position correspondence table; the main controller can also forward the data uploaded by the remote terminal device to the management device through the point position correspondence table.

[0108] It should be noted that the first register address may be a first read register address, and the corresponding second register address is a second read register address; the first register address may be a first write register address, and the corresponding second register address is a second write register address.

[0109] S505: Based on the serial port protocol type, according to the command processing list and the point correspondence table, a command message is generated according to the preset format. The command message includes at least one of a write command message and a read command message; step S505 includes step S5051 and step S5053.

[0110] S5051: Based on the serial port protocol type, according to the write instruction list and the point correspondence table, a write instruction message is generated according to the preset format; the preset format corresponds to the serial port protocol type.

[0111] Since the remote terminal device is connected to the main controller via a first protocol, such as the Modbus RTU protocol, the ModbusRTU protocol is a data link layer protocol, and the physical layer may be a communication protocol such as RS485 or RS232.

[0112] S5053: Based on the serial port protocol type, according to the read instruction list and the point correspondence table, a read instruction message is generated according to the preset format.

[0113] Still Figure 3 Taking the target worksheet provided as an example, taking the read instruction with row number 29 as an example, the read instruction message corresponding to the read instruction with row number 29 can be shown in Table 1:

[0114] Table 1

[0115]

[0116] Among them, the slave address indicates which slave station the message is sent to, that is, the target remote terminal device. On the RS485 bus, all slave stations can receive the message sent by the master station. The slave station determines whether the message is sent to itself based on the slave address in the message. Therefore, the slave address is used to distinguish each slave station, that is, each remote terminal device. The function code in the message corresponding to the read instruction in the read instruction list is 0x03, and the function code in the message corresponding to the write instruction in the write instruction list is 0x06. The register starting address and the number of registers are stored in the read instruction list generated in step S407. In order to prevent the byte transmission error or loss in the instruction message, a data check bit is also set in the instruction message.

[0117] In an embodiment of the present application, the instruction list is processed into an instruction message, and a point correspondence table is generated. The main controller can forward the read and write instructions of the management device to the remote terminal device in the form of an instruction message through the point correspondence table; the main controller can also forward the data uploaded by the remote terminal device to the management device through the point correspondence table, thereby ensuring the accuracy of communication.

[0118] In one embodiment, the method provided in the embodiment of the present application further includes:

[0119] Receive a one-time setting instruction sent by the management device; determine a target remote terminal device according to the one-time setting instruction; convert the one-time setting instruction into the instruction message according to the preset format, and send the instruction message to the target remote terminal device.

[0120] Since in the above embodiment, the instructions in the read instruction list and the write instruction list are data that need to be sent regularly, the main controller executes the pre-written VBA code, calls the task scheduling interface, and sends the read or write instructions in the list to the remote terminal device regularly. In addition, in addition to the read instructions and write instructions that need to be sent regularly, some instructions need to be sent on demand. In other words, if the management device issues a single setting command, the main controller needs to send the single setting command to the remote terminal device. The main controller can call the single instruction interface in the task scheduling interface according to the received single setting instruction, and add the single setting instruction to the single sending instruction list; then, similar to step S505, the single setting instruction is converted into a corresponding instruction message and sent to the remote terminal device.

[0121] In one implementation, since the master controller is connected to the remote terminal device via a first protocol and connected to the management device via a second protocol, for a received setting instruction, it is possible to determine which data point the setting instruction is for and which remote terminal device the data point corresponds to based on a pre-generated and stored point correspondence table, thereby determining the target remote terminal device. The master controller then forwards the instruction message corresponding to the setting instruction to the target remote terminal device.

[0122] In addition to sending command messages at regular intervals, the embodiments of the present application also consider sending command messages on demand, so that the commands of the management device can be sent normally to the remote terminal device, ensuring normal communication of data points and avoiding omission of commands.

[0123] In one embodiment, the method provided in the embodiment of the present application further includes:

[0124] Obtain a target number of times the command message is sent to the remote terminal device; when the target number is greater than a preset number threshold and no reply message sent by the remote terminal device is received within the target number, call an alarm interface to record alarm information.

[0125] After periodically sending command messages to the remote terminal device, the target number of transmissions is also counted during the sending process; the alarm interface is similar to the above-mentioned task scheduling interface, and is integrated into the main controller as software. The alarm interface will be triggered when the target number is greater than the preset number threshold and no reply message is received from the remote terminal device within the target number, and then the alarm information is recorded, so that the technicians can troubleshoot the remote terminal device and the main controller by checking the alarm information.

[0126] It should be noted that the preset number threshold can be set specifically according to the device performance of the remote terminal device, and this application does not limit the specific value of the preset number threshold.

[0127] In one implementation, the alarm information may also be reported to a management device to implement fault monitoring so that technical personnel can handle the fault in a timely manner.

[0128] It can be seen from the technical solution provided by the above embodiment of the present application that the present application records the communication information of the data point connected to the serial port channel of the master controller in the EXCEL sample file, parses the read point information and the write point information, and then determines the read instruction list and the write instruction list. This method makes the established read instruction list and the write instruction list in a unified form, so as to read the instructions in the instruction list and automatically generate the instruction message and send it to the remote terminal device. In addition, the master controller receives the reply message of the remote terminal device and forwards it to the management device, so as to realize the rapid establishment of communication between the remote terminal device and the management device. For technical personnel, when deploying the project, it is only necessary to record the communication information of the data point between the remote terminal device and the management device in the EXCEL sample file, and then automatically perform unified processing, so that the protocol can automatically adapt to the data point, without the need to manually write the protocol development code in a targeted manner, which reduces the development threshold, and quickly realizes the communication between the data point of the remote terminal device and the management device, and improves the development efficiency.

[0129] Figure 6 It is a structural diagram of an EXCEL file-based communication method device provided in an embodiment of the present application.

[0130] like Figure 6 As shown, the device 600 includes:

[0131] An acquisition module 601 is used to acquire a target worksheet in an EXCEL sample file; the target worksheet includes communication information between a target serial port channel of the master controller and a plurality of data points, and the target serial port channel is any one of the plurality of serial port channels of the master controller;

[0132] The instruction processing list determination module 602 is used to determine the instruction processing list based on the target work table; the instruction processing list includes at least one of a read instruction list and a write instruction list; the read instruction list is determined according to the read point information table; the write instruction list and the read point information table are obtained by parsing the target work table;

[0133] The instruction message generation module 603 is used to generate an instruction message according to the instruction processing list and a preset format;

[0134] The sending module 604 is used to periodically send the instruction message to the remote terminal device;

[0135] The receiving module 605 is used to receive and process the reply message sent by the remote terminal device, and send the processed reply message to the management device.

[0136] In some embodiments, the read point information table includes multiple point information, each of which includes a device type number of a remote terminal device corresponding to the data point, a first function code of the data point, and a first read register address; the device 600 may also include:

[0137] A first read register address set determination module, configured to determine a first read register address set according to a preset difference value; the first read register address set is a set of register addresses that can be read continuously in one instruction message; the preset difference value represents a difference threshold between two first read register addresses that can be read continuously;

[0138] a starting address determining module, configured to determine a first first read register address of the first read register set as a starting address of the first read register address set;

[0139] a register number determination module, configured to determine the number of registers corresponding to the first read register address set according to the start address and the last first read register address in the first read register address set;

[0140] A read instruction adding module is used to determine the starting address of the first read register address set, the number of registers corresponding to the first read register address set, and the device type number of the remote terminal device where the first read register address set is located as a read instruction, and add it to the read instruction list.

[0141] In some embodiments, the first read register address set determination module may include:

[0142] A sorting submodule, used to sort the plurality of point information according to a preset strategy to obtain a sorted point information table;

[0143] In the sorted point information table, when the difference between two first read register addresses in two adjacent rows of point information is less than or equal to the preset difference, the two first read register addresses in the two adjacent rows of point information are added to the first read register address set.

[0144] In some embodiments, the sorting submodule may include:

[0145] A first sorting unit, used to sort the plurality of point information in order according to the device type number;

[0146] The second sorting unit is used to sort the plurality of point information in sequence according to the first read register address when the device type numbers are the same, so as to obtain the sorted point information table.

[0147] In some embodiments, the command message includes at least one of a write command message and a read command message; the command message generation module may include:

[0148] An initialization submodule, configured to initialize the target serial port channel according to initialization information; the initialization information is obtained by parsing the target worksheet; the initialization information includes the type number, starting address, number of devices and serial port protocol type of multiple remote terminal devices connected to the target serial port channel;

[0149] A point position correspondence table determination submodule is used to determine, based on the read point position information table and the write point position information table, the first function code and the first register address corresponding to each of the data points, the second function code and the second register address of each of the data points on the management device, and the precision and offset of each of the data points during data conversion, to obtain a point position correspondence table;

[0150] A command message generation submodule, used to generate a command message according to the command processing list and the point correspondence table in accordance with the preset format; the preset format corresponds to the serial port protocol type;

[0151] In some embodiments, the instruction message generation submodule may include:

[0152] A write instruction message generating unit, configured to generate a write instruction message in accordance with the preset format based on the serial port protocol type, the write instruction list and the point position correspondence table;

[0153] A read instruction message generating unit is used to generate a read instruction message according to the preset format based on the serial port protocol type, the read instruction list and the point position correspondence table.

[0154] In some embodiments, the apparatus 600 may further include:

[0155] A one-time setting instruction receiving module, used to receive a one-time setting instruction sent by the management device;

[0156] A target remote terminal device determining module, used to determine the target remote terminal device according to the single setting instruction;

[0157] The instruction conversion and sending module is used to convert the single setting instruction into the instruction message according to the preset format, and send the instruction message to the target remote terminal device.

[0158] In one embodiment, the apparatus 600 may further include:

[0159] A target number acquisition module, used to acquire a target number of times the instruction message is sent to the remote terminal device;

[0160] The alarm module is used to call the alarm interface to record the alarm information when the target number of times is greater than a preset number of times threshold and no reply message sent by the remote terminal device is received within the target number of times.

[0161] The device and method embodiments in the described device embodiments are based on the same inventive concept.

[0162] An embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the method provided in the above method embodiment.

[0163] An embodiment of the present application also provides a computer storage medium, which can be set in a terminal to store at least one instruction or at least one program related to a method provided in the above method embodiment for implementing a method embodiment, and the at least one instruction or at least one program is loaded and executed by the processor to implement the method provided in the above method embodiment.

[0164] The embodiments of the present application also provide a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the method provided in the above method embodiment.

[0165] Optionally, in the embodiment of the present application, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in the present embodiment, the storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0166] The memory described in the embodiment of the present application can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, application programs required for functions, etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.

[0167] The method provided in the embodiment of the present application can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking running on a server as an example, Figure 7 1 is a hardware structure diagram of a server of a communication method based on an EXCEL file provided in an embodiment of the present application. Figure 7 As shown, the server 700 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 710 (the central processing unit 710 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 730 for storing data, and one or more storage media 720 (such as one or more mass storage devices) for storing application programs 723 or data 722. Among them, the memory 730 and the storage medium 720 can be short-term storage or permanent storage. The program stored in the storage medium 720 may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, the central processing unit 710 can be configured to communicate with the storage medium 720 and execute a series of instruction operations in the storage medium 720 on the server 700. The server 700 may also include one or more power supplies 760, one or more wired or wireless network interfaces 750, one or more input and output interfaces 740, and / or one or more operating systems 721, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0168] The input / output interface 740 may be used to receive or send data via a network. A specific example of the network may include a wireless network provided by a communication provider of the server 700. In one example, the input / output interface 740 includes a network adapter (Network Interface Controller, NIC), which may be connected to other network devices via a base station so as to communicate with the Internet. In one example, the input / output interface 740 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0169] It can be understood by those skilled in the art that Figure 7 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 7 Different configurations are shown.

[0170] It can be seen from the embodiments of the communication method, device and storage medium based on EXCEL file provided by the present application that the present application records the communication information of the data point connected to the serial port channel of the master controller in the EXCEL sample file, parses the read point information and the write point information, and then determines the read instruction list and the write instruction list. This method makes the established read instruction list and the write instruction list in a unified form, so as to read the instructions in the instruction list and automatically generate the instruction message and send it to the remote terminal device. In addition, the master controller receives the reply message of the remote terminal device and forwards it to the management device, so as to realize the rapid establishment of communication between the remote terminal device and the management device. For technical personnel, when deploying the project, it is only necessary to record the communication information of the data point between the remote terminal device and the management device in the EXCEL sample file, and then automatically perform unified processing, so that the protocol can automatically adapt to the data point, without the need to manually write the protocol development code in a targeted manner, which reduces the development threshold, and quickly realizes the communication between the data point of the remote terminal device and the management device, and improves the development efficiency.

[0171] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of this specification are described. Other embodiments are within the scope of the attached claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0172] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0173] A person skilled in the art will appreciate that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0174] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A communication method based on EXCEL file, characterized in that: The method is applied to a master controller, the master controller is connected to a remote terminal device via a first protocol, the master controller is connected to a management device via a second protocol, the remote terminal device includes a plurality of data points, and the method includes: Obtain a target worksheet in an EXCEL sample file; the target worksheet includes communication information between a target serial port channel of the master controller and a plurality of the data points, the target serial port channel being any one of the plurality of serial port channels of the master controller; the target worksheet includes an automatic generation of a read instruction list control and a generation of a code file control; Parse the target worksheet to obtain a read point information table and a write instruction list; the read point information table includes a plurality of point information, each of which includes a device type number of a remote terminal device corresponding to the data point, a first function code of the data point, and a first read register address; In response to a click operation based on the automatically generated read instruction list control, a first read register address set is determined according to a preset difference value; the first read register address set is a set of register addresses that can be continuously read in one instruction message; the preset difference value represents a difference threshold between two first read register addresses that can be continuously read; Determining a first first read register address of the first read register address set as a starting address of the first read register address set; Determine the number of registers corresponding to the first read register address set according to the starting address and the last first read register address in the first read register address set; Determine the starting address of the first read register address set, the number of registers corresponding to the first read register address set, and the device type number of the remote terminal device where the first read register address set is located as a read instruction, and add it to the read instruction list; Generate a command message in a preset format according to the command processing list; the command processing list includes at least one item in the read command list and the write command list; In response to a click operation of the generate code file control, periodically sending the instruction message to the remote terminal device; Receive and process the reply message sent by the remote terminal device, and send the processed reply message to the management device.

2. The method according to claim 1, characterized in that The step of determining the first read register address set according to the preset difference includes: Sorting the plurality of point information according to a preset strategy to obtain a sorted point information table; In the sorted point information table, when the difference between two first read register addresses in two adjacent rows of point information is less than or equal to the preset difference, the two first read register addresses in the two adjacent rows of point information are added to the first read register address set.

3. According to the method of claim 2, the step of sorting the plurality of point information according to a preset strategy to obtain a sorted point information table comprises: Sorting the plurality of pieces of point information in order according to the equipment type numbers; When the device type numbers are the same, the plurality of point information are sequentially sorted according to the first read register address to obtain the sorted point information table.

4. The method according to claim 1, characterized in that: The command message includes at least one of a write command message and a read command message; the generating the command message according to the command processing list and in a preset format includes: Initializing the target serial port channel according to initialization information; the initialization information is obtained by parsing the target worksheet; the initialization information includes the type number, starting address, number of devices and serial port protocol type of multiple remote terminal devices connected to the target serial port channel; Based on the read point information table and the write point information table, determine the first function code and the first register address corresponding to each of the data points, the second function code and the second register address of each of the data points on the management device, and the precision and offset of each of the data points during data conversion, and obtain a point correspondence table; Based on the serial port protocol type, according to the write instruction list and the point position correspondence table, the write instruction message is generated according to the preset format; the preset format corresponds to the serial port protocol type; or, Based on the serial port protocol type, according to the read instruction list and the point position correspondence table, the read instruction message is generated according to the preset format.

5. The method according to claim 1, characterized in that The method further comprises: Receiving a single setting instruction sent by the management device; Determining a target remote terminal device according to the single setting instruction; According to the preset format, the single setting instruction is converted into the instruction message, and the instruction message is sent to the target remote terminal device.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Acquire a target number of times the command message is sent to the remote terminal device; When the target number of times is greater than a preset number threshold, and no reply message sent by the remote terminal device is received within the target number of times, an alarm interface is called to record alarm information.

7. A communication device based on EXCEL file, characterized in that: include: An acquisition module is used to acquire a target worksheet in an EXCEL sample file; The target worksheet includes communication information between a target serial port channel of the master controller and a plurality of data points, wherein the target serial port channel is any one of the plurality of serial port channels of the master controller; the target worksheet includes an automatic generation of a read instruction list control and a generation of a code file control; An instruction processing list determination module is used to parse the target work table to obtain a read point information table and a write instruction list; the read point information table includes a plurality of point information, each of which includes a device type number of a remote terminal device corresponding to the data point, a first function code of the data point, and a first read register address; In response to a click operation based on the automatically generated read instruction list control, a first read register address set is determined according to a preset difference; the first read register address set is a set of register addresses that can be continuously read in one instruction message; The preset difference value represents a difference threshold between two first read register addresses that can be read continuously; the first first read register address of the first read register address set is determined as the starting address of the first read register address set; Determine the number of registers corresponding to the first read register address set according to the starting address and the last first read register address in the first read register address set; determine the starting address of the first read register address set, the number of registers corresponding to the first read register address set, and the device type number of the remote terminal device where the first read register address set is located as a read instruction, and add it to the read instruction list; An instruction message generation module, configured to generate an instruction message in a preset format according to an instruction processing list; the instruction processing list includes at least one item of the read instruction list and the write instruction list; A sending module, configured to periodically send the instruction message to the remote terminal device in response to a click operation of the generate code file control; The receiving module is used to receive and process the reply message sent by the remote terminal device, and send the processed reply message to the management device.

8. An electronic device, characterized in that: The electronic device comprises: a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the communication method based on an EXCEL file as described in any one of claims 1-6.

9. A computer storage medium, characterized in that The computer storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the communication method based on the EXCEL file as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Data acquisition and uploading method and device, gateway and computer readable medium

    CN116847003A