diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-16 23:57:45 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-16 23:57:45 -0500 |
commit | 192a06da8df1bf95e96d77d2fa0736bb7d2fe58b (patch) | |
tree | 82a7cbffa7f7e18b39f13a76bdbfa9ea6a378c54 /servers/gpib_server_lin/src | |
parent | 9c5e2aa99427fe125c631d4753b1f944992d8c03 (diff) | |
download | ulab-192a06da8df1bf95e96d77d2fa0736bb7d2fe58b.tar.gz ulab-192a06da8df1bf95e96d77d2fa0736bb7d2fe58b.zip |
Add trigger display
Diffstat (limited to 'servers/gpib_server_lin/src')
-rw-r--r-- | servers/gpib_server_lin/src/gpib_conn.cpp | 28 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.cpp | 105 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.h | 2 |
3 files changed, 133 insertions, 2 deletions
diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp index 6df70ec..b46f469 100644 --- a/servers/gpib_server_lin/src/gpib_conn.cpp +++ b/servers/gpib_server_lin/src/gpib_conn.cpp @@ -300,7 +300,6 @@ void GPIBSocket::commandLoop() { traceData[i] = scope_raw_trace_data[i]; positionData[i] = scope_raw_position_data[i]; } -printf("[RAJA DEBUG 680.0] traceData[10]: %E positionData[10]: %E\n\r", traceData[10], positionData[10]); fflush(stdout); ds << TQString("ACK"); ds << traceData; ds << positionData; @@ -395,7 +394,7 @@ printf("[RAJA DEBUG 680.0] traceData[10]: %E positionData[10]: %E\n\r", traceDat } } else if (m_instrumentCommand == "SETTRIGGERCHANNEL") { // Want to change trigger channel - TQ_INT32 value; + TQ_INT16 value; ds >> value; if (scope_set_trigger_channel(value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) { ds << TQString("ACK"); @@ -406,6 +405,19 @@ printf("[RAJA DEBUG 680.0] traceData[10]: %E positionData[10]: %E\n\r", traceDat writeEndOfFrame(); } } + else if (m_instrumentCommand == "GETTRIGGERCHANNEL") { // Want to get trigger channel + int channel; + if (scope_get_trigger_channel(&channel, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) { + TQ_INT16 safeChannel = channel; + ds << TQString("ACK"); + ds << safeChannel; + writeEndOfFrame(); + } + else { + ds << TQString("NCK"); + writeEndOfFrame(); + } + } else if (m_instrumentCommand == "SETTRIGGERLEVEL") { // Want to change trigger level double value; ds >> value; @@ -418,6 +430,18 @@ printf("[RAJA DEBUG 680.0] traceData[10]: %E positionData[10]: %E\n\r", traceDat writeEndOfFrame(); } } + else if (m_instrumentCommand == "GETTRIGGERLEVEL") { // Want to get trigger level + double triggerlevel; + if (scope_get_trigger_level(&triggerlevel, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket) == 0) { + ds << TQString("ACK"); + ds << triggerlevel; + writeEndOfFrame(); + } + else { + ds << TQString("NCK"); + writeEndOfFrame(); + } + } else if (m_instrumentCommand == "SETCHANVERTPOS") { // Want to change channel vertical position TQ_INT32 value1; ds >> value1; diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp index 68f2274..ce5adcd 100644 --- a/servers/gpib_server_lin/src/scope_functions.cpp +++ b/servers/gpib_server_lin/src/scope_functions.cpp @@ -486,6 +486,62 @@ int scope_set_trigger_channel(int desired_channel,const char * scopeType, int gp } } +int scope_get_trigger_channel(int * retval, const char * scopeType, int gpibDevice) { + char floatstring[1024]; + long ai; + int max_num_bytes = 0; + + printf("[INFO] Getting trigger channel\n\r"); + if (strcmp("HP54600OS", scopeType) == 0) { + // FIXME + // Not supported (yet) + return -1; + } + else if (strcmp("TDS744AOS", scopeType) == 0) { + sprintf(falpha, "TRIGGER:MAIN:EDGE:SOURCE?"); + #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; + TQString retchan(floatstring); + if (retchan.startsWith("CH1")) *retval = 1; + else if (retchan.startsWith("CH2")) *retval = 2; + else if (retchan.startsWith("CH3")) *retval = 3; + else if (retchan.startsWith("CH4")) *retval = 4; + else { + *retval = -1; + return -1; + } + } + + #ifdef ENABLE_EXTRA_DEBUGGING + printf("[DEBG] Read %li bytes from GPIB device\n", ai); + #endif + + return 0; + } + else { + return -1; + } +} + int scope_set_trigger_level(float desired_level,const char * scopeType, int gpibDevice) { if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) { printf("[INFO] Setting scope trigger level to %f\n\r", desired_level); @@ -522,6 +578,55 @@ int scope_set_trigger_level(float desired_level,const char * scopeType, int gpib } } +int scope_get_trigger_level(double * retval, 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 trigger level\n\r"); + sprintf(falpha,"TRIGGER:MAIN:LEVEL?"); + #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_set_channel_position(int desired_channel, float desired_level,const char * scopeType, int gpibDevice) { if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) { printf("[INFO] Setting scope channel %d level to %f\n\r", desired_channel, desired_level); diff --git a/servers/gpib_server_lin/src/scope_functions.h b/servers/gpib_server_lin/src/scope_functions.h index 4549b80..b38f821 100644 --- a/servers/gpib_server_lin/src/scope_functions.h +++ b/servers/gpib_server_lin/src/scope_functions.h @@ -44,6 +44,8 @@ long scope_get_channel_trace(int desired_channel, const char * scopeType, int gp 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_trigger_channel(int * retval, const char * scopeType, int gpibDevice); +int scope_get_trigger_level(double * retval, 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 |