示例#1
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);
    }
  }
  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);
      }
    }
  }