The large power grid simulation configuration platform introduces the object-oriented design idea into the development of large power grid scenario simulation analysis software. Algorithm module calls and logic configuration are performed on the terminal through graphics, and the large power grid simulation process is realized by the way of visual logic configuration. Then the logic configuration information is converted into logic codes and running parameters that can be quickly identified by the platform environment through the compiler. Finally, it is scheduled and run by the scheduling unit engine program built into the configuration platform to realize the software function of the configuration.
Among them, the compiler analyzes the logic diagram files and performs correct and efficient logic calculations, generates continuous coding files according to certain rules, schedule algorithm modules in order, and correctly transmits parameters; the engine reads data and configuration information by parsing the encoding file, The driving algorithm module is scheduled according to the coding logic, and the corresponding operation is performed according to the logical running result.
3.1 logic diagrams Compilation
The large power grid simulation configuration 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 specific application functions. and its instantiated objects (logic graph nodes) perform algorithms and other operations according to the configuration 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 configuration is the process of instantiating components, which is stored by object-oriented method. In the compilation work, the stored configuration logic data is encoded according to certain rules, and the coding file is formed by combining the resource definition; the engine reads the coding file 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 configuration can be executed correctly.
3.1.1 Component design and instantiation
The applied basic calculation module of the large power grid simulation configuration 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 specific function, with clear input and output and parameter definitions, relevant initialization functions and timed execution functions (scheduled according to the logical configuration order), and memory parameters can also be set.
The component is equivalent to an object-oriented class, and its instance in the logical configuration view is called a node; when components have been added to the catalog, and multiple instance nodes can be generated through configuration. The input of different nodes is the node connected in the graphical configuration Output, event or data file input.
For example, in the figure 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 first one which is the trigger event, The second to the fourth are three necessary input files, which are **.BSE, **.SWI, **.FLT. When the above four conditions are met at the same time, the configuration 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 configuration platform will drive the DECISION instance module to calculate and execute, and finally output Strategy.res result.
The input files and event numbers get the corresponding resources or fixed values through attribute configuration.
3.1.2 Node parameter and variable management
Logic configuration 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, first 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 efficiency.
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 configured 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 efficiency 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 unified 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 :
Table 1 Unified management of variables
Variable symbol
|
Generate location
|
Initial value
|
Data type
|
Variable offset
|
BYTE number
|
U32_0000_4
|
N1.1.1
|
0
|
Uint32
|
0
|
4
|
U32_0004_4
|
N1.2.1
|
0
|
Uint32
|
4
|
4
|
BOOL_0008_1
|
N1.3.1
|
0
|
BOOL
|
8
|
1
|
BOOL_0009_1
|
N1.3.2
|
0
|
BOOL
|
9
|
1
|
F32_0012_4
|
N1.3.3
|
0.0
|
Float32
|
12
|
4
|
3.1.3 Logical coding
Using the object-oriented method to record the configuration 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 configuration logic analysis. After the configuration logic is compiled, the coding file 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 configuration, memory allocation, input and output mapping, etc. By reading the coding file, the configuration platform engine allocates memory according to the configuration information and starts the task to execute logic coding to realize the function of configuration logic reflection.
3.2 Engine Implementation
3.2.1 Engine initialization
The large power grid simulation configuration 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 configuration.
After the design and initialization of the logic diagram is completed, the scheduling service program finishes loading the coding file, and the resource manager opens up the corresponding data and event mapping space according to the configuration in the encoding file. 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 configuration logic function; after the logic configuration 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 configuration platform engine is designed as follows: load the coding file, check the validity of the coding file, access the software and hardware resource parameters through the resource manager, and set the data mapping space for logic use; then read the variable configuration information, and allocate the variable space and initialize; finally, 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 figure 4 below.
The generation of the power network simulation logic list of the logic configuration platform is the key to the correct execution of the engine. A single page of the logic configuration 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, pConfig points to the configuration information of this page in the encoding file; pageID, taskID, pEncode cache the page ID, task ID and logical encoding address in the configuration 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.
3.2.2 Logical Processor
According to the task number parameter, the logic processor first reads the grid simulation data and maps it to the logic running cache, reads the first 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, fill 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 workflow:
3.2.3 Engine encapsulation
The logic execution engine of the large power grid simulation logic configuration platform initializes and generates the logic linked list of each task by reading the coding file, and the task scheduling execution completes the configuration 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 configuration 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 configuration platform and avoid their interdependence.