A communication method, device, equipment and medium for an electricity information collection terminal.

By encapsulating communication components and interfaces, the communication logic between multi-threaded applications in the ECU is simplified, the complexity of business logic caused by the standard message queue functions of the GNU C library is solved, and a simplified multi-threaded communication design is achieved.

CN117496688BActive Publication Date: 2026-03-10STATE GRID BEIJING ELECTRIC POWER CO +2
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-14
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In existing technologies, the use of standard message queue functions from the GNU C library for communication between multi-threaded applications in an ECU leads to complex business logic design.

Method used

A communication method for an electricity information collection terminal is provided, which simplifies the communication logic between multiple threads by encapsulating the interfaces for initializing communication components, subscribing to messages, unsubscribing to messages, dispatching messages, and responding to messages.

Benefits of technology

It simplifies the design logic of electricity information collection terminal applications, provides universal communication components, and simplifies the development process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117496688B_ABST
    Figure CN117496688B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of electrical automation control technology, specifically relating to a communication method, device, equipment, and medium for an electricity information acquisition terminal application. The communication method provided in this solution identifies the target electricity information acquisition terminal application and its various threads, acquires a target message, and responds to the target message by having each thread call its corresponding pre-encapsulated interface for communication. In this solution, upon receiving a target message, each thread within the electricity information acquisition terminal application calls its corresponding pre-encapsulated interface for communication. This solution encapsulates the message-driven mechanism, simplifying the design logic of the electricity information acquisition terminal application.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of electrical automation control, and particularly relates to a power utilization information collection terminal application communication method, device, equipment and medium. BACKGROUND

[0002] With the expansion of power utilization information collection business, a new generation of power utilization information collection terminal energy controller (hereinafter referred to as "ECU") software has developed from the traditional single power utilization information collection terminal application (APP) multi-thread mode to a multi-application mode.

[0003] The ECU multi-APP communication adopts the MQTT bus protocol, and the multi-thread communication in the APP mainly adopts the message driving mechanism. The existing application APP design can only use the standard message queue function provided by the GNU C library. When the multi-thread in the APP receives the same message and processes the function, the way of adding a buffer area and setting a global variable flag in the APP is adopted to realize the business logic by using the message timeout judgment, which makes the business design logic complex. SUMMARY

[0004] The purpose of the present application is to provide a power utilization information collection terminal application communication method, device, equipment and medium to solve the problem of complex business logic design when the multi-thread in the APP receives the same message and processes the function using the GNU C library standard message queue function.

[0005] In order to achieve the above purpose, the present application adopts the following technical solutions:

[0006] In the first aspect of the present application, a power utilization information collection terminal application communication method is provided, comprising the following steps:

[0007] Determine the target power utilization information collection terminal application and each thread in the target power utilization information collection terminal application;

[0008] Get the target message;

[0009] In response to the target message, each thread calls the corresponding pre-encapsulated interface for communication.

[0010] Further, in the step of each thread calling the corresponding pre-encapsulated interface for communication, the pre-encapsulated interface includes: communication component initialization, thread message subscription, thread message unsubscription, thread message dispatching and thread message response.

[0011] Further, the communication component initialization includes: initializing the buffer area according to the maximum supported thread message queue number and the maximum number of messages that each thread message queue can accommodate; and setting the linked list as an idle linked list according to the maximum supported message type number and the maximum number of thread subscriptions allowed for each message.

[0012] Further, the thread subscription message comprises: all business threads in the power consumption information acquisition terminal application subscribe to the message type according to the message type demand, the message type records the subscription of each thread message, and is added to the head of the message type thread subscription linked list.

[0013] Further, the thread cancellation subscription message comprises: the business thread in the power consumption information acquisition terminal application cancels the subscription according to the message type demand, checks whether there is a thread message record in the message type thread subscription linked list, and if so, deletes the thread message record from the message type thread subscription linked list.

[0014] Further, the thread dispatch message comprises: the business thread in the power consumption information acquisition terminal application dispatches the message to the message type according to the demand of the business thread, checks all thread message records in the message type thread subscription linked list, and dispatches the message to other threads.

