General thermal power plant machine room DCS equipment data transmission method, equipment, medium and product

By defining configuration files and mapping tables, setting retransmission mechanisms and error handling mechanisms, the problem of delay and inefficiency of communication protocols in the transmission of large data volumes in general thermal power plant computer rooms is solved, and flexible data acquisition and transmission is realized, and the improvement of the Communication compatibility and scalability avoid data loss or corruption.

CN119232748AActive Publication Date: 2024-12-31ZHEJIANG HAOPU INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202411336729.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2024-12-31
Estimated Expiration
2044-09-24

AI Technical Summary

Technical Problem

The communication protocol of DCS equipment in the existing general thermal power plant computer room has problems of delay and inefficiency when transmitting large data volumes, and lacks retransmission mechanism and data integrity guarantees. It is susceptible to noise and interference to cause data loss or damage, and cannot be flexibly obtained. The required data, poor reusability and scalability.

Method used

By defining configuration files and mapping tables, setting communication parameters and data item lists based on YAML format, parsing configuration files to establish connections with DCS equipment in general thermal power plant computer room, setting up retransmission mechanisms and error handling mechanisms, realizing flexible data acquisition and transmission, and is compatible with multiple compatible This communication protocol ensures data integrity and reliability.

Benefits of technology

It realizes the increase and decrease of data volume and makes it convenient, solves the problems of delay and inefficiency in the transmission of big data, avoids data loss or damage, improves communication compatibility and scalability, and simplifies communication between devices. process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119232748A_ABST
    Figure CN119232748A_ABST
Patent Text Reader

Abstract

The invention discloses a general thermal power plant machine room DCS equipment data transmission method, equipment, a medium and a product, and relates to the field of data transmission, and the method comprises the steps: after a configuration file is defined, analyzing the configuration file, building a connection with general thermal power plant machine room DCS equipment according to a communication parameter and a mapping table, and based on a user request, according to a to-be-acquired data item list, obtaining a data item list; and reading data from the general thermal power plant machine room DCS equipment to obtain original data, processing the original data based on regulations of a communication protocol, and setting a retransmission mechanism and an error processing mechanism to obtain a data reading result. According to the application, the increase and decrease of the data volume become more convenient, the problems of delay and low efficiency in the big data transmission process can be solved, and the problem of data loss or damage caused by the influence of noise and interference is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data transmission, and in particular to a method, device, medium and product for data transmission of DCS equipment in a general thermal power plant computer room. Background Art

[0002] In the factory automation environment, the DCS (Distributed Control System) equipment in the general thermal power plant computer room and the computer room side generally use communication protocols (such as Modbus protocol) to communicate. The serial port and baud rate used for communication are generally fixed. At the same time, the data read by the DCS equipment in the general thermal power plant computer room is also fixed. This form of communication is more suitable for a single general thermal power plant computer room DCS equipment, but in the case of multiple general thermal power plant computer room DCS equipment or different factory operating conditions, the overall communication logic needs to be reconstructed, and the scalability and reusability are very poor.

[0003] The existing technical solutions mainly focus on writing separate communication programs for each DCS device in the general thermal power plant room, and cannot fully cover the different communication protocols required by different factories. For example, the Modbus TCP protocol and the common big-end and small-end correspondence require large-scale modifications to the existing communication.

[0004] Existing communication protocols have some limitations when processing large amounts of data. One of the main drawbacks is that it is impossible to specify the amount of data to be acquired, which makes it subject to many restrictions when large amounts of data need to be processed. In addition, existing communication protocols usually use serial communication with limited bandwidth and speed, which leads to delays and inefficiencies in the process of large data transmission. In addition, existing communication protocols lack retransmission mechanisms and data integrity guarantees during transmission, and are easily affected by noise and interference, resulting in data loss or corruption. Summary of the invention

[0005] In order to solve the above problems existing in the prior art, the present application provides a general thermal power plant machine room DCS equipment data transmission method, equipment, medium and product.

[0006] To achieve the above objectives, this application provides the following solutions:

[0007] In a first aspect, the present application provides a general thermal power plant room DCS equipment data transmission method, comprising:

[0008] Define a configuration file, in which a configuration block is defined for the communication program, and the configuration content of the configuration block is set based on the YAML format; the configuration content includes: communication parameters and a list of data items to be acquired; the communication parameters include one or more of a serial port number, a baud rate, an IP address, a data bit, a stop bit, a parity check, a slave address (device ID), a timeout, a frame interval, a start character, an end character, an error detection, an MBAP header, a data rate, a function code, a byte order, and a port number;

