Design of logic conguration platform for large power grid security and stability simulation based on object-oriented

In response to the multi-state simulation business process requirements of large power grids in actual engineering, this paper designs a set of logic conguration platform for large power grid security and stability simulation. In order to improve the application adaptability of the existing conguration software, rstly, the overall architecture and visual operation interface design of the large power grid security and stability simulation logic conguration platform were proposed. Secondly, the key technology of realization of generalized large-scale power grid simulation logic conguration platform was discussed in depth from the aspects of logic compilation and engine implementation. Based on the conguration platform, the innovative application of the intelligent large-scale grid operation arrangement system is realized. System development replaces the engineering customization mode of conventional manual software coding with visual logic conguration mode, which greatly improves the engineering adaptability of multi-state large power grid simulation business requirements.


Introduction
Con guration software is a special software for data acquisition and process monitoring in the eld of industrial control. It provides users with a good development interface in a exible and diverse con guration mode. Its pre-set software modules can realize real-time collection of eld device data and can monitor the equipment in real time. Due to its outstanding advantages such as cross-platform, open technology, demand customization, and diversi ed operating platform [1], it has become more and more widely used in various industries and elds.
First of all, the con guration software is divided into two parts from the function and use stage: the system con guration environment and the system operation environment. All con guration processes of control scheme designed by automation engineer must be completed in the system con guration environment. Various software modules provided by the system and user-expanded functions are used to con gure and model the various resources of the industrial control system to form a realistic Human Machine interface (HMI) for engineering applications [2][3].
The basic characteristics of general con guration software include the following three aspects [4]: (1) Continuity and scalability Application programs developed based on con guration software, when the external software and hardware environment of the system changes or user needs change, there is no need to make more complex modi cations, and software upgrades and secondary development can be carried out easily and simply, and maintenance is more convenient.
(2) Encapsulation For the convenience of users, the con guration software packs the functions that can be operated in different categories. Users do not need a programmer's background, as long as they master basic computer programming techniques. All the functions required by a complex engineering system can be easily developed.
(3) Versatility According to the actual situation of the project, each designer can complete a project including data processing, business processing, network interaction and other functions by using the underlying tools provided by the general con guration software.
Secondly, there are two major types of application modes for con guration software. One is humanmachine application, which obtains monitoring and operating data of the eld controller through the network, and combines other components to complete speci c functions (such as reports, historical records, etc.). The other is process control, based on the real-time controller, it realizes the control function of embedded systems, that is, logical con guration [5].
At present, the general con guration software widely used in various elds at home and abroad includes foreign Intouch, iFix, Win CC, LabVIWE and domestic MCGS, FameVIEW, Kingview and Force Control. With the advancement of intelligent technology and the continuous development of industry, the demand for con guration software has been improved. It has also been determined that con guration software will develop from the simple con guration monitoring function in the past to a higher and broader level [6].
The speci c features of some mainstream software are as follows: iFIX is developed from the FIX con guration software. It can seamlessly integrate all the components of Intellution Dynamics to realize real-time monitoring of the dynamic production process of complex application systems and large-scale process control systems. However, it is not widely used in China due to its high price [7]. The Win CC of German Siemens also provides a very complete development platform, which once occupied a large market share for a period of time, but its structure is relatively complicated and di cult to be mastered. It usually requires relevant professional training to be familiar with the application of Win CC con guration software [8]. Kingview (Kingview) was developed by Beijing Yakong Technology Development Co., Ltd., and it is also the earliest self-developed con guration software in China, and has a large in uence in the country, but the network function of Kingview is weak and not suitable to be used in large-scale industrial monitoring systems [9].Force Control is a con guration software of Beijing Sanwei Force Control Technology Co., Ltd. It is simple to use, convenient to develop, and has strong compatibility. It can be integrated with most third-party software and hardware systems, and can realize network communication, which has a strong network communication function [10].
Thirdly, in the eld of traditional industrial automation control, ABB, Siemens and some domestic manufacturers have carried out research work on industrial automation control equipment with modular con guration design, and the relevant technologies are now very mature. Typical representatives are ABB, Siemens, etc. The programmable logic control equipment (PLC) [11]. of the iconic enterprise in the traditional industrial automation control eld adopts the concept of modular con guration design in software design and hardware design. The hardware can be arbitrarily combined added, removed, pluged and used according to the actual needs of industrial control. Software functions can also be used through ladder diagram language (LD), instruction list language (IL), function block diagram language (FBD), sequential function owchart language (SFC) and structured text language (ST) for programming and con guration. This method has been universally recognized and accepted in the eld of industrial automation control, but there is a big gap between the actual application requirements of the system and the distribution automation in the aspects of its application scenarios, actual functional requirements, external input/output interface requirements and others [12]. Especially in power system applications, ABB, Siemens and domestic related equipment manufacturers have also implemented many applications in substation automation equipment, but currently they are all based on the programmable control of protection functions, and the protection logic is implemented through a programmable language. Due to the usage scenarios, in most cases a single device only completes the measurement and control of a single line, and the type and number of external input/output interfaces are relatively xed. Therefore, the hardware is still designed with a chassis-type plug-in board structure. And the structure does not adopt the modular con guration design, that is, the traditional soft PLC form [13]. The structure is still designed with a chassis-type plug-in board structure, and the software uses a logic programming language to realize functional con guration and user selfprogramming. Due to its application environment of power automation system is special, now some application scenarios require a single device to meet the measurement and control of more than 16 lines, and the types and numbers of external interfaces vary greatly according to the actual use scenarios of the project site. Therefore, higher requirements are put forward in terms of exible expansion of hardware modules and exible con guration of functions for the power automation terminal equipment. However, there are very few researches on the application and research of hardware equipment modularization and con guration design in the eld of power automation at home and abroad.
At present, the modular design and application of power con guration software has become a frontier hot issue in ensuring the operation and maintenance safety of smart large-scale grid automation systems. Based on the data acquisition and monitoring system as the core, other advanced application functions of the power system, such as EMS, power market, advanced application functions (power consumption forecasting, state estimation, power ow calculation, etc.) are further expand. The modular power con guration software generally includes three major modules: data acquisition module (I/O module), database management module, man-machine interface module, etc. This paper designs and develops a set of logic con guration software system for the safety and stability simulation of large power grids, replaces the complete code development model with a visual logic con guration method, separates data processing, algorithm development, and simulation business logic design, and achieves multiplethe rapid development and application of generalized power grid simulation business requirements. The application of the large power grid simulation logic con guration platform can give full play to the strengths of power grid analysts, meet the engineering needs of multi-state large power grid simulation business, avoid duplication of labor, and reduce the di culty of application.
2. Design Of The Logic Con guration Platform For The Safety And Stability Simulation Of Large Power Grids 2.1 Con guration platform structure design In the eld of power systems, the logic con guration method is applied in relay protection. In the microprocessor-based relay protection device, different protected equipment uses different algorithms and processing logics, and sets the pressure plate (function switching) and xed values according to the speci c operating environment, and performs fault identi cation and tripping operations. The status is diverse. For example, in the over-current protection software, when the line power supply mode or the installation position of the protection device is different, the software ow is different; when the protection model is dual power supply or with power load, the software ow will become more complicated. Although the software process is diverse, because the ltering, value determination, delay and exit operation used in the overcurrent protection software are the same software modules [14], the overcurrent protection can be constructed in the way of logic diagrams, and the same modules can be reused. The way of logical con guration adapts to different application scenarios.
Similar to the above-mentioned relay protection application scenarios, the large power grid simulation process also has the following characteristics: according to the different entry points of large power grid simulation analysis, the simulation process shows polymorphism (diversity), but the basic units used at the bottom layer are the same, so the basic simulation module can be reused, and various themes of the security and stability of the large power grid can be simulated by the logic con guration method. The concept and design of the large power grid simulation logic con guration platform has not been reported at home and abroad. This paper designs and develops a set of logic con guration system applied to the safety and stability simulation of large power grids, changes the original complete code development model by visual logic con guration, and separates algorithm research, software writing, and power grid analysis logic con guration, etc., which can fully Give full play to the expertise of developers, avoid duplication of labor, reduce the di culty of testing, and improve the rapid adaptability of scenario-based large power grid simulation applications.
The large power grid simulation logic con guration platform is a logic con guration platform for resource con guration and scene description for large power grid security and stability simulation. It needs to con gure algorithm function modules, task logic con guration, communication information and manmachine display. Combined with networked software, the supporting environment realizes the overall con guration of simulation tasks and speci c goals for large power grids.
The core part of the con guration platform is the con guration system, which includes con guration tools, compilers, scheduling engines that perform con guration logic functions, communication interfaces, etc, for software and hardware resource con guration and logical con guration operations.
This large power grid simulation logic con guration platform generates the task group code from the con guration logic, and the dispatch engine recognizes the task group code and completes the calculation.
The rst is to carry out modular packaging of the simulation unit, reconstruct the existing simulation software to generate con guration components, and use automatic testing and error injection testing methods to ensure the credibility of the reconstruction work; The second is to design object-oriented con guration data storage, to construct objects for steady-state, electromechanical transient, electromagnetic transient, and mid-and long-term dynamic model data, and to enhance the exibility of data selection with object-oriented analyzability; The third is to perform logic functions on the PC to strengthen the testability of logic con guration development and engineering applications. The con guration system performs con guration and logic con guration tool maintenance, I/O and other hardware information con guration on the PC side, realizes the simulation calculation unit, xed value and other software parameter con guration, and the component library is formed by the power grid components (models, parameters) participating in the con guration, carries out visual logic con guration.
After completing the con guration function, the con guration information data is stored in Xxx_prj.db through the con guration project management module, and the compiler is called to generate a resource code le. The code le contains software and hardware resource con guration information and e cient con guration logic codes. The con guration system engine reads the logic code in the code le generated by the compiler, and executes the logic execution interface by the scheduled interrupt or high-priority timed task scheduling logic. The data and software parameters are read through the resource manager, and the algorithm is executed in the logical code order function and logic. After the logic processor is executed, it outputs the operation data and logic execution state, operates the peripherals according to the logic execution state, and the internal communication management module uploads the operation data and logic results to the MASTER to form HMI information and communicate with the system outside of the device.