[0015] Further, the thread message response comprises: after the business thread in the power consumption information acquisition terminal application receives the thread message, the thread subscription is traversed and it is checked whether the message type is the thread subscription of the business thread, if yes, the message processing is performed, and if not, the message is discarded.

[0016] In the second aspect of the present application, a power consumption information acquisition terminal application communication device is provided, comprising:

[0017] A determination module is configured to determine a target power consumption information acquisition terminal application and each thread in the target power consumption information acquisition terminal application.

[0018] An acquisition module is configured to acquire a target message.

[0019] A communication module is configured to respond to the target message, so that each thread calls a corresponding pre-encapsulated interface to perform communication.

[0020] In the third aspect of the present application, an electronic device is provided, comprising a processor and a memory, the processor is configured to execute a computer program stored in the memory to realize the power consumption information acquisition terminal application communication method as described above.

[0021] In the fourth aspect of the present application, a computer readable storage medium is provided, the computer readable storage medium stores at least one instruction, the at least one instruction is executed by a processor to realize the power consumption information acquisition terminal application communication method as described above.

[0022] Compared with the prior art, the present application has the following beneficial effects:

[0023] 1) The power consumption information collection terminal application communication method provided in the scheme determines a target power consumption information collection terminal application and each thread in the target power consumption information collection terminal application, acquires a target message, and in response to the target message, causes each thread to call a corresponding pre-packaged interface to perform communication. In the scheme, when the target message is received, each thread in the power consumption information collection terminal application calls a corresponding pre-packaged interface to perform communication. The scheme encapsulates the message driving mechanism, simplifying the design logic of the power consumption information collection terminal application. The power consumption information collection terminal application communication device, electronic equipment and computer readable storage medium provided in the scheme also solve the problems proposed in the background section.

[0024] 2) The power consumption information collection terminal application communication method provided in the scheme provides communication component initialization, message subscription, message unsubscription, message dispatch, message response and other interfaces for communication between multiple threads in the power consumption information collection terminal application, forms a general communication component, and simplifies the development of the power consumption information collection terminal application. BRIEF DESCRIPTION OF DRAWINGS

[0025] The drawings accompanying the specification of this application form a part thereof, serve to provide further understanding of the present application, and together with the description of the exemplary embodiments of the present application and their description serve to explain the present application, and do not constitute improper limitations on the present application. In the drawings:

[0026] Figure 1 A flowchart of a power consumption information collection terminal application communication method according to an embodiment of the present application;

[0027] Figure 2 A flowchart of a communication component initialization according to an embodiment of the present application;

[0028] Figure 3 A flowchart of a thread message subscription according to an embodiment of the present application;

[0029] Figure 4 A flowchart of a thread message unsubscription according to an embodiment of the present application;

[0030] Figure 5 A flowchart of a thread message dispatch according to an embodiment of the present application;

[0031] Figure 6 A flowchart of a thread message response according to an embodiment of the present application;

[0032] Figure 7 A structural block diagram of a power consumption information collection terminal application communication device according to an embodiment of the present application;

[0033] Figure 8 A structural block diagram of an electronic equipment according to an embodiment of the present application. DETAILED DESCRIPTION

[0034] The application will be described in detail below with reference to the drawings and in conjunction with embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0035] The following detailed description is exemplary and is intended to provide further explanation of the application. Unless otherwise defined, all technical terms used in the present application have the same meanings as generally understood by those skilled in the art to which the present application belongs. The terms used in the present application are only for the purpose of describing the specific embodiments and are not intended to limit the exemplary embodiments according to the present application.

[0036] Embodiment 1

[0037] The application mainly solves the problem of complex business logic design when using GNU C library standard message queue functions for APP internal multi-threaded receiving and processing of the same message, encapsulates the communication component initialization, thread message subscription, thread message unsubscription, thread message dispatch, thread message response and other interfaces for communication between APP internal multi-threads, and simplifies the design logic of the APP.

[0038] A power consumption information acquisition terminal application communication method, comprising the following steps:

