summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/part
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-14 16:05:39 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-14 16:05:39 -0500
commitfe06492794c15013e4511d1fcd623b0234c21afe (patch)
treeef6cc5128d33feb3fc73c218607d509a4c2a26e8 /clients/tde/src/part
parente382ba1107906e9f6725fe7b4f15f62b5bb282c5 (diff)
downloadulab-fe06492794c15013e4511d1fcd623b0234c21afe.tar.gz
ulab-fe06492794c15013e4511d1fcd623b0234c21afe.zip
Can now grab initial scope traces
Diffstat (limited to 'clients/tde/src/part')
-rw-r--r--clients/tde/src/part/commanalyzer/part.cpp2
-rw-r--r--clients/tde/src/part/scope/part.cpp283
-rw-r--r--clients/tde/src/part/scope/part.h17
3 files changed, 154 insertions, 148 deletions
diff --git a/clients/tde/src/part/commanalyzer/part.cpp b/clients/tde/src/part/commanalyzer/part.cpp
index 8b92ea4..6042829 100644
--- a/clients/tde/src/part/commanalyzer/part.cpp
+++ b/clients/tde/src/part/commanalyzer/part.cpp
@@ -572,7 +572,7 @@ void CommAnalyzerPart::mainEventLoop() {
if (result == "ACK") {
#if 1
- // Trace grap is slow on most instruments
+ // Trace grab is slow on most instruments
// Put in the next trace request before processing the trace we just got so as to increase the overall update rate
if (m_commHandlerMode == 0) {
// Get trace, step 1
diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp
index 4d27930..a3400c4 100644
--- a/clients/tde/src/part/scope/part.cpp
+++ b/clients/tde/src/part/scope/part.cpp
@@ -65,10 +65,6 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
m_base = new ScopeBase(widget());
m_traceWidget = m_base->traceWidget;
m_traceWidget->setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding));
- m_traceWidget->setTraceEnabled(0, true);
- m_traceWidget->setTraceName(0, "Trace 1");
- m_traceWidget->setTraceHorizontalUnits(0, "Hz");
- m_traceWidget->setTraceVerticalUnits(0, "dBm");
m_traceWidget->setNumberOfCursors(4);
m_traceWidget->setCursorOrientation(0, TQt::Horizontal);
m_traceWidget->setCursorOrientation(1, TQt::Horizontal);
@@ -89,10 +85,6 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
m_traceWidget->setZoomBoxEnabled(true);
m_base->traceZoomWidget->setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding));
- m_base->traceZoomWidget->setTraceEnabled(0, true, false);
- m_base->traceZoomWidget->setTraceName(0, "Trace 1");
- m_base->traceZoomWidget->setTraceHorizontalUnits(0, "Hz");
- m_base->traceZoomWidget->setTraceVerticalUnits(0, "dBm");
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)));
@@ -219,10 +211,22 @@ void ScopePart::setTickerMessage(TQString message) {
} \
else { \
m_commHandlerState = 255; \
- }
+ } \
+ printf("[RAJA DEBUG 640.0] Entering state %d\n\r", m_commHandlerState); fflush(stdout);
#define EXEC_NEXT_STATE_IMMEDIATELY m_forcedUpdateTimer->start(0, TRUE);
+int getNextActiveChannel(int current, bool* activity, int maxtracenumber) {
+ int ret = -1;
+ for (int i=current+1; i<=maxtracenumber; i++) {
+ if (activity[i]) {
+ ret = i;
+ break;
+ }
+ }
+ return ret;
+}
+
void ScopePart::mainEventLoop() {
TQDataStream ds(m_socket);
ds.setPrintableData(true);
@@ -267,8 +271,8 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 2) {
- // Set spectrum analyzer mode
- ds << TQString("SETMODESPECTRUMANALYZER");
+ // Reset scope
+ ds << TQString("RESET");
m_socket->writeEndOfFrame();
SET_NEXT_STATE(3)
@@ -299,8 +303,8 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 4) {
- // Get number of samples in trace, step 1
- ds << TQString("GETTRACESAMPLECOUNT");
+ // Get number of horizontal divisions, step 1
+ ds << TQString("GETHORIZONTALDIVCOUNT");
m_socket->writeEndOfFrame();
SET_NEXT_STATE(5)
@@ -310,16 +314,16 @@ void ScopePart::mainEventLoop() {
// Get response data
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
-
- // Get number of samples in trace, step 2
+
+ // Get number of horizontal divisions, step 2
TQString result;
ds >> result;
if (result == "ACK") {
- ds >> m_samplesInTrace;
+ ds >> m_hdivs;
}
m_socket->clearFrameTail();
-
- if (result == "ACK") {
+
+ if (result == "ACK") {
SET_NEXT_STATE(6)
EXEC_NEXT_STATE_IMMEDIATELY
}
@@ -334,8 +338,8 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 6) {
- // Get number of horizontal divisions, step 1
- ds << TQString("GETHORIZONTALDIVCOUNT");
+ // Get number of vertical divisions, step 1
+ ds << TQString("GETVERTICALDIVCOUNT");
m_socket->writeEndOfFrame();
SET_NEXT_STATE(7)
@@ -346,14 +350,14 @@ void ScopePart::mainEventLoop() {
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
- // Get number of horizontal divisions, step 2
+ // Get number of vertical divisions, step 2
TQString result;
ds >> result;
if (result == "ACK") {
- ds >> m_hdivs;
+ ds >> m_vdivs;
}
m_socket->clearFrameTail();
-
+
if (result == "ACK") {
SET_NEXT_STATE(8)
EXEC_NEXT_STATE_IMMEDIATELY
@@ -369,8 +373,8 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 8) {
- // Get number of vertical divisions, step 1
- ds << TQString("GETVERTICALDIVCOUNT");
+ // Get number of channels, step 1
+ ds << TQString("GETNUMBEROFCHANNELS");
m_socket->writeEndOfFrame();
SET_NEXT_STATE(9)
@@ -380,16 +384,20 @@ void ScopePart::mainEventLoop() {
// Get response data
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
-
- // Get number of vertical divisions, step 2
+
+ // Get number of channels, step 2
TQString result;
ds >> result;
if (result == "ACK") {
- ds >> m_vdivs;
+ ds >> m_maxNumberOfTraces;
+ if (m_maxNumberOfTraces > MAXTRACES) {
+ m_maxNumberOfTraces = MAXTRACES;
+ }
}
m_socket->clearFrameTail();
if (result == "ACK") {
+ m_currentOpChannel = 1;
SET_NEXT_STATE(10)
EXEC_NEXT_STATE_IMMEDIATELY
}
@@ -404,8 +412,9 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 10) {
- // Get reference power level, step 1
- ds << TQString("GETREFERENCEPOWERLEVEL");
+ // Get channel status, step 1
+ ds << TQString("GETCHANNELACTIVE");
+ ds << m_currentOpChannel;
m_socket->writeEndOfFrame();
SET_NEXT_STATE(11)
@@ -415,17 +424,32 @@ void ScopePart::mainEventLoop() {
// Get response data
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
-
- // Get reference power level, step 2
+
+ // Get channel status, step 2
TQString result;
ds >> result;
if (result == "ACK") {
- ds >> m_rpower;
+ TQ_INT16 active;
+ ds >> active;
+ m_channelActive[m_currentOpChannel] = (active != 0);
}
m_socket->clearFrameTail();
if (result == "ACK") {
- SET_NEXT_STATE(12)
+ if (m_currentOpChannel < m_maxNumberOfTraces) {
+ m_currentOpChannel++;
+ SET_NEXT_STATE(10)
+ }
+ else {
+ m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces);
+ if (m_currentOpChannel > 0) {
+ SET_NEXT_STATE(12)
+ }
+ else {
+ m_currentOpChannel = 1;
+ SET_NEXT_STATE(8)
+ }
+ }
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
@@ -439,8 +463,9 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 12) {
- // Get vertical division scale, step 1
- ds << TQString("GETVERTDIVSCALE");
+ // Get number of samples in trace, step 1
+ ds << TQString("GETTRACESAMPLECOUNT");
+ ds << m_currentOpChannel;
m_socket->writeEndOfFrame();
SET_NEXT_STATE(13)
@@ -450,17 +475,24 @@ void ScopePart::mainEventLoop() {
// Get response data
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
-
- // Get vertical division scale, step 2
+
+ // Get number of samples in trace, step 2
TQString result;
ds >> result;
if (result == "ACK") {
- ds >> m_vscale;
+ ds >> m_samplesInTrace[m_currentOpChannel];
}
m_socket->clearFrameTail();
if (result == "ACK") {
- SET_NEXT_STATE(14)
+ m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces);
+ if (m_currentOpChannel > 0) {
+ SET_NEXT_STATE(12)
+ }
+ else {
+ m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces);
+ SET_NEXT_STATE(14)
+ }
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
@@ -474,8 +506,9 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 14) {
- // Get center frequency, step 1
- ds << TQString("GETCENTERFREQUENCY");
+ // Get volts per division, step 1
+ ds << TQString("GETVOLTSDIV");
+ ds << m_currentOpChannel;
m_socket->writeEndOfFrame();
SET_NEXT_STATE(15)
@@ -486,16 +519,23 @@ void ScopePart::mainEventLoop() {
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
- // Get center frequency, step 2
+ // Get volts per division, step 2
TQString result;
ds >> result;
if (result == "ACK") {
- ds >> m_centerfreq;
+ ds >> m_voltsDiv[m_currentOpChannel];
}
m_socket->clearFrameTail();
if (result == "ACK") {
- SET_NEXT_STATE(16)
+ m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces);
+ if (m_currentOpChannel > 0) {
+ SET_NEXT_STATE(14)
+ }
+ else {
+ m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces);
+ SET_NEXT_STATE(16)
+ }
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
@@ -509,8 +549,9 @@ void ScopePart::mainEventLoop() {
}
}
else if (m_commHandlerState == 16) {
- // Get frequency span, step 1
- ds << TQString("GETFREQUENCYSPAN");
+ // Get seconds per division, step 1
+ ds << TQString("GETSECONDSSDIV");
+ ds << m_currentOpChannel;
m_socket->writeEndOfFrame();
SET_NEXT_STATE(17)
@@ -521,11 +562,11 @@ void ScopePart::mainEventLoop() {
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
- // Get frequency span, step 2
+ // Get seconds per division, step 2
TQString result;
ds >> result;
if (result == "ACK") {
- ds >> m_spanfreq;
+ ds >> m_secsDiv[m_currentOpChannel];
}
m_socket->clearFrameTail();
@@ -535,7 +576,14 @@ void ScopePart::mainEventLoop() {
}
if (result == "ACK") {
- SET_NEXT_STATE(18)
+ m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces);
+ if (m_currentOpChannel > 0) {
+ SET_NEXT_STATE(16)
+ }
+ else {
+ m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces);
+ SET_NEXT_STATE(50)
+ }
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
@@ -548,57 +596,52 @@ void ScopePart::mainEventLoop() {
}
}
}
- else if (m_commHandlerState == 18) {
+ else if (m_commHandlerState == 50) {
// Get trace, step 1
- ds << TQString("GETSPECTRUMTRACE");
+ ds << TQString("GETCHANNELTRACE");
+ ds << m_currentOpChannel;
m_socket->writeEndOfFrame();
- SET_NEXT_STATE(19)
+ SET_NEXT_STATE(51)
EXEC_NEXT_STATE_IMMEDIATELY
}
- else if (m_commHandlerState == 19) {
+ else if (m_commHandlerState == 51) {
// Get response data
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
// Get trace, step 2
TQDoubleArray trace;
+ TQDoubleArray positions;
TQString result;
ds >> result;
if (result == "ACK") {
ds >> trace;
+ ds >> positions;
}
m_socket->clearFrameTail();
if (result == "ACK") {
-#if 1
- // Trace grap is slow on most instruments
- // Put in the next trace request before processing the trace we just got so as to increase the overall update rate
- if (m_commHandlerMode == 0) {
- // Get trace, step 1
- ds << TQString("GETSPECTRUMTRACE");
- m_socket->writeEndOfFrame();
- }
-
-#endif
// Update display widget(s)
- m_traceWidget->setSamples(0, trace);
- m_base->traceZoomWidget->setSamples(0, trace);
+ m_traceWidget->setSamples(m_currentOpChannel, trace);
+ m_base->traceZoomWidget->setSamples(m_currentOpChannel, trace);
+ m_traceWidget->setPositions(m_currentOpChannel, positions);
+ m_base->traceZoomWidget->setPositions(m_currentOpChannel, positions);
postProcessTrace();
m_traceWidget->repaint(true);
m_base->traceZoomWidget->repaint(true);
}
-
if (result == "ACK") {
-#if 0
- //SET_NEXT_STATE(2)
- SET_NEXT_STATE(18)
- EXEC_NEXT_STATE_IMMEDIATELY
-#else
- SET_NEXT_STATE(19)
+ m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces);
+ if (m_currentOpChannel > 0) {
+ SET_NEXT_STATE(50)
+ }
+ else {
+ m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces);
+ SET_NEXT_STATE(50)
+ }
EXEC_NEXT_STATE_IMMEDIATELY
-#endif
}
else {
COMMUNICATIONS_FAILED
@@ -625,9 +668,10 @@ void ScopePart::mainEventLoop() {
EXEC_NEXT_STATE_IMMEDIATELY
}
else if (m_commHandlerCommandState == 1) {
- // Set reference power level
- ds << TQString("SETREFERENCEPOWERLEVEL");
- ds << m_rpower;
+ // Set channel active
+ ds << TQString("SETCHANNELACTIVE");
+ ds << m_nextOpChannel;
+ ds << m_nextOpParameter16;
m_socket->writeEndOfFrame();
m_commHandlerCommandState = 2;
@@ -638,50 +682,12 @@ void ScopePart::mainEventLoop() {
if (m_socket->canReadFrame()) {
PAT_WATCHDOG_TIMER
- // Set reference power level, step 2
+ // Set channel active, step 2
TQString result;
ds >> result;
m_socket->clearFrameTail();
if (result == "ACK") {
- m_commHandlerCommandState = 3;
- EXEC_NEXT_STATE_IMMEDIATELY
- }
- else {
- COMMUNICATIONS_FAILED
- }
- }
- else {
- if (!m_updateTimeoutTimer->isActive()) {
- UPDATEDISPLAY_TIMEOUT
- }
- }
- }
- else if (m_commHandlerCommandState == 3) {
- // Get reference power level, step 1
- ds << TQString("GETREFERENCEPOWERLEVEL");
- m_socket->writeEndOfFrame();
-
- m_commHandlerCommandState = 4;
- EXEC_NEXT_STATE_IMMEDIATELY
- }
- else if (m_commHandlerCommandState == 4) {
- // Get response data
- if (m_socket->canReadFrame()) {
- PAT_WATCHDOG_TIMER
-
- // Get reference power level, step 2
- TQString result;
- ds >> result;
- if (result == "ACK") {
- ds >> m_rpower;
- }
- m_socket->clearFrameTail();
-
- // Update display as needed
- updateGraticule();
-
- if (result == "ACK") {
m_commHandlerCommandState = 0;
EXEC_NEXT_STATE_IMMEDIATELY
}
@@ -722,42 +728,39 @@ void ScopePart::updateZoomWidgetLimits(const TQRectF& zoomRect) {
}
void ScopePart::updateGraticule() {
- m_traceWidget->setNumberOfSamples(0, m_samplesInTrace);
m_traceWidget->setNumberOfHorizontalDivisions(m_hdivs);
m_traceWidget->setNumberOfVerticalDivisions(m_vdivs);
- m_base->traceZoomWidget->setNumberOfSamples(0, m_samplesInTrace);
m_base->traceZoomWidget->setNumberOfHorizontalDivisions(m_hdivs);
m_base->traceZoomWidget->setNumberOfVerticalDivisions(m_vdivs);
- m_leftFrequency = m_centerfreq - (m_spanfreq/2.0);
- m_rightFrequency = m_centerfreq + (m_spanfreq/2.0);
+ for (int traceno=1; traceno<=m_maxNumberOfTraces; traceno++) {
+ m_traceWidget->setTraceEnabled(traceno, m_channelActive[traceno]);
+ m_traceWidget->setTraceName(traceno, TQString("Channel %1").arg(traceno));
+ m_traceWidget->setTraceHorizontalUnits(traceno, "s");
+ m_traceWidget->setTraceVerticalUnits(traceno, "V");
+
+ m_traceWidget->setNumberOfSamples(traceno, m_samplesInTrace[traceno]);
+ m_base->traceZoomWidget->setNumberOfSamples(traceno, m_samplesInTrace[traceno]);
- double freqincr = (m_rightFrequency-m_leftFrequency)/m_samplesInTrace;
- double freqpos = m_leftFrequency;
- TQDoubleArray tracepositions;
- tracepositions.resize(m_samplesInTrace);
- for (int i=0; i<m_samplesInTrace; i++) {
- tracepositions[i] = freqpos;
- freqpos = freqpos + freqincr;
+ m_traceWidget->setDisplayLimits(traceno, TQRectF(0.0, (m_voltsDiv[traceno]*m_vdivs)/2.0, (m_secsDiv[traceno]*m_hdivs), (m_voltsDiv[traceno]*m_vdivs)/-2.0));
+
+printf("[RAJA DEBUG 700.0] m_voltsDiv[%d]: %f m_vdivs: %d m_secsDiv[%d]: %f m_hdivs: %d\n\r", traceno, m_voltsDiv[traceno], m_vdivs, traceno, m_secsDiv[traceno], m_hdivs); fflush(stdout);
}
- m_traceWidget->setPositions(0, tracepositions);
- m_traceWidget->setDisplayLimits(0, TQRectF(m_leftFrequency, m_rpower, m_rightFrequency, m_rpower-(m_vscale*m_vdivs)));
- m_base->traceZoomWidget->setPositions(0, tracepositions);
updateZoomWidgetLimits(m_traceWidget->zoomBox());
- // Also update controls
- m_base->saRefLevel->blockSignals(true);
- m_base->saRefLevel->setFloatValue(m_rpower);
- m_base->saRefLevel->blockSignals(false);
+// // Also update controls
+// m_base->saRefLevel->blockSignals(true);
+// m_base->saRefLevel->setFloatValue(m_voltsDiv);
+// m_base->saRefLevel->blockSignals(false);
}
void ScopePart::saRefLevelChanged(double newval) {
- if (m_commHandlerMode < 2) {
- m_rpower = newval;
- m_commHandlerMode = 1;
- m_commHandlerCommandState = 1;
- mainEventLoop();
- }
+// if (m_commHandlerMode < 2) {
+// m_voltsDiv = newval;
+// m_commHandlerMode = 1;
+// m_commHandlerCommandState = 1;
+// mainEventLoop();
+// }
}
KAboutData* ScopePart::createAboutData() {
diff --git a/clients/tde/src/part/scope/part.h b/clients/tde/src/part/scope/part.h
index 2a988da..55c20c0 100644
--- a/clients/tde/src/part/scope/part.h
+++ b/clients/tde/src/part/scope/part.h
@@ -11,6 +11,8 @@
#include <tqtrla.h>
+#define MAXTRACES 255
+
class KAboutData;
using KParts::StatusBarExtension;
class TraceWidget;
@@ -59,15 +61,16 @@ namespace RemoteLab
TQTimer* m_updateTimeoutTimer;
bool m_connectionActiveAndValid;
unsigned char m_tickerState;
- TQ_INT16 m_samplesInTrace;
- double m_leftFrequency;
- double m_rightFrequency;
+ TQ_INT16 m_maxNumberOfTraces;
+ TQ_INT32 m_currentOpChannel;
+ TQ_INT32 m_nextOpChannel;
+ TQ_INT16 m_nextOpParameter16;
TQ_INT16 m_hdivs;
TQ_INT16 m_vdivs;
- double m_centerfreq;
- double m_spanfreq;
- double m_rpower;
- double m_vscale;
+ TQ_INT32 m_samplesInTrace[MAXTRACES+1];
+ bool m_channelActive[MAXTRACES+1];
+ double m_voltsDiv[MAXTRACES+1];
+ double m_secsDiv[MAXTRACES+1];
ScopeBase* m_base;
TQMutex* m_instrumentMutex;
bool stopTraceUpdate;