コード例 #1
0
 @Override
 public void run(WorkspaceEntry we) {
   final CheckDeadlockTask task = new CheckDeadlockTask(we);
   String description = "MPSat tool chain";
   String title = we.getTitle();
   if (!title.isEmpty()) {
     description += "(" + title + ")";
   }
   final Framework framework = Framework.getInstance();
   final TaskManager taskManager = framework.getTaskManager();
   final MpsatChainResultHandler monitor = new MpsatChainResultHandler(task);
   taskManager.queue(task, description, monitor);
 }
コード例 #2
0
  @Override
  public void generateTraceGraph(final GraphEditor editor) {
    Framework framework = Framework.getInstance();
    Stg stg = getUnderlyingStg();
    Trace trace = getCombinedTrace();
    if (trace.isEmpty()) {
      JOptionPane.showMessageDialog(
          framework.getMainWindow(),
          "Cannot generate a timing diagram for an empty trace.",
          "Generation of Timing Diagram",
          JOptionPane.WARNING_MESSAGE);
    } else {
      LinkedList<Pair<String, Color>> orderedTraceSignals = getOrderedTraceSignals(stg, trace);
      StgToDtdConverter converter = new StgToDtdConverter(stg, trace, orderedTraceSignals);
      VisualDtd dtd = converter.getVisualDtd();

      WorkspaceEntry we = editor.getWorkspaceEntry();
      final Path<String> directory = we.getWorkspacePath().getParent();
      final String desiredName = we.getWorkspacePath().getNode();
      final ModelEntry me = new ModelEntry(new DtdDescriptor(), dtd);
      final Workspace workspace = framework.getWorkspace();
      workspace.add(directory, desiredName, me, true, true);
    }
  }
コード例 #3
0
  private void handleSynthesisResult(
      ExternalProcessResult mpsatResult, boolean sequentialAssign, RenderType renderType) {
    final String log = new String(mpsatResult.getOutput());
    if ((log != null) && !log.isEmpty()) {
      System.out.println(log);
      System.out.println();
    }
    byte[] eqnOutput = mpsatResult.getFileData(MpsatSynthesisTask.EQN_FILE_NAME);
    if (eqnOutput != null) {
      LogUtils.logInfoLine("MPSat synthesis result in EQN format:");
      System.out.println(new String(eqnOutput));
      System.out.println();
    }
    byte[] verilogOutput = mpsatResult.getFileData(MpsatSynthesisTask.VERILOG_FILE_NAME);
    if (verilogOutput != null) {
      LogUtils.logInfoLine("MPSat synthesis result in Verilog format:");
      System.out.println(new String(verilogOutput));
      System.out.println();
    }
    if (MpsatSynthesisUtilitySettings.getOpenSynthesisResult() && (verilogOutput != null)) {
      try {
        ByteArrayInputStream in = new ByteArrayInputStream(verilogOutput);
        VerilogImporter verilogImporter = new VerilogImporter(sequentialAssign);
        final Circuit circuit = verilogImporter.importCircuit(in);
        final WorkspaceEntry we = task.getWorkspaceEntry();
        Path<String> path = we.getWorkspacePath();
        final Path<String> directory = path.getParent();
        final String name = FileUtils.getFileNameWithoutExtension(new File(path.getNode()));
        final ModelEntry me = new ModelEntry(new CircuitDescriptor(), circuit);
        boolean openInEditor = me.isVisual() || CommonEditorSettings.getOpenNonvisual();

        final Framework framework = Framework.getInstance();
        final Workspace workspace = framework.getWorkspace();
        WorkspaceEntry newWorkspaceEntry = workspace.add(directory, name, me, true, openInEditor);
        VisualModel visualModel = newWorkspaceEntry.getModelEntry().getVisualModel();
        if (visualModel instanceof VisualCircuit) {
          VisualCircuit visualCircuit = (VisualCircuit) visualModel;
          for (VisualFunctionComponent component : visualCircuit.getVisualFunctionComponents()) {
            component.setRenderType(renderType);
          }
          String title = we.getModelEntry().getModel().getTitle();
          visualCircuit.setTitle(title);
          if (!we.getFile().exists()) {
            JOptionPane.showMessageDialog(
                null,
                "Error: Unsaved STG cannot be set as the circuit environment.",
                TITLE,
                JOptionPane.ERROR_MESSAGE);
          } else {
            visualCircuit.setEnvironmentFile(we.getFile());
            if (we.isChanged()) {
              JOptionPane.showMessageDialog(
                  null,
                  "Warning: The STG with unsaved changes is set as the circuit environment.",
                  TITLE,
                  JOptionPane.WARNING_MESSAGE);
            }
          }
          SwingUtilities.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  framework.getMainWindow().getCurrentEditor().updatePropertyView();
                }
              });
        }
      } catch (DeserialisationException e) {
        throw new RuntimeException(e);
      }
    }
  }
