summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--servers/gpib_server_lin/src/gpib_conn.cpp136
-rw-r--r--servers/gpib_server_lin/src/scope_functions.cpp519
-rw-r--r--servers/gpib_server_lin/src/scope_functions.h12
6 files changed, 701 insertions, 268 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;
diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp
index c0d43ca..6837725 100644
--- a/servers/gpib_server_lin/src/gpib_conn.cpp
+++ b/servers/gpib_server_lin/src/gpib_conn.cpp
@@ -263,7 +263,17 @@ void GPIBSocket::commandLoop() {
if (m_instrumentCommand != "") {
if (m_activeDeviceType == 2) {
// Oscilloscope
- if (m_instrumentCommand == "SETHORIZTIMEBASE") { // Want to change horizontal timebase
+ if (m_instrumentCommand == "RESET") { // Want to reset scope
+ if (scope_reset(m_serverParent->m_funcgenType.ascii(), m_serverParent->m_funcgenDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");;
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "SETHORIZTIMEBASE") { // Want to change horizontal timebase
double value;
ds >> value;
if (scope_set_timebase(value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
@@ -282,13 +292,17 @@ void GPIBSocket::commandLoop() {
traceLength = scope_get_channel_trace(value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
if (traceLength > 0) {
int i;
- TQFloatArray traceData;
+ TQDoubleArray traceData;
+ TQDoubleArray positionData;
traceData.resize(traceLength);
+ positionData.resize(traceLength);
for (i=0; i<traceLength; i++) {
traceData[i] = scope_raw_trace_data[i];
+ positionData[i] = scope_raw_position_data[i];
}
ds << TQString("ACK");
ds << traceData;
+ ds << positionData;
writeEndOfFrame();
}
else {
@@ -310,6 +324,49 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else if (m_instrumentCommand == "GETVOLTSDIV") { // Want to get volts per division
+ double voltsdiv;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_volts_div(&voltsdiv, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ ds << voltsdiv;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETSECONDSSDIV") { // Want to get seconds per division
+ double secondsdiv;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_seconds_div(&secondsdiv, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ ds << secondsdiv;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETTRACESAMPLECOUNT") { // Want to get number of samples in the trace
+ unsigned long samples;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_sample_count(&samples, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ ds << TQString("ACK");
+ TQ_INT32 safeSamples = samples;
+ ds << safeSamples;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
else if (m_instrumentCommand == "SETRUNNING") { // Want to change run status
TQ_INT32 value;
ds >> value;
@@ -325,7 +382,7 @@ void GPIBSocket::commandLoop() {
else if (m_instrumentCommand == "SETCHANNELACTIVE") { // Want to change channel enable
TQ_INT32 value1;
ds >> value1;
- TQ_INT32 value2;
+ TQ_INT16 value2;
ds >> value2;
if (scope_set_channel_state(value1, value2, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
ds << TQString("ACK");
@@ -374,6 +431,60 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else if (m_instrumentCommand == "GETHORIZONTALDIVCOUNT") { // Want the number of horizontal divisions available
+ TQ_INT16 divisions = scope_get_number_of_vertical_divisions(m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
+ if (divisions >= 0) {
+ ds << TQString("ACK");
+ ds << divisions;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETVERTICALDIVCOUNT") { // Want the number of vertical divisions available
+ TQ_INT16 divisions = scope_get_number_of_horizontal_divisions(m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
+ if (divisions >= 0) {
+ ds << TQString("ACK");
+ ds << divisions;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETNUMBEROFCHANNELS") { // Want the number of channels available
+ TQ_INT16 divisions = scope_get_number_of_channels(m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket);
+ if (divisions >= 0) {
+ ds << TQString("ACK");
+ ds << divisions;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "GETCHANNELACTIVE") { // Want to get channel activity
+ int state;
+ TQ_INT32 value;
+ ds >> value;
+ if (scope_get_channel_state(&state, value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) {
+ TQ_INT16 safeState = state;
+ ds << TQString("ACK");
+ ds << safeState;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else {
+ printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
+ }
}
else if (m_activeDeviceType == 3) {
// Function generator
@@ -476,6 +587,9 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else {
+ printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
+ }
}
else if (m_activeDeviceType == 4) {
// Communications analyzer
@@ -714,8 +828,8 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
- else if (m_instrumentCommand == "GETVERTICALDIVCOUNT") { // Want the number of vertical divisions available
- TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_vertical_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
+ else if (m_instrumentCommand == "GETHORIZONTALDIVCOUNT") { // Want the number of horizontal divisions available
+ TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_horizontal_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
if (divisions >= 0) {
ds << TQString("ACK");
ds << divisions;
@@ -726,8 +840,8 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
- else if (m_instrumentCommand == "GETTRACESAMPLECOUNT") { // Want the number of samples in a trace
- TQ_INT16 divisions = commanalyzerTraceLength(m_serverParent->m_commanalyzerType.ascii());
+ else if (m_instrumentCommand == "GETVERTICALDIVCOUNT") { // Want the number of vertical divisions available
+ TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_vertical_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
if (divisions >= 0) {
ds << TQString("ACK");
ds << divisions;
@@ -738,8 +852,8 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
- else if (m_instrumentCommand == "GETHORIZONTALDIVCOUNT") { // Want the number of horizontal divisions available
- TQ_INT16 divisions = commanalyzer_get_spectrum_analyzer_number_of_horizontal_divisions(m_serverParent->m_commanalyzerType.ascii(), m_serverParent->m_commanalyzerDeviceSocket);
+ else if (m_instrumentCommand == "GETTRACESAMPLECOUNT") { // Want the number of samples in a trace
+ TQ_INT16 divisions = commanalyzerTraceLength(m_serverParent->m_commanalyzerType.ascii());
if (divisions >= 0) {
ds << TQString("ACK");
ds << divisions;
@@ -798,6 +912,9 @@ void GPIBSocket::commandLoop() {
writeEndOfFrame();
}
}
+ else {
+ printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
+ }
}
else {
// Unknown
@@ -970,6 +1087,7 @@ int GPIBServer::readConfig() {
printf("[INFO] %s\n\r", timebuffer);
if (gpib_write(m_scopeDeviceSocket, timebuffer) == 0) {
gpib_write(m_scopeDeviceSocket, datebuffer);
+ scope_perform_initial_setup(m_scopeType.ascii(), m_scopeDeviceSocket);
printf("[INFO] Communication verified\n\r");
}
else {
diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp
index dc6bf5f..abfc9e4 100644
--- a/servers/gpib_server_lin/src/scope_functions.cpp
+++ b/servers/gpib_server_lin/src/scope_functions.cpp
@@ -37,6 +37,7 @@
extern char falpha[1024];
unsigned char scope_raw_screenshot_data[4194304];
double scope_raw_trace_data[65535];
+double scope_raw_position_data[65535];
unsigned long scopeScreenWidth (const char * scopeType) {
if (strcmp("HP54600OS", scopeType) == 0) {
@@ -175,6 +176,11 @@ int scope_get_screenshot_stage2(const char * scopeType, int gpibDevice) {
return 1;
}
+int scope_reset(const char * funcgenType, int gpibDevice) {
+ // FIXME
+ // GNDN
+ return 0;
+}
int scope_get_screenshot(const char * scopeType, int gpibDevice) {
if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) {
@@ -255,6 +261,9 @@ int scope_set_timebase(float desired_timebase,const char * scopeType, int gpibDe
return 2;
}
}
+ else {
+ return -1;
+ }
}
else {
return 1;
@@ -288,6 +297,9 @@ int scope_set_volts_div(int desired_channel, float desired_volts,const char * sc
return 2;
}
}
+ else {
+ return -1;
+ }
}
else {
return 1;
@@ -326,6 +338,9 @@ int scope_set_acquisition(int status,const char * scopeType, int gpibDevice) {
return 2;
}
}
+ else {
+ return -1;
+ }
}
else {
return 1;
@@ -375,12 +390,63 @@ int scope_set_channel_state(int desired_channel, int status,const char * scopeTy
return 2;
}
}
+ else {
+ return -1;
+ }
}
else {
return 1;
}
}
+int scope_get_channel_state(int * retval, int desired_channel, const char * scopeType, int gpibDevice) {
+ char floatstring[1024];
+ long ai;
+ int max_num_bytes = 0;
+
+ printf("[INFO] Getting channel %d state\n\r", desired_channel);
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ sprintf(falpha, "SELECT:CH%d?", desired_channel);
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ max_num_bytes = 24; // Request more bytes than are possible to ensure no bytes are left behind
+ }
+ else {
+ return 2;
+ }
+
+ // Read response
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
+ #endif
+
+ ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
+ if (ai == -1) {
+ return 1;
+ }
+ else {
+ floatstring[ai]=0;
+ *retval = atoi(floatstring);
+ }
+
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
int scope_set_trigger_channel(int desired_channel,const char * scopeType, int gpibDevice) {
if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) {
printf("[INFO] Setting scope trigger channel to %d\n\r", desired_channel);
@@ -408,6 +474,9 @@ int scope_set_trigger_channel(int desired_channel,const char * scopeType, int gp
return 2;
}
}
+ else {
+ return -1;
+ }
}
else {
return 1;
@@ -441,6 +510,9 @@ int scope_set_trigger_level(float desired_level,const char * scopeType, int gpib
return 2;
}
}
+ else {
+ return -1;
+ }
}
else {
return 1;
@@ -474,21 +546,66 @@ int scope_set_channel_position(int desired_channel, float desired_level,const ch
return 2;
}
}
+ else {
+ return -1;
+ }
}
else {
return 1;
}
}
-int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice) {
- int max_num_bytes = 0;
+int scope_perform_initial_setup(const char * scopeType, int gpibDevice) {
+ // Send request
+ printf("[INFO] Configuring oscilloscope\n\r");
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ sprintf(falpha,"DATA:ENCDG RIBINARY");
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ sprintf(falpha,"DATA:WIDTH 2");
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ sprintf(falpha,"DATA:START 1");
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ sprintf(falpha,"DATA:STOP 65535");
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ return 0;
+ }
+ else {
+ return -2;
+ }
+ }
+ else {
+ return -2;
+ }
+ }
+ else {
+ return -2;
+ }
+ }
+ else {
+ return -1;
+ }
+}
+int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice) {
char segarray[4194304];
- char floatstring[1024];
long array_pointer;
long ai;
- long left_char;
- long right_char;
// Send request
printf("[INFO] Getting oscilloscope trace for channel %d [Stage 1]\n\r", desired_channel);
@@ -504,132 +621,77 @@ int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpi
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
- sprintf(falpha,"DATA:ENCDG RIBINARY");
+ sprintf(falpha,"WFMPRE?");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
- sprintf(falpha,"DATA:WIDTH 2");
+ // Read response
#ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Writing: %s\n\r", falpha);
+ printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535);
#endif
- if (gpib_write(gpibDevice, falpha) == 0) {
- sprintf(falpha,"DATA:START 1");
+ ai = gpib_read_array(gpibDevice, 65535, segarray);
+ if (ai == -1) {
+ return -1;
+ }
+ else {
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+ TQString preamble(segarray);
+ TQStringList resultPairs = TQStringList::split(";", preamble, FALSE);
+ // Find/initialize critical data values
+ double ymult;
+ double yoffset;
+ double yposition;
+ const char* yunits;
+ double xincr;
+ double xposition;
+ const char* xunits;
+
+ ymult = resultPairs[13].toDouble();
+ yoffset = resultPairs[14].toDouble()*ymult;
+ yposition = resultPairs[15].toDouble()*ymult;
+ yunits = strdup(resultPairs[12]);
+ xincr = resultPairs[9].toDouble();
+ xposition = resultPairs[10].toDouble();
+ xunits = strdup(resultPairs[8]);
+
+ // Get the curve data now
+ sprintf(falpha,"CURVE?");
#ifdef ENABLE_EXTRA_DEBUGGING
printf("[DEBG] Writing: %s\n\r", falpha);
#endif
if (gpib_write(gpibDevice, falpha) == 0) {
- sprintf(falpha,"DATA:STOP 65535");
#ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Writing: %s\n\r", falpha);
+ printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535*2);
#endif
- if (gpib_write(gpibDevice, falpha) == 0) {
- sprintf(falpha,"WFMPRE?");
+ ai = gpib_read_array(gpibDevice, 65535*2, segarray);
+ if (ai == -1) {
+ return -1;
+ }
+ else {
#ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Writing: %s\n\r", falpha);
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
#endif
- if (gpib_write(gpibDevice, falpha) == 0) {
- // Read response
- #ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535);
- #endif
- ai = gpib_read_array(gpibDevice, 65535, segarray);
- if (ai == -1) {
- return -1;
- }
- else {
- #ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Read %li bytes from GPIB device\n", ai);
- #endif
- TQString preamble(segarray);
- TQStringList resultPairs = TQStringList::split(";", preamble, FALSE);
- // Find/initialize critical data values
- double ymult;
- double yoffset;
- double yposition;
- const char* yunits;
- double xincr;
- double xposition;
- const char* xunits;
- for (TQStringList::Iterator it = resultPairs.begin(); it != resultPairs.end(); ++it) {
- TQString curVal = *it;
- if (curVal.startsWith("YMULT ")) {
- curVal.replace("YMULT ", "");
- ymult = curVal.toDouble();
- }
- else if (curVal.startsWith("YOFF ")) {
- curVal.replace("YOFF ", "");
- yoffset = curVal.toDouble();
- }
- else if (curVal.startsWith("YZERO ")) {
- curVal.replace("YZERO ", "");
- yposition = curVal.toDouble();
- }
- else if (curVal.startsWith("YUNIT ")) {
- curVal.replace("YUNIT ", "");
- yunits = strdup(curVal.ascii());
- }
- else if (curVal.startsWith("XINCR ")) {
- curVal.replace("XINCR ", "");
- xincr = curVal.toDouble();
- }
- else if (curVal.startsWith("XZERO ")) {
- curVal.replace("XZERO ", "");
- xposition = curVal.toDouble();
- }
- else if (curVal.startsWith("XUNIT ")) {
- curVal.replace("XUNIT ", "");
- xunits = strdup(curVal.ascii());
- }
- }
- // Get the curve data now
- sprintf(falpha,"CURVE?");
- #ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Writing: %s\n\r", falpha);
- #endif
- if (gpib_write(gpibDevice, falpha) == 0) {
- #ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535*2);
- #endif
- ai = gpib_read_array(gpibDevice, 65535*2, segarray);
- if (ai == -1) {
- return -1;
- }
- else {
- #ifdef ENABLE_EXTRA_DEBUGGING
- printf("[DEBG] Read %li bytes from GPIB device\n", ai);
- #endif
- // Interpret the results
- long pointCount = ai/2;
- for (array_pointer=0; array_pointer<pointCount; array_pointer++) {
- TQ_INT16 tempvalue;
- tempvalue = segarray[(array_pointer*2)+1]; // LSB
- tempvalue = tempvalue | (segarray[(array_pointer*2)+0] << 8); // MSB
- scope_raw_trace_data[array_pointer] = tempvalue;
- scope_raw_trace_data[array_pointer] = scope_raw_trace_data[array_pointer] * ymult;
- }
- }
- }
- else {
- return -2;
- }
- }
- }
- else {
- return -2;
+ // Interpret the results
+ long pointCount = ai/2;
+ double horizPos = 0.0;
+ for (array_pointer=0; array_pointer<pointCount; array_pointer++) {
+ TQ_INT16 tempvalue;
+ tempvalue = segarray[(array_pointer*2)+1]; // LSB
+ tempvalue = tempvalue | (segarray[(array_pointer*2)+0] << 8); // MSB
+ scope_raw_trace_data[array_pointer] = tempvalue;
+ scope_raw_trace_data[array_pointer] = (scope_raw_trace_data[array_pointer] * ymult)-yoffset;
+ scope_raw_position_data[array_pointer] = horizPos;
+ horizPos = horizPos + xincr;
}
}
- else {
- return -2;
- }
}
else {
return -2;
}
}
- else {
- return -2;
- }
}
else {
return -2;
@@ -641,4 +703,241 @@ int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpi
return array_pointer;
}
+ else {
+ return -1;
+ }
+}
+
+int scope_get_number_of_horizontal_divisions(const char * scopeType, int gpibDevice) {
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ return 8;
+ }
+ else {
+ return -1;
+ }
+}
+
+int scope_get_number_of_vertical_divisions(const char * scopeType, int gpibDevice) {
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ return 10;
+ }
+ else {
+ return -1;
+ }
+}
+
+int scope_get_number_of_channels(const char * scopeType, int gpibDevice) {
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ return 2;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ return 4;
+ }
+ else {
+ return -1;
+ }
+}
+
+int scope_get_channel_volts_div(double * retval, int desired_channel, const char * scopeType, int gpibDevice) {
+ char floatstring[1024];
+ long ai;
+ int max_num_bytes = 0;
+
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ // Send request
+ printf("[INFO] Getting scope volts per division for channel %d\n\r", desired_channel);
+ sprintf(falpha,"CH%d:SCALE?", desired_channel);
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ max_num_bytes = 24; // Request more bytes than are possible to ensure no bytes are left behind
+ }
+ else {
+ return 2;
+ }
+
+ // Read response
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
+ #endif
+
+ ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
+ if (ai == -1) {
+ return 1;
+ }
+ else {
+ floatstring[ai]=0;
+ *retval = atof(floatstring);
+ }
+
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+int scope_get_channel_seconds_div(double * retval, int desired_channel, const char * scopeType, int gpibDevice) {
+ char floatstring[1024];
+ long ai;
+ int max_num_bytes = 0;
+
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ double xincr;
+
+ // Send request
+ printf("[INFO] Getting scope seconds per division for channel %d\n\r", desired_channel);
+ sprintf(falpha,"DATA:SOURCE CH%d", desired_channel);
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) != 0) {
+ return 2;
+ }
+
+ sprintf(falpha,"WFMPRE:CH%d:XINCR?",desired_channel);
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ max_num_bytes = 24; // Request more bytes than are possible to ensure no bytes are left behind
+ }
+ else {
+ return 2;
+ }
+
+ // Read response
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
+ #endif
+
+ ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
+ if (ai == -1) {
+ return 1;
+ }
+ else {
+ floatstring[ai]=0;
+ xincr = atof(floatstring);
+ }
+
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+
+ sprintf(falpha,"WFMPRE:CH%d:NR_P?", desired_channel);
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ max_num_bytes = 24; // Request more bytes than are possible to ensure no bytes are left behind
+ }
+ else {
+ return 2;
+ }
+
+ // Read response
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
+ #endif
+
+ ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
+ if (ai == -1) {
+ return 1;
+ }
+ else {
+ floatstring[ai]=0;
+ *retval = ((atof(floatstring)*xincr)/scope_get_number_of_vertical_divisions(scopeType, gpibDevice));
+ }
+
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+
+ return 0;
+ }
+ else {
+ return -1;
+ }
+}
+
+int scope_get_channel_sample_count(unsigned long * retval, int desired_channel, const char * scopeType, int gpibDevice) {
+ char floatstring[1024];
+ long ai;
+ int max_num_bytes = 0;
+
+ if (strcmp("HP54600OS", scopeType) == 0) {
+ // FIXME
+ // Not supported (yet)
+ return -1;
+ }
+ else if (strcmp("TDS744AOS", scopeType) == 0) {
+ // Send request
+ printf("[INFO] Getting number of samples in trace for channel %d\n\r", desired_channel);
+ sprintf(falpha,"DATA:SOURCE CH%d", desired_channel);
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) != 0) {
+ return 2;
+ }
+
+ sprintf(falpha,"WFMPRE:CH%d:NR_P?", desired_channel);
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Writing: %s\n\r", falpha);
+ #endif
+ if (gpib_write(gpibDevice, falpha) == 0) {
+ max_num_bytes = 24; // Request more bytes than are possible to ensure no bytes are left behind
+ }
+ else {
+ return 2;
+ }
+
+ // Read response
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes);
+ #endif
+
+ ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring);
+ if (ai == -1) {
+ return 1;
+ }
+ else {
+ floatstring[ai]=0;
+ *retval = atof(floatstring);
+ }
+
+ #ifdef ENABLE_EXTRA_DEBUGGING
+ printf("[DEBG] Read %li bytes from GPIB device\n", ai);
+ #endif
+
+ return 0;
+ }
+ else {
+ return -1;
+ }
} \ No newline at end of file
diff --git a/servers/gpib_server_lin/src/scope_functions.h b/servers/gpib_server_lin/src/scope_functions.h
index fbab514..2c0bcd1 100644
--- a/servers/gpib_server_lin/src/scope_functions.h
+++ b/servers/gpib_server_lin/src/scope_functions.h
@@ -22,18 +22,28 @@
extern unsigned char scope_raw_screenshot_data[4194304];
extern double scope_raw_trace_data[65535];
+extern double scope_raw_position_data[65535];
unsigned long scopeScreenSize (const char * scopeType);
unsigned long scopeScreenWidth (const char * scopeType);
unsigned long scopeScreenHeight (const char * scopeType);
int gpib_read_binary(int ud, int max_num_bytes);
+int scope_reset(const char * funcgenType, int gpibDevice);
int scope_get_screenshot(const char * scopeType, int gpibDevice);
int scope_get_screenshot_stage2(const char * scopeType, int gpibDevice);
+int scope_perform_initial_setup(const char * scopeType, int gpibDevice);
int scope_set_timebase(float desired_timebase,const char * scopeType, int gpibDevice);
int scope_set_volts_div(int desired_channel, float desired_volts,const char * scopeType, int gpibDevice);
int scope_set_acquisition(int status,const char * scopeType, int gpibDevice);
int scope_set_channel_state(int desired_channel, int status,const char * scopeType, int gpibDevice);
+int scope_get_channel_state(int * retval, int desired_channel, const char * scopeType, int gpibDevice);
int scope_set_trigger_channel(int desired_channel,const char * scopeType, int gpibDevice);
int scope_set_trigger_level(float desired_level,const char * scopeType, int gpibDevice);
int scope_set_channel_position(int desired_channel, float desired_level,const char * scopeType, int gpibDevice);
-int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice); \ No newline at end of file
+int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice);
+int scope_get_number_of_horizontal_divisions(const char * scopeType, int gpibDevice);
+int scope_get_number_of_vertical_divisions(const char * scopeType, int gpibDevice);
+int scope_get_number_of_channels(const char * scopeType, int gpibDevice);
+int scope_get_channel_volts_div(double * retval, int desired_channel, const char * scopeType, int gpibDevice);
+int scope_get_channel_seconds_div(double * retval, int desired_channel, const char * scopeType, int gpibDevice);
+int scope_get_channel_sample_count(unsigned long * retval, int desired_channel, const char * scopeType, int gpibDevice); \ No newline at end of file