///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2000-2021 Ericsson Telecom AB
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
///////////////////////////////////////////////////////////////////////////////
/* state machine of the MC */

digraph state_mach_mc {
  // states
  node [fontsize=20];
  // start state (invisible)
  START [style=invis]
  // durable states
  node [shape=box,style="filled,rounded",fillcolor=lightgray];
  INACTIVE;
  LISTENING;
  LISTENING_CONFIGURED;
  HC_CONNECTED;
  ACTIVE;
  READY;
  EXECUTING_CONTROL;
  EXECUTING_TESTCASE;
  PAUSED;
  // transient states
  node[shape=box,style=rounded];
  SHUTDOWN;
  CONFIGURING;
  CREATING_MTC;
  TERMINATING_MTC;
  TERMINATING_TESTCASE;
  // edges
  edge [fontsize=14];
  START -> INACTIVE [arrowtail=odot];

  INACTIVE -> LISTENING [label="start_session()/\nlisten()"];
  {LISTENING; LISTENING_CONFIGURED} -> INACTIVE [label="shutdown_session()/\nclose()"];
  {HC_CONNECTED; ACTIVE} -> SHUTDOWN [label="shutdown_session()/\nEXIT_HC"];
  LISTENING -> HC_CONNECTED [label="VERSION/\n-"];
  HC_CONNECTED -> HC_CONNECTED [label="VERSION/\n-"];
  SHUTDOWN -> INACTIVE [label="all_hc_down()/\n-"];
  {HC_CONNECTED; ACTIVE} -> CONFIGURING [label="configure()/\nCONFIGURE"];
  {LISTENING; LISTENING_CONFIGURED} -> LISTENING_CONFIGURED [label="configure()/\n-"];
  LISTENING_CONFIGURED -> CONFIGURING [label="VERSION/\nCONFIGURE"];
  CONFIGURING -> CONFIGURING [label="VERSION/\n-"];
  CONFIGURING -> ACTIVE [label="all_hc_configured()/\n-"];
  ACTIVE -> CONFIGURING [label="VERSION/\nCONFIGURE"];
  CONFIGURING -> HC_CONNECTED [label="CONFIGURE_NAK/\nerror"];
  ACTIVE -> CREATING_MTC [label="create_mtc()/\nCREATE_MTC"];
  CREATING_MTC -> ACTIVE [label="CREATE_NAK/\nerror"];
  CREATING_MTC -> READY [label="MTC_CREATED/\n-"];
  READY -> TERMINATING_MTC [label="exit_mtc()/\nEXIT_MTC"];
  TERMINATING_MTC -> ACTIVE [label="MTC_connection_terminates/\n-"];
  READY -> EXECUTING_CONTROL [label="execute_control()/\nEXECUTE_CONTROL"];
  READY -> EXECUTING_CONTROL [label="execute_testcase()/\nEXECUTE_TESTCASE"];
  EXECUTING_CONTROL -> READY [label="MTC_READY/\n-"];
  EXECUTING_CONTROL -> EXECUTING_TESTCASE [label="TESTCASE_STARTED/\n-"];
  EXECUTING_TESTCASE -> TERMINATING_TESTCASE [label="TESTCASE_FINISHED/\nSTOP"];
  TERMINATING_TESTCASE -> EXECUTING_CONTROL [label="all_PTCs_terminated/\nPTC_VERDICT"];
  TERMINATING_TESTCASE -> PAUSED [label="all_PTCs_terminated/\nPTC_VERDICT"];
  PAUSED -> EXECUTING_CONTROL [label="continue_testcase()/\nCONTINUE"];

  // error handling edges
  // commented out, to get a clearer picture :)
  /*
  {HC_CONNECTED; CONFIGURING; ACTIVE} -> LISTENING_CONFIGURED [label="all_hc_down()/\nerror"];
  */
}
