diff options
| author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-14 17:13:49 -0500 | 
|---|---|---|
| committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-14 17:13:49 -0500 | 
| commit | c50fa83bfd137b6b5aa7f9c1e4c310ddde75e585 (patch) | |
| tree | 9a930f79f16690d94244815d4b2e36d68b94dd6a /servers/gpib_server_lin/src/scope_functions.cpp | |
| parent | fe06492794c15013e4511d1fcd623b0234c21afe (diff) | |
| download | ulab-c50fa83bfd137b6b5aa7f9c1e4c310ddde75e585.tar.gz ulab-c50fa83bfd137b6b5aa7f9c1e4c310ddde75e585.zip | |
Add profiling to scope trace grabber
Diffstat (limited to 'servers/gpib_server_lin/src/scope_functions.cpp')
| -rw-r--r-- | servers/gpib_server_lin/src/scope_functions.cpp | 36 | 
1 files changed, 36 insertions, 0 deletions
| diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp index abfc9e4..b0571d6 100644 --- a/servers/gpib_server_lin/src/scope_functions.cpp +++ b/servers/gpib_server_lin/src/scope_functions.cpp @@ -32,6 +32,8 @@  #include "gpib_functions.h"  #include "gpib/ib.h" +#include <time.h> +  #include <tqimage.h>  extern char falpha[1024]; @@ -602,11 +604,21 @@ 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 array_pointer;  	long ai; +#ifdef ENABLE_PROFILING +struct timespec tp1, tp2, tp3, tp4, tp5, tp6, tp7; +#endif + +#ifdef ENABLE_PROFILING +clock_gettime(CLOCK_REALTIME, &tp1); +#endif +  	// Send request  	printf("[INFO] Getting oscilloscope trace for channel %d [Stage 1]\n\r", desired_channel);  	if (strcmp("HP54600OS", scopeType) == 0) { @@ -621,11 +633,19 @@ 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) { +#ifdef ENABLE_PROFILING +clock_gettime(CLOCK_REALTIME, &tp2); +printf("[PROFILE] %f s\n\r", ((tp2.tv_nsec+(tp2.tv_sec*1e9))-(tp1.tv_nsec+(tp1.tv_sec*1e9)))/1e9); +#endif  			sprintf(falpha,"WFMPRE?");  			#ifdef ENABLE_EXTRA_DEBUGGING  			printf("[DEBG] Writing: %s\n\r", falpha);  			#endif  			if (gpib_write(gpibDevice, falpha) == 0) { +#ifdef ENABLE_PROFILING +clock_gettime(CLOCK_REALTIME, &tp3); +printf("[PROFILE] %f s\n\r", ((tp3.tv_nsec+(tp3.tv_sec*1e9))-(tp2.tv_nsec+(tp2.tv_sec*1e9)))/1e9); +#endif  				// Read response  				#ifdef ENABLE_EXTRA_DEBUGGING  				printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535); @@ -638,6 +658,10 @@ int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpi  					#ifdef ENABLE_EXTRA_DEBUGGING  					printf("[DEBG] Read %li bytes from GPIB device\n", ai);  					#endif +#ifdef ENABLE_PROFILING +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);  					TQStringList resultPairs = TQStringList::split(";", preamble, FALSE);  					// Find/initialize critical data values @@ -663,6 +687,10 @@ 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) { +#ifdef ENABLE_PROFILING +clock_gettime(CLOCK_REALTIME, &tp5); +printf("[PROFILE] %f s\n\r", ((tp5.tv_nsec+(tp5.tv_sec*1e9))-(tp4.tv_nsec+(tp4.tv_sec*1e9)))/1e9); +#endif  						#ifdef ENABLE_EXTRA_DEBUGGING  						printf("[DEBG] Trying to read %i bytes from GPIB device...\n", 65535*2);  						#endif @@ -671,6 +699,10 @@ int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpi  							return -1;  						}  						else { +#ifdef ENABLE_PROFILING +clock_gettime(CLOCK_REALTIME, &tp6); +printf("[PROFILE] %f s\n\r", ((tp6.tv_nsec+(tp6.tv_sec*1e9))-(tp5.tv_nsec+(tp5.tv_sec*1e9)))/1e9); +#endif  							#ifdef ENABLE_EXTRA_DEBUGGING  							printf("[DEBG] Read %li bytes from GPIB device\n", ai);  							#endif @@ -701,6 +733,10 @@ int scope_get_channel_trace(int desired_channel, const char * scopeType, int gpi  			return -2;  		} +#ifdef ENABLE_PROFILING +clock_gettime(CLOCK_REALTIME, &tp7); +printf("[PROFILE] %f s\n\r", ((tp7.tv_nsec+(tp7.tv_sec*1e9))-(tp6.tv_nsec+(tp6.tv_sec*1e9)))/1e9); +#endif  		return array_pointer;  	}  	else { | 