[0039] S100, determining a target power consumption information acquisition terminal application and each thread in the target power consumption information acquisition terminal application;

[0040] S200, acquiring a target message;

[0041] S300, in response to the target message, each thread calling a corresponding pre-encapsulated interface for communication.

[0042] The interface includes: communication component initialization, thread message subscription, thread message unsubscription, thread message dispatch and thread message response.

[0043] The power consumption information acquisition terminal application communication method provided by the above scheme, when receiving a target message, each thread in the power consumption information acquisition terminal application calls a corresponding pre-encapsulated interface for communication. The present scheme encapsulates the message driving mechanism, simplifying the design logic of the APP.

[0044] In order to further explain the content of the present application, the present scheme further provides a power consumption information acquisition terminal application communication method, as shown in Figure 1 The specific steps are as follows:

[0045] S1, determining a target power consumption information acquisition terminal application and each thread in the target power consumption information acquisition terminal application.

[0046] Specifically, the target power consumption information collection terminal application can be power monitoring, energy management, power quality monitoring and the like. In implementing the application of the power consumption information collection terminal, each thread can include a data collection thread, a data processing thread, a data transmission thread and the like.

[0047] S2, acquiring a target message.

[0048] Specifically, the target message in the present scheme can be an instruction sent by a master station system, such as a voltage and current data collection instruction and the like.

[0049] S3, in response to the target message, each thread calls a corresponding pre-packaged interface for communication.

[0050] In an optional embodiment, the pre-packaged interface includes: communication component initialization, thread subscription message, thread unsubscription message, thread dispatch message and thread message response.

[0051] In a specific embodiment, the communication component initialization mainly initializes a thread message queue and initializes a message type linked list and the like.

[0052] Specifically, a buffer area is initialized according to a maximum supported thread message queue number and a maximum number of messages that each thread message queue can accommodate; and a linked list is set as an idle linked list according to a maximum supported message type number and a maximum thread subscription number allowed for each message.

[0053] As an optional embodiment, as shown in Figure 2 The communication component initialization includes the following:

[0054] Starting from the first thread message queue, a judgment is made on the size relationship between the number corresponding to the current thread message queue and the maximum thread message queue number; if the number corresponding to the current thread message queue is less than the maximum thread message queue number, it is proved that the current thread message queue is not the last queue to be initialized.

[0055] For example, each thread message queue can correspond to a number from 1 to n, and n is the maximum thread message queue number.

[0056] In the current thread message queue, a judgment is made on whether the number corresponding to the current thread message queue is less than the maximum thread message queue number; if the number corresponding to the current thread message queue is less than the maximum thread message queue number, it is proved that the current thread message queue is not the last queue to be initialized.

[0057] If the thread message queue has been initialized completely, the message type is initialized.

[0058] At the beginning, the first message type is initialized, and the number of the current message type is compared with the maximum number of message types. If the number of the current message type is less than the maximum number of message types, it is proved that the current message type is not the last one to be initialized, and the message type chain table buffer corresponding to the current message type is initialized. It is judged whether the current message type is the last one to be initialized. If not, the subscription number of the current message type is initialized, and the message type thread subscription chain table is set to an idle chain table, until the initialization of all message types is completed.

[0059] In one embodiment, the thread subscription message mainly includes: all business threads in the APP subscribe to the message type according to the message type demand, and the message type records the subscription of each thread message and adds it to the head of the message type thread subscription chain table.

[0060] As an optional embodiment, as shown in Figure 3 , the thread subscription message includes:

[0061] Starting from the first message type, the number of the current message type to which the thread subscribes is compared with the maximum number of message types.

[0062] For example, each message type corresponds to a digital number, arranged from 1 to m, and m is the number of message types.

[0063] If the number of the current message type is less than the maximum number of message types, it is proved that it is not the last one to be subscribed, and the current message type is added to the head of the message type chain table, and it is judged whether it is successfully added. If it is successfully added to the head of the message type chain table, the process is ended. If it is not successfully added to the head of the message type chain table, an error flag is recorded and the process is ended.

[0064] If the thread has subscribed to all message types, an error flag is recorded and the process is ended.