[0009] Define a mapping table, use Mysql database to store and manage various mapping relationships in the mapping table; the mapping table contains the following contents: protocol content mapping import module, connection error mapping, unit mapping conversion and data type mapping; the protocol content mapping import module is used to define the data mapping relationship between different communication protocols; the protocol content mapping import module includes the identification of the source protocol and the target protocol, and the data point mapping rules; the connection error mapping is used to standardize the processing methods of various connection errors; the connection error types are stored in the database, and each error has a corresponding error code, description text and severity level; the unit mapping conversion is used to define the conversion rules between different measurement units; the source unit, the target unit and the corresponding conversion formula or conversion factor are stored in the database; the data type mapping is used to define the data type of various data items, and is used to correctly handle the data type when transmitting data between different systems or protocols;

[0010] Parsing the configuration file, establishing a connection with a DCS device in a general thermal power plant room according to the communication parameters and the mapping table, reading data from the DCS device in the general thermal power plant room according to a list of data items to be acquired based on a user request to obtain original data, and processing the original data based on the provisions of the communication protocol to obtain a data reading result;

[0011] In the process of obtaining data reading results, set up a retransmission mechanism and an error handling mechanism;

[0012] When no data read response is obtained within a set time, the retransmission mechanism is triggered;

[0013] When the data reading result obtained is abnormal, the error handling mechanism is triggered.

[0014] Optionally, the raw data is processed based on a provision of a communication protocol to obtain a data reading result, including:

[0015] According to the data format of the original data, traverse and parse the data structures of each layer of the original data;

[0016] Defining data parsing logic, and based on the data parsing logic, locating the location of the data item corresponding to the user request in each layer of the data structure of the original data, and extracting the data item value;

[0017] For the data item value, according to the original unit and point situation of the data item value, query the rule base to obtain the conversion rule; the rule base definition is obtained;

[0018] The data item value is converted based on the conversion rule, and the data reading result is obtained based on the converted data item value.

[0019] Optionally, when no data read response is obtained within a set time, triggering the retransmission mechanism includes:

[0020] Resending the request identical to the user request, and determining whether a data reading response is obtained within a set time;

[0021] If a data reading response is obtained within a set time, the data reading result is output;

[0022] If no data read response is obtained within the set time, the process returns to the step of resending the same request as the user request and determining whether a data read response is obtained within the set time, until the upper limit of request retransmission is reached, and then a read failure message is returned; for each retransmission request, the set time is increased gradually.

[0023] Optionally, when the obtained data reading result is abnormal, triggering the error handling mechanism includes:

[0024] Performing an integrity check on the data reading result to obtain a test result;

[0025] When the inspection result shows that the data reading result is complete, outputting the data reading result;

[0026] When the inspection result is that the data reading result is incomplete, it is determined that the data reading result is damaged, the retransmission mechanism is triggered, and the step of performing an integrity check on the data reading result to obtain the inspection result is returned, until the requested retransmission upper limit is reached and the inspection result is still that the data reading result is incomplete, a read error message is returned.

[0027] Optionally, the configuration file is loaded and parsed by a PyYAML library.

[0028] Optionally, the process of parsing the configuration file and establishing a connection with a DCS device in a general thermal power plant room according to the communication parameters and the mapping table includes:

[0029] According to the protocol type of the DCS equipment in the general thermal power plant room, the corresponding module path and class name are found from the mapping table, and the module corresponding to the module path is dynamically imported using the importlib module of Python to obtain a reference to the class;

[0030] Using the reflection mechanism, create the communication object of the class through the reference of the class;

[0031] Parsing the configuration file to obtain the communication parameters of the DCS equipment in the general thermal power plant room;

[0032] The communication parameters of the general thermal power plant room DCS device are passed to the communication object, and the corresponding initialization method is called according to different protocol types to establish a connection with the general thermal power plant room DCS device.

[0033] Optionally, the process of setting the configuration content of the configuration block based on the YAML format includes:

[0034] An editing tool is used to set the configuration content of the configuration block based on the YAML format.

[0035] In a second aspect, the present application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-mentioned general thermal power plant room DCS equipment data transmission method.

[0036] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned general thermal power plant machine room DCS equipment data transmission method.

[0037] In a fourth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned general thermal power plant room DCS equipment data transmission method.

[0038] According to the specific embodiments provided in this application, this application discloses the following technical effects:

[0039] The present application provides a method, device, medium and product for transmitting data of a general thermal power plant machine room DCS device. By defining a configuration file, the required data can be flexibly obtained, making the increase or decrease of the data volume more convenient. Parse the configuration file, establish a connection with the general thermal power plant machine room DCS device (hereinafter referred to as the device) according to the communication parameters and mapping table, so that the communication between the devices is more convenient. At the same time, even when the equipment is replaced later, there is no need to make major adjustments to the communication program of the equipment. In addition, parse the configuration file, establish a connection with the general thermal power plant machine room DCS device (hereinafter referred to as the device) according to the communication parameters and mapping table, which can solve the delay and inefficiency problems that occur during the transmission of large data. By setting an error handling mechanism and a retransmission mechanism, the problem of data loss or damage due to noise and interference can be avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments 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 creative work.

