# Design and Application of a Distribution Network Phasor Data Concentrator
## 3 DPDC Design  
### Software Architecture  
In the software design of DPDC, to improve the high concurrency and asynchronous processing capability of the software, we adopt an event-driven mechanism and structured program design, run multiple threads to realize multi-tasking processing and use callbacks to complete asynchronous non-blocking operations. Figure 2 is a schematic diagram of the proposed DPDC considering multi-communication mode, which shows some major software functional modules inside the DPDC. The figure simplifies the \(\upmu\)MPMUs, the communication network, and the main station. 1 Indicates that the \(\upmu\)MPMU communicates directly with the DPDC over a twisted pair. 2 Indicates that the \(\upmu\)MPMU communicates with the DPDC over the power line carrier. 3 Indicates that the \(\upmu\)MPMU communicates with the DPDC over the wireless network. 4 Indicates that the \(\upmu\)MPMU communicates with the DPDC via EPON. 5 Indicates that the \(\upmu\)MPMU communicates with the DPDC over possibly other communication networks. The communication network from the DPDC to the main station is simplified to a dotted line. The green port on the DPDC boundary indicates the network port. The DPDC has more network ports. First, the communication is initialized in the main function of the DPDC, including establishing a client to complete the connection with the \(\upmu\)MPMU and establishing a server to listen for the connection from the main station. The open-source iPDC [23] establishes a thread for each connected PMU and the main station and has only one connection to each PMU or main station, and all types of data are transmitted over one connection. The difference is that DPDC only creates two child threads in addition to the main thread. In the main thread, DPDC establishes two TCP connections for each \(\upmu\)MPMU and each main station, which serve as data pipes and command pipes. One sub-thread is responsible for establishing a TCP connection as a file pipe with each \(\upmu\)MPMU, and the other is responsible for establishing a file pipe with the main station. This can avoid the impact of file transfer on real-time \begin{table}
\begin{tabular}{c c c} \hline \hline
**No.** & **Situation Faced** & **DPDC Extended Functions and Features** \\ \hline
1 & Accessing more \(\upmu\)MPMUs & DPDC should have strong access capabilities and keep costs low \\ \hline
2 & \(\upmu\)MPMUs adopt different communication methods & The DPDC should be able to aggregate data frames that have the same timestamp but arrive at the DPDC with a large time difference; when some devices are disconnected, the normally arriving data is not discarded \\ \hline
3 & \(\upmu\)MPMUs expand distribution terminal functions & In the communication protocol, power distribution automation functions such as remote control, telemetry, and fault diagnosis should be added. \\ \hline
4 & Processing of large amounts of data of different kinds & DPDC should improve data processing capabilities and keep data delay low. \\ \hline \hline \end{tabular}
\end{table} 
Table 2: DPDC extended functions and features. data transmission, save the resources consumed by creating a large number of threads, reduce the time overhead of thread switching, and reduce the internal delay of DPDC. We use libuv to establish a TCP connection because libuv is a multi-platform support library that focuses on asynchronous I/O. It uses the high-concurrency asynchronous model provided by the operating system. In Linux, epoll supports full-featured event loops [24]. Due to libuv's event-loop and callback mechanisms, callback functions can be invoked when the event occurs. When the connection is established, the uv_read_start function defined by libuv will automatically read the data from the stream and trigger the callback function. Since the DPDC and each \(\upmu\)MPMU have dedicated pipes, the data received from a pipe is the corresponding \(\upmu\)MPMU data.