[0065] In one embodiment, the thread subscription message mainly includes: all business threads in the APP subscribe to the message type according to the message type demand, and the message type records the subscription of each thread message and adds it to the head of the message type thread subscription chain table.

[0066] As an optional embodiment, as shown in Figure 4 , the thread subscription message includes:

[0067] Starting from the first message type, the number of the current message type to which the thread subscribes is compared with the maximum number of message types.

[0068] If the number of current message types is less than the maximum number of message types, the message type chain table is pointed to the first one, and it is determined whether the current message type chain table has thread records. If the current message type chain table has thread records, the thread records of the message type chain table are deleted, and the process ends. If the current message type chain table has no thread records, the message type chain table is pointed to the last one, it is determined whether the current message type chain table has thread records. If the current message type chain table has thread records, an error flag is recorded and the process ends. If the current message type chain table has no thread records, the message type chain table is pointed to the next one, and it is determined whether the current message type chain table has thread records.

[0069] If the thread has unsubscribed from all message types, an error flag is recorded and the process ends.

[0070] In one embodiment, thread dispatching messages mainly includes: the APP internal business thread dispatches messages to message types according to its own needs, checks all thread message records in the message type thread subscription chain table, and dispatches messages to other threads.

[0071] As an optional embodiment, as shown in Figure 5 the thread dispatching messages include:

[0072] Starting from the first message type, it is determined whether the number of message types currently subscribed by the thread is less than the maximum number of message types.

[0073] If the number of current message types is less than the maximum number of message types, the message type chain table is pointed to the first one, and it is determined whether the current message type chain table has thread records. If the current message type chain table has thread records, the message is dispatched to the corresponding thread. It is determined whether the thread record is the last one of the message type chain table. If it is the last one of the message type chain table, the process ends. If it is not the last one of the message type chain table, the message type chain table is pointed to the next one, and it is determined whether the current message type chain table has thread records. If the current message type chain table has no thread records, the message type chain table is pointed to the next one, and it is determined whether the current message type chain table has thread records.

[0074] If all message types have been dispatched, an error flag is recorded and the process ends.

[0075] In one embodiment, thread message response mainly includes: after the APP internal business thread receives a thread message, it traverses thread subscription and checks whether it is a message type subscribed by itself. If it is, the message is processed. If not, it is discarded.

[0076] As an optional embodiment, as shown in Figure 6 the thread message response includes:

[0077] Start from the first message type, judge the number of message types that the thread currently subscribes to and the maximum number of message types;

[0078] If the number of the current message type is less than the maximum number of message types, start from the first thread subscription to judge whether the thread subscription is consistent with the message type, if consistent, perform message response processing and end, if inconsistent, ignore and go to the next thread subscription for judgment.

[0079] If all message types have been judged with the thread subscription, record an error flag and end.

[0080] Embodiment 2

[0081] As shown in Figure 7 Based on the same inventive concept as the above embodiment, the application also provides a power consumption information collection terminal application communication device, comprising:

[0082] A determination module is configured to determine a target power consumption information collection terminal application and each thread in the target power consumption information collection terminal application;

[0083] An acquisition module is configured to acquire a target message;

[0084] A communication module is configured to, in response to the target message, enable each thread to call a corresponding pre-packaged interface to perform communication.

[0085] Embodiment 3

[0086] As shown in Figure 8 The application also provides an electronic device 100 for implementing the power consumption information collection terminal application communication method of any of the above embodiments; the electronic device 100 comprises a memory 101, at least one processor 102, a computer program 103 stored in the memory 101 and executable on the at least one processor 102, and at least one communication bus 104.

[0087] The memory 101 can be used to store the computer program 103, and the processor 102 can implement the steps of the power consumption information collection terminal application communication method of embodiment 1 by running or executing the computer program stored in the memory 101 and calling the corresponding data stored in the memory 101.

[0088] The memory 101 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program (such as a sound playing function, an image playing function, etc.) required by a function, etc.; and the data storage area can store corresponding data (such as audio data) created according to the use of the electronic device 100, etc. In addition, the memory 101 can include a non-volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device.