コード例 #4
0
 @Override
 public boolean isApplicableTo(WorkspaceEntry we) {
   if (we.getModelEntry() == null) return false;
   if (we.getModelEntry().getVisualModel() instanceof VisualCpog) return true;
   return false;
 }
コード例 #5
0
ファイル: VerTool.java プロジェクト: tuura/workcraft
  public void run(final WorkspaceEntry we) {
    System.out.println("Verifying Model");

    Xmas xnet = (Xmas) we.getModelEntry().getMathModel();
    VisualXmas vnet = (VisualXmas) we.getModelEntry().getVisualModel();

    try {
      File cpnFile = XmasSettings.getTempVxmCpnFile();
      File inFile = XmasSettings.getTempVxmInFile();
      FileUtils.copyFile(cpnFile, inFile);

      ArrayList<String> vxmCommand = new ArrayList<>();
      vxmCommand.add(XmasSettings.getTempVxmCommandFile().getAbsolutePath());
      vxmCommand.addAll(processArg(XmasSettings.getTempVxmVsettingsFile().getAbsolutePath()));
      ExternalProcessTask.printCommandLine(vxmCommand);
      String[] cmdArray = vxmCommand.toArray(new String[vxmCommand.size()]);
      Process vxmProcess =
          Runtime.getRuntime().exec(cmdArray, null, XmasSettings.getTempVxmDirectory());

      String s, str = "";
      InputStreamReader inputStreamReader = new InputStreamReader(vxmProcess.getInputStream());
      BufferedReader stdInput = new BufferedReader(inputStreamReader);
      int n = 0;
      int test = -1;
      initHighlight(xnet, vnet);
      while ((s = stdInput.readLine()) != null) {
        if (test == -1) test = checkType(s);
        if (n > 0) str = str + s + '\n';
        n++;
        System.out.println(s);
      }
      if (level.equals("advanced")) {
        System.out.println("LEVEL IS ADVANCED ");
        File qslFile = XmasSettings.getTempVxmQslFile();
        processQsl(qslFile.getAbsolutePath());

        File equFile = XmasSettings.getTempVxmEquFile();
        str = processEq(equFile.getAbsolutePath());
      } else if (level.equals("normal") && test == 2) {
        System.out.println("LEVEL IS NORMAL ");
        File locFile = XmasSettings.getTempVxmLocFile();
        str = processLoc(locFile.getAbsolutePath());
      }
      if (test > 0) {
        if (display.equals("popup")) {
          if (!level.equals("advanced")) {
            new SolutionsDialog1(test, str);
          } else {
            new SolutionsDialog2(test, str);
          }
        }
        if (test == 2) {
          if (highlight.equals("local")) {
            localHighlight(str, xnet, vnet);
          } else if (highlight.equals("rel")) {
            relHighlight(str, xnet, vnet);
            // System.out.println("str = " + str);
            activeHighlight(xnet, vnet);
          }
        }
      } else if (test == 0) {
        if (display.equals("popup")) {
          String message = "The system is deadlock-free.";
          JOptionPane.showMessageDialog(null, message);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    // final SolutionsDialog solutionsDialog = new SolutionsDialog("hello", null);
    // GUI.centerAndSizeToParent(solutionsDialog, we.getFramework().getMainWindow());
    // solutionsDialog.setVisible(true);
    final Framework framework = Framework.getInstance();
    for (GraphEditorPanel e : framework.getMainWindow().getEditors(we)) {
      editor1 = e;
      g = (Graphics2D) e.getGraphics();
      for (int i = 0; i < 25; i++) {
        // GUI.drawEditorMessage(editor1, g, Color.RED, "hello");
      }
    }
  }