Logical con guration platform interface
The simulation logic of the large power grid is con gured in the way of logic diagrams, which can realize logical con guration such as AND, OR, and NOT. The data part can also carry out mathematical operations such as addition and subtraction, as well as complex function con guration and parameter transmission.
Power grid simulation logic con guration operation interface, including logic control unit library as shown in the upper left picture (Module), driving events are shown in the lower left picture (Event), Instantiate a symbol into a logical object in the current page by dragging and dropping from the logical control unit library, Data transmission is realized through connection between objects. When the logical unit is selected, the corresponding attribute con guration can also be performed in the attribute window. The main window is the ow chart of con guration design.

Overall simulation function implementation
After completing the software and hardware resource con guration and logic con guration through the con guration tool, the compiler is called to generate the coding le, which contains the software and hardware resource con guration information and e cient con guration logic code.
The supporting software running in the con guration platform mainly includes con guration logic code parser, event monitoring program, scheduling service program, interrupt service program, communication service program and logic engine.
According to the logical coding sequence, the scheduling service program performs simulation calculation functions, logical operations, data transmission, data statistics, result display and other functions, logically processes the output data and status, and can also upload the internal communication management module to MASTER, to form SOCKET information and communicate with the external system of the machine.

Logic Diagram Compilation And Engine Implementation
The large power grid simulation con guration platform introduces the object-oriented design idea into the development of large power grid scenario simulation analysis software. Algorithm module calls and logic con guration are performed on the terminal through graphics, and the large power grid simulation process is realized by the way of visual logic con guration. Then the logic con guration information is converted into logic codes and running parameters that can be quickly identi ed by the platform environment through the compiler. Finally, it is scheduled and run by the scheduling unit engine program built into the con guration platform to realize the software function of the con guration.
Among them, the compiler analyzes the logic diagram les and performs correct and e cient logic calculations, generates continuous coding les according to certain rules, schedule algorithm modules in order, and correctly transmits parameters; the engine reads data and con guration information by parsing the encoding le, The driving algorithm module is scheduled according to the coding logic, and the corresponding operation is performed according to the logical running result.

