private void addNextStateAndCalculateCycles() {
    int stateToBeAdded = EOF_STATE;
    if (Flow.HAS_MORE_STATE == stateFlow) {
      if (nextState == NO_NEXT_STATE) {
        LOG.error(
            "StateMachineProcedure pid={} not set next state, but return HAS_MORE_STATE. It is likely that there is some problem with the code. Please check the code. This procedure is about to be terminated: {}",
            getProcId(),
            this);
        stateFlow = Flow.NO_MORE_STATE;
      } else {
        stateToBeAdded = nextState;
      }
    }
    if (Flow.NO_MORE_STATE == stateFlow) {
      if (nextState != NO_NEXT_STATE) {
        LOG.warn(
            "StateMachineProcedure pid={} set next state to {}, but return NO_MORE_STATE",
            getProcId(),
            nextState);
      }
    }
    if (getStateId(getCurrentState()) == stateToBeAdded) {
      cycles++;
    } else {
      cycles = 0;
    }
    states.add(stateToBeAdded);
    nextState = NO_NEXT_STATE;
  }
Add a child procedure to execute.

@param childProcedure the child procedure
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/StateMachineProcedure.java