public String convertModel(String path, String modelName) {
    if (matlab.isDisconnected()) {
      matlab.connect();
    }

    MontiArcStringBuilder builder = new MontiArcStringBuilder();

    if (matlab.isConnected()) {
      matlab.loadModel(path, modelName);

      builder.addPackage(MontiArcStringBuilder.EXPORT_PACKAGE);

      builder.startCreateComponent(modelName);

      convertPorts(modelName, builder);

      convertModelReferences(modelName, builder);

      convertSubSystems(modelName, builder);

      convertSignals(modelName, builder);

      builder.endCreateComponent();
    } else {
      // TODO handle
    }

    return builder.getConvertedModel();
  }
  public String convertDeltaModel(String path, String deltaModelName) {
    if (matlab.isDisconnected()) {
      matlab.connect();
    }
    DeltaMontiArcModelBuilder builder = new DeltaMontiArcModelBuilder();
    matlab.loadModel(path, deltaModelName);

    // create delta head
    String aoc = getApplicationOrderCondition(deltaModelName);
    builder.startCreateDelta(deltaModelName, aoc);

    // create modify blocks at top lvl
    convertDeltaSubSystems(deltaModelName, builder);
    builder.closeBody();

    return builder.getConvertedModel();
  }
  protected List<SimulinkSignal> getSignals(String rootName) {
    List<SimulinkSignal> signals = new ArrayList<SimulinkSignal>();

    // find all (top-level) connectors in the model or block
    Object[] foundConnectors =
        matlab.returningFeval(
            1, find_system, rootName, SearchDepth, 1, FindAll, "on", LineType, SimulinkType.signal);

    if ((foundConnectors != null) && (foundConnectors.length == 1)) {
      // handles (ids) of the connectors
      double[] connHandles = (double[]) foundConnectors[0];

      for (int i = 0; i < connHandles.length; i++) {
        double connHandle = connHandles[i];
        double srcConnHandle = connHandle;

        double[] lineChildren =
            ((double[]) (matlab.returningFeval(1, get_param, connHandle, "LineChildren"))[0]);

        // Signals with children are not handled (directly). This is the case when a
        // block has more than one outgoing signal.
        if (lineChildren.length > 0) {
          continue;
        }

        double lineParent =
            ((double[]) (matlab.returningFeval(1, get_param, connHandle, "LineParent"))[0])[0];

        // If lineParent has another value than -1.0 the source block has more than one outgoing
        // signal.
        // The id of the source block can now only be get by the root line parent...
        if (lineParent != -1.0) {
          // ...Started by the source block every signal fork creates line children for the current
          // signal.
          // These children can also have children of their own (if they have a fork).
          // So to get the source block we need to get the source block of the root line parent.
          double rootLineParent = lineParent;
          do {
            srcConnHandle = rootLineParent;
            rootLineParent =
                ((double[]) (matlab.returningFeval(1, get_param, rootLineParent, "LineParent"))[0])
                    [0];
          } while (rootLineParent != -1.0);
        }

        String srcBlockName = (String) matlab.returningFeval(get_param, srcConnHandle, SrcBlock);
        String srcQualifiedBlockName = rootName + "/" + srcBlockName;
        String srcBlockType =
            (String) matlab.returningFeval(get_param, srcQualifiedBlockName, BlockType);
        String srcPortNumber = (String) matlab.returningFeval(get_param, srcConnHandle, SrcPort);

        String dstBlockName = (String) matlab.returningFeval(get_param, connHandle, DstBlock);
        String dstQualifiedBlockName = rootName + "/" + dstBlockName;
        String dstBlockType =
            (String) matlab.returningFeval(get_param, dstQualifiedBlockName, BlockType);
        String dstPortNumber = (String) matlab.returningFeval(get_param, connHandle, DstPort);

        SimulinkSignal signal =
            new SimulinkSignal(
                srcQualifiedBlockName,
                Integer.valueOf(srcPortNumber),
                dstQualifiedBlockName,
                Integer.valueOf(dstPortNumber),
                srcConnHandle);

        // ====== Handle Source ======= //

        if (srcBlockType.equals(SubSystem.toString())) {
          // src block is a sub system
          String srcPortName = getPortNameByNumber(srcQualifiedBlockName, srcPortNumber, false);
          signal.setSrcPortName(srcPortName);
        } else if (srcBlockType.equals(ModelReference.toString())) {
          // src block is a model reference
          String referencedModelName =
              (String) matlab.returningFeval(get_param, srcQualifiedBlockName, ModelName);
          matlab.loadModel(referencedModelName);

          String srcPortName = getPortNameByNumber(referencedModelName, srcPortNumber, false);
          signal.setSrcPortName(srcPortName);
        }

        // ====== Handle Destination ======= //

        if (dstBlockType.equals(SubSystem.toString())) {
          // dst block is a sub system
          String dstPortName = getPortNameByNumber(dstQualifiedBlockName, dstPortNumber, true);
          signal.setDstPortName(dstPortName);
        } else if (dstBlockType.equals(ModelReference.toString())) {
          // dst block is a model reference
          String referencedModelName =
              (String) matlab.returningFeval(get_param, dstQualifiedBlockName, ModelName);
          matlab.loadModel(referencedModelName);

          String dstPortName = getPortNameByNumber(referencedModelName, dstPortNumber, true);
          signal.setDstPortName(dstPortName);
        }

        signals.add(signal);
      }
    }

    return signals;
  }