[0041] Figure 1 A flowchart of a method for transmitting data of a DCS device in a general thermal power plant room provided in one embodiment of the present application;

[0042] Figure 2 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0043] 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 creative work are within the scope of protection of this application.

[0044] In order to make the purpose, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0045] In the embodiments of this application, Figure 1 As shown, a general thermal power plant room DCS equipment data transmission method is provided, which is executed by a computer device, specifically, it can be executed by a computer device such as a terminal or a server alone, or it can be executed by a terminal and a server together. In the embodiment of the present application, the method is applied to an electronic device as an example for explanation, including the following steps 100 to 105. Among them:

[0046] Step 100: define a configuration file, in which a configuration block is defined for the communication program, and the configuration content of the configuration block is set based on the YAML format. The configuration content includes: communication parameters and a list of data items to be obtained. The communication parameters include one or more of serial port number, baud rate, IP address, data bit, stop bit, parity check, slave address (device ID), timeout, frame interval, start character, end character, error detection, MBAP header, data rate, function code, byte order and port number. Among them, communication parameters refer to the communication parameters of a single device, and multiple devices have multiple communication parameters. Device refers to DCS device or PLC device. IP address, port number, slave address, MBAP header all belong to Modbus Tcp protocol and Modbus Udp protocol. Serial port parameters, slave address: 1-247, start character: colon (:), end character: carriage return line feed (CR / LF), error detection: LRC (longitudinal redundancy check) part belongs to Modbus ASCII protocol. Port number (COM port): specifies which serial port to use for communication Baud rate: usually 9600, 19200, 38400, 57600 or 115200 bps, data bit stop bit: 1 bit or 2 bits, parity: none, odd or even, frame interval, CRC check This part belongs to the Modbus RTU protocol. Function code and byte code belong to the general protocol and exist in all protocols.

[0047] Step 101: Define a mapping table, and use a Mysql database to store and manage the various mapping relationships in the mapping table. The mapping table mainly includes the following aspects: (1) Protocol content mapping import module, which defines the data mapping relationship between different communication protocols. It includes the identification of the source protocol and the target protocol, as well as specific data point mapping rules; (2) Connection error mapping: used to standardize the handling methods of various connection errors. The possible types of connection errors are stored in the database, and each error has a corresponding error code, description text and severity level; (3) Unit mapping conversion: defines the conversion rules between different measurement units. The database stores the source unit, target unit and the corresponding conversion formula or conversion factor; (4) Data type mapping: defines the data type of various data items, which is used to ensure that the data type can be correctly processed when transmitting data between different systems or protocols.

[0048] Step 102: Parse the configuration file, establish a connection with the DCS device in the general thermal power plant room (hereinafter referred to as the device) according to the communication parameters and the mapping table, read data from the DCS device in the general thermal power plant room according to the list of data items to be obtained based on the user's request to obtain the original data, process the original data based on the provisions of the communication protocol, and obtain the data reading result.

[0049] Step 103: In the process of obtaining the data reading result, a retransmission mechanism and an error handling mechanism are set.

[0050] Step 104: When no data read response is obtained within a set time, a retransmission mechanism is triggered.

[0051] Step 105: When the obtained data reading result is abnormal, an error handling mechanism is triggered.

[0052] Implementing the above steps 100 to 105 makes it easier to increase or decrease the amount of data, solves the delay and inefficiency problems in the transmission of large data, and avoids the problem of data loss or damage due to noise and interference. In addition, the present application can also be compatible with common Modbus protocols on the market, including RTU, ASCII and TCP, to ensure the compatibility and scalability of communication.

[0053] In another exemplary embodiment of the present application, a serial communication device (such as a USB to serial port adapter) is used to establish a connection with the device. These communication devices provide a reliable physical connection and are compatible with the computer system, facilitating the transmission and processing of data. In the specific implementation process, the communication connection and data transmission are mainly completed through the communication program. Based on this, in the above-mentioned steps 100 and 101, the parsing configuration file is connected to the DCS equipment in the general thermal power plant room according to the communication parameters and the mapping table. The implementation process of the configuration file is:

[0054] The configuration file adopts the common YAML format, which is convenient for users to edit and parse. In the configuration file, you can define a configuration block for the communication program, which contains the communication parameters of the device and the list of data items that need to be obtained. According to the standard format of the YAML file, the configuration content is set. Users can edit these configuration blocks through text document editing tools or other editing tools to customize the communication settings and data acquisition requirements of each device. Communication parameters such as port (serial port name or TCP port number), baudrate (baud rate), host (IP address or host name), etc. For example, the communication parameters of the Modbus protocol are unit (slave address), address (register starting address), etc.