[0089] The at least one processor 102 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc. The processor 102 can be a microprocessor or the processor 102 can also be any conventional processor, etc. The processor 102 is a control center of the electronic device 100, and connects each part of the entire electronic device 100 through various interfaces and lines.

[0090] The memory 101 in the electronic device 100 stores a plurality of instructions to implement a power information collection terminal application communication method, and the processor 102 can execute the plurality of instructions to implement:

[0091] determining a target power information collection terminal application and each thread in the target power information collection terminal application;

[0092] obtaining a target message;

[0093] In response to the target message, each thread calls a corresponding pre-packaged interface to perform communication.

[0094] Embodiment 4

[0095] The modules / units integrated in the electronic device 100, if implemented in the form of software function units and sold or used as independent products, can be stored in a computer-readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of each method embodiment described above can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate forms. The computer-readable medium can include any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, and read-only memory (ROM).

[0096] Those skilled in the art will appreciate that embodiments of the application can be supplied as a method, a system, or a computer program product. Therefore, the application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.

[0097] The application is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one or more flows and / or blocks. Figure 1 The functions specified in one or more flows and / or blocks.

[0098] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including instruction means that implement the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one or more flows and / or blocks. Figure 1 The functions specified in one or more flows and / or blocks.

[0099] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flowcharts and / or blocks Figure 1 one or more flowcharts and / or blocks

[0100] In the description of the present specification, the description of the terms "one embodiment", "an example", "a specific example" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application but not to limit it, and although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the specific embodiments of the present application can be modified or replaced by the equivalent, without departing from the spirit and scope of the present application, and any modification or equivalent replacement should be covered in the protection scope of the claims of the present application.

Claims

1. A method for an electric power information collection terminal to apply communication, characterized by, The method comprises the following steps: determining a target power consumption information collection terminal application and each thread in the target power consumption information collection terminal application; acquiring a target message; in response to the target message, each thread calls a corresponding pre-packaged interface for communication; the pre-packaged interface comprises: communication component initialization, thread subscription message, thread unsubscription message, thread dispatch message and thread message response; the communication component initialization comprises: initializing a buffer area according to the maximum number of supported thread message queues and the maximum number of messages that each thread message queue can accommodate; and setting a linked list as an idle linked list according to the maximum number of supported message types and the maximum number of thread subscriptions allowed for each message; the thread subscription message comprises: all business threads in the power consumption information collection terminal application subscribing to a message type according to message type requirements, the message type recording each thread message subscription, and adding the thread message subscription to the head of a message type thread subscription linked list; the thread unsubscription message comprises: a business thread in the power consumption information collection terminal application canceling subscription to a message type according to message type requirements, checking whether there is a thread message record in the message type thread subscription linked list, and deleting the thread message record from the message type thread subscription linked list if there is; the thread dispatch message comprises: a business thread in the power consumption information collection terminal application dispatching a message to a message type according to its own requirements, checking all thread message records in the message type thread subscription linked list, and dispatching the message to other threads; the thread message response comprises: after a business thread in the power consumption information collection terminal application receives a thread message, traversing thread subscriptions and checking whether the message type is a thread subscription of the business thread, and if so, processing the message, and if not, discarding the message.

2. A power utilization information collection terminal application communication device for implementing the power utilization information collection terminal application communication method according to claim 1, characterized by comprise: a determination module configured to determine a target power consumption information collection terminal application and each thread in the target power consumption information collection terminal application; an acquisition module configured to acquire a target message; a communication module configured to, in response to the target message, cause each thread to call a corresponding pre-packaged interface for communication.

3. An electronic device, comprising: The computer readable storage medium stores at least one instruction, which is executed by the processor to implement the power consumption information collection terminal application communication method of claim 1.

4. A computer-readable storage medium, characterized in that, The computer readable storage medium stores at least one instruction, which is executed by the processor to implement the power consumption information collection terminal application communication method of claim 1.

Citation Information

Patent Citations

  • Implementation method for sharing serial port resources by multiple processes based on messages

    CN111782417A