A multi-source real-time data protocol high-speed conversion method and device
Through the multi-source real-time data protocol high-speed conversion device, shared memory and FNV algorithm are used to achieve high-speed data conversion, which solves the problem of high-speed real-time data protocol conversion between multiple devices in the industrial field, and achieves millisecond-level conversion latency and multi-cloud platform adaptation.
Patent Information
- Application Number
- CN202211036366.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-28
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-08-28
AI Technical Summary
Existing technology is difficult to achieve high-speed real-time data protocol conversion between multiple devices in industrial sites, especially when high frequency and low latency requirements are required, and it cannot adapt to multiple cloud platforms and heterogeneous environments.
Using a multi-source real-time data protocol high-speed conversion device, including a shared memory unit, a multi-source real-time data generation unit, a real-time data scheduling unit and a multi-source real-time data consumption unit, it quickly locates data addresses through customized real-time data structures and FNV algorithms, and uses hooks The method implements high-speed data stacking, scheduling and consumption, and supports multiple protocol conversions.
It achieves high-speed conversion between multiple real-time data transmission protocols, with conversion latency reaching the millisecond level, improving system throughput and operating speed, and adapting to multiple cloud platforms and heterogeneous environments.
Smart Images

Figure CN115396526B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a multi-source real-time data protocol high-speed conversion method and a conversion device, belonging to the technical field of industrial Internet. Background Art
[0002] With the rapid development of industrial Internet technology, real-time data of equipment operation has played a huge role in the application of industrial Internet big data.
[0003] For a long time, OT and IT (operation technology and information technology) have been isolated from each other, and data cannot be interoperable. A large amount of data from industrial sites is deposited in workshops, equipment, and sensors and cannot be used.
[0004] In the early days, enterprises were keen to get on the platform, develop functions, and build models. However, as time went by, more and more enterprises realized that a platform without fresh data is nothing but a castle in the air and cannot generate benefits. The data on the industrial site is the most important asset for industrial enterprises. However, in the data access link, due to the huge differences in processes and equipment in different industries, such as electricity, mineral mining, petrochemicals, steel, non-ferrous metallurgy, pharmaceuticals, electronics, automobiles, equipment manufacturing, machine tools, logistics, packaging, etc., the data is almost incomparable; even in one industry, there are multiple links and different processes. In addition, because the procurement time of equipment in the production line may be different, sometimes the front-end equipment and the back-end equipment are separated by several years, the degree of equipment automation and informatization is separated by generations, and the more advanced equipment and backward equipment are produced on the same line, resulting in multiple devices on the same production line cannot be connected to the field bus, and can only use traditional electrical signals to transmit information.
[0005] In summary, the number of connected IoT hardware devices is increasing day by day. Different types of devices have different operating environments and communication protocols. Upper-layer applications need to achieve unified and intelligent management by obtaining information from these devices and controlling them. This requires the corresponding support platform to be able to adapt to various heterogeneous environments and have the ability to access massive hardware devices. In terms of providing a large amount of computing and storage capabilities, the use of cloud computing technology is currently the main way.
[0006] However, when the data collected by the device is directly transmitted to the application layer, the massive amount of raw data will overwhelm the application system during processing. At the same time, changes in the underlying devices will also affect the upper-layer applications, resulting in frequent changes in the application layer code. The use of IoT edge devices can shield the complexity of the underlying network for upper-layer application development, analyze data at the edge, and provide a common data source for the cloud platform. Data protocol conversion is an important part of IoT edge devices.
[0007] For general IoT applications, such as automatic meter reading, environmental monitoring, agricultural plant protection, etc., although there are a large number of nodes, the types of information collected by sensors are single and the amount of information transmitted is limited. It often takes several minutes or even hours to send information, and the analysis and control are relatively simple. There are currently corresponding solutions for data converters for such edge devices. For example, based on the one M2M architecture, the original data is sent to the resource virtualization middleware through the data interaction pipeline, and resource data is formed through data conversion (see the literature: Research and Verification of Resource Virtualization Technology for Distributed Heterogeneous Unmanned Systems, [D]. University of Electronic Science and Technology of China, 2021. DOI: 10.27005 / d.cnki.gdzku.2021.002997.), but there is no mention of real-time optimization measures, performance analysis and results. Although the technical solution based on IoT data protocol conversion mentions real-time requirements (see the literature: Design and Implementation of Message Middleware for Industrial IoT [D]. Huazhong University of Science and Technology, 2019. DOI: 10.27157 / d.cnki.ghzku.2019.003844.), it corresponds to sending a frame of water meter data every hour, which does not involve "high-speed" real-time. Chinese invention patent CN113242248B discloses an industrial heterogeneous network high-speed protocol conversion device and parallel processing unit, which completes the protocol conversion between the industrial site and the IPv6 backbone network through large page memory, high-speed cache, packet queue prefetching and macro programming. On the one hand, the design is designed for IPv6-oriented conversion and has output restrictions; on the other hand, there is a lack of corresponding data for the high-speed conversion level mentioned. Chinese invention patent CN111930666A discloses a high-speed configurable industrial protocol converter, which uses FPGA chip technology to complete the conversion of field bus data by extracting the device address, function code and other information of the protocol frame and writing it into the target protocol frame. On the one hand, this method has the limitation that the input only supports "bus type data" and does not support other data such as Ethernet and wireless data. On the other hand, no data description is given for the real-time and frequency of the original data, as well as the high-speed level that can be achieved by the optimization method of "extracting + writing protocol frame".
[0008] For high-speed sampled industrial field data that needs to be output all the time, such as physical quantities corresponding to power systems, equipment manufacturing, steel smelting, process control, video surveillance, etc., there are higher requirements than general IoT applications. There are mainly three points: First, the input information sources are diverse, different devices and systems have different collection methods, and use different protocols and communication methods; second, the real-time processing requirements are high, so the data conversion devices in such edge devices are required to have high-speed transmission and low latency; third, because there are multiple commercial platforms on the market, if enterprises have different business needs, they need to send the underlying data to different application platforms, and the output of the converter needs to be able to adapt to multiple cloud platforms. Summary of the invention
[0009] In view of the deficiencies in the prior art, the present invention provides a multi-source real-time data protocol high-speed conversion method and conversion device, which effectively improves the operating speed and system throughput, realizes the mutual conversion between multiple real-time data transmission protocols, and the conversion delay reaches millisecond level.
[0010] The technical solution to achieve the purpose of the present invention is to provide a multi-source real-time data protocol high-speed conversion device, which includes a shared memory unit, a multi-source real-time data generation unit, a data real-time scheduling unit and a multi-source real-time data consumption unit;
[0011] The shared memory unit includes a static information area and a dynamic information area; the static information area is used to store static information of acquisition points obtained and loaded from external configuration after the device is started, and to allocate addresses for dynamic information; the dynamic information area is used for subsequent storage and update of real-time data;
[0012] The multi-source real-time data generation unit includes a data acquisition interface, a built-in input communication protocol library, and a data production module; the data production module is used to quickly unpack the received data packets of various data protocols, stack them into the shared memory unit at high speed, and send change events to the data real-time scheduling unit;
[0013] The data real-time scheduling unit includes a consumption registration management module and a change event management module; it is used for receiving and scheduling change events, and quickly notifies the multi-source real-time data consumption unit of the changes of the real-time data input from multiple sources after protocol conversion;
[0014] The multi-source real-time data consumption unit includes a data output interface, a built-in output communication protocol library, and a data consumption module; the data consumption module is used to realize consumption information registration, monitor change events, obtain real-time data, and distribute it to the corresponding output application platform after protocol conversion.
[0015] The technical solution of the present invention also provides a multi-source real-time data protocol high-speed conversion method, comprising the following steps: high-speed stacking of real-time data, high-speed scheduling of real-time data and high-speed consumption of real-time data;
[0016] The real-time data high-speed stacking comprises the following steps:
[0017] (1) Constructing a collection table
[0018] Build a collection table on the disk, including 4 attributes: point unique identifier PID, collection address CollectAdress, collection type ParseType, dynamic information shared memory address ValueAdress;
[0019] (2) Pre-definition of collection point information
[0020] After the device is started, the data production module initiates a connection with the device, and preloads the point unique identifier PID, collection address CollectAdress, and collection type ParseType in the collection table from the disk to the process memory area; the FNV algorithm is used to locate the corresponding point in the static information area based on the point unique identifier PID, obtain the dynamic information shared memory address ValueAddress, and complete the loading of the memory collection table;
[0021] (3) Obtaining real-time data
[0022] The data production module sends a data request to the device according to the "collection address CollectAdress + collection type ParseType", and the device returns the data, and the data format conversion is completed through the input communication protocol library built into the multi-source real-time data generation unit;
[0023] (4) Update dynamic information
[0024] Update the dynamic information data according to the dynamic information shared memory address ValueAddress in the memory collection table to complete the dynamic information update of the point;
[0025] The real-time data high-speed scheduling comprises the following steps:
[0026] (1) Pre-definition of consumption point information
[0027] The consumption registration management module builds a consumption registration table, which contains 3 fields: point unique identifier PID, consumption status Status, and hook method Hook; among them, consumption status Status is 16 bits, supporting 16 consumer subscriptions. Starting from the lowest bit, each bit represents the consumption status of one consumer in sequence, and is associated with the corresponding hook method Hook trigger;
[0028] (2) Change event reception
[0029] The data production module sends a notification of the change event of the unique identifier PID list of the points that have completed the dynamic information update. After the change event management module receives the change event notification, it locates the corresponding record in the consumer registration table through the FNV algorithm;
[0030] (3) Point change event scheduling
[0031] After the change event management module locates the record in the consumer registration table, it sets the registered position of the consumption status Status to 1, triggers the corresponding hook method Hook, and sends a hook call request to the consumer module;
[0032] (4) Consumption result record
[0033] The consumption module returns the value result to the change event management module, and the change event management module sets the corresponding position of the consumption status Status of successful consumption to 0 for subsequent query of the consumption result;
[0034] The real-time data high-speed consumption comprises the following steps:
[0035] (1) Constructing a consumption table
[0036] Build a consumption table on the disk, including 5 fields: consumer unique identifier CID, subscription point unique identifier PID, dynamic information shared memory address ValueAddress, upload address UploadAddress, upload type UploadType;
[0037] (2) Pre-definition of consumption points
[0038] After the device is started, the consumption module first initiates a connection with the application platform, and preloads the consumer unique identifier CID, the subscription point unique identifier PID, the upload address UploadAddress, and the upload type UploadType from the disk to the process memory area; then the FNV algorithm is used to locate the point in the static information area based on the subscription point PID, obtain the dynamic information memory address ValueAddress and load it into the memory consumption table; based on each record in the consumption table, define the consumer unique hook method Hook to complete the predefinition of the consumption point; the consumer unique hook method Hook is used for the subsequent change event management module to trigger the consumption module to receive and obtain the value of the change event;
[0039] (3) Consumer information registration
[0040] The predefined consumption point actively registers with the consumption registration management module, sends the subscription point unique identifier PID and the consumer unique hook method Hook, and the consumption registration management module forms a consumption registration table based on the subscription point unique identifier PID and the hook method Hook;
[0041] (4)Hook trigger
[0042] The change event management module sets the status position of the registered point to 1 according to the change event notification sent by the data production module, and triggers the call request of the hook method Hook;
[0043] (5) The consumption module obtains real-time data
[0044] After receiving the hook method (Hook) call request from the change event management module, the consumption module obtains the value of the shared memory address ValueAddress according to the dynamic information in the memory consumption table, obtains the real-time data, and feeds back the value result to the change event management module. The consumption registration table status position is 0;
[0045] (6) Real-time data consumption
[0046] After the consumption module obtains the real-time data, it converts the format according to the upload address UploadAddress and upload type UploadType in the memory consumption table through the output communication protocol library built into the multi-source real-time data consumption unit, and actively pushes the changed data to the application platform.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] 1. The present invention adopts a custom real-time data structure and a shared memory solution, which greatly reduces the program's copying of data and the occupation of device hardware and software resources, thereby improving the operating speed and system throughput.
[0049] 2. The present invention adopts the FNV algorithm based on one-way hashing for the point unique identification PID. Compared with the existing tree search, it can locate the shared memory address more quickly and accurately, obtain data information, and perform operations such as searching, inserting, and deleting data records.
[0050] 3. The present invention adopts a hook method in data scheduling. Once the consumer receives a hook trigger, it can jump out of its current task and directly execute the hook thread. Compared with the prior art that adopts a continuous request query method, it can capture data update notifications more quickly, thereby improving the scheduling speed of change events.
[0051] 4. The multi-source real-time data protocol high-speed conversion device provided by the present invention organically embeds a shared memory unit, a multi-source real-time data generation unit, a data real-time scheduling unit and a multi-source real-time data consumption unit, which can provide mutual conversion between multiple real-time data transmission protocols, and the conversion delay is only at the millisecond level. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 Schematic diagram of the hardware structure of a multi-source real-time data protocol high-speed conversion device provided by an embodiment of the present invention;
[0053] Figure 2 It is a schematic diagram of the unit and module structure of a multi-source real-time data protocol high-speed conversion device provided by an embodiment of the present invention;
[0054] Figure 3 It is a custom real-time data structure in the multi-source real-time data protocol high-speed conversion method provided by an embodiment of the present invention;
[0055] Figure 4 It is a work flow chart of a data production unit of a multi-source real-time data protocol high-speed conversion device provided by an embodiment of the present invention;
[0056] Figure 5 It is the structure of the acquisition table in the multi-source real-time data protocol high-speed conversion method provided by the embodiment of the present invention;
[0057] Figure 6 It is a work flow chart of a real-time scheduling unit of a multi-source real-time data protocol high-speed conversion device provided by an embodiment of the present invention;
[0058] Figure 7 The structure of the consumer registration table in the multi-source real-time data protocol high-speed conversion method provided in the embodiment of the present invention;
[0059] Figure 8 It is the structure of the consumption table in the multi-source real-time data protocol high-speed conversion method provided by the embodiment of the present invention;
[0060] Fig. 9 It is a work flow chart of a data consumption unit of a multi-source real-time data protocol high-speed conversion device provided by an embodiment of the present invention;
[0061] Fig.10 The present invention provides a method for high-speed conversion of multi-source real-time data protocols. DETAILED DESCRIPTION
[0062] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0063] Example 1
[0064] In this embodiment, the RJ45 interface is used to connect to the southbound power system A and power system B. Real-time information such as phase A current, phase B current, generator protection device alarm, active power, reactive power, excitation current, excitation voltage, etc. is collected, and one piece of data is generated approximately every 1ms. After the data of the power system is converted by the device provided in this embodiment, it is sent to the northbound consumer X (a group big data platform) and consumer Y (a certain energy management platform).
[0065] Among them, data production and consumption specifically refer to:
[0066] (1) Southbound Data Producers
[0067] (A) Power system A uses the custom M protocol; 200 points are collected, and the PID is 1001~1200.
[0068] 1) "Excitation current": point name = excitation current; point unique identifier PID = 1100; acquisition address = 11.ZB_excitationCurrent; acquisition type = float64; point type = analog quantity; point upper and lower limits = 120 ~ 150;
[0069] 2) "Excitation Voltage": Point Name = Excitation Voltage; Point Unique Identifier PID = 1200, Collection Address = 11.ZB_excitationVoltage; Collection Type = float32; Point Type = Analog; Point Upper and Lower Limits are 30 to 36;
[0070] (B) Power system B uses Modbus protocol; 300 points are collected, and PID is 1201-1500;
[0071] 1) "1F generator protection 1_machine end A phase current": point name = 1F generator protection 1_machine end A phase current; point unique identifier PID = 1400, acquisition address = 1.40001; acquisition type = float32; point type = analog; point upper and lower limits = 30 to 36;
[0072] 2) "Generator A set protection device locked": point name = generator A set protection device locked; point unique identifier PID = 1500; collection address = 1.1; collection type = bool; point type = switch value;
[0073] (2) Northbound data consumers:
[0074] (A) Consumer X A group's big data platform uses the Kafka protocol, and the consumption points include:
[0075] 1) "Excitation current": upload type = float64; upload address = 16525;
[0076] 2) "Excitation voltage": upload type = float64; upload address = 16526;
[0077] 3) "1F generator protection 1_machine end A phase current": upload type = float64; upload address = 18724;
[0078] (B) Consumer Y’s energy management platform uses a custom protocol N, and the consumption points include:
[0079] 1) "Excitation current": upload type = float64; upload address = FBHA_HUYH__AS21;
[0080] 2) "1F generator protection 1_machine end A phase current": upload type = float32; upload address = FBHA_DEVB__QH21;
[0081] 3) "Generator A set protection device locked": upload type = bool; upload address = FBHA_DEVB__DI41.
[0082] The server configuration selected in this embodiment is: 128 cores / 2.3GHz / Hygon C86 7291 32-coreProcessor.
[0083] See attached Figure 1 , which is a hardware structure diagram of the multi-source real-time data protocol high-speed conversion device provided in this embodiment, which includes an industrial Internet of Things input and output interface, a disk storage, a memory, an arithmetic unit and a controller.
[0084] See attached Figure 2 , which is a schematic diagram of the unit and module structure of the multi-source real-time data protocol high-speed conversion device provided in this embodiment; it includes a shared memory unit, a multi-source real-time data generation unit, a data real-time scheduling unit and a multi-source real-time data consumption unit.
[0085] The data generation unit is used to support the reception of real-time data through signal interfaces such as AI, DI, RS232, RS485, RJ45, CAN, PLC bus, etc. It has a built-in protocol library including 450+ mainstream control system protocols, including traditional control network protocols, industrial Ethernet protocols, industrial wireless network protocols, fieldbus protocols, control system communication protocols, such as: SIEMENS, AB, Schneider, Mitsubishi, OMRON, ABB, FANUC, OPC-DA, OPC-UA, EtherNet / IP, IEC-61850, IEC60870-5-101 / 103 / 104, MQTT, Kafka, HTTP, etc. It can quickly input the received data packets of various data protocols into the data high-speed conversion unit.
[0086] The real-time scheduling unit is used to provide a set of optimization methods for high-speed data conversion, which converts the real-time data input from multiple sources into protocols and quickly distributes them to the corresponding output objects.
[0087] The data consumption unit is used to support sending real-time data through signal interfaces such as RS232, RS485, RJ45, WIFI, etc. The built-in protocol library completes the conversion of data protocol formats such as OPC-UA, IEC104, HJ212, MQTT, Http, Kafka, etc., and supports multi-channel rapid distribution of data packets of various protocols to third-party consumers.
[0088] The multi-source real-time data protocol high-speed conversion device provided in this embodiment adopts the method of customizing real-time data structure to divide the collected point information into static information and dynamic information. Static information refers to the basic information of the point, and the static information includes the dynamic information shared memory address ValueAddress, offset offset, length length, and point type type. Dynamic information refers to the attribute information that changes over time, including time (4 bytes), value (4 bytes), and status (2 bytes). This embodiment loads all collected point information into the shared memory unit in the form of this custom data structure.
[0089] See attached Figure 3 , which is a schematic diagram of the custom real-time data structure provided in this embodiment.
[0090] In this embodiment, static information is fixed and unchanged after external configuration, which will greatly reduce the flow of data. At the same time, by adopting the shared memory method, it does not need to be completed through system calls or other processes that require entering the kernel, and is as fast as accessing the memory area unique to the process. The use of shared memory can also greatly reduce the copying of data and resource occupation by the program, which is conducive to improving the running speed and system throughput.
[0091] The workflow of each unit in this embodiment is as follows:
[0092] 1. Data generation unit
[0093] In this embodiment, static information is stored on the disk after external configuration. After the device is started, all static information is loaded into the memory. At the same time, a fixed-size dynamic memory is applied for dynamic information to store real-time dynamic information of the point, and the application address is assigned to the dynamic information memory address related field in the shared memory static information area, so that the subsequent data production unit updates the real-time data and the data consumption unit obtains the real-time data, which can be achieved through the shared memory.
[0094] See attached Figure 4 , is a flowchart of the data generation unit of this embodiment; the data generation unit completes high-speed stacking of real-time data; the specific steps are as follows:
[0095] (1) The data generation unit defines a collection table, whose structure is as shown in the attached figure. Figure 5 As shown, it includes four attributes: point unique identifier PID, collection address CollectAdress, collection type ParseType, and dynamic information shared memory address ValueAdress.
[0096] (2) Collection point pre-definition, including two parts: first, after the device is started, the data generation unit first initiates a connection with the device, and preloads the point unique identifier PID, collection address CollectAdress, and collection type ParseType from the disk to the collection table in the process memory area. Second, through the FNV (Fowler-Noll-Vo) algorithm, the corresponding point in the static information area is located based on the point unique identifier PID, and the dynamic information shared memory address ValueAddress is obtained and loaded into the collection table.
[0097] (3) Obtaining real-time data: The data production unit sends a list of "collection address CollectAdress + collection type ParseType" to the device, and the device returns the data, and the data format conversion is completed through the protocol library.
[0098] (4) Update dynamic information area: Update data according to the shared memory address ValueAddress of dynamic information in the collection table.
[0099] 2. Real-time scheduling unit
[0100] The data consumption unit predefines the consumption point information and registers it with the dispatch unit. The dispatch unit manages it uniformly based on the point unique identifier PID. After the device is started, the dispatch unit receives the data change event notification from the data generation unit, combines the change event and the registration table, records the point update status, and triggers the subsequent update event of the data consumption unit.
[0101] See attached Figure 6 , which is a workflow diagram of the real-time scheduling unit of this embodiment; the specific steps are as follows:
[0102] (1) The consumption registration management module of the scheduling unit defines a consumption registration table as shown in the attached Figure 7 As shown, it contains 3 fields: point unique identifier PID, consumption status Status, hook method Hook. Among them, the consumption status is 2 bytes or 16 bits, which means that 16 consumer subscriptions are supported. Starting from the low bit, each bit represents the consumption status of one consumer in sequence and is associated with the corresponding Hook trigger. Consumer active registration. It means that the consumer actively sends the subscription point unique identifier PID and the unique hook method Hook to the consumption registration management module, and the consumption registration management module loads it into the consumption registration table according to the PID.
[0103] (2) Receiving point change events. The data production unit sends a change event, which contains a list of unique identifiers (PIDs) of the points whose dynamic information has been updated. The change event management module receives the event and locates the corresponding record in the consumer registry through the FNV algorithm.
[0104] (3) Point change event scheduling. After the change event management module locates the record in the consumer registration table, it sets all the registered bits of Status to 1, triggering the corresponding hook method and sending a hook call request to the consumer unit.
[0105] (4) Consumption result record. The consumption unit returns the value result to the scheduling unit, and the change event management module sets the corresponding position of the successful consumption Status to 0. The consumption result can be queried later.
[0106] 3. Data consumption unit
[0107] The consumer predefines the consumption point and actively completes the point subscription registration with the scheduling unit. After the device is started, the hook function predefined by the consumer is ready to be triggered at any time. When the hook call request from the scheduling unit is received, the hook method is executed to obtain data according to the predefined dynamic information shared memory address. After completing the data acquisition, the hook execution result is fed back to the scheduling unit, the point consumption status is updated, and the real-time data is converted by the protocol library and uploaded to the third-party database / system.
[0108] The hook method can be used to intercept messages when the system is processing them. When a specific message is sent, it is captured before it reaches the window, triggering the execution of the hook function. Compared with the continuous request query method, data update notifications can be captured earlier at the system level, and the hook function is directly triggered by the system, without the need for additional message transmission between units, thereby improving the scheduling speed of change events.
[0109] See attached Fig. 9 , which is a workflow diagram of the data consumption unit in this embodiment; the specific steps are as follows:
[0110] (1) The consumption unit defines a consumption table, as shown in the following figure. Figure 8 As shown, it includes 5 fields: consumer unique identifier CID, subscription point unique identifier PID, dynamic information shared memory address ValueAddress, upload address UploadAddress, and upload type UploadType.
[0111] (2) Pre-definition of consumption points, including three parts: First, after the device is started, the consumption unit first initiates a connection with the device, and pre-loads the consumer unique identifier CID, subscription point unique identifier PID, upload address UploadAddress, and upload type UploadType from the disk to the consumption table in the process memory; second, through the FNV algorithm, the point in the static information area is located based on the PID, the dynamic information memory address ValueAddress is obtained and loaded into the consumption table; third, based on each record in the consumption table, a hook method is defined to trigger the subsequent change event reception and value acquisition.
[0112] (3) Consumption information registration. After the consumption point is predefined, it actively registers with the scheduling unit and sends the subscription point unique identifier PID and the consumer's unique hook method Hook.
[0113] (4) Hook triggering: The scheduling unit generates the point change notification from the data generation unit, sets the status position of the registered point to 1, and triggers the call request of the hook method.
[0114] (5) Consumers obtain real-time data. After receiving the hook method Hook call request from the scheduling unit, the consumer obtains the value of the shared memory address ValueAddress according to the predefined dynamic information, and feeds back the result to the scheduling unit.
[0115] (6) Real-time data consumption. After the consumer obtains the real-time data, it sends it to the protocol library for format conversion according to the predefined upload address UploadAddress and upload type UploadType, and actively pushes the changed data to the northbound database system.
[0116] In this embodiment, the implementation of the Hook hook function includes defining the hook function by the real-time data high-speed consumption unit, and triggering the hook function by the real-time data high-speed scheduling unit; the specific implementation process includes:
[0117] (1) The real-time data high-speed consumption unit preloads the unique identification PID of the consumption point, dynamically binds the hook function f() to each point, and generates the consumption table of the current consumption module;
[0118] (2) The real-time data high-speed consumption unit registers the unique identifier PID of the consumption point and the address of the associated hook function f() to the real-time data high-speed scheduling unit;
[0119] (3) The real-time data high-speed dispatching unit allocates relevant consumption records to each consumption output unit in the consumption registration table;
[0120] (4) The real-time data high-speed dispatch unit monitors the real-time data update notification. When receiving the real-time data update notification event of the specified PID point, it traverses the consumption registration table, obtains the address of the hook function f() of the relevant consumption data unit, and triggers the call of the hook function f();
[0121] (5) After the defined hook function f() is triggered, the real-time data high-speed consumption unit obtains the latest data from the shared memory area, pushes the data to the northbound application platform in the output protocol library message format, and notifies the real-time data high-speed scheduling unit of the consumption status in the form of the return value of the hook function f();
[0122] (6) Repeat steps 4 to 5 to complete asynchronous notification of real-time data.
[0123] This embodiment adopts the FNV algorithm hash (PID), which is defined as follows:
[0124] Input: unique point identifier PID (n);
[0125] Output: static information area corresponding point address Static_Area_Address; dynamic shared memory address ValueAddress;
[0126] Constants: FNV initial value offset_bisis; FNV hash prime number FNV_prime; hash length N byte;
[0127] The algorithm (expressed in Golang) is as follows:
[0128] func hash(PID string) (result uint32) {
[0129] result=offset_basis
[0130] for i := 0; i < N; i++ {
[0131] result*=FNV_Prime
[0132] result^=uint32(PID(n))
[0133] }
[0134] return result
[0135] }
[0136] Static_Area_Address=hash(PID)
[0137] ValueAddress=hash(PID)+N
[0138] The specific method in this embodiment is:
[0139] Input: PID character array (point unique identifier);
[0140] Output: starting address of point static information (Static_Area_Address), starting address of point dynamic information (ValueAddress);
[0141] Constants: initial hash value offset_bisis=2166136261, FNV hash prime number FNV_Prime=16777619, hash length N=32 bytes, PID byte data group subscript IDX(0);
[0142] The specific process is:
[0143] (1) Multiply offset_bisis by the FNV hash prime number FNV_Prime, and assign the result to offset_bisis;
[0144] (2) offset_bisis is XORed with the character array IDX subscript character, the result is assigned to offset_bisis, and the IDX subscript is increased by 1;
[0145] (3) Repeat steps (1) and (2) until IDX is equal to the length of the byte array minus 1;
[0146] (4) After the above steps, the offset_bisis value is the starting address of the point static information, Static_Area_Address = offset_bisis;
[0147] (5) According to the static information structure of the shared memory area, the starting address of the point dynamic information ValueAddress = the static information address Static_Area_Address + 32 bytes offset (in this embodiment, the PID occupies a fixed 32 bytes).
[0148] See attached Fig.10 , is a workflow diagram of the multi-source real-time data high-speed protocol conversion method provided by this embodiment; the implementation steps are as follows:
[0149] 1. After the device is started, the static information of all collection points is loaded from the disk to the memory, a fixed-size dynamic memory space is applied for, and the address is assigned to the dynamic information shared memory address field in the static information, so that subsequent data interaction can be achieved only through shared memory.
[0150] 2. The data generation unit, real-time scheduling unit, and consumption unit complete the preloading of the collection table, consumption registration table, and consumption table respectively. Specifically: the data production module preloads the unique identifier PID of the point, the collection address CollectAdress, and the collection type ParseType from the disk to the collection table in the process memory area; then, through the FNV algorithm, based on the unique identifier PID of the point, locates the record in the static information area, obtains the dynamic information memory address ValueAddress, etc. and loads it into the collection table; the consumption module preloads the consumer unique identifier CID, the subscription point unique identifier PID, the upload address UploadAddress, and the upload type UploadType from the disk to the consumption table, and through the FNV algorithm, locates the point in the static information area based on PID, obtains the dynamic information memory address ValueAddress, etc. and loads it into the consumption table. Based on each record in the consumption table, a unique hook method is defined to trigger the subsequent change event reception and value acquisition. After the consumption module completes the preloading, it sends the unique identifier PID of the consumer subscription point and the list of hook methods Hook to the scheduling module for active registration, and the scheduling module generates the consumption registration table.
[0151] 3. The data production module generates a message to request data from power system A according to the collection address and collection type "11.ZB_excitationCurrent, float64; 11.ZB_excitationVoltage float32;" of the points "excitation current" and "excitation voltage"; and requests data from power system B according to the collection address and collection type "1.40001, float32; 1.1, bool;" of the points "1F generator protection 1_machine end A phase current" and "generator A set protection device locked".
[0152] 4. The protocol library converts the returned data according to the custom protocol M of power system A, and converts the returned data according to the Modbus protocol of power system B.
[0153] 5. After receiving the data, the data production module updates the data according to the dynamic information shared memory address in the collection table.
[0154] 6. Change event issuance: After completing the dynamic information update of the above points, the data production module sends change events to the scheduling unit, that is, the point unique identification list PID, that is, 1100, 1200, 1400, 1500.
[0155] 7. Change event reception: The change event management module of the dispatch unit receives the point unique identifier list. Then, through the FNV algorithm, it locates the corresponding 4 point records in the consumer registration table according to the point unique identifier PID.
[0156] 8. Point change event scheduling: The change event management module changes the consumption status bit status according to the registration status of the corresponding point.
[0157] At the point of PID=1100, the lower 2 bits of status are registered and set from 0 to 1, triggering the corresponding hook methods of consumers X and Y.
[0158] At the point of PID=1200, the lower bit of status is registered and set from 0 to 1, triggering the corresponding hook method of consumer X.
[0159] At the point of PID=1400, the lower 2 bits of status are registered and set from 0 to 1, triggering the corresponding hook methods of consumers X and Y.
[0160] At the point of PID=1500, the lower bit of status is registered and set from 0 to 1, triggering the corresponding hook method of consumer Y.
[0161] 9. Hook trigger: When consumers X and Y receive the corresponding hook method call request triggered by the scheduling unit (i.e., receive the data change notification), they fetch values from the dynamic information area of the shared memory according to the dynamic information shared memory address ValueAddress predefined in the consumption table, and feed back the fetching result to the scheduling unit, and the success status bit is set to 0.
[0162] 10. Real-time data consumption: After acquiring real-time data, the consumption module sends a list of "data + upload type + upload address" of "excitation current, excitation voltage, 1F generator protection 1_machine end A phase current", which is converted into kafka format by the protocol library and pushed to consumer X; sends a list of "data + upload type + upload address" of "excitation current, 1F generator protection 1_machine end A phase current, generator A set protection device locking", which is converted into custom protocol N by the protocol library and pushed to consumer Y.
[0163] The device and method provided in this embodiment are tested as follows: According to different execution units, the whole is divided into two steps: parsing and conversion into storage. Among them, the parsing is performed 5 groups per second, each group has 100 points. The conversion into storage is performed 10 groups per second, each group has 50,000 data. Due to different storage rules, the logs in this test are interpreted as a group of 2 seconds. From the above, each statistical group completes the parsing and conversion of 1 million data into storage. In order to ensure the credibility of the data, 5 groups of log data are extracted. The time when the data packet is received is the starting time T0, and the time when the data is distributed into the storage is the end time T1. The conversion time T=T1-T0 is calculated. The five groups of data are as follows:
[0164] Group 1: T = T1-T0 = 09:43:45.476634829- 09:43:43.782360688 = 1694.274141 (ms);
[0165] Group 2: T = T1-T0 = 09:43:47.456741172- 09:43:45.803925048 = 1652.816124 (ms);
[0166] Group 3: T = T1-T0 = 09:43:49.452204161- 09:43:47.787241430 = 1664.962731 (ms);
[0167] Group 4: T = T1-T0 = 09:43:51.478590585- 09:43:49.793214582 = 1685.376003 (ms);
[0168] Group 5: T = T1-T0 = 09:43:53.445374087- 09:43:51.793744437 = 1651.629650 (ms);
[0169] Average time per point
[0170] = Total processing time / processing points
[0171] = sum(T) / (500*2*5)
[0172] =(1694.274141+1652.816124+1664.962731+1685.376003+1651.629650) / 5000
[0173] =1.6698117298
[0174] ≈1.67ms.
[0175] The test results show that under the condition that one piece of real-time data is generated every 1ms at each point, it takes 8349ms to parse, convert and store 5000 points, that is, each piece of data takes about 1.67ms.
Claims
1. A multi-source real-time data protocol high-speed conversion method, characterized in that The steps include: high-speed stacking of real-time data, high-speed scheduling of real-time data and high-speed consumption of real-time data; The real-time data high-speed stacking comprises the following steps: (1) Constructing a collection table Build a collection table on the disk, including 4 attributes: point unique identifier PID, collection address CollectAdress, collection type ParseType, dynamic information shared memory address ValueAdress; (2) Pre-definition of collection point information After the device is started, the data production module initiates a connection with the device, and preloads the point unique identifier PID, collection address CollectAdress, and collection type ParseType in the collection table from the disk to the process memory area; the FNV algorithm is used to locate the corresponding point in the static information area based on the point unique identifier PID, obtain the dynamic information shared memory address ValueAddress, and complete the loading of the memory collection table; (3) Obtaining real-time data The data production module sends a data request to the device according to the "collection address CollectAdress + collection type ParseType", and the device returns the data, and the data format conversion is completed through the input communication protocol library built into the multi-source real-time data generation unit; (4) Update dynamic information Update the dynamic information data according to the dynamic information shared memory address ValueAddress in the memory collection table to complete the dynamic information update of the point; The real-time data high-speed scheduling comprises the following steps: (1) Pre-definition of consumption point information The consumption registration management module builds a consumption registration table, which contains three fields: point unique identifier PID, consumption status Status, and hook method Hook; Among them, the consumption status Status is 16 bits, supporting 16 consumer subscriptions. Starting from the lowest bit, each bit represents the consumption status of one consumer in sequence and is associated with the corresponding hook method Hook trigger; (2) Change event reception The data production module sends a notification of the change event of the unique identifier PID list of the points that have completed the dynamic information update. After the change event management module receives the change event notification, it locates the corresponding record in the consumer registration table through the FNV algorithm; (3) Point change event scheduling After the change event management module locates the record in the consumer registration table, it sets the registered position of the consumption status Status to 1, triggers the corresponding hook method Hook, and sends a hook call request to the consumer module; (4) Consumption result record The consumption module returns the value result to the change event management module, and the change event management module sets the corresponding position of the consumption status of successful consumption to 0 for subsequent query of the consumption result; The real-time data high-speed consumption comprises the following steps: (1) Constructing a consumption table Build a consumption table on the disk, including 5 fields: consumer unique identifier CID, subscription point unique identifier PID, dynamic information shared memory address ValueAddress, upload address UploadAddress, upload type UploadType; (2) Pre-definition of consumption points After the device is started, the consumption module first initiates a connection with the application platform, and preloads the consumer unique identifier CID, the subscription point unique identifier PID, the upload address UploadAddress, and the upload type UploadType from the disk to the process memory area; then the FNV algorithm is used to locate the point in the static information area based on the subscription point PID, obtain the dynamic information memory address ValueAddress and load it into the memory consumption table; based on each record in the consumption table, define the consumer unique hook method Hook to complete the predefinition of the consumption point; the consumer unique hook method Hook is used for the subsequent change event management module to trigger the consumption module to receive and obtain the value of the change event; (3) Consumer information registration The predefined consumption point actively registers with the consumption registration management module, sends the subscription point unique identifier PID and the consumer unique hook method Hook, and the consumption registration management module forms a consumption registration table based on the subscription point unique identifier PID and the hook method Hook; (4)Hook trigger The change event management module sets the status position of the registered point to 1 according to the change event notification sent by the data production module, and triggers the call request of the hook method Hook; (5) The consumption module obtains real-time data After receiving the hook method Hook call request from the change event management module, the consumption module obtains the value of the shared memory address ValueAddress according to the dynamic information in the memory consumption table, obtains the real-time data, and feeds back the value result to the change event management module. The consumption registration table status position is 0; (6) Real-time data consumption After the consumption module obtains the real-time data, it converts the format according to the upload address UploadAddress and upload type UploadType in the memory consumption table through the output communication protocol library built into the multi-source real-time data consumption unit, and actively pushes the changed data to the application platform.
