# A Method for Modeling and Testing Near-Real-Time System Scenarios
## 4 Modeling the System Scenarios with Finite-State Machines
### System Dynamics Modeling with UML State Machines  
The section presents a method of describing system dynamics using UML state machines containing orthogonal states. It is based on a simple example of controlling UAVs. A key element of the section is the claim that any orthogonal state model can be converted into a state machine without orthogonal states. The test coverage can be determined by the model created in this way. The article describes an example of designing test cases for a flight mode change scenario and a more complicated scenario of transferring the UAV under the control of another pilot working in another GCS. An example scenario is shown in Figure 3.  
This is a simplified version of the scenario that does not include handling dangerous situations that may occur during a UAV flight. The described model makes several assumptions simplifying its form, which increases its readability but does not significantly reduce the practical significance of the model. Infinite paths are not allowed, which in the case of UAVs has its justification: it is impossible to fly without distance limits. The length of a flight is always determined by the parameters that can be measured. The presented model is conservative, i.e., in the event of a communication failure, the mission is assumed to be interrupted. This is not the rule for advanced systems. The orthogonal states can be transformed into a nonorthogonal state. Suppose the orthogonal state has \(n\) regions and the \(i\)th region has \(m_{i}\) states. Each new state is a tuple \((s_{1},\ldots,s_{i},\ldots,s_{n})\), where \(s_{i}\) is a state in the \(i\)th region. There exists a transition from \((s_{1},\ldots,s_{i|1},\ldots,s_{n})\) to \((s_{1},\ldots,s_{i|2},\ldots,s_{n})\) if there is a transition from \(s_{i|1}\) to \(s_{i|2}\) in the \(i\)th region. Figure 4 shows the example of orthogonal to nonorthogonal state transformation. In the presented model, platform states are described by the states (U(WP), P(CO)) and (U(LO), P(CO)). State (U(LA), P(AL)) indicates the landing mode of the platform that remains under the supervision of the pilot. The (U(PA), P(PA)) state means the emergency parachute landing mode. Interesting transitions in the model shown in Figure 4 are the transitions to the (U(UR), P(RF)) state, which are generated based on time transitions in the UAV mission block of the orthogonal state shown in Figure 3. In practice, the system designer must guarantee that in the event of loss of communication, the system will go to the state (U(PA), P(RF)), which is only signaled by the pilot as no communication. The description of methods for restoring communication, searching for a lost UAV, and controlling autonomous flight is beyond the scope of the article. Figure 4: A state machine without orthogonal states after transforming the state machine model shown in Figure 3. The connected states of the base machine and the allowable transitions between states are shown. Figure 3: An example state machine diagram for an unmanned system. Two orthogonal state machines are shown: the pilot and the UAV. In the UML language, the exchange of messages between orthogonal machines is carried out using defined paradigms containing initiating events and changing parameters. The output event of the pilot machine generates an action consisting of sending a message to the machine describing the operation of the UAV. A state machine that does not contain orthogonal states is a model on which one can precisely define test scenarios of the system in the form of the so-called path coverage for the state machine. Given a directed graph \(G=(V,E)\), a path coverage is a set of directed paths such that every vertex \(v\in V\) belongs to at least one path. Note that a path coverage may include paths of length 0 (a single vertex) ([PERSON] and [PERSON] [31]). A path coverage may also refer to a vertex-disjoint path coverage, i.e., a set of paths such that every vertex \(v\in V\) belongs to exactly one path. Vertex-disjoint path coverage is sometimes used in system testing.