/** * Repeats the capture with the current settings. * * @param aParent the parent window to use, can be <code>null</code>. */ public boolean repeatCaptureData(final Window aParent) { final DeviceController devCtrl = getDeviceController(); if (devCtrl == null) { return false; } try { setStatus( "Capture from {0} started at {1,date,medium} {1,time,medium} ...", devCtrl.getName(), new Date()); devCtrl.captureData(this); return true; } catch (IOException exception) { captureAborted("I/O problem: " + exception.getMessage()); exception.printStackTrace(); // Make sure to handle IO-interrupted exceptions properly! HostUtils.handleInterruptedException(exception); return false; } finally { updateActions(); } }
/** * stores the data to a HTML file * * @param aFile file object */ private void storeToHtmlFile(final File aFile, final UARTDataSet aDataSet) { try { toHtmlPage(aFile, aDataSet); } catch (final IOException exception) { // Make sure to handle IO-interrupted exceptions properly! if (!HostUtils.handleInterruptedException(exception)) { LOG.log(Level.WARNING, "HTML export failed!", exception); } } }
/** * Saves the current project to the given file. * * @param aFile the file to save the project information to, cannot be <code>null</code>. * @throws IOException in case of I/O problems. */ public void saveProjectFile(final String aName, final File aFile) throws IOException { FileOutputStream out = null; try { final Project project = this.projectManager.getCurrentProject(); project.setFilename(aFile); project.setName(aName); out = new FileOutputStream(aFile); this.projectManager.saveProject(out); } finally { HostUtils.closeResource(out); } }
/** {@inheritDoc} */ @Override protected void onToolEnded(final UARTDataSet aAnalysisResult) { try { final String htmlPage; if (aAnalysisResult != null) { htmlPage = toHtmlPage(null /* aFile */, aAnalysisResult); } else { htmlPage = getEmptyHtmlPage(); } this.outText.setText(htmlPage); this.outText.setEditable(false); this.runAnalysisAction.restore(); } catch (final IOException exception) { // Make sure to handle IO-interrupted exceptions properly! if (!HostUtils.handleInterruptedException(exception)) { // Should not happen in this situation! throw new RuntimeException(exception); } } }
/** * exports the data to a CSV file * * @param aFile File object */ private void storeToCsvFile(final File aFile, final UARTDataSet aDataSet) { try { final CsvExporter exporter = ExportUtils.createCsvExporter(aFile); exporter.setHeaders( "index", "start-time", "end-time", "event?", "event-type", "RxD event", "TxD event", "RxD data", "TxD data"); final List<UARTData> decodedData = aDataSet.getData(); for (int i = 0; i < decodedData.size(); i++) { final UARTData ds = decodedData.get(i); final String startTime = Unit.Time.format(aDataSet.getTime(ds.getStartSampleIndex())); final String endTime = Unit.Time.format(aDataSet.getTime(ds.getEndSampleIndex())); String eventType = null; String rxdEvent = null; String txdEvent = null; String rxdData = null; String txdData = null; switch (ds.getType()) { case UARTData.UART_TYPE_EVENT: eventType = ds.getEventName(); break; case UARTData.UART_TYPE_RXEVENT: rxdEvent = ds.getEventName(); break; case UARTData.UART_TYPE_TXEVENT: txdEvent = ds.getEventName(); break; case UARTData.UART_TYPE_RXDATA: rxdData = Integer.toString(ds.getData()); break; case UARTData.UART_TYPE_TXDATA: txdData = Integer.toString(ds.getData()); break; default: break; } exporter.addRow( Integer.valueOf(i), startTime, endTime, Boolean.valueOf(ds.isEvent()), eventType, rxdEvent, txdEvent, rxdData, txdData); } exporter.close(); } catch (final IOException exception) { // Make sure to handle IO-interrupted exceptions properly! if (!HostUtils.handleInterruptedException(exception)) { LOG.log(Level.WARNING, "CSV export failed!", exception); } } }