logic diagrams Compilation
The large power grid simulation con guration platform uses the concept of components (classes) to design application function modules, which makes the power grid simulation module have good encapsulation, reusability and combination. The component is an object-oriented encapsulation that completes speci c application functions. and its instantiated objects (logic graph nodes) perform algorithms and other operations according to the con guration parameters and input datas, and the output data is the input of the node connected to it; the application function is encapsulated according to the concept of components with clear structure and clear objects, which is the basis of visual programming.
Logical con guration is the process of instantiating components, which is stored by object-oriented method. In the compilation work, the stored con guration logic data is encoded according to certain rules, and the coding le is formed by combining the resource de nition; the engine reads the coding le and invokes the component methods (functions) of each node according to the coding rules, so that the function of the power network simulation software with logical con guration can be executed correctly.

Component design and instantiation
The applied basic calculation module of the large power grid simulation con guration platform is encapsulated in the form of components. Component is the basic unit for function division and code reuse, which is equivalent to the "class" of object-oriented programming, which helps to improve the reusability, readability and maintainability of the code. Each component completes a speci c function, with clear input and output and parameter de nitions, relevant initialization functions and timed execution functions (scheduled according to the logical con guration order), and memory parameters can also be set.
The component is equivalent to an object-oriented class, and its instance in the logical con guration view is called a node; when components have been added to the catalog, and multiple instance nodes can be generated through con guration. The input of different nodes is the node connected in the graphical con guration Output, event or data le input.
For example, in the gure below, "AND logical AND", "PFNT", "BATSWNT", and "DECISION" are examples of component classes; the input of the "AND logical AND" node includes 4 conditions, the rst one which is the trigger event, The second to the fourth are three necessary input les, which are **.BSE, **.SWI, **.FLT. When the above four conditions are met at the same time, the con guration platform will drive the calculation and execution of the BATSWNT instance module. one of the inputs of the second "AND logic AND" module is the output of "BATPFNT" (Instability.scr). When Instability.scr is valid, the con guration platform will drive the DECISION instance module to calculate and execute, and nally output Strategy.res result.
The input les and event numbers get the corresponding resources or xed values through attribute con guration.

