Research and Application of OOP Technology in Waveform Analysis Systems
2026-04-06 07:58:32··#1
0 Introduction With the rapid development of integrated circuits, high-speed A/D sampling, DSP, and computer technology, various waveform testing instruments used for recording and analyzing power systems have also developed rapidly. These waveform testing instruments adopt a hardware structure of instrument + computer, making them portable and suitable for both indoor testing and outdoor debugging, analysis, and problem finding, thus their application range is becoming increasingly wide. The software analysis system配套 (matching) these instruments plays a crucial role in their promotion and application. OOP (Object-Oriented Programming) technology, following structured programming, represents a qualitative leap in programming methodologies. It encapsulates and abstracts data and methods around objects, possessing inheritance, polymorphism, and reusability, facilitating system maintenance and functional expansion, and greatly improving software development efficiency and shortening the software development cycle. Developing waveform analysis systems using OOP technology not only allows for the reuse of code resources from the DOS platform but also makes system upgrades and adaptation to multiple platforms possible. The following section uses the development of a background analysis system for the DF1024 portable waveform recorder as an example to specifically analyze the application of OOP technology in waveform analysis systems. To ensure the waveform analysis system is compatible with the Windows (3.x~98) series window platforms, Visual C++ was chosen as the development platform. Microsoft's Visual C++ not only implements object-oriented programming but also effectively utilizes its code, offering a powerful visual working platform, rich programming tools, and the inherent continuity and reliability of the language itself. Based on the concept of building applications using the MFC (Multi-Functional Class Library), it constructs four types of application outlines for programmers: application classes, main framework classes, document classes, and view classes. These four types of applications work together to complete the various functions of the software. [b]1. Composition and Functions of the Waveform Analysis System[/b] The DF1024 waveform analysis system is shown in Figure 1. It consists of approximately six main modules: a communication module, a real-time monitoring module, a human-computer interaction module, a file processing module, a data offline display and printing module, and an analysis function module. The system establishes several classes to complete the functions of these six modules. The modules are closely interconnected; by creating objects of the corresponding classes, data display, exchange, and retrieval are achieved. [img=241,228]http://zszl.cepee.com/cepee_kjlw_pic/files/wx/zgdl/zgdl99/zgdl9909/image/t45-1.gif[/img] Figure 1 Waveform Analysis System Structure 1.1 Front-end and Back-end Communication Front-end and back-end communication is the only way to obtain waveform data. The quality and speed of communication directly affect the performance of the entire system. There are many ways to communicate. In addition to using networks, USB, and infrared devices, serial ports and parallel ports are mostly used in the control and measurement fields. Serial port communication requires fewer connections and is easier to program and control than parallel port, but the data transmission speed is slower and it is not convenient for transmitting large amounts of data. There are basically three implementation modes for serial/parallel port communication programming: (1) Using communication controls. This method is used in many visual programming development platforms, such as VB, VFP, Delphi, etc.; (2) Using communication drivers and a set of Windows API functions. This is used in many Windows applications and is a common method for communication programming. However, it requires programmers to be familiar with the Windows message-driven mechanism, communication API functions and data transmission process, making programming complex and inconvenient to use communication code in the DOS environment; (3) Directly read and write to the port. Although this method goes against the principle that "Windows operating system prohibits applications from directly interacting with hardware", it is simple to program and can make the most of the communication code in the DOS environment, so it is also a way to shorten the development cycle and effectively utilize program resources. DF1024 is a high-speed sampling system (up to 50 kHz sampling rate) with a 2M data buffer and a large amount of data transmitted each time, so the system adopts parallel port communication mode. In terms of programming, in order to make full use of the existing DOS communication functions, the method of directly reading and writing to the port is adopted. The original DF1024 DOS communication functions include multiple functions: parallel port initialization (Resetdf(), Inspectdf()), sampling judgment (Trgsample()), sending data (InputData()), receiving data (OutputData()). They are all managed by the main() function call. To achieve objectification, a class CCom derived from CObject is created, and the functions under DOS are used as member functions of the CCom class. A communication control and scheduling member function (CCom::Commuctrl()) is also created to manage the entire communication process. This modification encapsulates the entire communication operation within a single class. In application, simply creating an object of CCom allows for easy communication with the DF1024 instrument, such as initialization, waveform recording, and real-time monitoring. 1.2 Data File Processing The sampling and setting data obtained from the DF1024 and the human-machine interface are recorded, managed, and stored by the system using a document class (CDfwDocument). The content recorded in the document class can be output as file data in a specified format as needed. For example, to facilitate the sharing and exchange of waveform recording files, the system can output data files in the internationally recognized Comtrade format. Because the DF1024 waveform recording data consists of analog signals (voltage, current) and switching signal data, the system establishes two classes: Analog Data Class (CDfwAnalog) and Switching Data Class (CDfwDigital) to manage analog and switching signals. Both are derived from CObject, enabling data serialization for easy access. In addition to the signal name, range, position, unit, display attributes, and signal attributes, each class includes an integer pointer to the waveform data. Furthermore, within the document class, the system also establishes a Calculation Data Class (CVirtual), which records the results of channel analysis calculations. The document class structure is shown in Figure 2. Member variables consist of setting information, communication objects, intermediate data pointers, calculation channel pointers, and object pointers for the analog data class and the switching data class. Information obtained through human-computer interaction is stored in the setting member variables. Based on the setting information and the waveform recording information obtained from the DF1024 using the communication object, the system selectively allocates the necessary memory space for the analog object and switching object pointers. Once the waveform recording operation is performed, meaningful values are assigned to these objects. [img=115,291]http://zszl.cepee.com/cepee_kjlw_pic/files/wx/zgdl/zgdl99/zgdl9909/image/t45-2.gif[/img] Figure 2. Document Class Composition. The document class has many member functions, including various file operation functions, communication object calling functions, display operation functions, data analysis functions, channel assignment functions, memory space allocation functions, etc. 1.3 Multi-mode Data Display and Printing. The display of data is the focus of the entire waveform analysis system. The system is built with MFC multi-document multi-window, but displays in a single-document style, which not only ensures the concise display of graphs and curves, but also ensures that they are displayed in the largest area within the window. The data obtained from waveform recording is stored in the corresponding member variables of the document, and the display plot is shown in Figure 3. In addition to the Windows framework elements, main menu, and toolbar, the rest of the diagram consists of five parts: name area, waveform area, curve information, switch transition information, and status bar. Their functions are as follows: [img=475,306]http://zszl.cepee.com/cepee_kjlw_pic/files/wx/zgdl/zgdl99/zgdl9909/image/t46-1.gif[/img] Figure 3 Waveform Analysis Main Interface (1) Name area: Displays the channel name, the center line marker of each waveform curve, and the marker of the currently active curve. In the name area, the channel name, waveform color, vertical scaling ratio, and vertical position can be modified arbitrarily. (2) Waveform area: Graphically represents the sampled data and is the main screen area of the waveform analysis system. Through this area, users can directly observe the change process of a waveform at different times and compare the differences between different waveforms at the same time. (3) Curve information: Numerically represents the sampled analog data and is the auxiliary screen area of the waveform analysis system. The area consists of 3 columns of data tables. The channel name in the first column is consistent with the channel name in the name area. The calculated data in the second column includes the instantaneous value, effective value, average value, phase angle and frequency of the channel. The data values of each channel are displayed independently. Each row in the curve information table can not only display a certain type of data such as instantaneous value at the same time, but also display different types of calculated data separately. For example, one channel displays the instantaneous value, while another channel displays the effective value. When editing the curve, the curve information can be turned on/off at any time. (4) Switch jump information, which displays the distance from the relative time scale origin, the jump attributes (up/down) of each switch quantity and the jump time. (5) Status bar, which mainly displays 3 times: the absolute time of the trigger moment, the time difference between the time scale and the trigger moment, and the time difference between the time scale and the relative time scale origin. In view of the characteristics of waveform data, the system adopts a unique multi-page display management method. The system has 8 built-in display pages, which is equivalent to 8 pages of office paper. One curve can be placed on 8 pages at the same time, and one page can also accommodate multiple waveforms at the same time. Different pages can be switched to observe each other. This waveform management method allows for the pagination and categorized analysis of all channel curves by topic. Data obtained from timed or manual sampling in the background is displayed in two ways: spreadsheets and curve plotting within a specified area of a window. Displayed data is not directly stored in document-type data members but instead directly performs I/O operations with the file. All displayed curves and data tables can be output in any way using any printer supported by Windows. Users can preview the waveform and set various print styles before printing. 1.4 Several Analysis Functions The analysis function is the core of the waveform analysis system for power applications, possessing at least two functions: time series analysis and quantity analysis. The system's time series analysis consists of three basic time elements: trigger absolute time, relative time scale origin, and time scale. The default trigger absolute time corresponds to the computer time at the waveform recording trigger moment. Dragging the time scale displays the time difference between the time scale and the relative time scale zero point, as well as the trigger absolute time, on the status bar. Additionally, the system uses a switch transition information window to centrally display the switch quantity transition attributes and precise transition time. When performing quantitative analysis, frequency tracking technology is used, and the FFT algorithm is appropriately improved. In addition to observing the instantaneous value, effective value, average value, phase angle, and frequency of the waveform at a certain moment through the curve information table, users can also perform the following analyses and calculations: (1) Perform harmonic effective value, frequency, absolute value, negative number, Nth power, average value, and logarithmic operations on a single channel; (2) Perform addition, subtraction, multiplication, and division between two channels or between a channel and a constant, calculate percentages, and calculate vector angle differences; (3) Calculate the positive sequence, negative sequence, and zero sequence components of the three-phase AC signal; (4) Calculate the fundamental/harmonic active, reactive, apparent power and power factor, active and reactive power ratios of single-phase, two-phase, and three-phase signals. The analysis function is completed within the document class. The analysis member function calculates various specified calculation formulas, and the calculation results are assigned to the calculation data pointer and displayed in the waveform area and curve table. 1.5 Implementation of Shortcut Functions Smart right-click shortcuts are implemented in commonly used modules such as the name area, waveform area, waveform recording settings, and curve information. These smart right-clicks utilize a typical Windows message mapping structure. First, several message items are defined using resource tools. Then, the mapping function for each message item is declared in the class definition header file. Next, in the implementation file, a smart menu pops up from the right-click function, and a corresponding response function is written based on the user's selected menu item. In the response function, the user-selected menu item is retrieved from the current message. The shortcut menu in the waveform area (see Figure 3) centralizes convenient waveform operations: full curve expansion, full curve compression, fixed-ratio curve expansion, fault point search, etc. For single-channel fault point search, the system provides threshold value over-limit and ratio over-limit search methods; for multi-channel fault point search, the system provides current over-limit, negative-sequence and zero-sequence current over-limit, and zero-sequence current over-limit search methods. In addition, to broaden the application field of the system, the system also has the following functions: (1) automated waveform recording management function to realize dynamic monitoring and recording of abnormal operating status of the system and equipment; (2) digital meter function to measure multi-channel current and voltage values and switch status in real time; (3) vector diagram function to observe the changes in the size of multi-channel vectors in real time; (4) automatic backup function to prevent data loss due to accidental accidents during the waveform recording process; (5) waveform truncation function to reduce data storage capacity. [b]2 Conclusion[/b] Since the waveform analysis system adopts OOP technology, it not only effectively utilizes the code resources of DOS and shortens the development cycle, but also the communication class and data class established have good reusability, which facilitates the development of new modules and program upgrades. Applications over nearly three years have demonstrated that, in addition to the excellent hardware performance of the DF1024 itself, the software system is easy to operate, powerful in function, and user-friendly in human-computer interaction. It can adapt well to various application scenarios in power systems, such as testing of relay protection, circuit breakers, generator sets, TV characteristics, TA characteristics, etc., dynamic model tests, commissioning of power transmission and transformation projects, and monitoring of abnormal operating conditions of power systems and equipment.