Modeling and Analysis of Network Control System Based on Hierarchical Coloured Petri Net and Markov Chain

+is paper investigates a modified modeling of networked control systems (NCSs) with programmable logic controller (PLC). First, the controller-to-actuator and sensor-to-controller network-induced delays are investigated by a modeling tactics based on hierarchical coloured petri net (HCPN) in a structure-conserving way. Comparing with the recent result, the signal transmission delay is set in a random interval instead of a fixed mode; moreover, the data packet drop out and disorder are also taken into consideration. Second, delays captured form CPN tools are analyzed with a strategy based on Baum–Welch algorithm and statistics science. Besides, time delays are modeled as a Markov chain and the transition probabilities is calculated using the consequent from the previous operation. Finally, a comparison verification illustrates the equivalence property between proposed models.


Introduction
As a kind of control system [1][2][3][4][5][6], NCSs have motivated a lot of research studies in the control field during recent years [7][8][9][10] by many advantages it shares; for example, reduced weight, high flexibility, simple installation and maintenance, and low cost. Because of those practical characteristics, more and more efforts have been devoted to these systems [11][12][13]. Admired for past achievements, NCSs have been found in widespread applications such as feedback control systems [14,15], stabilization of linear systems [16], control of nonlinear systems [17], and adaptive tracking control of nonlinear multiagent systems [18][19][20]. Compared with traditional point-to-point hardwiring system, typical NCSs is a young generation of control architectures which has a feedback control structure consisting with the controller, sensor, and actuator through network communication. e insertion of this performance condition, with a finite bandwidth, brings serial challenging and undesirable issues on account of data packet loss, scheduling, and latency in the process of communication signal's transmission to remote analog input/output unit. Affected by these cases, the communication channel, which takes the place of traditional signal transmission technologies, brings hard-to-solve problems in the stability analysis and controller synthesis because of transmission time delays. As a result, this issue received increasing interests in this field [21][22][23]. Traditional time-delay analysis usually assumes that the time delay is constant, time-varying or obeys some random distribution, and rarely analyzes it from the perspective of system operation mechanism. Modeling from the perspective of operation mechanism can effectively show various state changes that may occur in the system and the relationship between changes. is prompts us to adopt HCPN to carry out structural reservation modeling and then analyze the time-delay characteristics.
In 1992, Petri nets were introduced by Petri [24] firstly as a net-theoretic approach to implement a particular purpose.
e relationships between departments could be represented by a net, and it is a good approximation to imitate the appearance and character of asynchronous and concurrent operation in discrete event systems. Petri nets is a kind of mathematical structures which is a bipartite-directed graph consisting of two kinds of compositions; one is drawn as a circle which is called Place, and another drown as a rectangles named Transition. ese two nodes combine with each other with arcs which are drawn as arrows. Coloured Petri net (CPN) [25][26][27][28], in which groups of objects is thus distinguished by colour, inherits all the advantages of classical Petri net. e wide practical application distributes on the direction of distributed control systems [29] and domains environments [30]. Recently, a novel of theoretical results has been done on the application of Petri nets for NCSs [31,32]. Regarding the execution of the NCSs practical operational fundamental principle, the CPN has been chosen to build a formalism model [31]. With the rapid development of scientific technologies, the process in largescale systems is more and more complicated, which makes it hard to solve problems in modeling. erefore, to solve the problem of state explosion during formal verification, HCPN is invented [33][34][35] which is a new type of Petri net for creating large-scale and complex systems. Its main purpose is to summarize the system model with simple network model and to expand and fill it with substitution change. is method is not only beneficial to the excessive number of reservoirs, transitions, and arcs in the model but also beneficial to avoid the explosion of system state space and simplify the analysis of the model. In [31], a mapping from the established hypothetical delays in Ethernet of NCSs to entities of a CPN model was defined, and the simulation analysis of network induced delays was tested and verified in a simple way. Following a similar way, in [32], a two-step approach was included in the estimation of delays in the modeling of NCSs. However, the Ethernet model in the proposed model was studied in a hypothesis, in which time delays were not interrelating with network bandwidth-limited bit limit and packet dropouts. Further investigation and analysis is in [36,37] and the references therein.
e primary contributions of this paper are as follows: (i) First, considering the potential cause for the deteriorating performance or instability on NCSs, this paper sets network band delay in an interval instead of the definite transmission delay in [32] to make the model more realistic. In this method, it is supported by the HCPN model to simulate some challenging issues on account of network information propagation. (ii) Second, the CPN model in [31,32] is not considered data packet latency and dropout in the Ethernet CPN model of NCSs. Focusing on those challenges in network transmission, this paper has some alterations on the base of the model in [32]; close to the reality, data packets' dropout and packet out-oforder are taken into consideration in the proposed model of data transmission on the network. (iii) ird, the exploration and research of random time delays existing in the sensor-to-controller and controller-to-actuator in discrete time networked control systems are acquiescence with random Markovian delays in recent literature [38][39][40].
However, it is not clear if this theoretical acquiescence can be put into practice. is paper makes a certification of equivalence between time delays and Markov model [41].
is paper is organized as follows. Section 2 is the conceptual framework of Petri net. Section 3 is the HCPN model of NCSs-PLC. Section 4 analyzes the time delay extracted from the HCPN model. Section 5 is the equivalence analysis of the time delay of both the Markov model and the HCPN model.

