///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2000-2025 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 port connections as seen by the MC */

digraph state_mach_conn_mc {
  // states
  node [fontsize=16];
  // start state (invisible)
  START [style=invis];

  // durable states
  node[shape=box,style="filled,rounded"];
  IDLE;
  CONNECTED;

  // transient states
  node[shape=box,style=rounded];
  LISTENING;
  CONNECTING;
  DISCONNECTING;

  // edges
  edge [fontsize=12];
  START -> IDLE [arrowtail=odot];

  // state transitions for connect() operation
  IDLE -> LISTENING [label="CONNECT_REQ/\nCONNECT_LISTEN"];
  IDLE -> CONNECTING [label="CONNECT_REQ/\nCONNECT"];
  LISTENING -> CONNECTING [label="CONNECT_LISTEN_ACK/\nCONNECT"];
  CONNECTING -> CONNECTED [label="CONNECTED/\nCONNECT_ACK"];
  CONNECTED -> CONNECTED [label="CONNECT_REQ/\nCONNECT_ACK"];
  LISTENING -> LISTENING [label="CONNECT_REQ/\n-"];
  CONNECTING -> CONNECTING [label="CONNECT_REQ/\n-"];
  DISCONNECTING -> DISCONNECTING [label="CONNECT_REQ/\nERROR"];

  // state transitions for disconnect() operation
  CONNECTED -> DISCONNECTING [label="DISCONNECT_REQ/\nDISCONNECT"];
  DISCONNECTING -> IDLE [label="DISCONNECTED or\ncomponent terminates/\nDISCONNECT_ACK"];
  IDLE -> IDLE [label="DISCONNECT_REQ/\nDISCONNECT_ACK"];
  LISTENING -> LISTENING [label="DISCONNECT_REQ/\nERROR"];
  CONNECTING -> CONNECTING [label="DISCONNECT_REQ/\nERROR"];
  DISCONNECTING -> DISCONNECTING [label="DISCONNECT_REQ/\n-"];

  // handling of connection-related errors
  edge [fontsize=12,style=dashed];
  LISTENING -> IDLE [label="CONNECT_ERROR or\ncomponent terminates/\nERROR"];
  CONNECTING -> IDLE [label="CONNECT_ERROR or\ncomponent terminates/\n[DISCONNECT,] ERROR"];
  CONNECTED -> IDLE [label="DISCONNECTED or\ncomponent terminates/\n-"];
}
