public void unrelateAcrossR517From(StateMachine_c target, boolean notifyChanges) {
    if (target == null) return;

    if (IsSupertypeStateMachine == null) return; // already unrelated

    if (target != IsSupertypeStateMachine) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R517", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR517To(this);
    }

    if (IsSupertypeStateMachine != null) {

      m_sm_id = IsSupertypeStateMachine.getSm_id();
      IsSupertypeStateMachine = null;
      target.removeRef();
      if (notifyChanges) {
        RelationshipChangeModelDelta change =
            new RelationshipChangeModelDelta(
                Modeleventnotification_c.DELTA_ELEMENT_UNRELATED, this, target, "517", "");
        Ooaofooa.getDefaultInstance().fireModelElementRelationChanged(change);
      }
    }
  }
  public void relateAcrossR517To(StateMachine_c target, boolean notifyChanges) {
    if (target == null) return;

    if (target == IsSupertypeStateMachine) return; // already related

    if (IsSupertypeStateMachine != target) {

      Object oldKey = getInstanceKey();

      if (IsSupertypeStateMachine != null) {

        IsSupertypeStateMachine.clearBackPointerR517To(this);

        if (Boolean.valueOf(System.getenv("PTC_MCC_ENABLED")) == true) { // $NON-NLS-1$
          Ooaofooa.log.println(
              ILogger.CONSISTENCY,
              "InstanceStateMachine_c.relateAcrossR517To(StateMachine_c target)",
              "Relate performed across R517 from Instance State Machine to State Machine without unrelate of prior instance.");
        }
      }

      IsSupertypeStateMachine = target;
      m_sm_id = target.getSm_id();
      updateInstanceKey(oldKey, getInstanceKey());
      target.setBackPointerR517To(this);
      target.addRef();
      if (notifyChanges) {
        RelationshipChangeModelDelta change =
            new RelationshipChangeModelDelta(
                Modeleventnotification_c.DELTA_ELEMENT_RELATED, this, target, "517", "");
        Ooaofooa.getDefaultInstance().fireModelElementRelationChanged(change);
      }
    }
  }
  public boolean Newcreationtransition(
      final java.util.UUID p_From,
      final boolean p_Fromtypeisimportedclass,
      final java.util.UUID p_To,
      final boolean p_Totypeisimportedclass) {
    Ooaofooa.log.println(
        ILogger.OPERATION,
        "Instance State Machine",
        " Operation entered: InstanceStateMachine::Newcreationtransition");
    final ModelRoot modelRoot = getModelRoot();
    StateMachine_c v_sm = StateMachine_c.getOneSM_SMOnR517(this);

    return v_sm.Newcreationtransition(p_From, p_To);
  } // End newCreationTransition
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Instance State Machine.dispose call: ";
    ModelClass_c testR518Inst = ModelClass_c.getOneO_OBJOnR518(this, false);

    if (testR518Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "518 ";
    }
    StateMachine_c testR517Inst1 = StateMachine_c.getOneSM_SMOnR517(this, false);

    if (testR517Inst1 != null) {
      delete_error = true;
      errorMsg = errorMsg + "517 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Instance State Machine", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
 public static InstanceStateMachine_c getOneSM_ISMOnR517(
     StateMachine_c target, ClassQueryInterface_c test) {
   if (target != null) {
     return getOneSM_ISMOnR517(target.getModelRoot(), target, test);
   }
   return null;
 }
  public void Pastestatemachineevent(final java.util.UUID p_Id) {
    Ooaofooa.log.println(
        ILogger.OPERATION,
        "Instance State Machine",
        " Operation entered: InstanceStateMachine::Pastestatemachineevent");
    final ModelRoot modelRoot = getModelRoot();
    StateMachine_c v_sm = StateMachine_c.getOneSM_SMOnR517(this);

    if (v_sm != null) {
      v_sm.Pastestatemachineevent(p_Id);
    } else {
      Throwable t = new Throwable();
      t.fillInStackTrace();
      CorePlugin.logError("Attempted to call an operation on a null instance.", t);
    }
  } // End pasteStateMachineEvent
  public java.util.UUID Getstateid(final int p_Index) {
    Ooaofooa.log.println(
        ILogger.OPERATION,
        "Instance State Machine",
        " Operation entered: InstanceStateMachine::Getstateid");
    final ModelRoot modelRoot = getModelRoot();
    java.util.UUID v_id = Gd_c.Null_unique_id();

    StateMachineState_c[] v_states =
        StateMachineState_c.getManySM_STATEsOnR501(StateMachine_c.getManySM_SMsOnR517(this));

    int v_count = -1;

    StateMachineState_c v_state = null;
    for (int i37214 = 0; i37214 < v_states.length; i37214++) {
      v_state = v_states[i37214];

      if (((v_state != null))) {

        v_count = v_count + 1;
      }

      if ((v_count == p_Index)) {

        return v_state.Get_ooa_id();
      }
    }

    return v_id;
  } // End getStateId
  public void Dispose() {
    Ooaofooa.log.println(
        ILogger.OPERATION,
        "Instance State Machine",
        " Operation entered: InstanceStateMachine::Dispose");
    final ModelRoot modelRoot = getModelRoot();
    StateMachine_c v_sm = StateMachine_c.getOneSM_SMOnR517(this);

    if (v_sm != null) {
      v_sm.Dispose();
    } else {
      Throwable t = new Throwable();
      t.fillInStackTrace();
      CorePlugin.logError("Attempted to call an operation on a null instance.", t);
    }
  } // End dispose
  public int Getstatecount() {
    Ooaofooa.log.println(
        ILogger.OPERATION,
        "Instance State Machine",
        " Operation entered: InstanceStateMachine::Getstatecount");
    final ModelRoot modelRoot = getModelRoot();
    StateMachineState_c[] v_states =
        StateMachineState_c.getManySM_STATEsOnR501(StateMachine_c.getManySM_SMsOnR517(this));

    return (v_states.length);
  } // End getStateCount
  public boolean performFinish() {
    TransactionUtil.TransactionGroup transactionGroup = null;
    ModelRoot modelRoot = v_asyncMessage.getModelRoot();
    try {
      transactionGroup =
          TransactionUtil.startTransactionsOnSelectedModelRoots(
              "Instance Event Formalize"); //$NON-NLS-1$
      Message_c v_message = Message_c.getOneMSG_MOnR1018(v_asyncMessage);

      InteractionParticipant_c v_participant =
          InteractionParticipant_c.getOneSQ_POnR1007(v_message);

      Lifespan_c v_ls = Lifespan_c.getOneSQ_LSOnR930(v_participant);

      ClassInstanceParticipant_c v_cip =
          ClassInstanceParticipant_c.getOneSQ_CIPOnR930(
              InteractionParticipant_c.getOneSQ_POnR940(v_ls));

      ModelClass_c v_cipclass =
          (ModelClass_c)
              modelRoot.getInstanceList(ModelClass_c.class).getGlobal(null, Gd_c.Null_unique_id());

      if (((v_cip != null))) {

        v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip);

      } else {

        v_cip =
            ClassInstanceParticipant_c.getOneSQ_CIPOnR930(
                InteractionParticipant_c.getOneSQ_POnR1007(v_message));

        if (((v_cip != null))) {

          Communication_c v_communication =
              Communication_c.getOneCOMM_COMMOnR1126(
                  ParticipantInCommunication_c.getOneCOMM_PICOnR1126(
                      InteractionParticipant_c.getOneSQ_POnR930(v_cip)));

          if (((v_communication != null))) {

            v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip);
          }
        }
      }

      if (((v_cipclass != null))) {

        StateMachineEvent_c v_evt =
            StateMachineEvent_c.getOneSM_EVTOnR1009(
                EventMessage_c.getOneMSG_EOnR1019(v_asyncMessage));

        java.util.UUID v_existingId = Gd_c.Null_unique_id();

        if (((v_evt != null))) {

          v_existingId = v_evt.getSmevt_id();
        }

        StateMachine_c v_stateMachine =
            StateMachine_c.getOneSM_SMOnR517(InstanceStateMachine_c.getOneSM_ISMOnR518(v_cipclass));

        StateMachine_c[] v_machines =
            StateMachine_c.getManySM_SMsOnR517(
                InstanceStateMachine_c.getManySM_ISMsOnR518(
                    ModelClass_c.getManyO_OBJsOnR8001(
                        PackageableElement_c.getManyPE_PEsOnR8000(
                            Package_c.getManyEP_PKGsOnR1405(
                                SystemModel_c.getManyS_SYSsOnR1405(
                                    Package_c.getManyEP_PKGsOnR8000(
                                        PackageableElement_c.getManyPE_PEsOnR8001(
                                            v_cipclass))))))));

        if (((v_machines.length == 0))) {

          v_machines =
              StateMachine_c.getManySM_SMsOnR517(
                  InstanceStateMachine_c.getManySM_ISMsOnR518(
                      ModelClass_c.getManyO_OBJsOnR2(
                          Subsystem_c.getManyS_SSsOnR1(
                              Domain_c.getManyS_DOMsOnR1(
                                  Subsystem_c.getManyS_SSsOnR2(v_cipclass))))));
        }

        if (((v_Message != null))) {

          if (v_asyncMessage != null) {
            v_asyncMessage.Formalizewithevent(v_Message.getSmevt_id());
          } else {
            Throwable t = new Throwable();
            t.fillInStackTrace();
            CorePlugin.logError("Attempted to call an operation on a null instance.", t);
          }
        }
      }

      // catch all exceptions and cancel the transaction
    } catch (Exception e) {
      if (transactionGroup != null) TransactionUtil.cancelTransactions(transactionGroup, e);
      CorePlugin.logError("Transaction: Instance Event Formalize failed", e); // $NON-NLS-1$
      // return true so that the wizard will
      // close
      return true;
    }
    if (transactionGroup != null) TransactionUtil.endTransactions(transactionGroup);
    if (m_viewer != null) {
      if (m_viewer instanceof StructuredViewer) {
        ((StructuredViewer) m_viewer).refresh(v_asyncMessage);
      } else {
        m_viewer.refresh();
      }
    }
    return true;
  }
  public boolean checkConsistency() {
    Ooaofooa.log.println(
        ILogger.OPERATION,
        "Instance State Machine", //$NON-NLS-1$
        " Operation entered: Instance State Machine::checkConsistency"); //$NON-NLS-1$
    if (Boolean.valueOf(System.getenv("PTC_MCC_ENABLED")) == false) { // $NON-NLS-1$
      return true;
    }
    ModelRoot modelRoot = getModelRoot();
    boolean retval = true;
    class InstanceStateMachine_c_test39208_c implements ClassQueryInterface_c {
      InstanceStateMachine_c_test39208_c(java.util.UUID p39209) {
        m_p39209 = p39209;
      }

      private java.util.UUID m_p39209;

      public boolean evaluate(Object candidate) {
        InstanceStateMachine_c selected = (InstanceStateMachine_c) candidate;
        boolean retval = false;
        retval = (selected.getSm_id().equals(m_p39209));
        return retval;
      }
    }

    InstanceStateMachine_c[] objs39207 =
        InstanceStateMachine_c.InstanceStateMachineInstances(
            modelRoot, new InstanceStateMachine_c_test39208_c(getSm_id()));

    if (((objs39207.length) == 0)) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(
            ILogger.CONSISTENCY,
            "Instance State Machine", //$NON-NLS-1$
            "Consistency: Object: Instance State Machine: Cardinality of an identifier is zero. " //$NON-NLS-1$
                + "Actual Value: "
                + Integer.toString(objs39207.length)); // $NON-NLS-1$
      } else {
        Exception e = new Exception();
        CorePlugin.logError(
            "Consistency: Object: Instance State Machine: Cardinality of an identifier is zero. " //$NON-NLS-1$
                + "Actual Value: " //$NON-NLS-1$
                + Integer.toString(objs39207.length),
            e);
      }
      retval = false;
    }

    if (((objs39207.length) > 1)) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(
            ILogger.CONSISTENCY,
            "Instance State Machine", //$NON-NLS-1$
            "Consistency: Object: Instance State Machine: Cardinality of an identifier is greater than 1. " //$NON-NLS-1$
                + "Actual Value: " //$NON-NLS-1$
                + Integer.toString(objs39207.length)
                + " SM_ID: "
                + "Not Printable"); //$NON-NLS-1$
      } else {
        Exception e = new Exception();
        CorePlugin.logError(
            "Consistency: Object: Instance State Machine: Cardinality of an identifier is greater than 1. " //$NON-NLS-1$
                + "Actual Value: " //$NON-NLS-1$
                + Integer.toString(objs39207.length)
                + " SM_ID: "
                + "Not Printable",
            e); //$NON-NLS-1$
      }
      retval = false;
    }

    // Instance State Machine is a subtype in association: rel.Numb = 517
    // The supertype class is: State Machine
    class StateMachine_c_test39213_c implements ClassQueryInterface_c {
      StateMachine_c_test39213_c(java.util.UUID p39214) {
        m_p39214 = p39214;
      }

      private java.util.UUID m_p39214;

      public boolean evaluate(Object candidate) {
        StateMachine_c selected = (StateMachine_c) candidate;
        boolean retval = false;
        retval = (selected.getSm_id().equals(m_p39214));
        return retval;
      }
    }

    StateMachine_c[] objs39212 =
        StateMachine_c.StateMachineInstances(modelRoot, new StateMachine_c_test39213_c(getSm_id()));

    if (((objs39212.length) != 1)) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(
            ILogger.CONSISTENCY,
            "Instance State Machine", //$NON-NLS-1$
            "Consistency: Object: Instance State Machine: Association: 517: Cardinality of a supertype is not equal to 1. " //$NON-NLS-1$
                + "Actual Value: "
                + Integer.toString(objs39212.length)); // $NON-NLS-1$
      } else {
        Exception e = new Exception();
        CorePlugin.logError(
            "Consistency: Object: Instance State Machine: Association: 517: Cardinality of a supertype is not equal to 1. " //$NON-NLS-1$
                + "Actual Value: " //$NON-NLS-1$
                + Integer.toString(objs39212.length),
            e);
      }
      retval = false;
    }

    // Instance State Machine is a referring class in association: rel.Numb = 518
    // The participating class is: Model Class
    class ModelClass_c_test39216_c implements ClassQueryInterface_c {
      ModelClass_c_test39216_c(java.util.UUID p39217) {
        m_p39217 = p39217;
      }

      private java.util.UUID m_p39217;

      public boolean evaluate(Object candidate) {
        ModelClass_c selected = (ModelClass_c) candidate;
        boolean retval = false;
        retval = (selected.getObj_id().equals(m_p39217));
        return retval;
      }
    }

    ModelClass_c[] objs39215 =
        ModelClass_c.ModelClassInstances(modelRoot, new ModelClass_c_test39216_c(getObj_id()));

    // The participant is unconditional
    // The multiplicity of the participant is one
    if (((objs39215.length) != 1)) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(
            ILogger.CONSISTENCY,
            "Instance State Machine", //$NON-NLS-1$
            "Consistency: Object: Instance State Machine: Association: 518: Cardinality of a participant is not equal to 1. " //$NON-NLS-1$
                + "Actual Value: " //$NON-NLS-1$
                + Integer.toString(objs39215.length)
                + " Obj_ID: "
                + "Not Printable"); //$NON-NLS-1$
      } else {
        Exception e = new Exception();
        CorePlugin.logError(
            "Consistency: Object: Instance State Machine: Association: 518: Cardinality of a participant is not equal to 1. " //$NON-NLS-1$
                + "Actual Value: " //$NON-NLS-1$
                + Integer.toString(objs39215.length)
                + " Obj_ID: "
                + "Not Printable",
            e); //$NON-NLS-1$
      }
      retval = false;
    }

    return retval;
  }
 public java.util.UUID getSm_id() {
   if (IsSupertypeStateMachine != null) {
     return IsSupertypeStateMachine.getSm_id();
   }
   return IdAssigner.NULL_UUID;
 }
 // declare attribute accessors
 public long getSm_idLongBased() {
   if (IsSupertypeStateMachine != null) {
     return IsSupertypeStateMachine.getSm_idLongBased();
   }
   return 0;
 }
  public void batchRelate(
      ModelRoot modelRoot, boolean relateProxies, boolean notifyChanges, boolean searchAllRoots) {
    InstanceList instances = null;
    ModelRoot baseRoot = modelRoot;

    if (ModelClass == null) {
      // R518
      ModelClass_c relInst39205 =
          (ModelClass_c) baseRoot.getInstanceList(ModelClass_c.class).get(new Object[] {m_obj_id});
      // if there was no local element, check for any global elements
      // failing that proceed to check other model roots
      if (relInst39205 == null) {
        relInst39205 =
            (ModelClass_c)
                Ooaofooa.getDefaultInstance()
                    .getInstanceList(ModelClass_c.class)
                    .get(new Object[] {m_obj_id});
      }
      if (relInst39205 == null && searchAllRoots && !baseRoot.isCompareRoot()) {
        Ooaofooa[] roots = Ooaofooa.getInstances();
        for (int i = 0; i < roots.length; i++) {
          if (roots[i].isCompareRoot()) {
            // never use elements from any compare root
            continue;
          }
          relInst39205 =
              (ModelClass_c)
                  roots[i].getInstanceList(ModelClass_c.class).get(new Object[] {m_obj_id});
          if (relInst39205 != null) break;
        }
      }
      // synchronized
      if (relInst39205 != null) {
        if (relateProxies || !isProxy() || (inSameComponent(this, relInst39205) && !isProxy())) {
          relInst39205.relateAcrossR518To(this, notifyChanges);
        }
      }
    }

    // R517
    StateMachine_c relInst39206 =
        (StateMachine_c) baseRoot.getInstanceList(StateMachine_c.class).get(new Object[] {m_sm_id});
    // if there was no local element, check for any global elements
    // failing that proceed to check other model roots
    if (relInst39206 == null) {
      relInst39206 =
          (StateMachine_c)
              Ooaofooa.getDefaultInstance()
                  .getInstanceList(StateMachine_c.class)
                  .get(new Object[] {m_sm_id});
    }
    if (relInst39206 == null && searchAllRoots && !baseRoot.isCompareRoot()) {
      Ooaofooa[] roots = Ooaofooa.getInstances();
      for (int i = 0; i < roots.length; i++) {
        if (roots[i].isCompareRoot()) {
          // never use elements from any compare root
          continue;
        }
        relInst39206 =
            (StateMachine_c)
                roots[i].getInstanceList(StateMachine_c.class).get(new Object[] {m_sm_id});
        if (relInst39206 != null) break;
      }
    }
    // synchronized
    if (relInst39206 != null) {
      if (relateProxies || !isProxy() || (inSameComponent(this, relInst39206) && !isProxy())) {
        relInst39206.relateAcrossR517To(this, notifyChanges);
      }
    }
  }
 public static InstanceStateMachine_c getOneSM_ISMOnR517(
     StateMachine_c target, boolean loadComponent) {
   return getOneSM_ISMOnR517(target.getModelRoot(), target, null, loadComponent);
 }
 public boolean evaluate(Object candidate) {
   StateMachine_c selected = (StateMachine_c) candidate;
   boolean retval = false;
   retval = (selected.getSm_id().equals(m_p39214));
   return retval;
 }