Industrial communication soft gateway
By designing an industrial communication soft gateway that includes channel operation process, data exchange threads and custom protocol analysis, the problem of inflexible protocol conversion in the existing technology is solved, efficient data collection and forwarding is achieved, project implementation costs are reduced, and compatibility with non-standard protocol equipment is enhanced.
Patent Information
- Application Number
- CN202510625769.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2025-08-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing industrial communication soft gateways cannot implement N-to-N mapping relationships, support custom protocols, timed meter reading and complex arithmetic operations, and cannot generate reports in a specified format, resulting in high cost and low efficiency in project implementation.
An industrial communication soft gateway is designed, including channel operation process, data exchange thread, custom communication protocol data analysis process, data freezing storage algorithm and report generation algorithm, supporting custom protocols, timed storage data, generating reports in EXCEL and CSV formats, and implementing simple serial communication protocol data acquisition through configuration.
It realizes flexible data collection and forwarding, improves project implementation efficiency, reduces costs, enhances compatibility with non-standard communication protocol devices, supports complex arithmetic operations and timing data storage, and generates reports in a specified format.
Smart Images

Figure CN120498926A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of industrial communications, and in particular relates to an industrial communications soft gateway. Background Art
[0002] Communication gateways are used for communication, data collection, and data forwarding between information systems, DCSs, PLCs, smart devices, and instruments. Typically, a device, instrument, or system only supports one to three industrial communication protocols. Since there isn't a single, mutually supported industrial communication protocol between the communicating devices, instruments, or systems, a hard gateway, soft gateway, or protocol conversion interface is required for transfer. Currently, hard gateways and soft gateways convert other protocols into several more widely used industrial communication protocols, such as Modbus, OPC DA, and MQTT.
[0003] Existing industrial communication soft gateways, hard gateways, and protocol converters have the following shortcomings: they only realize the conversion of one to N protocols into specified one to M protocols, which is an N to M mapping relationship, and do not support N to N mapping relationships; existing gateways do not support the definition of new communication protocols through configuration and configuration. Simple serial port communication protocols that the gateway does not support cannot be implemented through user configuration or user secondary development, and can only be implemented by the gateway manufacturer upgrading the program; existing gateways do not support scheduled meter reading functions. In order to obtain data at a specified time or hour, the information system often has to use algorithm interpolation to obtain approximate values; it is impossible to export reports in a specified format. Users need to use other reporting tools or information systems to export reports. In order to automatically generate reports, customers have to purchase expensive reporting systems or large information systems; simple range conversion, scaling, compression or aggregation operations can be performed, but complex multi-layer nested arithmetic operations are not supported. Non-linear range conversion requires multiple calculations with the help of multiple tags. Summary of the Invention
[0004] The purpose of the present invention is to provide an industrial communication soft gateway to solve the problems raised in the above background technology.
[0005] In order to achieve the above objectives, the present invention provides the following technical solutions: an industrial communication soft gateway, which includes a channel operation process, a data exchange thread, a custom communication protocol data parsing process, a data freezing and storage algorithm, a report generation algorithm, and a data calculation algorithm:
[0006] S1: Channel operation process
[0007] S1.1. Create a channel thread;
[0008] S1.2. Open the channel. If successful, proceed to the next step. If the channel fails, try again in the next cycle.
[0009] S1.3. Set communication parameters;
[0010] S1.4. Initialize the devices under the channel and complete the communication efficiency optimization task;
[0011] S1.5. Test the channel status. If the communication status is normal, proceed to the next step. Otherwise, return to S1.1.
[0012] S1.6. Cycle through all devices in the channel to read the specified data.
[0013] S1.7. When device data changes, update the entry list and notify other devices to receive the new data;
[0014] S1.8. Write updated data from other devices to the device
[0015] S1.9, determine whether there is a stop operation, if there is a stop operation, go to the next step, otherwise return
[0016] S1.6;
[0017] S1.10, close the channel;
[0018] S1.11. Exit the thread and stop running;
[0019] S2: Data exchange thread
[0020] S2.1. Create a data exchange thread;
[0021] S2.2, clear the entry table;
[0022] S2.3. Traverse the tags under all channels, devices, and groups, create an entry using the tag ID as the primary key, and add the tag pointer to the tag list of the entry;
[0023] S2.4. Traverse the entry table and check whether the tag corresponding to each entry has an updated value;
[0024] S2.5. If an entry has an updated value, send the updated value to all tags in the entry tag list except those that generated the updated value.
[0025] S2.6. Check whether there is a stop operation. If not, return to S2.3. Otherwise, proceed to the next step.
[0026] S2.7. Exit the data exchange thread;
[0027] S3: Custom communication protocol data parsing process
[0028] S3.1. Receive data packets;
[0029] S3.2. Define the message location based on the message header, message tail, or fixed location;
[0030] S3.3. Verify the message according to the configured verification method;
[0031] S3.4. If the verification is correct, proceed to the next step. Otherwise, return to S3.1.
[0032] S3.5. Decode the data according to the configured decoding method;
[0033] S3.6. Assign the data to the tags under the current device in sequence;
[0034] S3.7. Determine whether data parsing is complete. If not, return to step S3.5. Otherwise, proceed to the next step.
[0035] S3.8. Determine whether there is a stop signal. If there is no stop signal, return to step S3.1. Otherwise, proceed to the next step.
[0036] S3.9, exit the thread;
[0037] S4: Data freezing and storage algorithm
[0038] S4.1. Create a relational database table containing four fields: an auto-increment integer ID, a tag name with a maximum length of 256 characters, a double-precision floating-point tag value, and a timestamp, with the tag name and time as the primary keys.
[0039] S4.2. Calculate the next data storage time point;
[0040] S4.3, if the data storage time point has not been reached, check whether there is any SQL statement that failed to be submitted.
[0041] If you submit it again, go to the next step;
[0042] S4.4. When the data storage time point is reached, critical section synchronization is performed and SQL statements are generated for the data to be stored.
[0043] S4.5. Exit critical section synchronization and submit SQL statements one by one.
[0044] S4.6. Save the SQL statement that failed to be submitted;
[0045] S4.7. Determine whether there is a stop signal. If there is no stop signal, return to S4.2. If there is a stop signal, proceed to the next step.
[0046] S4.8. Check whether there are any SQL statements that failed to be submitted. If so, submit them again and proceed to the next step.
[0047] S4.9. Exit the thread;
[0048] S5: Report Generation Algorithm
[0049] S5.1. Read the EXCEL or CSV file template;
[0050] S5.2. Read a specified row or column as a label name;
[0051] S5.3. Read the specified data export time interval and time span;
[0052] S5.4. Read the specified data to fill the starting cell;
[0053] S5.5. Calculate the next data export time point;
[0054] S5.6. Wait for the data export time and proceed to the next step;
[0055] S5.7. The first time you export data on a given day, you read the template file. This is not the first time you read the last exported report.
[0056] S5.8. Loop through all tags, find the data to be exported from the database, and fill it into the specified cells;
[0057] S5.9. Determine whether there is a stop signal. If there is a stop signal, proceed to the next step; otherwise, return to S5.5.
[0058] S5.10, exit the thread;
[0059] S6: Data Calculation Algorithm
[0060] S6.1, the tag address stores the computational expression;
[0061] S6.2, TAG() tag references other tag values, and the tag value being referenced replaces the TAG() tag string;
[0062] S6.3. Convert infix expressions to reverse Polish notation;
[0063] S6.4. Use Reverse Polish Notation to evaluate expressions.
[0064] As a preferred technical solution of the present invention, the data exchange described in S2 uses an entry list to track the tag update status. Each entry contains an ID and a tag list. If there is a data tag update, the entry is searched by ID, and all tags in the tag list in the entry are notified to update the data.
[0065] As a preferred technical solution of the present invention, the relational database described in S4.1 has a saving function, supports periodic saving and condition-triggered saving, and the relational database contains three segments: tag name, time, and value. The tag name and time are used as the database joint primary key, and the time is accurate to seconds.
[0066] As an optimal technical solution of the present invention, the condition-triggered saving is divided into entry condition saving and exit condition saving: entry condition saving is saving once when the condition changes from unsatisfied to satisfied; exit condition saving is saving once when the condition changes from satisfied to unsatisfied.
[0067] As a preferred technical solution of the present invention, the report generation algorithm described in S5 supports two custom report templates, horizontal and vertical. The horizontal custom template: all label names are in one column, and all time period values corresponding to the label are in the same row and subsequent columns; the vertical custom template: all label names are in one row, and all time period values corresponding to the label are in the same column and subsequent rows.
[0068] As a preferred technical solution of the present invention, the custom communication protocol described in S3 supports three communication modes: serial port, Ethernet TCP, and Ethernet UDP. The serial port communication mode includes three links: RS232, RS422, and RS485. The Ethernet TCP communication requires configuration of the local IP and port, and the Ethernet UDP communication requires configuration of the local and target IP and port.
[0069] As a preferred technical solution of the present invention, the custom communication protocol described in S3 supports four modes in the data packet sending and receiving mode: send-only mode, receive-only mode, send first and receive later, and receive first and send later: the send-only mode is used to forward data externally and send the data to the specified receiving end according to the configured format; the receive-only mode is used to receive data and parse the received message according to the configured format; the send-first and receive-later mode is used for scenarios where it is necessary to send a request data command before receiving the data packet, or to receive the data first and then send a response; the receive-first and send-later mode is used for scenarios where it is necessary to receive a data request command first and then send data, or to receive the data packet first and then respond.
[0070] As a preferred technical solution of the present invention, the message described in S3 supports two parsing methods: specified data delimiter and fixed data length: the specified data delimiter parsing method parses the byte data between the delimiters (excluding the delimiters) into one data according to the set encoding; the fixed data length parsing method starts from the starting position of the data and parses the fixed length bytes into one data in sequence.
[0071] As a preferred technical solution of the present invention, the check described in S3 supports three check modes: CRC check, LRC check and summation. Each check mode can specify the check starting position and length, as well as the check value starting position and length.
[0072] The beneficial effects of the present invention are as follows:
[0073] The present invention searches for data bytes through the relative positions and specified absolute positions of the industrial communication protocol message header and message tail, thereby realizing the collection of simple serial communication protocol data through configuration; a solution for regularly storing data in a relational database by day, hour, and minute period is adopted, and the information system can find the hour and period by specifying the precise time without the need for algorithm filtering or interpolation; report templates are created through EXCEL and CSV files, and report functions can be exported according to the template format; in addition, the mutual conversion function of the protocols of the present invention improves the flexibility of data collection and forwarding, improves the efficiency of project implementation, and the custom protocol function improves the compatibility of the software with non-standard communication protocol equipment, reduces project costs, and accelerates the project implementation cycle. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 This is a software architecture diagram of the present invention;
[0075] Figure 2 This is a communication flow chart of the present invention. DETAILED DESCRIPTION
[0076] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0077] like Figures 1 to 2 As shown, an embodiment of the present invention provides an industrial communication soft gateway, which includes a channel operation process, a data exchange thread, a custom communication protocol data parsing process, a data freezing and storage algorithm, a report generation algorithm, and a data calculation algorithm:
[0078] S1: Channel operation process
[0079] S1.1. Create a channel thread;
[0080] S1.2. Open the channel. If successful, proceed to the next step. If the channel fails, try again in the next cycle.
[0081] S1.3. Set communication parameters;
[0082] S1.4. Initialize the devices under the channel and complete the communication efficiency optimization task;
[0083] S1.5. Test the channel status. If the communication status is normal, proceed to the next step. Otherwise, return to S1.1.
[0084] S1.6. Cycle through all devices in the channel to read the specified data.
[0085] S1.7. When device data changes, update the entry list and notify other devices to receive the new data;
[0086] S1.8. Write updated data from other devices to the device
[0087] S1.9, determine whether there is a stop operation, if there is a stop operation, go to the next step, otherwise return
[0088] S1.6;
[0089] S1.10, close the channel;
[0090] S1.11. Exit the thread and stop running;
[0091] S2: Data exchange thread
[0092] S2.1. Create a data exchange thread;
[0093] S2.2, clear the entry table;
[0094] S2.3. Traverse the tags under all channels, devices, and groups, create an entry using the tag ID as the primary key, and add the tag pointer to the tag list of the entry;
[0095] S2.4. Traverse the entry table and check whether the tag corresponding to each entry has an updated value;
[0096] S2.5. If an entry has an updated value, send the updated value to all tags in the entry tag list except those that generated the updated value.
[0097] S2.6. Check whether there is a stop operation. If not, return to S2.3. Otherwise, proceed to the next step.
[0098] S2.7. Exit the data exchange thread;
[0099] S3: Custom communication protocol data parsing process
[0100] S3.1. Receive data packets;
[0101] S3.2. Define the message location based on the message header, message tail, or fixed location;
[0102] S3.3. Verify the message according to the configured verification method;
[0103] S3.4. If the verification is correct, proceed to the next step. Otherwise, return to S3.1.
[0104] S3.5. Decode the data according to the configured decoding method;
[0105] S3.6. Assign the data to the tags under the current device in sequence;
[0106] S3.7. Determine whether data parsing is complete. If not, return to step S3.5. Otherwise, proceed to the next step.
[0107] S3.8. Determine whether there is a stop signal. If there is no stop signal, return to step S3.1. Otherwise, proceed to the next step.
[0108] S3.9, exit the thread;
[0109] S4: Data freezing and storage algorithm
[0110] S4.1. Create a relational database table containing four fields: an auto-increment integer ID, a tag name with a maximum length of 256 characters, a double-precision floating-point tag value, and a timestamp, with the tag name and time as the primary keys.
[0111] S4.2. Calculate the next data storage time point;
[0112] S4.3, if the data storage time point has not been reached, check whether there is any SQL statement that failed to be submitted.
[0113] If you submit it again, go to the next step;
[0114] S4.4. When the data storage time point is reached, critical section synchronization is performed and SQL statements are generated for the data to be stored.
[0115] S4.5. Exit critical section synchronization and submit SQL statements one by one.
[0116] S4.6. Save the SQL statement that failed to be submitted;
[0117] S4.7. Determine whether there is a stop signal. If there is no stop signal, return to S4.2. If there is a stop signal, proceed to the next step.
[0118] S4.8. Check whether there are any SQL statements that failed to be submitted. If so, submit them again and proceed to the next step.
[0119] S4.9. Exit the thread;
[0120] S5: Report Generation Algorithm
[0121] S5.1. Read the EXCEL or CSV file template;
[0122] S5.2. Read a specified row or column as a label name;
[0123] S5.3. Read the specified data export time interval and time span;
[0124] S5.4. Read the specified data to fill the starting cell;
[0125] S5.5. Calculate the next data export time point;
[0126] S5.6. Wait for the data export time and proceed to the next step;
[0127] S5.7. The first time you export data on a given day, you read the template file. This is not the first time you read the last exported report.
[0128] S5.8. Loop through all tags, find the data to be exported from the database, and fill it into the specified cells;
[0129] S5.9. Determine whether there is a stop signal. If there is a stop signal, proceed to the next step; otherwise, return to S5.5.
[0130] S5.10, exit the thread;
[0131] S6: Data Calculation Algorithm
[0132] S6.1, the tag address stores the computational expression;
[0133] S6.2, TAG() tag references other tag values, and the tag value being referenced replaces the TAG() tag string;
[0134] S6.3. Convert infix expressions to reverse Polish notation;
[0135] S6.4. Use Reverse Polish Notation to evaluate expressions.
[0136] The communication soft gateway of the present invention adopts .net Core language to develop application programs and supports cross-platform deployment; adopts a single document framework, configuration parameters are saved in files, configuration and operation are performed on the same software, and the specified default configuration file is loaded when the software starts. If no default configuration file is specified, the last edited configuration file is opened. If the software is run for the first time and the last opened file does not exist, a new empty file is created; for communication protocol drivers, four object models are designed: channel, device, group, and tag, which are used to manage and operate communication links, device communication functions, and measurement point data parameters. Each channel uses one thread for communication.
[0137] Among them, the data exchange in S2 uses an entry list to track the tag update status. Each entry contains an ID and a tag list. If there is a data tag update, the entry is found by the ID and all tags in the tag list in the entry are notified to update the data.
[0138] The soft bus function is implemented using an entry table. The entry table creates an entry for each ID. The entry also contains pointers to all tags with the same ID. Various communication protocols drive the acquisition device data, update the tag value, and find the corresponding entry through the tag ID. All tag pointers in the entry are notified to update the tag value, thus realizing data synchronization. In addition, data conversion is achieved through tag ID association. Tags that require data transmission or protocol conversion are configured with the same ID. When any tag value changes, all tags with the same ID are notified to update the value. The ID consists of one or more numbers, letters, underscores, and non-control visible characters. The tag address uses a dotted format, i.e., XXX.YYY.Z. Each communication protocol determines how many segments to use based on the address range and division method. The lowest segment can represent a binary bit.
[0139] Among them, the relational database in S4.1 has a saving function and supports periodic saving and condition-triggered saving. The relational database contains three segments: tag name, time, and value. The tag name and time are used as the database joint primary key, and the time is accurate to seconds.
[0140] The save cycle can be set to the minute of each hour and the hour and minute of each day; any save time point can be set for each time period, and the maximum save cycle can be set. When the save cycle is exceeded, the data will be automatically deleted to prevent excessive data from affecting query response speed or filling up disk space.
[0141] Among them, conditional trigger saving is divided into entry condition saving and exit condition saving. Entry condition saving is saved once when the condition changes from unsatisfied to satisfied; exit condition saving is saved once when the condition changes from satisfied to unsatisfied.
[0142] Condition-triggered save is a flexible data persistence mechanism. Its core advantage is that it automatically triggers data save through preset conditions, reducing redundant operations, improving efficiency, and enhancing data consistency, thereby improving the efficiency and reliability of relational databases in data management.
[0143] Among them, the report generation algorithm in S5 supports two custom report templates: horizontal and vertical. The horizontal custom template: all label names are in one column, and the corresponding time period values of the label are in the same row and subsequent columns; the vertical custom template: all label names are in one row, and the corresponding time period values of the label are in the same column and subsequent rows.
[0144] Both horizontal and vertical custom report templates are arranged in chronological order, supporting both ascending and descending time order.
[0145] Among them, the custom communication protocol in S3 supports three communication modes: serial port, Ethernet TCP, and Ethernet UDP. The serial port communication mode includes three links: RS232, RS422, and RS485. Ethernet TCP communication requires configuration of the local IP and port, and Ethernet UDP communication requires configuration of the local and target IP and port.
[0146] The serial port needs to be configured with the serial port number, baud rate, data bits, stop bits, and parity bit parameters. If the gateway acts as a client, Ethernet TCP also needs to be configured with the target IP and port.
[0147] Among them, the custom communication protocol in S3 supports four modes in data packet sending and receiving mode: send-only, receive-only, send first and receive later, and receive first and send later: the send-only mode is used to forward data externally and send the data to the specified receiving end in the configured format; the receive-only mode is used to receive data and parse the received message according to the configured format; the send-first and receive-later mode is used in scenarios where it is necessary to send a request data command before receiving the data packet, or to receive the data before sending a response; the receive-first and send-later mode is used in scenarios where it is necessary to receive a data request command before sending data, or to receive the data packet before responding.
[0148] In receive-only communication mode, the data mode supports single-frame and multi-frame. Single-frame data mode means that one message updates all tag data of this device, and multi-frame data mode means that multiple messages update all tag data of this device. Frame length mode is divided into fixed frame length and variable frame length. Fixed frame length requires specifying the frame length, while variable frame length does not require specifying the frame length.
[0149] Among them, the message in S3 supports two parsing methods: specified data delimiter and fixed data length. The specified data delimiter parsing method parses the byte data between the delimiters (excluding the delimiters) into one data according to the set encoding; the fixed data length parsing method starts from the starting position of the data and parses the fixed-length bytes into one data in sequence.
[0150] The custom driver supports locating the starting byte of the data part based on the message header, control word, function code, and message tail; if the non-standard communication protocol message header has fixed characters or byte content, the data part is located by matching the configured hexadecimal message header. The position of the message header in the message is configurable, and the length is automatically calculated based on the configured hexadecimal content; if the non-standard communication protocol control word has fixed characters or byte content, the data part is located by matching the configured hexadecimal control word. The position of the control word in the message is configurable, and the length is automatically calculated based on the configured hexadecimal content; if the non-standard communication protocol function code has fixed characters or byte content, the data part is located by matching the configured hexadecimal function code. The position of the function code in the message is configurable, and the length is automatically calculated based on the configured hexadecimal content; if the non-standard communication protocol message tail has fixed characters or byte content, the data part is located by matching the configured hexadecimal message tail. The position of the message tail in the message is configurable, and the length is automatically calculated based on the configured hexadecimal content; data encoding supports three encodings: ASCII, BCD, and hexadecimal. In addition, OPC is supported. DA service and OPC UA service, and also provides OPC DA client and OPC UA client.
[0151] Among them, the verification in S3 supports three verification methods: CRC verification, LRC verification, and summation. Each verification method can specify the verification starting position and length, as well as the verification value starting position and length.
[0152] The label value is assigned to the message byte order. The big-endian and little-endian byte orders are supported. The order of two bytes in a word and two words in a double word can also be adjusted.
[0153] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.
[0154] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. An industrial communication soft gateway, characterized by: The communication soft gateway includes channel operation process, data exchange thread, custom communication protocol data parsing process, data freezing and storage algorithm, report generation algorithm, and data calculation algorithm: S1: Channel operation process S1.
1. Create a channel thread; S1.
2. Open the channel. If successful, proceed to the next step. If the channel fails, try again in the next cycle. S1.
3. Set communication parameters; S1.
4. Initialize the devices under the channel and complete the communication efficiency optimization task; S1.
5. Test the channel status. If the communication status is normal, proceed to the next step. Otherwise, return to S1.
1. S1.
6. Cycle through all devices in the channel to read the specified data. S1.
7. When device data changes, update the entry list and notify other devices to receive the new data; S1.
8. Write updated data from other devices to the device S1.9, determine whether there is a stop operation, if there is a stop operation, go to the next step, otherwise return S1.6; S1.10, close the channel; S1.
11. Exit the thread and stop running; S2: Data exchange thread S2.
1. Create a data exchange thread; S2.2, clear the entry table; S2.
3. Traverse the tags under all channels, devices, and groups, create an entry using the tag ID as the primary key, and add the tag pointer to the tag list of the entry; S2.
4. Traverse the entry table and check whether the tag corresponding to each entry has an updated value; S2.
5. If an entry has an updated value, send the updated value to all tags in the entry tag list except those that generated the updated value. S2.
6. Check whether there is a stop operation. If not, return to S2.
3. Otherwise, proceed to the next step. S2.
7. Exit the data exchange thread; S3: Custom communication protocol data parsing process S3.
1. Receive data packets; S3.
2. Define the message location based on the message header, message tail, or fixed location; S3.
3. Verify the message according to the configured verification method; S3.
4. If the verification is correct, proceed to the next step. Otherwise, return to S3.
1. S3.
5. Decode the data according to the configured decoding method; S3.
6. Assign the data to the tags under the current device in sequence; S3.
7. Determine whether data parsing is complete. If not, return to step S3.
5. Otherwise, proceed to the next step. S3.
8. Determine whether there is a stop signal. If there is no stop signal, return to step S3.
1. Otherwise, proceed to the next step. S3.9, exit the thread; S4: Data freezing and storage algorithm S4.
1. Create a relational database table containing four fields: an auto-increment integer ID, a tag name with a maximum length of 256 characters, a double-precision floating-point tag value, and a timestamp, with the tag name and time as the primary keys. S4.
2. Calculate the next data storage time point; S4.3: If the data storage time point has not been reached, check whether there are any SQL statements that failed to be submitted. If so, submit them again and proceed to the next step. S4.
4. When the data storage time point is reached, critical section synchronization is performed and SQL statements are generated for the data to be stored. S4.
5. Exit critical section synchronization and submit SQL statements one by one. S4.
6. Save the SQL statement that failed to be submitted; S4.
7. Determine whether there is a stop signal. If there is no stop signal, return to S4.
2. If there is a stop signal, proceed to the next step. S4.
8. Check whether there are any SQL statements that failed to be submitted. If so, submit them again and proceed to the next step. S4.
9. Exit the thread; S5: Report Generation Algorithm S5.
1. Read the EXCEL or CSV file template; S5.
2. Read a specified row or column as a label name; S5.
3. Read the specified data export time interval and time span; S5.
4. Read the specified data to fill the starting cell; S5.
5. Calculate the next data export time point; S5.
6. Wait for the data export time and proceed to the next step; S5.
7. The first time you export data on a given day, you read the template file. This is not the first time you read the last exported report. S5.
8. Loop through all tags, find the data to be exported from the database, and fill it into the specified cells; S5.
9. Determine whether there is a stop signal. If there is a stop signal, proceed to the next step; otherwise, return to S5.
5. S5.10, exit the thread; S6: Data Calculation Algorithm S6.1, the tag address stores the computational expression; S6.2, TAG() tag references other tag values, and the tag value being referenced replaces the TAG() tag string; S6.
3. Convert infix expressions to reverse Polish notation; S6.
4. Use Reverse Polish Notation to evaluate expressions.
2. The industrial communication soft gateway according to claim 1, characterized in that: The data exchange described in S2 uses an entry list to track the tag update status. Each entry contains an ID and a tag list. If there is a data tag update, the entry is found by the ID and all tags in the tag list within the entry are notified to update the data.
3. The industrial communication soft gateway according to claim 2, characterized in that: The relational database described in S4.1 has a saving function and supports periodic saving and condition-triggered saving. The relational database contains three segments: tag name, time, and value. The tag name and time are used as the database joint primary key, and the time is accurate to seconds.
4. The industrial communication soft gateway according to claim 3, characterized in that: The condition trigger saving is divided into two types: entry condition saving and exit condition saving. Entry condition saving is saving once when the condition changes from unsatisfied to satisfied; exit condition saving is saving once when the condition changes from satisfied to unsatisfied.
5. The industrial communication soft gateway according to claim 1, characterized in that: The report generation algorithm described in S5 supports two custom report templates, horizontal and vertical. For the horizontal custom template, all label names are in one column, and all time period values corresponding to the label are in the same row and subsequent columns; for the vertical custom template, all label names are in one row, and all time period values corresponding to the label are in the same column and subsequent rows.
6. The industrial communication soft gateway according to claim 1, characterized in that: The custom communication protocol described in S3 supports three communication modes: serial port, Ethernet TCP, and Ethernet UDP. The serial port communication mode includes three links: RS232, RS422, and RS485. The Ethernet TCP communication requires configuration of the local IP and port, and the Ethernet UDP communication requires configuration of the local and target IP and port.
7. The industrial communication soft gateway according to claim 1, characterized in that: The custom communication protocol described in S3 supports four modes in data packet sending and receiving modes: send-only, receive-only, send first and receive later, and receive first and send later: the send-only mode is used to forward data externally and send the data to the specified receiving end in the configured format; the receive-only mode is used to receive data and parse the received message according to the configured format; the send-first and receive-later mode is used in scenarios where it is necessary to send a request data command before receiving a data packet, or to receive data first and then send a response; the receive-first and send-later mode is used in scenarios where it is necessary to receive a data request command before sending data, or to receive a data packet first and then respond.
8. The industrial communication soft gateway according to claim 1, characterized in that: The message described in S3 supports two parsing methods: specified data delimiter and fixed data length. The specified data delimiter parsing method parses the byte data between the delimiters (excluding the delimiters) into one data according to the set encoding; the fixed data length parsing method starts from the starting position of the data and parses the fixed length bytes into one data in sequence.
9. The industrial communication soft gateway according to claim 1, characterized in that: The check described in S3 supports three check modes: CRC check, LRC check, and summation. Each check mode can specify the check start position and length, as well as the check value start position and length.