diff options
-rw-r--r-- | lib/libtqtrla/src/tqtrla.cpp | 50 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/gpib_conn.cpp | 3 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.cpp | 61 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.h | 2 |
4 files changed, 43 insertions, 73 deletions
diff --git a/lib/libtqtrla/src/tqtrla.cpp b/lib/libtqtrla/src/tqtrla.cpp index b3fc1ec..711804e 100644 --- a/lib/libtqtrla/src/tqtrla.cpp +++ b/lib/libtqtrla/src/tqtrla.cpp @@ -326,30 +326,9 @@ TQDataStream &operator<<( TQDataStream &s, const TQFloatArray &data ) { TQ_UINT32 i; TQ_UINT32 count = data.count(); s << count; - - TQIODevice* dev = s.device(); - if (dev) { - // This uses the channel efficiently by writing all the data in one large block - TQBuffer ba; - ba.open(IO_ReadWrite); - TQDataStream ds(&ba); - ds.setPrintableData(s.isPrintableData()); - - for (i=0; i<count; i++) { - ds << data[i]; - } - - ba.close(); - TQByteArray buffer = ba.buffer(); - dev->writeBlock(buffer.data(), buffer.size()); - } - else { - // This uses the channel inefficiently by writing the data in byte-sized chunks - for (i=0; i<count; i++) { - s << data[i]; - } + for (i=0; i<count; i++) { + s << data[i]; } - return s; } @@ -368,30 +347,9 @@ TQDataStream &operator<<( TQDataStream &s, const TQDoubleArray &data ) { TQ_UINT32 i; TQ_UINT32 count = data.count(); s << count; - - TQIODevice* dev = s.device(); - if (dev) { - // This uses the channel efficiently by writing all the data in one large block - TQBuffer ba; - ba.open(IO_ReadWrite); - TQDataStream ds(&ba); - ds.setPrintableData(s.isPrintableData()); - - for (i=0; i<count; i++) { - ds << data[i]; - } - - ba.close(); - TQByteArray buffer = ba.buffer(); - dev->writeBlock(buffer.data(), buffer.size()); - } - else { - // This uses the channel inefficiently by writing the data in byte-sized chunks - for (i=0; i<count; i++) { - s << data[i]; - } + for (i=0; i<count; i++) { + s << data[i]; } - return s; } diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp index 6837725..6df70ec 100644 --- a/servers/gpib_server_lin/src/gpib_conn.cpp +++ b/servers/gpib_server_lin/src/gpib_conn.cpp @@ -291,7 +291,7 @@ void GPIBSocket::commandLoop() { TQ_INT32 traceLength; traceLength = scope_get_channel_trace(value, m_serverParent->m_scopeType.ascii(), m_serverParent->m_scopeDeviceSocket); if (traceLength > 0) { - int i; + long i; TQDoubleArray traceData; TQDoubleArray positionData; traceData.resize(traceLength); @@ -300,6 +300,7 @@ 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; diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp index fb7d9a1..68f2274 100644 --- a/servers/gpib_server_lin/src/scope_functions.cpp +++ b/servers/gpib_server_lin/src/scope_functions.cpp @@ -41,6 +41,8 @@ unsigned char scope_raw_screenshot_data[4194304]; double scope_raw_trace_data[65535]; double scope_raw_position_data[65535]; +char scope_segarray[4194304]; + unsigned long scopeScreenWidth (const char * scopeType) { if (strcmp("HP54600OS", scopeType) == 0) { return 512; @@ -79,7 +81,6 @@ unsigned long scopeScreenSize (const char * scopeType) { int gpib_read_binblock(int ud, int max_num_bytes, const char * scopeType) { - char segarray[4194304]; long array_pointer; long ai; @@ -95,7 +96,7 @@ int gpib_read_binblock(int ud, int max_num_bytes, const char * scopeType) ibtmo(ud, T30s); ibeos(ud, 0x0); - ai = gpib_read_array(ud, max_num_bytes, segarray); + ai = gpib_read_array(ud, max_num_bytes, scope_segarray); if (ai == -1) { return 1; } @@ -104,14 +105,14 @@ int gpib_read_binblock(int ud, int max_num_bytes, const char * scopeType) ai = 0; for (x=0;x<scopeScreenWidth(scopeType);x++) { for (y=0;y<scopeScreenHeight(scopeType);y++) { - if ((x & 0x7) == 0) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x80) << 0; - if ((x & 0x7) == 1) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x40) << 1; - if ((x & 0x7) == 2) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x20) << 2; - if ((x & 0x7) == 3) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x10) << 3; - if ((x & 0x7) == 4) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x08) << 4; - if ((x & 0x7) == 5) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x04) << 5; - if ((x & 0x7) == 6) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x02) << 6; - if ((x & 0x7) == 7) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (segarray[((x >> 3)+(y*(560/8)))+17] & 0x01) << 7; + if ((x & 0x7) == 0) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x80) << 0; + if ((x & 0x7) == 1) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x40) << 1; + if ((x & 0x7) == 2) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x20) << 2; + if ((x & 0x7) == 3) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x10) << 3; + if ((x & 0x7) == 4) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x08) << 4; + if ((x & 0x7) == 5) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x04) << 5; + if ((x & 0x7) == 6) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x02) << 6; + if ((x & 0x7) == 7) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = (scope_segarray[((x >> 3)+(y*(560/8)))+17] & 0x01) << 7; if (scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] == 0x0) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = 255; if (scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] == 0x80) scope_raw_screenshot_data[y+(x*scopeScreenHeight(scopeType))] = 0; } @@ -606,8 +607,7 @@ int scope_perform_initial_setup(const char * scopeType, int gpibDevice) { #define ENABLE_PROFILING -int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice) { - char segarray[4194304]; +long scope_get_channel_trace(int desired_channel, const char * scopeType, int gpibDevice) { long array_pointer; long ai; @@ -657,7 +657,7 @@ printf("[PROFILE] %f s\n\r", ((tp3.tv_nsec+(tp3.tv_sec*1e9))-(tp2.tv_nsec+(tp2.t #ifdef ENABLE_EXTRA_DEBUGGING printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535); #endif - ai = gpib_read_array(gpibDevice, 65535, segarray); + ai = gpib_read_array(gpibDevice, 65535, scope_segarray); if (ai == -1) { return -1; } @@ -669,16 +669,16 @@ printf("[PROFILE] %f s\n\r", ((tp3.tv_nsec+(tp3.tv_sec*1e9))-(tp2.tv_nsec+(tp2.t clock_gettime(CLOCK_REALTIME, &tp4); printf("[PROFILE] %f s\n\r", ((tp4.tv_nsec+(tp4.tv_sec*1e9))-(tp3.tv_nsec+(tp3.tv_sec*1e9)))/1e9); #endif - TQString preamble(segarray); + TQString preamble(scope_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; + double ymult = 0; + double yoffset = 0; + double yposition = 0; + char* yunits = NULL; + double xincr = 0; + double xposition = 0; + char* xunits = NULL; if (resultPairs.count() > 15) { ymult = resultPairs[13].toDouble(); @@ -690,6 +690,14 @@ printf("[PROFILE] %f s\n\r", ((tp4.tv_nsec+(tp4.tv_sec*1e9))-(tp3.tv_nsec+(tp3.t xunits = strdup(resultPairs[8]); } + // If the units are desired, comment out these lines... + if (yunits) { + free(yunits); + } + if (xunits) { + free(xunits); + } + // Get the curve data now sprintf(falpha,"CURVE?"); #ifdef ENABLE_EXTRA_DEBUGGING @@ -703,7 +711,7 @@ printf("[PROFILE] %f s\n\r", ((tp5.tv_nsec+(tp5.tv_sec*1e9))-(tp4.tv_nsec+(tp4.t #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); + ai = gpib_read_array(gpibDevice, 65535*2, scope_segarray); if (ai == -1) { return -1; } @@ -718,10 +726,14 @@ printf("[PROFILE] %f s\n\r", ((tp6.tv_nsec+(tp6.tv_sec*1e9))-(tp5.tv_nsec+(tp5.t // Interpret the results long pointCount = ai/2; double horizPos = 0.0; + char yheaderlen[2]; + yheaderlen[0] = scope_segarray[1]; + yheaderlen[1] = 0; + int data_offset = atoi(yheaderlen) + 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 + tempvalue = scope_segarray[(array_pointer*2)+1+data_offset]; // LSB + tempvalue = tempvalue | (scope_segarray[(array_pointer*2)+0+data_offset] << 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; @@ -925,7 +937,6 @@ int scope_get_channel_seconds_div(double * retval, int desired_channel, const ch else { floatstring[ai]=0; *retval = ((atof(floatstring)*xincr)/scope_get_number_of_vertical_divisions(scopeType, gpibDevice)); -printf("[RAJA DEBUG 650.0] nr_p: %f, xincr: %E, vert_divs: %d, s/div: %f\n\r", atof(floatstring), xincr, scope_get_number_of_vertical_divisions(scopeType, gpibDevice), *retval); fflush(stdout); } #ifdef ENABLE_EXTRA_DEBUGGING diff --git a/servers/gpib_server_lin/src/scope_functions.h b/servers/gpib_server_lin/src/scope_functions.h index 2c0bcd1..4549b80 100644 --- a/servers/gpib_server_lin/src/scope_functions.h +++ b/servers/gpib_server_lin/src/scope_functions.h @@ -40,7 +40,7 @@ int scope_get_channel_state(int * retval, int desired_channel, const char * scop 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); +long 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); |