[0055] The communication program parses the configuration file to obtain the configuration information of each device. Then, it establishes a connection with the device [such as a programmable logic controller, PLC, or remote terminal unit (RTU)] based on the communication parameters. For example, you can choose to use Python's serial communication library Pymodbus or pyModbusTCP to implement it.

[0056] Based on the description of this embodiment, the process of parsing the configuration file in step 101 and establishing a connection with the DCS equipment in the general thermal power plant room according to the communication parameters and the mapping table can be summarized as follows:

[0057] (1) According to the protocol type of the DCS equipment in the general thermal power plant room, the corresponding module path and class name are found in the mapping table, and the module corresponding to the module path is dynamically imported using Python's importlib module to obtain the class reference.

[0058] (2) Using the reflection mechanism, create a communication object of the class through the reference of the class.

[0059] (3) Obtain the communication parameters of the DCS equipment in the general thermal power plant room from the configuration file.

[0060] (4) The communication parameters of the DCS equipment in the general thermal power plant room are passed to the communication object, and the corresponding initialization method is called according to different protocol types to establish a connection with the DCS equipment in the general thermal power plant room.

[0061] In another exemplary embodiment of the present application, in step 101, the original data is processed based on the provisions of the communication protocol to obtain the data reading result, which includes:

[0062] (1) According to the data format of the original data, traverse and parse the data structures of each layer of the original data.

[0063] (2) Define the data parsing logic, and based on the data parsing logic, locate the data item corresponding to the user request in each layer of the data structure of the original data and extract the data item value.

[0064] (3) For the data item value, according to the original unit and point situation of the data item value, query the rule base to obtain the conversion rule. The rule base definition is obtained.

[0065] (4) The data item value is converted based on the conversion rule, and the data reading result is obtained based on the converted data item value.

[0066] In another exemplary embodiment of the present application, in step 101, based on a user request and according to a list of data items to be acquired, data is read from a DCS device in a general thermal power plant room to obtain raw data, and the raw data is processed based on the provisions of the communication protocol to obtain a data reading result, the process includes:

[0067] First, the communication program sends a request to the DCS device or PLC device to obtain the original data of the required communication protocol (such as Modbus RTU protocol) according to the list of data items that each device needs to obtain in the configuration file, and parses and extracts the specified data items. The obtained data needs to be converted into units. Among them, the original data of the communication protocol is generally composed of the format of ([start bit][slave address][function code][data][CRC check]).

[0068] Next, parse and extract the specified data items. According to the original data format (JSON, YAML format) returned by the device, traverse and parse the data structure of each layer to locate the location of the data item to be extracted. For each data item to be extracted, write the corresponding data parsing logic to accurately extract the value of the data item from the original data. Considering that the data formats returned by different devices may be different, different data parsing logic needs to be written for different device types and models. For example, the data parsing logic of the Transmission Control Protocol (TCP) is used for Siemens S7-1200 PLC, the data parsing logic of RTU is used for Schneider Modicon M241 PLC, ABB ACS880 inverter and Rosemount 3051S pressure transmitter, and the data parsing logic of American Standard Code for Information Interchange (ASCII) is used for Anderson-Yeger EJA110E pressure transmitter.

[0069] Among them, the process of writing the corresponding data parsing logic and accurately extracting the value of the data item from the original data is as follows: first import the necessary modules in the pymodbus library such as Modbus Tcp Client, Modbus Serial Client, Binary Payload Decoder, and Endian. Then, create a base class ModbusDeviceBase, which contains methods for initialization, reading data, parsing data, and obtaining parsed data. Next, create a subclass for each device, inherit from the base class, and define the methods for initialization, reading data, and parsing data for a specific device in each subclass. For example, the SiemensS71200 class initializes the Modbus TCP client through the IP address, reads the holding register, and uses the Binary PayloadDecoder to parse the register data and convert it into specific measurement values ​​(such as temperature, pressure, and flow). Other device classes such as SchneiderM241 and ABBACS880 also follow similar logic. The parsing logic needs to have fault-tolerant processing capabilities and be able to handle abnormal situations (such as data format errors, missing key fields, etc.) to avoid data loss caused by parsing failure. The parsed data item value needs to be converted to ensure that it matches the expected data type.

[0070] In the raw data returned by different devices, the units of the same data item may be different, and a unified unit conversion is required. Unit conversion is mainly achieved by maintaining a unit conversion rule base, clarifying the standard unit of each data item, and the conversion formula from different source units to standard units. For example:

[0071] (1) Temperature conversion:

[0072] The conversion formula from Celsius (℃) to Fahrenheit (°F) is: °F = (℃×9 / 5) + 3.

[0073] The conversion formula from Fahrenheit (°F) to Celsius (℃) is: ℃ = (°F-32) × 5 / 9.

[0074] The conversion formula from Kelvin (K) to Celsius (℃) is: ℃ = K-273.15.

