# Design and Application of a Distribution Network Phasor Data Concentrator
## 3 DPDC Design
### Software Architecture
The data structure members have integer haspmu, long integer soc, and fracsec, and array pmusData[ ]. Similarly, pmusData[ ] is a structure array with a length of n + 1. The value is the same as the number of \(\mu\)MPMUs. It is used to store the data frames of the \(\mu\)MPMU. The order of the array elements is the same as that of the \(\mu\)MPMU. The haspmu indicates the number of data frames of the \(\mu\)MPMU that this pdcData array element has stored. When haspmu = n + 1, this buffer is full and the data aggregation is completed. Proceeding to the next step, involved forming the collected data into a standard DPDC data frame, and then sending it to the master station and write the file. The soc and fracsec represent time, and their source can be local time or the \(\mu\)MPMU time-synchronized data frame. Which source to choose depends on whether there is a time-synchronized data frame in this buffer. If an element of pdcData[ ] has not received a time-synchronized data frame when it is about to be sent to the next stage, the DPDC's local time is assigned to it. When the cache is initialized, haspmu, soc, and fracsec are all cleared, and the status word stat of each element of pmusData[ ] is set to 0x8000, indicating that the data is not available and the rest of the data is cleared. The program flow of the data aggregation stage is shown in Figure 4. The problem that will be solved during the data aggregation stage is also the abnormal communication situation that may  
Figure 3: The cache structure of the DPDC. be faced: (i) when the communication connection is normal, some or all of the \(\mu\)MPMUs are out of synchronization and receive their data frames; (ii) some \(\mu\)MPMUs are disconnected from the DPDC and cannot receive their data frames; (iii) some \(\mu\)MPMUs are disconnected, and some \(\mu\)MPMUs with normal communication connections are out of synchronization. In the data aggregation stage, the thread lock mechanism is used to prevent data in the DPDC buffer from being overwritten by other threads. In Figure 4, the data frame of the i-th \(\mu\)MPMU (\(0\leq i\leq n\)) is first acquired, stored in pmusData[i], and then the local time is acquired. According to IEEE C37.118.2-2011 and GB/T 26865.2-2011, in the stat, bit 13 = 0 means data frame time synchronization, so it is judged according to stat whether the data frame time is synchronized. If the data frame time is synchronized, the process flow F1 will be entered, otherwise, the process flow F2 will be entered. (1) The first step of F1 is to find the pdcData[ ] element with the same time as pmusData[i]. If the element is found, it is assumed to be pdcData[j] and proceed to flow F11. Put pmusData[i] into the corresponding pdcData[j].pmusData[i] and increase the value of pdcData[j].haspmu by 1. If the value of pdcData[j].haspmu is equal to n, it indicates that pdcData[j] has already aggregated the data frames of all \(\mu\)MPMUs. Process pdcData[j] means that the data contained in pdcData[j] is composed into a standard format DPDC data frame, and then pdcData[j] is cleared, and these data frames are all written to the file and sent to the U_data_pipe data processing module. Because 50  
Figure 4: Data aggregation program flow. or 100 writes per second affect the life of the hard disk, the write operation does not have the same frequency as the framing. The program uses another large buffer to hold the data to be written and writes at regular intervals. 2. If pdcData[j] is not found, continue to look for elements with zero time. If an element that meets the criteria is found, the process flow F12 is performed, otherwise, the process flow F13 is performed. There may be two cases when the time is 0. The first is that the element has not yet obtained the data frame of the uMPMU, and the second is that the element has not yet obtained the time-synchronized data frame.