Basic Conception
Definition 1. A ordinary non-HCPN can be defined as a nine elements' tuple [42], satisfying the requirements below: (i) Σ is called colour set which is a finite set describing nonempty types. (ii) P is Place representing a ellipse which interprets a passive component with discrete status. (iii) T is Transition establishing with a rectangle which explains an active component; tokens can consume, produce, and change the carrying information in Transitions. (iv) A is arcs which connects Places and Transitions in the model. It can be represented by arrows, and it is a finite set which meets the expectations with ∀P i ∈ P; T i ∈ T: (v) N is defined as a map into arcs. It is defined from A into P i × T i ∪ T i × P i which has two elements, the first element means arcs' source and the second element means arcs' destination. (vi) C is defined a map in places. It is defined from P i into Σ which means that every token on every P i has a corresponding colour set type. (vii) G is the guard function which is defined a map in transitions. G(T i ) is the type appertain to Σ, and the binding must perform every Boolean expressions. It is can be shown as ∀T i ∈ T [Type (Var (Guard(T)))⊆Σ∧Type(Guard(T i )) � Boolean]. (viii) E is called arc expression which maps every element in A to an expression, and the type of it can be written as C(P i ) MS ; it can be shown as where P i is defined as the place of N i . (ix) I illustrates a map between P i and the type C i It is the initialization function which can be shown as (i) S e is a congregations for nonhierarchical pages in the model, and each page does not have collaborative net elements. It can be shown as (ii) S e N ∈ T is substitution nodes.
(iii) S e A is called page assignment, and every page must not be the subpage of itself; it is satisfied by the following conditions: (iv) PL PN ⊆P is defined as a set of place nodes or transition nodes. (v) POT is a function of port type, and it has four types, in type, out type, in/out type, and general.
(vi) PO A is port assignment. It is binary relations such that (vii) PL FS ∈ P s is a finite set of fusion sets such that ∀fs ∈ PL FS : (ix) PP ∈ S MS is a multiset of the prime page.

e Top
Model. e integrated model can be divided into two levels, one is top level which simulates the relationship between the controller, the sensor, and the actuator with a cursory method, as shown in Figure 1. e other level is the detailed function description of the controller, the sensor, and the actuator. In the proposed top-level model, the sensor and the actuator connect with PLC Remote IO. PLC-CPU sends packets from the controller to PLC Remote IO through Ethernet; then, PLC Remote IO sends acknowledgments from the sensor and the actuator back to PLC-CPU.
ere are three subpages and one top page in the whole model. After some introductions of time delay in PLC-CPU, those pages are explained one by one in detail.