[0075] (2) Pressure conversion:

[0076] The conversion formula from bar to kilopascals (kPa) is: kPa = bar × 100.

[0077] The conversion formula from pounds per square inch (psi) to kilopascals (kPa) is: kPa = psi × 6.89476.

[0078] The conversion formula from megapascal (MPa) to kilopascal (kPa) is: kPa = MPa × 1000.

[0079] (4) Traffic conversion:

[0080] Cubic meter / hour (m 3 The conversion formula from liters / hour to liters / minute (L / min) is: L / min = (m 3 / h×1000) / 60.

[0081] Gallons per minute (gpm) to cubic meters per hour (m 3 / h) is converted into: m 3 / h=gpm×0.227124.

[0082] (5) Power conversion:

[0083] The conversion formula from kilowatt (kW) to megawatt (MW) is: MW = kW / 1000.

[0084] The conversion formula from horsepower (hp) to kilowatts (kW) is: kW = hp × 0.745699.

[0085] (6) Heat conversion:

[0086] The conversion formula from kilocalorie (kcal) to kilojoule (kJ) is: kJ = kcal × 4.184.

[0087] The conversion formula from British thermal units (BTU) to kilojoules (kJ) is: kJ = BTU × 1.055056.

[0088] (7) Voltage conversion:

[0089] The conversion formula from kilovolt (kV) to volt (V) is: V = kV × 1000.

[0090] (8) Current conversion:

[0091] The conversion formula from ampere (A) to milliampere (mA) is: mA = A × 1000.

[0092] (9) Frequency conversion:

[0093] The conversion formula from Hertz (Hz) to kilohertz (kHz) is: kHz = Hz / 1000.

[0094] In addition, other conversion formulas are included, which will not be described in detail here.

[0095] For each parsed data item value, query the rule base to obtain the corresponding conversion formula according to its original unit and point situation. Through unit conversion calculation, the data item value is converted from the original unit to the standard unit. The converted data needs to ensure no loss of accuracy, and for floating-point calculations, attention should be paid to rounding errors. If the unit conversion rule for a data item cannot be found, the original value and unit are retained, and a warning message is recorded in the log. The processed data is stored in files and databases, and the visualization library can also be used to display the data in charts or other forms.

[0096] During the whole process, the communication program will record relevant log information for debugging and tracking, and handle and report any abnormal situations that may occur (such as communication errors, data format errors, etc.) appropriately.

[0097] In another exemplary embodiment of the present application, the implementation process of step 103 includes:

[0098] (1) Resend the same request as the user request and determine whether a data read response is obtained within the set time.

[0099] (2) If a data read response is obtained within the set time, the data read result is output.

[0100] (3) If no data read response is obtained within the set time, the process returns to the step of resending the same request as the user request and determining whether a data read response is obtained within the set time, until the upper limit of request resending is reached, and a read failure message is returned. For each resending request, the set time is gradually increased.

[0101] In another exemplary embodiment of the present application, the implementation process of step 104 includes:

[0102] (1) Perform integrity check on the data reading result to obtain the test result.

[0103] (2) When the inspection result shows that the data reading result is complete, the data reading result is output.

[0104] (3) When the inspection result shows that the data reading result is incomplete, it is determined that the data reading result is damaged, the retransmission mechanism is triggered, and the process returns to the step of performing an integrity check on the data reading result to obtain the inspection result, until the upper limit of the requested retransmission is reached and the inspection result still shows that the data reading result is incomplete, and a read error message is returned.

[0105] In another exemplary embodiment of the present application, in the general thermal power plant room DCS equipment data transmission method provided by the present application, the data acquisition and processing process can be described as follows:

[0106] The communication program establishes a connection with the device according to the communication parameters defined in the configuration file, and reads data from the device according to the list of data items specified by the user. The data read is raw data, which is processed by the provisions of the Modbus RTU protocol or other protocols such as TCP, ASCII, etc., and converted into normal read data. Take the ModbusRTU protocol as an example. The process of converting the raw data a and b read in the Modbus protocol into normal floating point values ​​is as follows:

[0107] First, use the hex() function to convert a and b into hexadecimal strings, remove the prefix "0x" and use the zfill(4) method to fill the string length to 4 characters. Then, according to the IEEE 754 floating-point format rule that the high byte comes first and the low byte comes last, concatenate the two filled hexadecimal strings, and use the bytes.fromhex() method to convert the concatenated strings into a byte sequence. Finally, use the unpack() function of the struct module to unpack the byte sequence according to the network byte order and floating-point format, and take the first element of the returned tuple as the converted floating-point value.

[0108] When reading data, a retransmission mechanism and error handling are set up to ensure the integrity and reliability of the data. The retransmission mechanism starts a timer after sending a request. If no response is received after the timeout, the same request will be resent. The number of retransmissions is capped, and the timeout period will be appropriately increased before each retransmission.

[0109] Error handling will check the integrity of the response data. After receiving the original data returned by the device, the data needs to be checked for integrity. According to the Modbus protocol, the last two bytes of the data returned by the device are checksums [such as cyclic redundancy check (CRC), checksum, etc.], which are used to verify whether the data has been tampered with during transmission. Get the checksum field in the original data and recalculate the checksum value of the data according to the checksum algorithm (such as CRC16, CRC32, etc.). Taking the CRC16 algorithm as an example, for the Modbus protocol, there is an initialization CRC value of 0xFFFF and a 16-bit polynomial value of 0xA001. The following processing is performed on each data byte:

[0110] Perform an XOR operation on the data byte and the lower 8 bits of the CRC. Repeat the following operation multiple times (for example 8 times) (corresponding to the 8 bits of a byte): Check the lowest bit of the CRC (the first bit on the right), if it is 1, shift the CRC value right by one bit, and then perform an XOR operation with the polynomial value (0xA001). If it is 0, just shift the CRC value right by one bit. Repeat the previous steps until all data bytes have been processed. The final 16-bit value is the CRC checksum. In the Modbus protocol, this value is usually appended to the end of the message in low byte first order (little endian).

[0111] Compare the recalculated checksum with the checksum in the original data to see if they are consistent. If they are not consistent, the data is considered to be damaged. For recoverable errors such as checksum errors, the request will be resent and the retransmission mechanism will be started. If a checksum error is found, it is usually considered that the data is contaminated during transmission, but the device itself is operating normally. At this time, you can try to request the data again to give the device a chance to retransmit. Implement a retry mechanism, set the maximum number of retries (such as 3 times), and terminate the communication after the number is exceeded. Before each retry, set a reasonable waiting interval to avoid excessive requests that cause the device to be overloaded. If response data with the correct checksum is received within the specified number of retries, the recoverable error is considered to have been resolved and subsequent processing can continue.

[0112] For unrecoverable errors such as device return exception codes (e.g., Modbus IOException indicates I / O related errors, Modbus Exception indicates Modbus protocol related exceptions, and Connection Exception indicates connection related exceptions), these exceptions are captured to determine whether an exception response has been received. Indicates that the device itself is faulty or in an abnormal state. By maintaining an exception code mapping table, a dictionary is created to map exception codes and descriptions, such as exception_codes = {1: "illegal function", 2: "illegal data address", 3: "illegal data value", 4: "device failure", 5: "confirmation", 6: "device busy"}, and the exception code returned by the device is matched to the specific error information. Parse the data returned by the device and check whether it contains the exception code field. If it does, query the mapping table to obtain the corresponding error information. After obtaining the error information, the detailed error information is recorded in the log. The error information includes timestamp, device ID, error code, and description. Subsequently, the error is classified as recoverable or unrecoverable according to its nature, and the relevant personnel are notified in a timely manner through multiple channels (such as control room alarms, text messages, etc.). At the same time, the monitoring interface can also be updated in real time to display the error status. For recoverable errors, such as: short communication interruptions caused by network congestion or temporary interference. Data verification error: such as CRC verification failure, it may be caused by noise interference during transmission. Device busy state: the device is temporarily unable to respond to the request, but it is expected to return to normal later, etc. The system will try to recover automatically, such as resending instructions or restarting communication. For unrecoverable errors, certain specific exception codes may indicate serious problems. It is usually necessary to terminate communication with the device and output the corresponding error prompt information in the log / UI to facilitate subsequent troubleshooting. The error prompt information needs to contain sufficient context information, such as device ID, error code, error description, etc., to quickly locate the problem. In addition, the program will also handle exceptions at the communication level, such as serial port opening failure, connection interruption, and try to reconnect. If it still fails, it will prompt to check the hardware. Unrecoverable errors include connection exceptions (ConnectionException): indicating that the connection with the device cannot be established or maintained. Specific Modbus exception codes indicate device failures. For example, code 4 indicates that an unrecoverable error has occurred inside the device. Code 5 (confirmation) indicates that being in this state for a long time may indicate that the device is stuck. Code 6 (Device Busy) indicates that if it continues to occur, it may indicate a serious problem with the device. Repeated failure means that if an operation fails more than a predetermined number of times in a row, it can be considered an unrecoverable error. Custom serious errors refer to device characteristics.

[0113] In another exemplary embodiment of the present application, the communication program realizes compatibility with different Modbus protocols (such as RTU, ASCII and TCP). According to the device definition in the configuration file, the appropriate protocol is dynamically selected to communicate with the device. In this way, users can flexibly switch and use different communication protocols in different industrial environments without modifying or recompiling the program. The specific implementation process is:

[0114] First, use the PyYAML library to load and parse the YAML-formatted configuration file to obtain the Modbus protocol type used by each device. The configuration file defines an entry for each device, including device ID, protocol type, communication parameters (such as serial port number, baud rate, IP address, port number, etc.) and other information.

[0115] Secondly, maintain a protocol type mapping table to map different protocol type strings (such as "RTU", "TCP") to corresponding Python module paths and class names. The mapping table acts as a lookup table to facilitate finding the modules and classes that need to be dynamically imported based on the protocol type strings read from the configuration file.

[0116] Then, for each device, the corresponding module path and class name are found in the mapping table according to its protocol type, and the specified module is dynamically imported using Python's importlib module to obtain the class reference. Using the reflection mechanism, an instance object of the class is created through the class reference, that is, the communication host object of the corresponding protocol type.

[0117] Next, read the specific communication parameters of the device from the configuration file, such as serial port number, baud rate, IP address, port number, etc., pass these parameters to the communication object created earlier, call the corresponding initialization method according to different protocol types, and establish a connection with the device.

[0118] In order to unify the interaction between the upper-level business logic and the underlying communication objects, a general communication interface class is defined, and the specific communication objects are used as attributes of the interface class. The methods for reading and writing data are implemented in the interface class, and the corresponding read and write methods of the underlying communication objects are called internally. In this way, the upper-level logic only needs to interact with the unified interface without paying attention to the specific protocol used by the underlying layer. Finally, when the system is initialized, all devices in the configuration file are traversed, and corresponding communication objects are dynamically created for each device according to its protocol type. The created objects are encapsulated in an instance of the communication interface class and saved as attributes. When the upper-level logic needs to communicate with a device, it obtains the corresponding instance of the device from the interface class and calls its read and write methods to interact with the device without paying attention to the protocol used by the underlying layer. This dynamic loading method enhances scalability.

[0119] When a new protocol type needs to be supported, you only need to add a new protocol type entry to the mapping table and implement the corresponding modules and classes without modifying the main logic code. At the same time, since communication objects of different protocol types implement similar read and write interfaces, the changes to the upper-level business logic are also small, and new protocol support can be integrated more easily. Then set other communication parameters to the object, call the object method to establish a connection with the device according to the protocol. Then use the unified interface to read and write data from the communication object, use the appropriate method to exchange data with the device according to the protocol, and finally close the connection.

[0120] Through this dynamic switching process, you only need to specify the protocol type in the configuration file, and you can switch to different Modbus protocols in different industrial environments without modifying the program, reducing development and maintenance costs. You can further use design patterns to optimize the code and support more protocol variants to meet the needs of more scenarios.

[0121] In summary, this application solves the limitations of the Modbus protocol in transmitting large amounts of data. It flexibly obtains the required data through configuration files, making it easier to increase or decrease the amount of data. At the same time, configuration files are also used to process parameters such as serial port names and baud rates in serial communications, making communication between devices more convenient. Even when replacing devices later, there is no need to make major adjustments to the program.

[0122] Furthermore, the general thermal power plant room DCS equipment data transmission method provided by the present application has the following advantages over the prior art:

[0123] 1) Unified management: This application manages communications and data through configuration files, eliminating the need to write separate communication programs for each device, thus simplifying maintenance and management.

