コード例 #1
0
  protected DeltaOperation getConnectorOperation(
      DeltaOperation sourceOp, DeltaOperation targetOp, SimulinkSignal signal) {
    DeltaOperation result = DeltaOperation.UNDEFINED;
    matlab.setvar("TEMP_DOUBLE_VAL", signal.getSrcConnHandle());
    String command =
        "if(exist('TEMP_DOUBLE_VAL','var')) TEMP_VAR=get_param(get_param(TEMP_DOUBLE_VAL,'SrcBlockHandle'),'UserData'); end;";
    matlab.eval(command);
    String command2 =
        "a=''; if(exist('TEMP_VAR','var')) if isKey(TEMP_VAR.lineMap,getfullname(TEMP_DOUBLE_VAL)) a=TEMP_VAR.lineMap(getfullname(TEMP_DOUBLE_VAL)).opName; end; end; a;";
    matlab.eval(command2);
    Object[] opResult = matlab.reval("a", 1);
    // "a=''; if isKey(TEMP_VAR.lineMap,TEMP_DOUBLE_VAL) a=TEMP_VAR.lineMap(TEMP_DOUBLE_VAL).opName;
    // end; a"
    String operation = "";

    if (opResult != null && opResult.length == 1 && opResult[0] instanceof String) {
      operation = (String) opResult[0];
    }

    if (operation.equals("add")) {
      result = DeltaOperation.ADD;
    } else if (operation.equals("remove")) {
      result = DeltaOperation.REMOVE;
    } else if (operation.equals("modify")) {
      result = DeltaOperation.MODIFY;
    } else if (operation.equals("replace")) {
      result = DeltaOperation.REPLACE;
    } else {
      result = DeltaOperation.UNDEFINED;
    }

    return result;
  }
コード例 #2
0
  protected DeltaOperation getDeltaOperationForElement(String element) {
    String command = "TEMP_DATA=get_param('DAddPort/modify model ModelToModify','UserData');";
    StringBuilder sb = new StringBuilder("TEMP_DATA=get_param('");
    sb.append(element);
    sb.append("','UserData');");
    command = sb.toString();
    matlab.eval(command);
    Object[] opResult = matlab.reval("TEMP_DATA.opName", 1);

    String operation = "";
    DeltaOperation result;

    if (opResult != null && opResult.length == 1 && opResult[0] instanceof String) {
      operation = (String) opResult[0];
    }

    if (operation.equals("add")) {
      result = DeltaOperation.ADD;
    } else if (operation.equals("remove")) {
      result = DeltaOperation.REMOVE;
    } else if (operation.equals("modify")) {
      result = DeltaOperation.MODIFY;
    } else if (operation.equals("replace")) {
      result = DeltaOperation.REPLACE;
    } else {
      result = DeltaOperation.UNDEFINED;
    }

    return result;
  }