Skip to content

Commit 52ead8b

Browse files
committed
implementation for #365
Quick and dirty.Doubleclick open save dialogue and dumps all the visual data. you need too hurry if the scope is still running.
1 parent d897daa commit 52ead8b

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

it.baeyens.arduino.monitor/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Bundle-Activator: it.baeyens.arduino.monitor.internal.Activator
77
Bundle-Vendor: jan baeyens
88
Require-Bundle: org.eclipse.ui,
99
org.eclipse.core.runtime,
10-
it.baeyens.arduino.common
10+
it.baeyens.arduino.common,
11+
org.eclipse.core.resources
1112
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
1213
Bundle-ActivationPolicy: lazy
1314
Export-Package: it.baeyens.arduino.monitor;uses:="org.eclipse.jface.resource,org.eclipse.ui.plugin,org.osgi.framework"

it.baeyens.arduino.monitor/src/it/baeyens/arduino/monitor/views/ScopeView.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.swt.layout.GridLayout;
1818
import org.eclipse.swt.widgets.Composite;
1919
import org.eclipse.swt.widgets.Event;
20+
import org.eclipse.swt.widgets.FileDialog;
2021
import org.eclipse.swt.widgets.Listener;
2122
import org.eclipse.ui.PlatformUI;
2223
import org.eclipse.ui.part.ViewPart;
@@ -53,8 +54,7 @@ protected IStatus run(IProgressMonitor monitor) {
5354
IEclipsePreferences mySCope = InstanceScope.INSTANCE.getNode(Const.NODE_ARDUINO);
5455
int curFsiStatus = mySCope.getInt(flagMonitor, 0) + 1;
5556
mySCope.putInt(flagMonitor, curFsiStatus);
56-
URL pluginStartInitiator = new URL(
57-
ScopeView.this.uri.replaceAll(" ", Const.EMPTY_STRING) + Integer.toString(curFsiStatus)); //$NON-NLS-1$
57+
URL pluginStartInitiator = new URL(ScopeView.this.uri.replaceAll(" ", Const.EMPTY_STRING) + Integer.toString(curFsiStatus)); //$NON-NLS-1$
5858
ScopeView.this.mstatus = pluginStartInitiator.getContent();
5959
} catch (Exception e) {// JABA is not going to add code
6060
}
@@ -174,6 +174,15 @@ public void handleEvent(Event event) {
174174
this.inDrag = false;
175175
this.inSize = false;
176176
break;
177+
case SWT.MouseDoubleClick:
178+
// save the data
179+
FileDialog dialog = new FileDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.SAVE);
180+
dialog.setFilterExtensions(new String[] { "*.cvs" }); //$NON-NLS-1$
181+
String fileName = dialog.open();
182+
if (!fileName.isEmpty()) {
183+
ScopeView.this.myScope.saveData(fileName);
184+
}
185+
break;
177186
default:
178187
break;
179188
}
@@ -183,6 +192,7 @@ public void handleEvent(Event event) {
183192
this.myScope.addListener(SWT.MouseDown, listener);
184193
this.myScope.addListener(SWT.MouseUp, listener);
185194
this.myScope.addListener(SWT.MouseMove, listener);
195+
this.myScope.addListener(SWT.MouseDoubleClick, listener);
186196
this.myScope.addControlListener(new ControlAdapter() {
187197
@Override
188198
public void controlResized(ControlEvent e) {

it.baeyens.arduino.monitor/src/multichannel/Oscilloscope.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package multichannel;
22

3+
import java.io.FileNotFoundException;
4+
import java.io.PrintWriter;
5+
import java.io.UnsupportedEncodingException;
36
import java.util.ArrayList;
47

58
import org.eclipse.swt.SWT;
@@ -486,23 +489,15 @@ protected void PositionPolyLine(int[] l1) {
486489

487490
protected void paintControl(PaintEvent e) {
488491

489-
// long start = System.currentTimeMillis();
490-
491492
for (int c = 0; c < this.chan.length; c++) {
492493

493-
// if (chan[c].tailSize <= 0) {
494-
// chan[c].stack.popNegate(0);
495-
// continue;
496-
// }
497-
498494
// Go calculate the line
499495
Object[] result = calculate(c);
500496
int[] l1 = (int[]) result[0];
501497
int[] l2 = (int[]) result[1];
502498

503499
PositionPolyLine(l1);
504500
PositionPolyLine(l2);
505-
// System.out.print(System.currentTimeMillis() - start + "-");
506501

507502
// Draw it
508503
GC gc = e.gc;
@@ -532,20 +527,15 @@ protected void paintControl(PaintEvent e) {
532527
}
533528

534529
} else {
535-
// long time = System.nanoTime();
536530
gc.drawPolyline(l1);
537531
gc.drawPolyline(l2);
538-
// System.out.println(System.nanoTime() - time + " nanoseconds");
539532
}
540533

541534
// Connects the head with the tail
542535
if (isConnect(c) && !isFade(c) && this.chan[c].originalTailSize == TAILSIZE_MAX && l1.length > 0 && l2.length > 0) {
543536
gc.drawLine(l2[l2.length - 2], l2[l2.length - 1], l1[0], l1[1]);
544537
}
545538
}
546-
547-
// System.out.println(System.currentTimeMillis() - start + " milliseconds for all channels");
548-
549539
}
550540

551541
public Color getForeground(int channel) {
@@ -570,11 +560,6 @@ private Object[] calculate(int channel) {
570560
int[] line2 = null;
571561
int splitPos = 0;
572562

573-
// for (int progress = 0; progress < getProgression(c); progress++) {
574-
575-
// if (chan[c].stack.isEmpty() && chan[c].stackListeners != null)
576-
// notifyListeners(c);
577-
578563
splitPos = this.chan[c].tailSize * 4;
579564

580565
if (!isSteady(c))
@@ -585,9 +570,6 @@ private Object[] calculate(int channel) {
585570
line1 = new int[this.chan[c].tailSize * 4];
586571
line2 = new int[this.chan[c].tailSize * 4];
587572

588-
// chan[c].tail[chan[c].tailSize] = transform(c, chan[c].width,
589-
// chan[c].height, chan[c].stack.popNegate(0));
590-
591573
for (int i = 0; i < this.chan[c].tailSize; i++) {
592574

593575
int posx = this.chan[c].cursor - this.chan[c].tailSize + i;
@@ -1095,4 +1077,21 @@ public void dispose() {
10951077
super.dispose();
10961078
}
10971079

1080+
public void saveData(String fileName) {
1081+
1082+
try (PrintWriter writer = new PrintWriter(fileName, "UTF-8");) { //$NON-NLS-1$
1083+
writer.println("chan1;chan2;chan3;chan4;chan5;chan6;nothing"); //$NON-NLS-1$
1084+
for (int curvalue = 0; curvalue < this.chan[0].tail.length; curvalue++) {
1085+
for (int channel = 0; channel < this.chan.length; channel++) {
1086+
writer.print(this.chan[channel].tail[curvalue]);
1087+
writer.print(';');
1088+
}
1089+
writer.println();
1090+
}
1091+
} catch (FileNotFoundException | UnsupportedEncodingException e) {
1092+
// TODO Auto-generated catch block
1093+
e.printStackTrace();
1094+
}
1095+
}
1096+
10981097
}

0 commit comments

Comments
 (0)