[0124] 2) Full coverage of protocols: The dynamic protocol switching method provided by this application can support common Modbus protocols such as TCP, RTU, and ASCII, without the need for large-scale communication modifications, thereby improving communication compatibility and flexibility.

[0125] In addition, in the specific implementation process, you can also use the existing communication library and Modbus protocol stack to write communication programs for different devices, or use special communication devices and protocol converters, such as gateway devices, to achieve communication conversion between different protocols.

[0126] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 2As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store transmission data of a general thermal power plant machine room DCS device. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a general thermal power plant machine room DCS device data transmission method is implemented.

[0127] Those skilled in the art will understand that Figure 2 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components. In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0128] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0129] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0130] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0131] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0132] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.

[0133] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0134] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A general thermal power plant room DCS equipment data transmission method, characterized in that: The general thermal power plant room DCS equipment data transmission method comprises: Define a configuration file, in which a configuration block is defined for the communication program, and the configuration content of the configuration block is set based on the YAML format; the configuration content includes: communication parameters and a list of data items to be acquired; the communication parameters include one or more of a serial port number, a baud rate, an IP address, a data bit, a stop bit, a parity check, a slave address (device ID), a timeout, a frame interval, a start character, an end character, an error detection, an MBAP header, a data rate, a function code, a byte order, and a port number; Define a mapping table, use Mysql database to store and manage various mapping relationships in the mapping table; the mapping table contains the following contents: protocol content mapping import module, connection error mapping, unit mapping conversion and data type mapping; the protocol content mapping import module is used to define the data mapping relationship between different communication protocols; the protocol content mapping import module includes the identification of the source protocol and the target protocol, and the data point mapping rules; the connection error mapping is used to standardize the processing methods of various connection errors; the connection error types are stored in the database, and each error has a corresponding error code, description text and severity level; the unit mapping conversion is used to define the conversion rules between different measurement units; the source unit, the target unit and the corresponding conversion formula or conversion factor are stored in the database; the data type mapping is used to define the data type of various data items, and is used to correctly handle the data type when transmitting data between different systems or protocols; Parsing the configuration file, establishing a connection with a DCS device in a general thermal power plant room according to the communication parameters and the mapping table, reading data from the DCS device in the general thermal power plant room according to a list of data items to be acquired based on a user request to obtain original data, and processing the original data based on the provisions of the communication protocol to obtain a data reading result; In the process of obtaining data reading results, set up a retransmission mechanism and an error handling mechanism; When no data read response is obtained within a set time, the retransmission mechanism is triggered; When the data reading result obtained is abnormal, the error handling mechanism is triggered.