Node parameter and variable management
Logic con guration is the instantiation of components, and each node is an instance object of the component, so different parameter spaces need to be allocated at compilation time. The generation of node parameters is a key to compiling. Forming a completely independent parameter space for each node is a common method of instantiating objects; However, when this method runs logically, it needs to insert coding, rst copy the node input parameters to the corresponding memory unit of the node, and then call the node logic operation method (function), resulting in memory consumption, at the same time, the increase of logic coding also reduces the execution e ciency.
For this reason, the node parameters are divided into input and output parts for distribution, that is, the node only allocates output parameter space, and its input space uses the output space of the connected node through the con gured connection relationship. the input parameters allocate their own space and assign initial values only in the case of no connection. This method can reduce the allocation of node input space, and does not need special parameter copy coding, which solves the problem of space e ciency of conventional object-oriented allocation method.
In the compilation, a variable management module is designed to manage the application and memory allocation of variable uniformly. The data management of this module can be realized by using the database. The generation location is "page ID_node ID_parameter ID". When the initial value is not set, it defaults to 0. According to the uni ed naming rules, the variable symbol table is output, and combined with the generated position information, the parameters of the running node can be directly located and obtained, which is convenient for the implementation of auxiliary tools such as debuggers. The variable representation is shown in Table 1 as follows :

Logical coding
Using the object-oriented method to record the con guration logic in units of nodes, and the logic diagram information is stored according to the page. This storage method is convenient for the compiler to use the object-oriented method for con guration logic analysis. After the con guration logic is compiled, the coding le is output. Which includes the execution order of the logic unit, the functions and parameters corresponding to the logic node, the parameter relationship between the nodes, as well as the logic task con guration, memory allocation, input and output mapping, etc. By reading the coding le, the con guration platform engine allocates memory according to the con guration information and starts the task to execute logic coding to realize the function of con guration logic re ection.

