summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <tpearson@raptorengineering.com>2019-06-30 04:50:41 -0500
committerTimothy Pearson <tpearson@raptorengineering.com>2019-06-30 04:50:41 -0500
commitb9302c6da3ffa7afd922aec91b7bf578359936a4 (patch)
treed9c3f1359ebefb9f9b5409ba44501773fb403bd7
parentaf6a13021057009105e7248ddff23529044344ba (diff)
downloadulab-b9302c6da3ffa7afd922aec91b7bf578359936a4.tar.gz
ulab-b9302c6da3ffa7afd922aec91b7bf578359936a4.zip
Add preliminary data export support to oscilloscope part
-rw-r--r--clients/tde/src/part/scope/layout.ui8
-rw-r--r--clients/tde/src/part/scope/part.cpp25
-rw-r--r--clients/tde/src/part/scope/part.h1
3 files changed, 34 insertions, 0 deletions
diff --git a/clients/tde/src/part/scope/layout.ui b/clients/tde/src/part/scope/layout.ui
index 16b0d0c..43a0be8 100644
--- a/clients/tde/src/part/scope/layout.ui
+++ b/clients/tde/src/part/scope/layout.ui
@@ -150,6 +150,14 @@
<cstring>mathTraceControlLayoutWidget</cstring>
</property>
</widget>
+ <widget class="TQPushButton" row="2" column="0" colspan="1">
+ <property name="name">
+ <cstring>dumpSamples</cstring>
+ </property>
+ <property name="text">
+ <string>Export Selected Data</string>
+ </property>
+ </widget>
</grid>
</widget>
<widget class="TQGroupBox" row="2" column="0">
diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp
index 401fd66..efa05a0 100644
--- a/clients/tde/src/part/scope/part.cpp
+++ b/clients/tde/src/part/scope/part.cpp
@@ -638,6 +638,7 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
connect(m_traceWidget, SIGNAL(zoomBoxChanged(const TQRectF&)), this, SLOT(updateZoomWidgetLimits(const TQRectF&)));
connect(m_traceWidget, SIGNAL(offsetChanged(uint, double)), m_base->traceZoomWidget, SLOT(setTraceOffset(uint, double)));
+ connect(m_base->dumpSamples, SIGNAL(clicked()), this, SLOT(dumpSamples()));
connect(m_base->acqStart, SIGNAL(clicked()), this, SLOT(startDAQ()));
connect(m_base->acqStop, SIGNAL(clicked()), this, SLOT(stopDAQ()));
connect(m_base->runControlStartButton, SIGNAL(clicked()), this, SLOT(startScope()));
@@ -2133,6 +2134,30 @@ void ScopePart::startDAQ() {
EXEC_NEXT_STATE_IMMEDIATELY
}
+void ScopePart::dumpSamples() {
+ // Calculate left and right extent of zoom area
+ TQRectF currentZoomBox = m_traceWidget->zoomBox();
+
+ TQString csvData = "";
+ for (int traceno=1; traceno<=m_maxNumberOfTraces; traceno++) {
+ if (m_channelActive[traceno]) {
+ TQString saveFileName = TQString("/tmp/trace%1.csv").arg(traceno);
+ TQFile file(saveFileName);
+ file.open(IO_WriteOnly);
+ csvData = "";
+ int start_sample = ((m_samplesInTrace[traceno] * currentZoomBox.x()) / 100.0);
+ int end_sample = ((m_samplesInTrace[traceno] * currentZoomBox.width()) / 100.0) + start_sample;
+ TQDoubleArray positions = m_traceWidget->positions(traceno-1);
+ TQDoubleArray values = m_traceWidget->samples(traceno-1);
+ for (int sample=start_sample; sample<end_sample; sample++) {
+ csvData += TQString("%1,%2\n").arg(positions[sample]).arg(values[sample]);
+ }
+ csvData += "\n";
+ file.writeBlock(csvData.ascii(), strlen(csvData.ascii()));
+ }
+ }
+}
+
void ScopePart::stopDAQ() {
if (m_commHandlerMode < 2) {
m_stopTraceUpdate = true;
diff --git a/clients/tde/src/part/scope/part.h b/clients/tde/src/part/scope/part.h
index 46e2f5d..dbe4066 100644
--- a/clients/tde/src/part/scope/part.h
+++ b/clients/tde/src/part/scope/part.h
@@ -223,6 +223,7 @@ namespace RemoteLab
void connectionStatusChangedCallback();
void setTickerMessage(TQString message);
void mainEventLoop();
+ void dumpSamples();
void startDAQ();
void stopDAQ();
void updateTraceControlWidgets();