A power grid topology automatic mapping method and system
By using a binary instruction model and automatic layout and avoidance algorithms, the problems of data inconsistency and non-standard layout in large-scale power grid topology drawing tools have been solved, achieving efficient and accurate automatic drawing of power grid topology and reducing operation and maintenance costs and time consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG UNIV OF SCI & TECH
- Filing Date
- 2026-06-10
- Publication Date
- 2026-07-10
AI Technical Summary
Existing power grid topology drawing tools are ill-suited to the rapid drawing needs of large-scale power grids, resulting in inconsistencies between data and graphics, non-standard layouts, and poor readability. Furthermore, they lack efficient automatic layout and obstacle avoidance algorithms, leading to high operation and maintenance costs and low efficiency.
By employing automatic layout and automatic obstacle avoidance algorithms and parsing power grid topology data through a binary instruction model, the system achieves precise location of switch positions and automatic detection and correction of topology conflicts. Combined with data interaction between the TCP server and client, it enables data-driven real-time drawing.
It enables efficient and accurate automatic drawing of power grid topology maps, reduces manual intervention, ensures real-time synchronization of data and graphics, improves drawing accuracy and operation and maintenance efficiency, and adapts to dynamic updates of power grid topology.
Smart Images

Figure CN122368232A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power grid topology drawing technology, and relates to an automatic power grid topology drawing method and system. Background Technology
[0002] In the field of power system automation operation and maintenance, the power grid topology map is the core foundation for realizing substation switch monitoring, line dispatching and fault diagnosis. The efficiency and accuracy of its drawing directly affect the quality and safety of power grid operation and maintenance.
[0003] Currently, power grid topology mapping mainly relies on traditional manual mapping tools or simple mapping software with a single architecture, which is difficult to adapt to the needs of large-scale and multi-scenario power grid topology mapping, and has become a key bottleneck restricting the digital operation and maintenance upgrade of the power grid.
[0004] Manual drawing relies on maintenance personnel to manually locate switches and draw lines, which is time-consuming and labor-intensive. It is prone to problems such as switch coordinate deviation and substation overlap, resulting in extremely low accuracy and efficiency, and cannot meet the needs of rapid drawing for large-scale power grids.
[0005] Most plotting tools are developed using a single language, making it difficult to balance data processing efficiency and human-computer interaction experience, resulting in performance bottlenecks.
[0006] In addition, most drawing tools are disconnected from the power grid switch database, making it impossible to achieve data-driven drawing. The graphics cannot be synchronized with the switch parameters and description information, requiring manual updates, which significantly increases the operation and maintenance costs.
[0007] In addition, existing drawing tools lack efficient automatic layout and obstacle avoidance algorithms, resulting in messy switch layouts and poor readability.
[0008] In summary, existing drawing tools are clearly unable to achieve efficient, accurate, and automated drawing of power grid topology. Therefore, there is an urgent need for a technical solution that balances efficiency, accuracy, and convenience to address the aforementioned issues.
[0009] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art. Summary of the Invention
[0010] This invention proposes an automatic power grid topology drawing method. This method solves the problem of accurately locating newly inserted outgoing switch positions by designing an automatic layout algorithm; and solves the problem of interconnection, overlap, and excessive spacing of adjacent substation topology maps during the global power grid topology drawing process by designing an automatic avoidance algorithm. Ultimately, this method helps to solve the technical problems of inconsistent data and graphics, non-standard layout, and poor visualization effect in existing automatic power grid topology drawing.
[0011] To achieve the above objectives, the present invention adopts the following technical solution: An automatic power grid topology mapping method includes the following steps: Step 1. First, receive the binary instruction code on the TCP server, and use the binary instruction model to decode and convert the received binary instruction code to obtain the power grid topology drawing mode; Step 2. Determine whether the power grid topology drawing mode after decoding and conversion is a new outgoing switch insertion operation; If yes, proceed to step 3; otherwise, proceed to step 4. Step 3. Invoke the Auto Layout algorithm and perform the following processing operations: The basic information of the switches is parsed from the instruction code according to the binary instruction model and inserted into the database; at the same time, the coordinates of all switches, connecting lines and text labels to be inserted into the substation are calculated and the coordinate information of switches, connecting lines and text labels in the database is updated. Then, proceed to step 7; Step 4. Further determine whether the decoded and converted power grid topology drawing mode is the global substation topology map mode; If yes, proceed to step 5; otherwise, proceed to step 6. Step 5. Call the automatic avoidance algorithm to identify the conflict area, recalculate the coordinates of all switches, connecting lines and text labels in the substation where the conflict occurred, update the corresponding information in the database, and correct the conflict location; Step 6. Call the automatic drawing algorithm, and based on the decoding and conversion results, traverse and query the basic switch information of the relevant switches from the switch information table in the database and traverse and query the basic connection information of the connection lines from the connection line information table; Extract the graphical and location models, and automatically render and draw the power grid topology diagram; Step 7. Process ends.
[0012] Furthermore, based on the aforementioned automatic power grid topology drawing method, this invention also proposes an automatic power grid topology drawing system corresponding to the aforementioned method, which adopts the following technical solution: An automatic power grid topology mapping system includes a TCP server and a TCP client, with data interaction between the TCP server and the TCP client based on TCP Socket local network communication; The TCP client is configured with a Python visual input module; The C# auto-drawing module is stored on the TCP server; the Python visualization input module sends binary command codes and transmits them to the TCP server via the TCP Socket local network. On the TCP server side, when the C# automatic drawing module is executed by the TCP server's processor, it implements the steps of the above-mentioned automatic power grid topology drawing method to draw the power grid topology diagram.
[0013] The present invention has the following advantages: As described above, this invention discloses an automatic power grid topology drawing method. This method uses 40-bit or 14-bit binary instructions as a unified data carrier, centrally carrying basic information such as substation address codes, switch address codes, connection line address codes, switch numbers, and switch types. A binary instruction model is established on the TCP server to achieve rapid instruction parsing and parameter extraction, providing standard input and addressing basis for extracting location models and graphical models from the database, facilitating system operation and maintenance and fault diagnosis. This invention follows the fixed arrangement rules of substation switches, adopting an even-descending and odd-ascending sorting method, resulting in a neat and uniform layout. The automatic layout algorithm automatically completes the numbering, classification, sorting, and recalculation of all switch coordinates when adding new switches, achieving dynamic insertion and updating the connection line positions in tandem, ensuring accurate topology connections. A substation grid-based positioning method is adopted, and an automatic avoidance algorithm automatically detects topology conflicts such as overlapping, connected, and excessively spaced adjacent substations. Corresponding offset adjustment strategies are adopted for different conflict types, with the entire substation moving in tandem and synchronously updating the coordinates of all switches and connection lines, resulting in a uniform and aesthetically pleasing layout without overlap or adhesion. This invention utilizes a Python visual input module on a TCP client to automatically complete the entire process of instruction parsing, layout calculation, conflict avoidance, and graphics rendering simply by issuing binary commands. This eliminates the need for manual drawing and coordinate fine-tuning, significantly saving manpower and time costs, and is suitable for scenarios involving real-time dynamic updates of power grid topology. Furthermore, this invention's data-driven mode uses a database as the core data source, achieving real-time synchronization between data and graphics. It automatically completes data insertion and update operations, ensuring data consistency without manual intervention, improving drawing accuracy and operational efficiency, and solving the problem of "separation of graphics and data" in traditional drawing methods. Attached Figure Description
[0014] Figure 1 This is a flowchart of the automatic power grid topology drawing method in Embodiment 1 of the present invention; Figure 2 This is a flowchart of the binary instruction model topology pattern recognition process in Embodiment 1 of the present invention; Figure 3 This is a flowchart of the automatic layout algorithm in Embodiment 1 of the present invention; Figure 4 This is a diagram illustrating the effect of the automatic layout algorithm in Embodiment 1 of the present invention; wherein Figure 4 (a) shows a schematic diagram of the No. 7 outgoing switch not being inserted in the substation of the 14th mining area, and (b) shows a schematic diagram of the No. 7 outgoing switch being inserted in the 14th mining area. Figure 5This is a standard single substation topology diagram in Embodiment 1 of the present invention; Figure 6 This is a flowchart of the automatic obstacle avoidance algorithm in Embodiment 1 of the present invention; Figure 7 This is a schematic diagram of the conflict area in Embodiment 1 of the present invention; Figure 8 This is a diagram showing the execution effect of the automatic obstacle avoidance algorithm in Embodiment 1 of the present invention; Figure 9 This is a rendering of the power grid topology diagram after embodiment 1 of the present invention. Detailed Implementation
[0015] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments: like Figure 1 As shown, the automatic power grid topology drawing method in this embodiment includes the following steps: Step 1. First, receive the binary instruction code on the TCP server, and use the binary instruction model to decode and convert the received binary instruction code to obtain the power grid topology drawing mode.
[0016] In this embodiment, the binary instruction code originates from the TCP client. This invention uses 40-bit or 14-bit binary instructions as a unified data carrier to centrally carry information such as substation address codes, switch address codes, and connection relationships.
[0017] The TCP client establishes a TCP connection with the TCP server and sends 40-bit or 14-bit binary instruction codes to the TCP server. The TCP server receives the binary instruction codes and decodes and converts them.
[0018] A binary instruction model is established on the TCP server to enable rapid instruction parsing and parameter extraction. The received binary instruction code is decoded and converted by the binary instruction model to obtain the power grid topology drawing mode.
[0019] The binary instruction model is the core data driver and information carrier of the entire power grid topology automatic mapping system.
[0020] In this embodiment, the binary instruction model uses binary instructions as the sole information carrier.
[0021] The binary instruction model is responsible for extracting substation address codes, switch types, switch numbers, switch address codes, switch text label information, and connection line address codes; parsing the power grid topology drawing mode; and decoding the basic data information of the transfer switches.
[0022] This invention standardizes the data input format of system commands, thereby providing standardized and structured raw data and binary control commands for subsequent automatic layout, automatic obstacle avoidance, and graphics rendering.
[0023] In this embodiment, there are six power grid topology drawing modes obtained after decoding and conversion: I. Topology diagram of the substation where the outgoing switch is located and the substation where the incoming switch is located connected to the downstream substation; II. Added outgoing line switch insertion operation; III. Topology diagram of the substation where the incoming switch is located and the substation where the outgoing switch is located; IV. Topology diagram of a substation where a single outgoing switch connects to the load; V. Single substation topology diagram mode; VI. Global Substation Topology Diagram Mode.
[0024] Define topology mode quantization identifier , These correspond to the six power grid topology drawing modes mentioned above.
[0025] like Figure 2 A complete flowchart of binary instruction model topology pattern recognition is presented.
[0026] First, after receiving the binary instruction on the TCP server, it determines whether it is 11111111111111 or 000000000000000 to draw the global power grid topology diagram mode.
[0027] If yes, proceed with the global power grid topology drawing process; otherwise, proceed to the next step. Determine if it is a 14-bit substation address code. If yes, proceed with the single substation topology drawing process; otherwise, proceed to the next step.
[0028] Determine whether the instruction is an outgoing switch instruction based on bits 15-16 of the binary instruction code. If it is not such an instruction, proceed with the process of drawing the topology diagram of the substation where the incoming switch is located and the substation where the outgoing switch is located connected to the upstream substation; otherwise, proceed to the next step.
[0029] After determining that it is an outgoing line switch instruction, the database is queried based on bits 1-14 and bits 15-24 of the instruction code to determine whether the outgoing line switch information exists. If it does not exist, the process of adding an outgoing line switch is performed; otherwise, the next step is determined.
[0030] After determining that the outgoing switch information exists in the database, further determination is made based on bits 23-24 of the binary instruction code to determine whether the outgoing switch is connected to the incoming switch of the downstream substation.
[0031] If so, proceed with the process of drawing the topology diagram of the substation where the outgoing switch is located and the substation where the downstream incoming switch is located; otherwise, proceed with the process of drawing the topology diagram of a single outgoing switch connected to the load and its substation.
[0032] For ease of description, a 40-dimensional instruction vector is used. For example, its expression is as follows: .
[0033] Define the model input as an instruction vector The output is a topology drawing mode identifier. and drawing trigger signals ,in , To draw the start signal.
[0034] definition , respectively corresponding to instructions The first to 40th bits of the binary value, .
[0035] I. Quantitative analysis of the substation address code where the outgoing switch is located ( ).
[0036] definition As the unique identifier of a substation, the formula is as follows: ... .
[0037] II. Quantitative Analysis of Switch Types ( ).
[0038] Define switch type parameters Identify the incoming / outgoing switch.
[0039] when When it is an outgoing switch, When the incoming line switch is used, the formula is as follows: .
[0040] Combined with examples for ,Right now (The substation where this switch is located is numbered) ); ,Right now The switch is an outgoing switch.
[0041] III. Define the switch existence flag. and switch address code The formula for the switch address code is as follows: ... .
[0042] Combined with examples, , The model calls the database retrieval interface, based on... and As a basis for retrieving switch information.
[0043] To better understand the database retrieval process, the database source mathematical model is defined as a binary tuple, used to quantify the storage rules of switches and query mapping relationships in the database, supporting the existence judgment of the binary instruction model, as follows: .
[0044] in Represents a database. It is a collection of all switch information in the database. This is a query mapping function.
[0045] gather Each element in the tuple is a unique identifier for the switch. .
[0046] in This is a database representation of the substation address code where the switch is located. The database representation of the switch address code, namely: .
[0047] in This represents the total number of outgoing switches in the database.
[0048] Define query function .
[0049] Used to parse binary instruction models (Substation address code) and (Switch address code), mapped to the existence result of the switch in the database, the mathematical expression is as follows: .
[0050] IV. Determining the existence of outgoing switches.
[0051] The binary instruction model calls the query function of the database source mathematical model. Define the existence flag bit of the outgoing switch. Its value is directly determined by the output of the query function, and the mathematical relationship is as follows: .
[0052] V. Type of downstream connection device for outgoing switch.
[0053] Define the flag bit of the downstream connection device of the outgoing switch as follows: .
[0054] when hour, =2 indicates that the outgoing switch is connected to a load; when hour, =1 indicates that the outgoing switch is connected to the incoming switch of the next substation.
[0055] In conjunction with the example, the database collection in the example Existing elements Therefore ,Right now 40-bit binary instruction model ,Right now =1.
[0056] according to , and This completes the mapping from binary instructions to the power grid topology drawing mode.
[0057] Output topology drawing mode identifier With trigger signal The formula is as follows: .
[0058] in, The drawing mode corresponds to the topology diagram of the substation where the outgoing switch is located and the substation where the downstream incoming switch is located. This indicates that the topology drawing process has been started.
[0059] Step 2. Determine whether the power grid topology drawing mode after decoding and conversion is a new outgoing switch insertion operation.
[0060] After the binary instruction code decoding and conversion in step 1 above, the specific power grid topology drawing mode has been obtained. If it is a new outgoing switch insertion operation, proceed to step 3; otherwise, proceed to step 4.
[0061] Specifically, the process for determining whether a new outgoing switch insertion operation is required is as follows: For the 40-bit binary instruction code received by the TCP server Analyze =(1,0).
[0062] At this point, a judgment is made. This is an outgoing line switch instruction; subsequently, the substation address code of the outgoing line switch should be extracted. and the address code of the outgoing switch The database switch information table is used to retrieve data based on the two address codes.
[0063] If the information of the outgoing switch in the instruction code is not found in the database, the flag bit of the outgoing switch is set to false, and the 40-bit binary instruction code is determined to be the instruction code for a newly added outgoing switch.
[0064] Step 3. Invoke the Auto Layout algorithm and perform the following processing operations: The basic information of the switches is parsed from the instruction code according to the binary instruction model and inserted into the database; at the same time, the coordinates of all switches, connecting lines and text labels to be inserted into the substation are calculated and the database coordinate information of switches, connecting lines and text labels is updated.
[0065] Then, proceed to step 7.
[0066] In this embodiment, the basic switch information of the newly added outgoing switch includes the substation address code, switch address code, switch text label information, switch number, address code of the lower-level linked device, and switch type.
[0067] The automatic layout algorithm can arrange the switch positions within the substation in an orderly manner according to preset rules, ensuring a standardized and uniform overall layout. When adding a new switch, it can automatically recalculate the coordinates of all switches to be inserted into the substation, achieving dynamic switch insertion and synchronously updating the coordinates of connecting lines. This ensures that the connecting lines and switches always maintain the correct connection relationship, thus providing standard and reusable position data for subsequent graphic drawing and conflict avoidance. The specific workflow is as follows: Figure 3 As shown.
[0068] First, the layout and arrangement rules of switches within the substation are clearly defined, serving as the core basis for the automatic layout algorithm: Each substation is equipped with two incoming line switches (denoted as No. 1 incoming line switch and No. 2 incoming line switch), with one bus tie switch between them. All outgoing line switches in the substation are divided into even-numbered outgoing line switches and odd-numbered outgoing line switches according to their numbers, following the "even down, odd up" sorting rule. Even-numbered outgoing line switches are arranged to the left of the bus tie switch, in descending order of their numbers from left to right. Odd-numbered outgoing line switches are arranged to the right of the bus tie switch, in ascending order of their numbers from left to right. Only one outgoing line switch can be inserted between the bus tie switch and the incoming line switches on both sides.
[0069] like Figure 3 As shown, the processing flow of the automatic layout algorithm for outgoing switches is as follows: Step 3.1. First, based on the binary instruction model, start from the 40-bit binary instruction code. Extract the basic switch information of the newly added outgoing switch and insert it into the substation switch information table in the database.
[0070] Parsing the target substation address code using a binary instruction model ~ ), and the analysis of the address code of the newly added outgoing switch ( ~ ), target bus number ( ~ ) and analysis of the type number of the lower-level connecting device ( ~ ).
[0071] The amount of information parsed is defined sequentially as follows: , , , It is automatically inserted into the corresponding switch information table in the database, completing the real-time update of the database data and providing data support for subsequent automatic layout algorithms.
[0072] Step 3.2. According to from Extract the address code of the substation where the outgoing switch is located from the instruction code. ).
[0073] According to the address code ( Retrieve the numbers of all outgoing switches under the substation from the database, including the numbers of newly inserted outgoing switches, and store all the retrieved numbers in the temporary array OrderList.
[0074] Step 3.3. Divide all switches in the temporary array OrderList into even numbers and odd numbers and store them in the EvenList array and OddList array respectively. Sort the numbers in the two arrays in "even descending and odd ascending".
[0075] Define an array of even-numbered exit switches as EvenList and an array of odd-numbered exit switches as... .
[0076] , ; , .
[0077] in, The number of outgoing switches is determined by an even number. The array follows an even-decreasing sort. The number of outgoing switches is odd-numbered. The array follows an odd-ascending sort.
[0078] Based on the target substation address code obtained through parsing It automatically accesses the database, retrieves the numbers of all existing outgoing switches in the substation (including the numbers of newly inserted outgoing switches), and stores them in a temporary array. Then, the outgoing switch numbers in the temporary array are categorized by parity and stored in a preset even-numbered array. and odd array In the middle, and through the "even descending, odd ascending" sorting algorithm, it is sorted into and The switches are numbered sequentially.
[0079] Step 3.4. According to the principle of switch topology arrangement in the substation, even-numbered outgoing switches should be arranged in descending order to the left of the bus tie switch, and odd-numbered switches should be arranged in ascending order to the right of the bus tie switch.
[0080] At this point, the address code of the substation where the outgoing switch is located is extracted. The database is queried to find the location information of the No. 1 incoming line switch in the substation where the outgoing line switch is located, and this information is used as the reference coordinate.
[0081] Step 3.5. Combining the index of each switch number in the EvenList and OddList arrays, the switch width, the height of the incoming switch, the width of the bus tie switch, and the switch topology arrangement principle in the substation, calculate the position information of each outgoing switch relative to the reference coordinates, and update the position information of all outgoing switches in the database in real time.
[0082] Based on the target substation address code Retrieve the coordinates of the No. 1 incoming switch of the substation from the database. This coordinate system will be used as the reference coordinate system for the layout of all outgoing switches.
[0083] Define switch width Incoming switch height Bus tie switch width .
[0084] According to the outgoing switch and The coordinates of each outgoing switch are calculated sequentially based on its sorting position, switch width, incoming switch height, and bus tie switch width. The specific calculation rules and mathematical expressions are as follows:
[0085] The ordinate of all even-numbered outgoing switches is uniformly set as follows: The x-coordinate is determined by its position in the even-numbered array. Index in (Starting from 0) the calculation is expressed as follows: .
[0086] in , These represent even-numbered indices. The horizontal and vertical coordinates of the outgoing switch.
[0087] Specifically, the smallest switch among the even-numbered switches (the last element of EvenList) has a x-coordinate of . The vertical axis remains the same. It is adjacent to the left side of the bus tie switch.
[0088] The ordinate of all odd-numbered outgoing switches is unified as follows: The x-axis is based on its position in the x-axis. Index in (Starting from 0) the calculation is expressed as follows: ; in , These represent odd-numbered indices. The horizontal and vertical coordinates of the outgoing switch.
[0089] In particular, the smallest switch among the odd-numbered ones ( The first element), whose x-coordinate is The vertical axis remains the same. It is adjacent to the right side of the bus tie switch.
[0090] The coordinates of all outgoing switches calculated through steps 3.1 to 3.5 above are updated in real time to the switch information table in the database to complete the automatic layout of the outgoing switches.
[0091] After adding a new outgoing switch, the coordinates of the original switch changed, which meant that the coordinates of the corresponding connecting lines needed to be optimized accordingly.
[0092] In this embodiment, after receiving the 40-bit insertion instruction, the automatic placement algorithm iteratively searches the database for the 40-bit address codes of all connecting lines. = The coordinates of each connecting line are iteratively optimized.
[0093] For any connecting line, according to The first 14 digits (address code of the superior substation) ) and bits 15-24 (address code of the upstream outgoing switch) (), retrieve the coordinates of the upstream outgoing switch from the database. ; from bits 25-38 of the connection line address code (lower-level substation address code) ) and bits 39-40 (address code of the next-level incoming switch) (), retrieve the coordinates of the downstream incoming switch from the database. .
[0094] Based on the retrieved coordinates of the upper and lower level switches, calculate the starting coordinates of the connecting line. ) and line length The mathematical expression is as follows: , .
[0095] It should be noted that the calculation of the starting coordinates and length parameters of the connector is explained using this example only. The calculation process for other types of connectors is the same, and you only need to modify the calculation order according to the actual situation.
[0096] The calculated starting coordinates of the connecting line and the length of the horizontal line The system updates the connection information table in the database in real time, completes the coordinate update of a single connection, and iterates to complete the automatic layout and update of all connection lines.
[0097] The automatic layout effect is shown in the following diagram. Figure 4 As shown, Figure 4 A comparison diagram shows the insertion of the new No. 7 outgoing line switch into the No. 14 mining area substation. Figure 4 (a) shows the initial substation topology of the 14th mining area without the insertion of the new No. 7 outgoing switch, and (b) shows the substation topology after the insertion of the No. 7 outgoing switch and the automatic layout algorithm.
[0098] Figure 4 There are two incoming line switches numbered I and II, and outgoing line switches numbered 14, 12, 8, 9, 11, and 13 respectively.
[0099] Figure 5 A schematic diagram of the topology of a single substation is shown (taking an underground central substation as an example), which includes two incoming switches numbered I and II, outgoing switches numbered 8, 6, 2, 1, 5, and 9, and a bus tie switch.
[0100] Step 4. Further determine whether the decoded and converted power grid topology drawing mode is the global substation topology map mode.
[0101] If yes, proceed to step 5; otherwise, proceed to step 6.
[0102] When the received binary instruction code is =000000000000000 or When the value is 11111111111111 (these two special 14-bit binary instructions represent drawing the global power grid topology), the global substation topology diagram mode is executed.
[0103] At this point, the automatic avoidance algorithm will be triggered to identify the conflict area, correct the conflict position, and avoid problems such as connection, crossing, overlap, and excessive spacing between adjacent substations caused by the insertion of a new outgoing switch. The automatic avoidance algorithm will automatically iterate and optimize the switch position information of all conflicting substations and update the switch position information in the database in real time.
[0104] Step 5. Call the automatic avoidance algorithm to identify the conflict area, recalculate the coordinates of all switches, connecting lines and text labels in the substation where the conflict occurred, update the corresponding information in the database, and correct the conflict location.
[0105] The core function of the automatic obstacle avoidance algorithm is to detect topological conflicts (connection, overlap, excessive spacing, etc.) between adjacent substations during the addition of new outgoing switch topology elements. The conflict area diagram is shown below. Figure 7 As shown.
[0106] in Figure 7 This indicates a conflict between the topology diagrams of the 14th mining area substation and the 8th mining area substation after the insertion of the new outgoing switch #7 at the 14th mining area substation.
[0107] from Figure 7 It can be seen that the topology diagram of the No. 13 outgoing switch of the No. 14 mining area substation is connected to the topology diagram of the No. 12 outgoing switch of the No. 8 mining area substation. The red box indicates the area where the topology diagrams of the two substations conflict.
[0108] By adjusting the overall location of substations, conflict avoidance is achieved, ensuring that the layout of each substation in the power grid topology is reasonable and that there are no location conflicts. The specific workflow of the automatic avoidance algorithm is as follows: Figure 6 As shown.
[0109] like Figure 6 As shown, the processing flow of the automatic obstacle avoidance algorithm in this embodiment is as follows: Step 5.1. Identification of conflict areas and conflict detection.
[0110] To facilitate the location of conflict areas, all substations in the power grid topology map are first located using a grid, treating each substation as an independent topological unit, and defining its grid coordinates as follows: ; The substation level (from top to bottom, level 1 to n). The number of columns for the substation (columns 1-n from left to right).
[0111] This embodiment can quickly locate adjacent substations using grid coordinates.
[0112] Iterate through the grid coordinates of all substations Set the grid coordinates as The substation and its horizontally adjacent substation Composition of substation , to perform conflict detection.
[0113] First, the coordinates are retrieved. The substation stores an array of odd-numbered switch numbers. The outgoing switch number with the largest subscript in the array is used to find its x-coordinate from the database, based on the retrieved outgoing switch number and the address code of the substation where the outgoing switch is located. , coordinates The x-coordinate of the rightmost switch in the substation.
[0114] The substation address code is based on the substation's grid coordinates. Found in the substation information table.
[0115] Meanwhile, the search coordinates are The substation's array storing even-numbered switch numbers The outgoing switch number with the smallest subscript in the array is used to find its x-coordinate from the database, based on the retrieved outgoing switch number and the address code of the substation where the outgoing switch is located. , coordinates The x-coordinate of the leftmost switch in the substation.
[0116] Calculate the actual distance between two adjacent substations in a substation centering system. : .
[0117] according to The numerical value is used to determine the conflict type. The mathematical description of the judgment logic is as follows: .
[0118] in For connected conflict threshold, To determine the overlap and conflict threshold, The appropriate spacing threshold.
[0119] Step 5.2. Substation topology location optimization.
[0120] For different conflict types, the coordinates are calculated as follows: The overall moving distance of the substation By adjusting the coordinates to The coordinates of the No. 1 incoming line switch of the substation are determined and an automatic layout algorithm is triggered to achieve the overall position adjustment of the substation.
[0121] Overall movement distance of the substation The specific calculation process is as follows: .
[0122] when When the substation topology shifts to the right, This indicates that the substation topology has shifted to the left.
[0123] Based on the grid coordinates of the substation The substation address code is retrieved from the substation information table, and then the coordinates are retrieved from the substation switch information table based on the substation address code. Original coordinates of substation No. 1 incoming switch .
[0124] Calculate the coordinates as New coordinates of substation No. 1 incoming switch after adjustment The mathematical expression is: .
[0125] Change the new coordinates of the No. 1 incoming line switch Update to the database.
[0126] Simultaneously, the automatic layout algorithm is triggered, and the coordinates are automatically updated based on the new coordinates of the #1 incoming line switch. The coordinates of all other topological elements (switches, connections, text labels) within the substation are determined, and finally, the adjacent areas of each pair of horizontally adjacent substations are iteratively optimized based on an automatic avoidance algorithm to ensure the visibility of the power grid topology.
[0127] For example, if a substation's grid coordinates are (2,1), then its approximate location is the second substation from top to bottom and the first substation from left to right; then mark the areas where conflicts may occur, to... Taking the insertion of instruction code into the substation where the new outgoing switch is located as an example, the grid coordinates of the outgoing switch have been defined as (2,1) in the database. Then the areas where conflicts may occur are the adjacent areas of the substation with grid coordinates (2,1) and the substation with grid coordinates (2,2).
[0128] Subsequently, conflict determination is performed on the marked areas. In the topology map, the distance between two substations can be determined by the distance between the rightmost outgoing switch of the left substation and the leftmost outgoing switch of the right substation. In the automatic avoidance algorithm, three thresholds are set. The distance between two substations is defined as distance. If distance=200, the area is identified as normal. If distance≤100, the area is identified as an intersecting or connected conflict area. If distance>200, the area is identified as an area with excessive spacing.
[0129] Next, based on the grid coordinates (2,1), the substation address code is retrieved from the substation information table in the database. Based on the retrieved substation address code, the numbers of all switches in the substation are retrieved from the switch information table in the database and stored in the OrderList array. Then, the left and right numbers in the array are classified as even or odd and sorted in "even descending, odd ascending". The sorted switch numbers are stored in the EvenList (even number array) and the OddList (odd number array) respectively. At this time, the rightmost switch of the substation is the outgoing switch corresponding to the switch number with the largest index in the OddList array. Similarly, the substation with grid coordinates (2,2) can also obtain the EvenList (even number array) and the OddList (odd number array). At this time, the leftmost switch of the substation is the outgoing switch corresponding to the switch number with the smallest index in the EvenList array. Thus, the boundary switches of the two substations are located.
[0130] After locating the two boundary switches, define the x-coordinates of the two switches as follows: , The initial default spacing between two substations was 100px, the width of one outgoing switch. However, because an outgoing switch was inserted into the substation at grid coordinates (2,1), the distance was increased. =100<200, the marked area is identified as a connected conflict area. A conflict diagram is shown below. Figure 5 As shown, the conflict region identification is now complete. Finally, the correction parameters are calculated. =-100 (positive numbers indicate moving to the right, negative numbers indicate moving to the left), adjust the horizontal coordinate of the No. 1 incoming switch of this substation. = +distance, and at the same time, trigger the automatic layout algorithm again to modify the position information of all outgoing switches in the substation relative to the No. 1 incoming switch and the position information of the connecting lines in real time. After the substation position correction is completed, iteratively optimize other possible conflicting marked areas in the power grid topology map, and finally achieve a reasonable layout of all substations.
[0131] The effect diagram of the automatic obstacle avoidance algorithm used in this embodiment is shown below. Figure 8 As shown.
[0132] It can be seen that the substation in the 14th mining area has shifted 100px to the left. At this point, the topology map interval between the substation in the 14th mining area and the substation in the 8th mining area is the usual distance of 100px. Figure 7 The conflicts that occurred have been optimized and resolved.
[0133] Step 6. Call the automatic drawing algorithm, and based on the decoding and conversion results, traverse the database switch information table to query the basic switch information (switch type, location information, text label) of the relevant switches and the connection information table to query the basic connection information (connection type, location information, connection length parameter) of the connection lines. Extract the graphic model and location model from them, and automatically render and draw the power grid topology diagram.
[0134] The automatic drawing algorithm includes automatic drawing and rendering, as well as database information query and update functions. Its processing is as follows: First, write the code to establish a MySQL database connection, thus connecting the C# auto-drawing module to the database; then, use the encapsulated SQL statements to perform database query and update operations. In addition, by first creating a Bitmap memory canvas in the memory of the C# AutoDrawing module, the Graphics object is used to perform drawing operations such as drawing graphics and text based on the information queried from the database. Once the drawing is complete, the PictureBox control in the form renders the canvas to the window via the Paint event. When a refresh is needed, calling the Invalidate() function in the PictureBox control triggers a redraw, which completes the automatic drawing process.
[0135] A bitmap is a bitmap object in memory, which is like a "canvas" on which image content can be defined pixel by pixel. After drawing, it is used for display or storage. When it is not directly displayed on the screen, all drawing operations are performed on the bitmap.
[0136] Graphics is the main utility class for drawing in C#, providing methods for drawing lines, shapes, text, images, etc. Graphics instances can be created from Bitmap objects.
[0137] PictureBox is a control in C# Windows Forms specifically designed to display images. You can assign a Bitmap to its Image property or manually draw content in its Paint event. It is typically used to quickly display dynamically generated images.
[0138] The Paint event is triggered when the PictureBox control needs to redraw the interface. The event parameter provides a Graphics object, and the drawn Bitmap is rendered to the screen in this event. It is the "exit" for displaying the drawing results.
[0139] The Invalidate() method is a built-in method of the control, used to "mark" the entire or part of the control as an invalid area. After being called, the system will automatically trigger the Paint event when the same thread is idle, thereby refreshing the display.
[0140] It should be noted that the automatic drawing algorithm in this embodiment is implemented through the cooperation of the built-in methods, classes and controls in C# mentioned above, which is quite conventional and will not be described in detail here.
[0141] The location model is based on the power grid topology drawing mode converted from the binary instruction model. It uses an automatic drawing algorithm to query the database for all switch location information, connection line location information, and text label location information to be drawn, and determines the location information of all switches, connection lines, and text labels in the power grid topology diagram to be drawn.
[0142] The core function of the position model is to use the trigger signal output by the binary instruction model to... The topology drawing mode conversion of binary instructions is obtained. The drawing mode corresponds to the "topology diagram of the substation where the outgoing switch is located and the substation where the downstream incoming switch is located". Through interaction with the database source model, it retrieves the location coordinates of all switches and their corresponding text labels within the upstream and downstream substations. Because... In the topology mode, the address code and command code of the connection lines between substations The same, therefore As the sole basis for retrieving connection information, the precise location coordinates of the upstream outgoing switch, the downstream incoming switch, and the connection line between them are defined using a triplet as follows: .
[0143] in Input set for the model; This is a cluster of location retrieval and computation functions; This is a cache set for location data. The input to the location model comes directly from the output of the binary instruction model and 40-bit binary instructions.
[0144] The input set is defined as follows: .
[0145] in, The topology drawing mode identifier output by the binary instruction model; The drawing trigger signal output by the binary instruction model; It is a 40-bit binary instruction vector.
[0146] ... The address code of the superior substation for parsing the binary instruction model.
[0147] ... Address codes of lower-level substations for parsing binary instruction models.
[0148] ... The address code of the upper-level outgoing switch for parsing the binary instruction model.
[0149] ... Address codes of lower-level input switches for parsing binary instruction models.
[0150] Using the database source mathematical model defined above Add a subset of location data As the retrieval data source for the location model, the four-tuple of switch and label information location information is defined as: .
[0151] in, This is the substation address code; This is the switch address code.
[0152] Switch coordinates; These are the coordinates of the label information corresponding to the switch.
[0153] Meanwhile, the position triplet mathematical expression of the connector topology is defined as follows: .
[0154] in For the connection line address code (in =1 Connection line address code in topology mode With 40-bit binary instruction vector correspond); The starting coordinates of the connecting line; The length of the horizontal line connecting the two lines.
[0155] Right now .
[0156] ; .
[0157] in The total number of switches, This represents the total number of connecting lines.
[0158] To facilitate the description and retrieval of location information for specific substations and switches, a retrieval function is defined. According to the substation address code Retrieve the address codes of all switches within the substation, and simultaneously retrieve the location coordinates of each switch's label information:
[0159] .
[0160] in This represents the total number of switches in the substation. For switch address code, For the first This method assigns coordinates to each switch and its corresponding text label, achieving a one-to-one correspondence between switches and labels. .
[0161] To facilitate the retrieval of information describing the precise location of a specific switch, a location retrieval function is defined. According to the substation address code With switch address code The precise coordinates of a specific switch are retrieved, and the specific mathematical expression is as follows:
[0162] .
[0163] in, The coordinates of a specific switch, Provide the coordinates of the annotation information corresponding to this specific switch to ensure the accurate association between the switch and the annotation.
[0164] To facilitate the description of the retrieval process for the location of the connecting line, a retrieval function is defined. , with 40-bit binary instructions As a unique address code for the connector, its location information can be retrieved, including the starting coordinates and length of the connector. : .
[0165] in, These are the starting coordinates of the connecting line.
[0166] in, The length of the horizontal line of the connecting line, together with the horizontal line, constitutes the complete positional information of the connecting line, accurately representing the positional relationship and dimensional parameters of "a switch in the upper-level substation is connected to a switch in the lower-level substation".
[0167] Define location data cache collection It is used to store all retrieved switch positions, corresponding label positions, and connecting line position parameters (starting coordinates, horizontal line length). This enables data reuse for subsequent graphical models: .
[0168] Define a function to save location data, and combine the function family. All output positional parameters are stored together in , As a temporary cache collection, it can be directly used for data retrieval in subsequent automatic drawing.
[0169] The graphical model uses the power grid topology drawing mode identifier output by the binary instruction model. and drawing trigger signals The system establishes standardized rules for representing switch graphics. Based on the power grid topology model to be drawn according to the binary instructions, the graphic model queries the database for basic switch information through an automatic drawing algorithm to determine the display style, text label information, location information, and switch type of the switch, providing a unified and standardized basis for graphic rendering for the system.
[0170] The graphical model primarily expands upon the given location to determine the type of switch topology to be drawn, rendering colors, and other information. (Continuing with...) For example.
[0171] The graphical model is defined as a triple as follows: \ .
[0172] in, Input set for the model; A cluster of functions for retrieving and rendering graphics type parameters; A collection of parameters to be cached for drawing graphics.
[0173] To facilitate the description of graphic types and color rendering, a set of switch types is defined as follows: .
[0174] Where 1 = outgoing switch, 2 = incoming switch, 3 = bus tie switch, 4 = connection wire style 1 (e.g.) Figure 7 (Connection wire between the No. 6 outgoing switch of the underground central substation and the No. 1 incoming switch of the No. 14 mining area substation), 5 = Connection wire style 2 (such as...) Figure 7 Connection line between the No. 2 outgoing switch of the underground central substation and the No. 1 incoming switch of the No. 8 mining area substation.
[0175] Define the color rendering set as , used to characterize different states of a circuit.
[0176] in Define the names of different colors in the data dictionary in the C# automatic drawing module, and look up the corresponding colors in the data dictionary using the status codes of the switches.
[0177] The graphics model is passed in using a binary instruction model. Based on the parameters, determine the switch type, switch rendering color, and text annotation rendering information, and define a subset of graphic parameters. It serves as a data source for retrieving graphical models.
[0178] in The graphical parameter subset is a set of data records in the database that specifically represent switch and connection information.
[0179] Because it is necessary to retrieve the switch and connection type and rendering information from the database, a switch graphic parameter triplet is defined. With the graphical parameters of the connecting line tuple .
[0180] in This is the substation address code; For switch address code; It is a switch type; The connection line address code corresponds to a 40-bit binary instruction vector; This is the style of the connector line.
[0181] Right now .in This indicates that the switch information already exists in the database. This indicates connection information that already exists in the database.
[0182] To facilitate the retrieval of all switch graphic types within a substation, a retrieval function is defined. The mathematical expression is as follows: .
[0183] in This represents the total number of switches in the substation. For switch address code, For the first The type of switch allows the automatic drawing algorithm to draw the switch.
[0184] To facilitate the description and retrieval definition of connection line graphic types The function, specifically expressed mathematically, is as follows: .
[0185] in, , This refers to the connector style type.
[0186] To facilitate the description of the color rendering definition of topological elements For the status drawing mode, the status code of the switch is determined based on the address code of the target switch and the address code of its substation. The graphical model only needs to complete the retrieval and determination of the status code. Then, the automatic drawing algorithm determines the rendering color based on the status code and the data dictionary. The mathematical expression is as follows: .
[0187] in This is the address code of the substation where the switch is located. Defines a specific switch address code. Defines a set of graphics drawing parameter caches. It is used to store all retrieved and determined switch types and status codes for direct use by automatic drawing algorithms, enabling parameter reuse and traceability. Its mathematical definition is as follows: .
[0188] Define a function to save graphics parameters, and store the function family. All output graphics rendering data is stored in a unified manner. The power grid topology rendered by the graphical model is as follows: Figure 9 As shown, Figure 9 The status topology diagram of the switches and connecting lines connecting the underground central substation and the No. 8 mining area substation is displayed.
[0189] The eight-bit binary number 00000000 of the No. 2 outgoing switch in the underground central substation is the switch's status code, which is pre-stored in the database to indicate the switch's operating status. Different colors are used to indicate different operating statuses of the switch and its connecting lines.
[0190] The color here is obtained from the data dictionary based on the switch status code.
[0191] The data dictionary is used to map switch status codes to specific graphic rendering colors (e.g., 00000000 → “Red” for fault, 00000001 → “Orange” for abnormal), and its format is usually a key-value pair mapping.
[0192] Step 7. Process ends.
[0193] This invention uses a power grid database as the core data source. By reading device parameters, location information, and instruction data from the Python visualization input module, it automatically drives topology layout calculation, graphic drawing, and line connection, achieving fully automatic drawing of power grid topology diagrams without manual drawing or intervention. When the switch positions, basic information, and line connection status in the database change, the system can reread the data and automatically redraw the topology diagram, achieving synchronous linkage between data and graphics.
[0194] Example 2
[0195] This embodiment 2 describes an automatic power grid topology drawing system, which includes a TCP server and a TCP client. The TCP server and the TCP client communicate with each other via TCP Socket local network communication.
[0196] The TCP client is configured with a Python visual input module.
[0197] The C# auto-drawing module is stored on the TCP server; the Python visualization input module sends binary command codes and transmits them to the TCP server via the TCP Socket local network.
[0198] On the TCP server, when the C# automatic drawing module is executed by the processor, it is used to draw the power grid topology diagram according to the steps of the power grid topology automatic drawing method described in Example 1 above.
[0199] This invention is a power grid topology automatic drawing system consisting of a Python visualization input module and a C# automatic drawing module. The two modules interact with each other based on TCP Socket local network communication.
[0200] The Python visual input module provides a GUI input window that receives the substation number from the user; clicking a button initiates a Socket connection and sends the number string; the connection is automatically closed upon completion, and a pop-up window displays the operation result.
[0201] The C# automatic drawing module resides in the background, listening on port 9000, waiting for client access; it receives the substation number transmitted by the Python visualization input module; and pushes the data to the UI layer through delegate callbacks to complete the automatic drawing of the power grid topology.
[0202] The specific architecture of the automatic power grid topology mapping system in this embodiment is described in Table 1.
[0203] Table 1 Overall Architecture Description of the Automatic Power Grid Topology Mapping System
[0204] The workflow of the automatic power grid topology mapping system in this embodiment is as follows: First, start the C# automatic drawing module, which internally starts a background thread and starts a TcpListener to listen to 127.0.0.1:9000, entering a blocking wait state for client connections; Then, the Pytho visual input module is launched, and an input window pops up, waiting for the user to input the substation number. At this point, the user enters a binary instruction code and clicks the auto-draw button, triggering the Python visualization input module to create a TCP client and actively connect to port 9000 of the TCP server where the C# auto-draw module is located; The Python visualization input module then converts the data (number) into a UTF-8 encoded byte stream, sends it via TCP, and closes the socket immediately after sending. After the TCP server detects a client connection, it receives the byte stream and converts it to a UTF-8 string.
[0205] The C# auto-drawing module receives binary commands from the Python visualization input module via a callback function. After receiving the binary commands, it securely invokes the auto-drawing algorithm through the UI delegate to complete the automatic drawing and display of the power grid topology diagram.
[0206] UI delegation is a security mechanism that allows the backend to delegate drawing tasks to the UI thread after receiving a message, thus preventing program errors.
[0207] Of course, the above description is only a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. It should be noted that any equivalent substitutions or obvious modifications made by those skilled in the art under the guidance of this specification fall within the scope of this specification and should be protected by the present invention.
Claims
1. A method for automatically drawing power grid topology, characterized in that, Includes the following steps: Step 1. First, receive the binary instruction code on the TCP server, and use the binary instruction model to decode and convert the received binary instruction code to obtain the power grid topology drawing mode; Step 2. Determine whether the power grid topology drawing mode after decoding and conversion is a new outgoing switch insertion operation; If yes, proceed to step 3; otherwise, proceed to step 4. Step 3. Invoke the Auto Layout algorithm and perform the following processing operations: The basic information of the switches is parsed from the instruction code according to the binary instruction model and inserted into the database; at the same time, the coordinates of all switches, connecting lines and text labels to be inserted into the substation are calculated and the coordinate information of switches, connecting lines and text labels in the database is updated. Then, proceed to step 7; Step 4. Further determine whether the decoded and converted power grid topology drawing mode is the global substation topology map mode; If yes, proceed to step 5; otherwise, proceed to step 6. Step 5. Call the automatic avoidance algorithm to identify the conflict area, recalculate the coordinates of all switches, connecting lines and text labels in the substation where the conflict occurred, update the corresponding information in the database, and correct the conflict location; Step 6. Call the automatic drawing algorithm, and based on the decoding and conversion results, traverse and query the basic switch information of the relevant switches from the switch information table in the database and traverse and query the basic connection information of the connection lines from the connection line information table; Extract the graphical and location models, and automatically render and draw the power grid topology diagram; Step 7. Process ends.
2. The automatic power grid topology drawing method according to claim 1, characterized in that, In step 1, the binary instruction code originates from the TCP client; The TCP client sends a 40-bit or 14-bit binary instruction code and establishes a TCP connection with the TCP server to send the 40-bit or 14-bit binary instruction code to the TCP server. The TCP server uses a binary instruction model to decode and convert the received binary instruction code.
3. The automatic power grid topology drawing method according to claim 1, characterized in that, The binary instruction model is used to extract substation address code, switch type, switch number, switch address code, switch text label information, and connection line address code, parse the power grid topology drawing mode, and decode the basic data information of the transfer switch.
4. The automatic power grid topology drawing method according to claim 1, characterized in that, In step 1, there are six power grid topology drawing modes, namely: I. Topology diagram of the substation where the outgoing switch is located and the substation where the incoming switch is located connected to the downstream substation; II. Added outgoing line switch insertion operation; III. Topology diagram of the substation where the incoming switch is located and the substation where the outgoing switch is located; IV. Topology diagram of a substation where a single outgoing switch connects to the load; V. Single substation topology diagram mode; VI. Global Substation Topology Diagram Mode.
5. The automatic power grid topology drawing method according to claim 1, characterized in that, In step 2, the process for determining whether it is a new outgoing switch insertion operation is as follows: For the 40-bit binary instruction code received by the TCP server First, analyze =(1,0); At this point, a judgment is made. This is an outgoing line switch instruction; subsequently, the substation address code of the outgoing line switch should be extracted. and the address code of the outgoing switch The database switch information table is used to retrieve data based on the two address codes; If the information of the outgoing switch in the instruction code is not found in the database, the flag bit of the outgoing switch is set to false, and then it is determined that the 40-bit binary instruction code is the instruction code for a newly added outgoing switch. in , , , All of these are the corresponding bits in a 40-bit binary instruction code.
6. The automatic power grid topology drawing method according to claim 1, characterized in that, In step 3, the basic switch information of the newly added outgoing switch includes the substation address code, switch number, address code of the lower-level linked device, switch address code, switch type, and text labeling information.
7. The automatic power grid topology drawing method according to claim 1, characterized in that, In step 3, the processing flow of the automatic layout algorithm is as follows: Step 3.
1. First, based on the binary instruction model, start from the 40-bit binary instruction code. Extract the basic switch information of the newly added outgoing switch and insert it into the substation switch information table in the database; Step 3.
2. From Extract the address code of the substation where the outgoing switch is located. ); According to the address code ( Retrieve the numbers of all outgoing switches under the substation from the database, including the numbers of newly inserted outgoing switches, and store all the retrieved numbers in the temporary array OrderList; in This corresponds to the number of bits in the 40-bit binary instruction code; Step 3.
3. Divide all switches in the temporary array OrderList into even-numbered and odd-numbered arrays and store them in EvenList and OddList arrays respectively. Sort the numbers in the two arrays in "even descending, odd ascending" order. Step 3.
4. According to the arrangement principle of the switch topology in the substation, even-numbered outgoing switches are arranged in descending order on the left side of the bus tie switch, and odd-numbered switches are arranged in ascending order on the right side of the bus tie switch. At this point, the address code of the substation where the outgoing switch is located is extracted. Query the database to find the location information of the No. 1 incoming switch in the substation where the outgoing switch is located, and use it as the reference coordinate; Step 3.
5. Combining the index of each switch number in the EvenList and OddList arrays, the switch width, the height of the incoming switch, the width of the bus tie switch, and the arrangement principle of the switch topology in the substation, calculate the position information of each outgoing switch relative to the reference coordinates, and update the position information of all outgoing switches in the database in real time.
8. The automatic power grid topology drawing method according to claim 1, characterized in that, In step 5, the processing flow of the automatic obstacle avoidance algorithm is as follows: Step 5.
1. Identification of conflict areas and conflict detection; First, all substations in the power grid topology are located in a grid, with each substation considered as an independent topological unit, and its grid coordinates defined as follows: ; For the substation level, This represents the column number of the substation. Iterate through the grid coordinates of all substations Set the grid coordinates as The substation and its horizontally adjacent substation Composition of substation Perform conflict detection; First, the coordinates are retrieved. The substation stores an array of odd-numbered switch numbers. The outgoing switch number with the largest subscript in the array is used to find its x-coordinate from the database, based on the retrieved outgoing switch number and the address code of the substation where the outgoing switch is located. , coordinates The x-coordinate of the rightmost switch in the substation; The substation address code is based on the substation's grid coordinates. Found in the substation information table; Meanwhile, the search coordinates are The outgoing switch number with the smallest array index in the EvenList array storing even-numbered switch numbers of the substation is retrieved. Based on the retrieved outgoing switch number and the address code of the substation where the outgoing switch is located, its x-coordinate is found in the database. , coordinates The x-coordinate of the leftmost switch in the substation; Calculate the actual distance between two adjacent substations in a substation centering system. ; ; according to The numerical value is used to determine the conflict type. The mathematical description of the judgment logic is as follows: ; in For connected conflict threshold, To determine the overlap and conflict threshold, To set a reasonable spacing threshold; Step 5.
2. Substation topology location optimization; For different conflict types, the coordinates are calculated as follows: The overall moving distance of the substation By adjusting the coordinates to The coordinates of the No. 1 incoming line switch of the substation are determined and an automatic layout algorithm is triggered to achieve overall substation position adjustment. Overall movement distance of the substation The specific calculation process is as follows: ; when When the substation topology shifts to the right, This indicates that the entire substation topology has shifted to the left; Based on the grid coordinates of the substation The substation address code is retrieved from the substation information table, and then the coordinates are retrieved from the substation switch information table based on the substation address code. Original coordinates of substation No. 1 incoming switch ; Calculate the coordinates as New coordinates of substation No. 1 incoming switch after adjustment The mathematical expression is: ; Change the new coordinates of the No. 1 incoming line switch Update to the database; Simultaneously, the automatic layout algorithm is triggered, and the coordinates are automatically updated based on the new coordinates of the #1 incoming line switch. The coordinates of all switches, connecting lines, and text labels within the substation are determined, and finally, the adjacent areas of each pair of horizontally adjacent substations are iteratively optimized based on an automatic avoidance algorithm to ensure the visibility of the power grid topology.
9. The automatic power grid topology drawing method according to claim 1, characterized in that, The graphical model is based on the power grid topology drawing mode identifier output by the binary instruction model. and drawing trigger signals To establish standardized rules for representing switch graphics; The graphical model, based on the power grid topology model to be drawn according to the binary instructions, queries the database for basic switch information through an automatic drawing algorithm to determine the rendering information, including switch type, display style, text label, and location information; The location model is based on the power grid topology drawing mode converted from binary instruction model parsing. It uses an automatic drawing algorithm to query the database for all switch location information, connection line location information, and text label location information to be drawn, and determines the location information of all switches, connection lines, and text labels in the power grid topology diagram to be drawn.
10. An automatic power grid topology mapping system, comprising a TCP server and a TCP client, wherein the TCP server and the TCP client exchange data based on TCP Socket local network communication, characterized in that, The TCP client is configured with a Python visual input module; The C# auto-drawing module is stored on the TCP server; the Python visualization input module sends binary command codes and transmits them to the TCP server via the TCP Socket local network. On the TCP server, when the C# automatic drawing module is executed by the processor, it is used to draw the power grid topology diagram according to the steps of the power grid topology automatic drawing method as described in any one of claims 1 to 9 above.