Engine initialization
The large power grid simulation con guration platform is divided into two parts: the scheduling service program and the application function module. Which includes event monitoring, interrupt management, task scheduling, logic execution engine and communication service; the application function module is the corresponding execution function of the components participating in the con guration.
After the design and initialization of the logic diagram is completed, the scheduling service program nishes loading the coding le, and the resource manager opens up the corresponding data and event mapping space according to the con guration in the encoding le. The input resource is read and mapped through the interrupt service program or task. The logic execution engine has been used to analysis and execute the corresponding logic codes, According to the coding order, the application function module is called to realize the simulation con guration logic function; after the logic con guration is completed, the communication service program sends the generated report information to the man-machine module for display operation.
The initialization process of the logic con guration platform engine is designed as follows: load the coding le, check the validity of the coding le, access the software and hardware resource parameters through the resource manager, and set the data mapping space for logic use; then read the variable con guration information, and allocate the variable space and initialize; nally, according to the logic linked list generated by the task, the hardware and software environment for logic execution are completed, the engine initialization process is shown in gure 4 below.
The generation of the power network simulation logic list of the logic con guration platform is the key to the correct execution of the engine. A single page of the logic con guration generally realizes complete simulation business functions such as power grid short-circuit current decision analysis, power grid static security decision analysis, power grid transient security decision-making analysis, the logic of different pages are arranged in the order of the design tree; this part constructs a logical linked list according to the task information of each page during initialization: Among them, pCon g points to the con guration information of this page in the encoding le; pageID, taskID, pEncode cache the page ID, task ID and logical encoding address in the con guration information to speed up logic scheduling; isExec is the real-time status of task scheduling, and curSamplepoint caches the simulation data when the logic execution of this page enters; pNext points to the next page information, which ends when the task is empty.

Logical Processor
According to the task number parameter, the logic processor rst reads the grid simulation data and maps it to the logic running cache, reads the rst page information (tPageInfo), and calls the corresponding function according to its logic coding to execute the logic and algorithm. When the coded function is _ When ENC_END_ completes the logic processing of this page (the function code is g_FB_FUNC array subscript, If the code is outside the range of the array, an exception is triggered, ll in the exception information and end the logic execution. After completing the logic of this page, access the next page information through pNext and follow the same process; when pNext is empty, all logic execution of this task have been completed, the output data is written into the corresponding drive queue according to the mapping information through the resource manager, and the coding execution is ended and the correct state is returned.
The logic processor executes logic coding according to the tasks, which is the core of the engine. The following is the logical processor work ow:

Engine encapsulation
The logic execution engine of the large power grid simulation logic con guration platform initializes and generates the logic linked list of each task by reading the coding le, and the task scheduling execution completes the con guration function.
The logic execution engine is an independent and complete software module. and the engine implemented in C language has the ability of cross-platform compilation and migration. For the perspective of maintainability, this article encapsulates the engine independently, providing initialization, task scheduling and con guration parameter access interface for initialization, interrupt and other related processing procedures; related projects encapsulate the logic processor, resource manager and internal communication management to form the kernel Engine. which partially isolates the engine from the visual design of the con guration platform and avoid their interdependence.

Cases And Tests Of Large Power Grid Simulation Logic
Con guration Platform 4.1 Intelligent large power grid operation mode arrangement system con guration implementation The formulation of the power grid operation mode plays a vital role in ensuring the safe and economic operation of the entire power grid. The power grid has gradually developed into a multi-source access, high-density, multi-load type network system, facing the impact of more and more variable factors. Faced with the computing needs to carry out more scenario operation methods, the scheduling process will become extremely cumbersome and complicated, and the amount of information that staff need to process will be greatly increased.
This section establishes the change rules that serve the grid arrangement and security veri cation of the operation mode, automatically processes the complicated power grid information, generates a more comprehensive mass operation mode, and arranges the automatic work ow based on the intelligent mode, and achieves it through the optimization indicators and high-performance parallel computing. The intelligent operation mode arrangement decision is realized. The application of the logic con guration platform can greatly reduce the development workload and computational burden, improve the comprehensiveness and effectiveness of the mode arrangement, enhance the calculation and analysis methods of the power grid, and improve the level of safe operation of power grid.
The business process of the large power grid operation mode arrangement system is shown in the following gure: After the above system logic is decomposed, it includes the following sub-processes: 1. Extract the generator branch, load branch, and transformer branch based on the basic operation mode data respectively; 2. Calculate short-circuit current and generate short-circuit results based on basic operation mode data, transient model data and control data; 3. Based on the short-circuit result, extract the cascaded branch of the busbar with the short-circuit current exceeding the standard, and generate the neighborhood branch; 4. Based on generator branch, load branch, transformer branch, neighborhood branch and out-of-limit condition, the branch combination operation is performed to generate the combined branch.
5. Based on the combination branch and combination conditions, the execution mode combination is used to generate mode set 1; . Based on mode set 1, perform island detection and generate mode set 2; 7. Based on the method set 2, transient model data, control data, and out-of-limit conditions, batch short-circuit current calculation is performed to generate short-circuit results; . Based on the short-circuit results, execute the effect evaluation and generate mode set 3; 9. Based on the basic operating mode data, perform xed value extraction and generate xed value results; 10. Based on the basic operating mode data, perform breaking extraction and generate breaking results; 15. The method set 5 is used as the output result and sent to the display computer-node through the network.
The logical con guration relationship of the above steps is shown in the gure 7:

System data analysis for the operation mode arrangement of large power grids
The test environment is shown in Table 2: The following is a statistical analysis of several key links datas in the operation mode arrangement system of the large power grid.

a) Basic data statistics
Select the BJ power grid full connection mode to arrange the mode. the data size of the method is shown in Table 3 as below: The test datas show that the logic con guration system can meet the whole ow calculation requirements of method arrangement.

