diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-15 00:51:18 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-15 00:51:18 -0500 |
commit | d865ad890422e5c9a53817186457269f613b4e5a (patch) | |
tree | fb6b9bc21c295ed0587be58eebe770540fe7b4f0 /clients/tde/src/part/scope | |
parent | 47f193b7dea740d95b0827855d0d4d3faefe3b72 (diff) | |
download | ulab-d865ad890422e5c9a53817186457269f613b4e5a.tar.gz ulab-d865ad890422e5c9a53817186457269f613b4e5a.zip |
Fix scope
Diffstat (limited to 'clients/tde/src/part/scope')
-rw-r--r-- | clients/tde/src/part/scope/layout.ui | 20 | ||||
-rw-r--r-- | clients/tde/src/part/scope/part.cpp | 111 | ||||
-rw-r--r-- | clients/tde/src/part/scope/part.h | 2 |
3 files changed, 124 insertions, 9 deletions
diff --git a/clients/tde/src/part/scope/layout.ui b/clients/tde/src/part/scope/layout.ui index 6a28939..f824d7a 100644 --- a/clients/tde/src/part/scope/layout.ui +++ b/clients/tde/src/part/scope/layout.ui @@ -45,7 +45,7 @@ <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="TQGroupBox" row="0" column="0"> + <widget class="TQGroupBox" row="0" column="0" rowspan="10"> <property name="name"> <cstring>groupOscilloscopeView</cstring> </property> @@ -159,7 +159,7 @@ </widget> </grid> </widget> - <widget class="TQGroupBox" row="0" column="1"> + <widget class="TQGroupBox" row="1" column="1"> <property name="name"> <cstring>groupOscilloscopeAcquisitionControls</cstring> </property> @@ -183,6 +183,22 @@ <string>Stop Acquisition</string> </property> </widget> + <widget class="TQPushButton" row="1" column="0" colspan="1"> + <property name="name"> + <cstring>waveformSave</cstring> + </property> + <property name="text"> + <string>Save Waveforms</string> + </property> + </widget> + <widget class="TQPushButton" row="1" column="1" colspan="1"> + <property name="name"> + <cstring>waveformRecall</cstring> + </property> + <property name="text"> + <string>Recall Waveforms</string> + </property> + </widget> </grid> </widget> </grid> diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp index aefaa20..eb31eea 100644 --- a/clients/tde/src/part/scope/part.cpp +++ b/clients/tde/src/part/scope/part.cpp @@ -8,6 +8,7 @@ #include <kaction.h> #include <klocale.h> #include <kmessagebox.h> //::start() +#include <kfiledialog.h> #include <kparts/genericfactory.h> #include <kstatusbar.h> #include <kstdaction.h> @@ -16,6 +17,7 @@ #include <tqvbox.h> #include <tqsocket.h> #include <tqmutex.h> +#include <tqgroupbox.h> #include <tqpushbutton.h> #include <tqeventloop.h> #include <tqapplication.h> @@ -97,6 +99,9 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject * connect(m_base->acqStart, SIGNAL(clicked()), this, SLOT(startDAQ())); connect(m_base->acqStop, SIGNAL(clicked()), this, SLOT(stopDAQ())); + connect(m_base->waveformSave, SIGNAL(clicked()), this, SLOT(saveWaveforms())); + connect(m_base->waveformRecall, SIGNAL(clicked()), this, SLOT(recallWaveforms())); + connect(m_base->saRefLevel, SIGNAL(floatValueChanged(double)), this, SLOT(saRefLevelChanged(double))); TQTimer::singleShot(0, this, TQT_SLOT(postInit())); @@ -131,12 +136,30 @@ bool ScopePart::closeURL() { void ScopePart::processLockouts() { if (m_connectionActiveAndValid) { - if ((m_commHandlerMode < 2) && (m_commHandlerState < 50)) { + if ((m_commHandlerMode < 2) && (m_commHandlerState < 2)) { m_base->setEnabled(false); } else { m_base->setEnabled(true); } + if ((m_commHandlerMode < 2) && (m_commHandlerState < 50)) { + m_base->groupOscilloscopeTraceControls->setEnabled(false); + } + else { + m_base->groupOscilloscopeTraceControls->setEnabled(true); + if (stopTraceUpdate) { + m_base->acqStop->setEnabled(false); + m_base->acqStart->setEnabled(true); + m_base->waveformSave->setEnabled(true); + m_base->waveformRecall->setEnabled(true); + } + else { + m_base->acqStop->setEnabled(true); + m_base->acqStart->setEnabled(false); + m_base->waveformSave->setEnabled(false); + m_base->waveformRecall->setEnabled(false); + } + } } else { m_base->setEnabled(false); @@ -586,7 +609,7 @@ void ScopePart::mainEventLoop() { updateGraticule(); // HACK // Force resize of parent frame - emit(usingFixedSizeChanged(false)); + emit(resizeToHintRequested()); } if (result == "ACK") { @@ -741,14 +764,10 @@ void ScopePart::postProcessTrace() { } void ScopePart::startDAQ() { - // RAJA FIXME - // Also process lockouts... + stopTraceUpdate = false; } void ScopePart::stopDAQ() { - // RAJA FIXME - // Also process lockouts... - if (m_commHandlerMode < 2) { stopTraceUpdate = true; m_commHandlerMode = 1; @@ -757,6 +776,84 @@ void ScopePart::stopDAQ() { } } +#define WAVEFORM_MAGIC_NUMBER 1 +#define WAVEFORM_FILE_VERSION 1 + +void ScopePart::saveWaveforms() { + TQString saveFileName = KFileDialog::getSaveFileName(TQString::null, "*.wfm|Waveform Files (*.wfm)", 0, i18n("Save waveforms...")); + if (saveFileName != "") { + TQFile file(saveFileName); + file.open(IO_WriteOnly); + TQDataStream ds(&file); + TQ_INT32 magicNumber = WAVEFORM_MAGIC_NUMBER; + TQ_INT32 version = WAVEFORM_FILE_VERSION; + ds << magicNumber; + ds << version; + ds << m_hdivs; + ds << m_vdivs; + ds << m_maxNumberOfTraces; + for (int traceno=1; traceno<=m_maxNumberOfTraces; traceno++) { + TQ_UINT8 boolValue; + boolValue = m_channelActive[traceno]; + ds << boolValue; + ds << m_samplesInTrace[traceno]; + ds << m_voltsDiv[traceno]; + ds << m_secsDiv[traceno]; + ds << m_traceWidget->samples(traceno-1); + ds << m_traceWidget->positions(traceno-1); + } + } +} + +void ScopePart::recallWaveforms() { + TQString openFileName = KFileDialog::getOpenFileName(TQString::null, "*.wfm|Waveform Files (*.wfm)", 0, i18n("Open waveforms...")); + if (openFileName != "") { + TQFile file(openFileName); + file.open(IO_ReadOnly); + TQDataStream ds(&file); + TQ_INT32 magicNumber; + TQ_INT32 version; + ds >> magicNumber; + if (magicNumber == WAVEFORM_MAGIC_NUMBER) { + ds >> version; + if (version == WAVEFORM_FILE_VERSION) { + ds >> m_hdivs; + ds >> m_vdivs; + ds >> m_maxNumberOfTraces; + for (int traceno=1; traceno<=m_maxNumberOfTraces; traceno++) { + TQ_UINT8 boolValue; + ds >> boolValue; + m_channelActive[traceno] = (boolValue!=0)?true:false; + ds >> m_samplesInTrace[traceno]; + ds >> m_voltsDiv[traceno]; + ds >> m_secsDiv[traceno]; + TQDoubleArray values; + TQDoubleArray positions; + ds >> values; + ds >> positions; + m_traceWidget->setSamples(traceno-1, values); + m_traceWidget->setPositions(traceno-1, positions); + m_base->traceZoomWidget->setSamples(traceno-1, values); + m_base->traceZoomWidget->setPositions(traceno-1, positions); + } + updateGraticule(); + postProcessTrace(); + // HACK + // Force resize of parent frame + emit(resizeToHintRequested()); + m_traceWidget->repaint(true); + m_base->traceZoomWidget->repaint(true); + } + else { + KMessageBox::error(0, i18n("<qt>The selected waveform file version does not match this client</qt>"), i18n("Invalid File")); + } + } + else { + KMessageBox::error(0, i18n("<qt>Invalid waveform file selected</qt>"), i18n("Invalid File")); + } + } +} + void ScopePart::updateZoomWidgetLimits(const TQRectF& zoomRect) { for (int traceno=0; traceno<m_maxNumberOfTraces; traceno++) { TQRectF fullZoomRect = m_traceWidget->displayLimits(traceno); diff --git a/clients/tde/src/part/scope/part.h b/clients/tde/src/part/scope/part.h index 7034300..0032a3e 100644 --- a/clients/tde/src/part/scope/part.h +++ b/clients/tde/src/part/scope/part.h @@ -51,6 +51,8 @@ namespace RemoteLab void mainEventLoop(); void startDAQ(); void stopDAQ(); + void saveWaveforms(); + void recallWaveforms(); virtual void postProcessTrace(); void saRefLevelChanged(double); |