2. The method for transmitting data of DCS equipment in a general thermal power plant room according to claim 1 is characterized in that: The raw data is processed based on the provisions of the communication protocol to obtain a data reading result, including: According to the data format of the original data, traverse and parse the data structures of each layer of the original data; Defining data parsing logic, and based on the data parsing logic, locating the location of the data item corresponding to the user request in each layer of the data structure of the original data, and extracting the data item value; For the data item value, according to the original unit and point situation of the data item value, query the rule base to obtain the conversion rule; the rule base definition is obtained; The data item value is converted based on the conversion rule, and the data reading result is obtained based on the converted data item value.

3. The method for transmitting data of DCS equipment in a general thermal power plant room according to claim 1 is characterized in that: When no data read response is obtained within a set time, the retransmission mechanism is triggered, including: Resending the request identical to the user request, and determining whether a data reading response is obtained within a set time; If a data reading response is obtained within a set time, the data reading result is output; If no data read response is obtained within the set time, the process returns to the step of resending the same request as the user request and determining whether a data read response is obtained within the set time, until the upper limit of request retransmission is reached, and then a read failure message is returned; for each retransmission request, the set time is increased gradually.

4. The method for transmitting data of DCS equipment in a general thermal power plant room according to claim 1 is characterized in that: When the data reading result is abnormal, the error handling mechanism is triggered, including: Performing an integrity check on the data reading result to obtain a test result; When the inspection result shows that the data reading result is complete, outputting the data reading result; When the inspection result is that the data reading result is incomplete, it is determined that the data reading result is damaged, the retransmission mechanism is triggered, and the step of performing an integrity check on the data reading result to obtain the inspection result is returned, until the requested retransmission upper limit is reached and the inspection result is still that the data reading result is incomplete, a read error message is returned.

