Example #1
0
  public SBoxModuleNode(IModuleDB portNode, VIRTPORT_TYPE virtType) {
    super();
    this.module = portNode;

    assert virtType != null && virtType.isModule() : "ERROR " + virtType.toString();
    this.virtType = virtType;
  }
Example #2
0
  public static SBoxModuleNode create(String moduleName, VIRTPORT_TYPE virtType) {
    int index = moduleName.indexOf(":");
    if (index != -1) {
      String s = moduleName.substring(index + 1);
      try {
        virtType = VIRTPORT_TYPE.optionToType(s);
      } catch (Exception e) {
        return null;
      }
      moduleName = moduleName.substring(0, index);
    }
    IModuleDB pNode =
        moduleName.equals("/")
            ? (ModelDBNode) DBNodeFactory.dbNode(UnwCore.project.model())
            : DBNodeTools.instanceDBNode(moduleName);

    if (pNode == null) return null;

    return new SBoxModuleNode(pNode, virtType);
  }
  public void run(IAction action) {
    if (BoxPlugin.forceIOTableModel == null || BoxPlugin.observedIOTableModel == null) {
      System.out.println("There are no IO tables to save. Quitting action.");
    }

    SBoxTableItem[] forcedTableItems = BoxPlugin.forceIOTableModel.getElements();
    SBoxTableItem[] observedTableItems = BoxPlugin.observedIOTableModel.getElements();

    ArrayList<String> commandsList =
        new ArrayList<String>(forcedTableItems.length + observedTableItems.length);

    String probeName = null;
    String probeValue = null;
    VIRTPORT_TYPE virtType;
    String type;
    for (SBoxTableItem item : forcedTableItems) {
      type = null;
      probeName = item.getPinName();

      virtType = item.getVirtType();
      if (virtType != null && virtType != VIRTPORT_TYPE.VOLTAGE) type = virtType.getTclOption();

      commandsList.add(
          AddProbe.command + " " + probeName + " -f" + (type != null ? " -t " + type : ""));

      if (item.isForced()) {
        switch (item.getPortDBNode().getPort().getComputerType()) {
          case STRING:
            probeValue = item.getValue().trim();
            break;
          case FLOAT:
            probeValue =
                EngineAccess.getInstance()
                    .getFloatResult(item.getPortDBNode(), item.getVirtType())
                    .toString();
            break;
          case INTEGER:
            probeValue =
                EngineAccess.getInstance()
                    .getResult(
                        item.getPortDBNode(), item.getVirtType(), false, ComputerTypes.INTEGER)
                    .toString();
            break;
        }

        commandsList.add(ForceProbe.command + " " + probeName + " " + probeValue);
      }
    }

    for (SBoxTableItem item : observedTableItems) {
      type = null;

      if (item.getPortDBNode() == null)
        probeName =
            ((SBoxTableItemList) item).getModule() instanceof ModelDBNode
                ? "/"
                : ((SBoxTableItemList) item).getModuleName();
      else probeName = item.getPinName();

      virtType = item.getVirtType();
      if (virtType != null && virtType != VIRTPORT_TYPE.VOLTAGE) type = virtType.getTclOption();

      commandsList.add(AddProbe.command + " " + probeName + (type != null ? " -t " + type : ""));
    }

    if (commandsList.size() == 0) {
      System.out.println("The IO tables are empty. Quitting action.");
      return;
    }

    dumpToWriter(commandsList);
  }