From d865ad890422e5c9a53817186457269f613b4e5a Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 15 Jul 2012 00:51:18 -0500 Subject: Fix scope --- clients/tde/src/part/scope/layout.ui | 20 ++++++- clients/tde/src/part/scope/part.cpp | 111 ++++++++++++++++++++++++++++++++--- clients/tde/src/part/scope/part.h | 2 + 3 files changed, 124 insertions(+), 9 deletions(-) (limited to 'clients/tde/src/part/scope') 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 @@ unnamed - + groupOscilloscopeView @@ -159,7 +159,7 @@ - + groupOscilloscopeAcquisitionControls @@ -183,6 +183,22 @@ Stop Acquisition + + + waveformSave + + + Save Waveforms + + + + + waveformRecall + + + Recall Waveforms + + 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 #include #include //::start() +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -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("The selected waveform file version does not match this client"), i18n("Invalid File")); + } + } + else { + KMessageBox::error(0, i18n("Invalid waveform file selected"), i18n("Invalid File")); + } + } +} + void ScopePart::updateZoomWidgetLimits(const TQRectF& zoomRect) { for (int traceno=0; tracenodisplayLimits(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); -- cgit v1.2.1