Add preliminary data export support to oscilloscope part

master
Timothy Pearson 5 years ago
parent af6a130210
commit b9302c6da3

@ -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">

@ -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;

@ -223,6 +223,7 @@ namespace RemoteLab
void connectionStatusChangedCallback();
void setTickerMessage(TQString message);
void mainEventLoop();
void dumpSamples();
void startDAQ();
void stopDAQ();
void updateTraceControlWidgets();

Loading…
Cancel
Save