3.2.
e Analysis of the Time Delays in PLC-NCSs. Figure 2 is a representative of traditional NCSs with the PLC controller. e sensor and actuator are connected to digital/ analog I/O section through Ethernet. Before entering or leaving network, data packets will enter into a transmission queue to wait for the scan cycle of I/O. Figure 3 gives detailed instructions of time delays in NCSs with the PLC controller, in which different samples were shown as different length arrows. In the upper part of the whole figure, there are some samples which are received in the sensor with periodic sampling. In the middle part, there are three kinds of axis showing the PLC controller. Before data packets arrive at execute program, it has to wait for the scan cycle so that it can be read into PLC. Both of the reading scan cycle and writing scan cycle in PLC communication are Tc. Another primary scan cycle is Tp which means that only at Tp scan cycles data packets can be captured into PLC-CPU to execute the programme. After a few execution time (τ c ), the communication module sends result data to the actuator node. During the process of the data packets' transmission, two network-induced delays are produced. One is called backward time delay and another is called forward time delay. e execution time delay in the controller is included in Tsc backward time delay which is the time costing in the transmission from the controller to the sensor, and Tca is forward time delay which is from CPU which received the sample to the actuator which received the same sample.  e module of controller is divided into two parts. One is the communication module part, which is used to sending and receiving data with scan cycles, such as left part in Figure 4. e another part is the PLC-CPU model, which simulates functions of CPU reading(input), CPU executing, and CPU writing(output), such as right part in Figure 4.
e Send R transition and the Rec A transition complete data packets' sending and receiving, respectively. PLC R transition, PLC E transition, and PLC W transition complete simulation of reading, executing, and writing in the PLC-CPU. e definition of token elements in the model is shown in Table 1. Figure 5 is the Ethernet model which is the primary part for whole NCSs' system. ere are two modified points contrasting with the model which has been designed by Ghanaim et al. [32]. When the data packets transmit in Ethernet, transmission will be influenced by a lot of uncertainties. In consideration of these cases, the transmission time is set into a random time with an interval time varying rather than a fix data. In the proposed model, time delays of this portion are discrete uniform distributions between 1000 and 2000 when packet data passed from the sensor to the controller or from the controller to the actuator. In addition, in the actual network transmission, the data packets' transmission is unstable because of some uncertain factors, such as packets lost and packets out of order. In this model, packets will be lost in ten percent probability, and this function is realized by fun Ok(s: Ten0, r: Ten1) � (r < � s). Data packets will be retransmitted based on Transmission Control Protocol/Internet Protocol if those transmission mistakes occurred. e mathematic presentation of this model is a tuple:

e Ethernet Model.
By the definition of HCPN, those elements in this tuple can be used to describe the Ethernet model, as shown in Figure 6.
Σ is the Token colour set in Figure 5. P is finite set of places and T is finite set of transitions. A is arc, and C to Store1 means that this arc is from place C to transition Store1. N is the node function. G is guard, for example, (#A, p1) � N, T � Net1, Net2 means that when transition is Net1 or Net2, the guard of transition is (#A, p1) � N; otherwise, transition guards are true. C is the colour definition of Place. Place A, B, C, and D are mean the Packet colour. I(P) is the initialization set if the place is SP1 or SP2, and the initial token is integer nine. E(a) means the arc expression in the Ethernet model, p1, a ∈ [A to Net1, C to Store1 · Store1 to A] means when the arc is from A to Net1, C to Store 1, and Store1 to A, and the arc expression on those arc is p1.

Transmission Delay in Ethernet.
Network transmission is an important element in the analysis of Tsc and Tca. Besides, it also can help to analyze the system state and performance.
Data packets may be lost at a probability such as ten percent in the model of network transmission. With reference to Transmission Control Protocol/Internet Protocol (TCP/IP), data packets would be retransmitted if it is lost in the network transmission. Figure 7 is network transmission latency which is collected in the proposed HCPN model running 5050 steps. From Figure 7, it can be clearly see that, in time delay Tsc and Tca, network transmission time delays are almost greater than 1000 and less than 2000; however, there are still ten percent points out of scope, Figure 7 shows several peak points, for example A, B, and C, which mean that, in this time, data packets are dropped out in network transmission. It will be retransmitted according to TCP/IP so that the value of it becomes very bigger than others. e network transmission latency was the transmission time and the retransmission time and other time spent on extracting data packets.

e Time Delay Tca and Tsc.
ere are three scan cycles which play important roles in the calculation of backward time delay and forward time delay. e first one is periodic scan Tp for CPU program, the second one is periodic IO scan Tc for the communication module, and the last one is the periodic sampling T h for the sensor. ere exists another important data to calculate: network transmission delay. Table 2 is the parameters defined in the NCSs model which can be used to simulate and analyze the efficiency of the difference system with the HCPN model.
In addition, in the communication module, IO periodic scan cycle Tc is a summation of reading time, executing time, and writing time.
e periodic scan Tp for CPU program is set to 17,000 and the periodic sampling Th for the sensor is 1000. When network transmission latency was obtained, such as in Figure 7, Tca and Tsc can be calculated under the rule of scan cycles, as shown in Figure 8. Before the calculation of Tca and Tsc, it is necessary to obtain the network latency, which are produced in network transmission and waiting time for the scan cycle. Contrasting with delays obtained from the HCPN model in [32], it can be clearly see that because of the indeterminacy transmission phenomenon and the random transmission time delay the periodicity of Tca and Tsc is broken.

Verification and Analysis
where A is the state transition probability matrix form one state to another state, which can be written as B is the observation probability matrix which can be written as and π 0 is the initial state probability which can be written as

Markov Model Results.
By the definition of HMM and the Baum Welth algorithm, the algorithm steps are as follows.
Step 1 : for a given observation sequence and HMM model, the probability variables of the hidden state S i are where α t (i) is called forward probability, where and β t (i) is called backward probability, where Step 2 : define the probability between the hidden state S i and the hidden state S j as follows: Step 3 : the formula between δ t (i) and ϕ t (i, j) is   Discrete Dynamics in Nature and Society Step 4 : find the corresponding expected values of the above two variables T−1 t�1 δ t (i) and T−1 t�1 ϕ t (i, j).
Tsc can be divided into two categories: one category is the low delay Tsc low which includes the value Tsc low � [3,4,5,6,7,8,9]. e other category is high delay Tsc high which includes the value Tsc high � [10,11,12,13,14,15,16,17]. e time delay Tsc can be written as Using the data from those two matrices, the stationary distribution of the Markov model λ sc and λ ca can be estimated by those two time delays (Tca and Tsc) with the Matlab statics toolbox. e probability density function(PDF) can be calculated by sample arrays which can be obtained from HCPN consecutive time delay sequence. e PDF is the distribution of the time delay which can be compared with the stationary distribution of the Markov model. Figures 11 and 12 are the stationary distribution of the Hidden Markov Model building above, and every observation probability value is similar to the probability density function of the time-delay sequence. e figures show that the Markov stationary distribution of both the time delay Tsc and the time delay Tca are approximately equivalent to the probability density function of HCPN. It is clearly seen

Conclusion
In this paper, we have investigated a novel HCPN model approach for the network control system with PLC. e modified structure-conserving model has been accomplished to calculate sequences of delays under the control of scan cycles for PLC-CPU. Besides, a series of special phenomenon has been taken into consideration based on the traditional mode, such as data packets drop and data packets out of order. Time delays in network transmission have been calculated to observe the transmission data packet state in Ethernet. Finally, Markov analytical models have been built for analyzing time delays which can be obtained from the forward step mathematically.

Data Availability
e data used to support the findings of this study are included within the article.

Conflicts of Interest
e authors declare that they have no conflicts of interest.