Application characteristics of con guration software
When constructing the large power grid operation mode arrangement system based-on the large power grid simulation con guration platform, the algorithm modules such as short circuit calculation and power ow calculation are relatively independent and have strong reusability. The reusable function modules and new algorithm modules that embedded in the platform are shown in Table 7 and 8 below: The rst thing for large power grid simulation analysis product is the analysis of existing software functions and the reconstruction of algorithms and function blocks, Starting from the realization of a simple input and output function and proceeding iteratively. The steps of using this platform for simulation analysis product development are: (1) Analyze the target function, clarify the reusable function modules and the algorithm components that need to be added; (2) Con gure the hardware resources of the simulation system; con gure the software parameters used by the simulation module; (3) Use the visual con guration tool to create a logic page according to the simulation function, and use the mouse to drag and drop the components for forming a node instance; realize the logic and parameter relationship between the nodes through the connection, and use the property box to set the corresponding parameters; (4) Invoke the compiler to generate the code le, and double-click to locate and handle when there is a compilation exception information; (5) Logic debugging of each link; (6) Carry on the system test of the actual product; monitor the real-time operation of each logic through the network connection tool; (7) Man-machine modules and tools display and con gure the corresponding data through encoding the resource information in the le.
The large power grid operation mode arrangement system con guration development process fully embodies the advantages of module independence and reuse: After clarifying the logical relationship, logic con guration based-on a large number of basic modules does not need to code and the problems caused by manual recoding are avoided. The debugging function of the environment greatly facilitates the simulation analysis developers and greatly improves the progress of product development.

Conclusion
Firstly, this paper puts forward the structure design and interface design method of large power grid con guration simulation platform; secondly, it introduces the compilation process of the logic diagram in detail from the aspects of component instantiation, node parameter variable management, logic coding methods and so on; at the same time, it is described in detail in the power grid simulation con guration platform. In the con guration platform, how to load coding le to generate the logic linked list, analyze the logic coding execution element function, and the independent encapsulation of logic execution engine to complete the realization of the con guration logic. Finally, taking the intelligent large-scale grid operation mode to arrange the system con guration implementation as an example, the con guration realization process, data testing situation and general implementation steps are introduced in detail.
Practice has proved that the object-oriented software design idea is introduced into the software development of large power grid simulation analysis platform by visual method, and the power grid simulation function is designed with the concept of components (classes), so that the power grid simulation software with visual logic con guration mode has good encapsulation, reusability, It greatly improves the engineering adaptability of polymorphic large power grid simulation business requirements.
Declarations Figure 1 The con guration system composition Figure 2 the large power grid simulation logic con guration interface   The large power grid operation mode arrangement system business process