summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/part/scope/part.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clients/tde/src/part/scope/part.cpp')
-rw-r--r--clients/tde/src/part/scope/part.cpp111
1 files changed, 104 insertions, 7 deletions
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);