5. The method for transmitting data of DCS equipment in a general thermal power plant room according to claim 1 is characterized in that: The configuration file is loaded and parsed through the PyYAML library.

6. The method for transmitting data of DCS equipment in a general thermal power plant room according to claim 1 is characterized in that: The process of parsing the configuration file and establishing a connection with the DCS equipment in the general thermal power plant room according to the communication parameters and the mapping table includes: According to the protocol type of the DCS equipment in the general thermal power plant room, the corresponding module path and class name are found from the mapping table, and the module corresponding to the module path is dynamically imported using the importlib module of Python to obtain a reference to the class; Using the reflection mechanism, create the communication object of the class through the reference of the class; Parsing the configuration file to obtain the communication parameters of the DCS equipment in the general thermal power plant room; The communication parameters of the general thermal power plant room DCS device are passed to the communication object, and the corresponding initialization method is called according to different protocol types to establish a connection with the general thermal power plant room DCS device.

7. The method for transmitting data of DCS equipment in a general thermal power plant room according to claim 1 is characterized in that: The process of setting the configuration content of the configuration block based on the YAML format includes: An editing tool is used to set the configuration content of the configuration block based on the YAML format.

8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the universal thermal power plant room DCS equipment data transmission method described in any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the universal thermal power plant machine room DCS equipment data transmission method described in any one of claims 1 to 7 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the universal thermal power plant machine room DCS equipment data transmission method described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Distributed secure transmission method applied to distributed control system (DCS)

    CN102664719A

  • Unified service system under multiple storage protocols

    CN103176751A

  • SVG (Static Var Generator) interactive acquisition method and system capable of configuring multiple protocols, and SVG equipment

    CN115484321A

  • Symbol access and method for industrial equipment system based on externally deployed gateway equipment

    CN116089657A

  • Template-based easy-to-expand data analysis method and system

    CN117435653A

Cited By

  • Flow meter communication method and device, computer equipment and storage medium

    CN119854390A

  • Energy storage equipment multi-protocol compatibility data processing method and device and computer equipment

    CN120676066A

  • ICS-oriented efficient multi-source data interaction method and system

    CN121012851A