Branch: master

305821c2 2015-09-12 19:55:33 Timothy Pearson
Add initial component analyzer capability request support
Fix a couple of minor errors in component analyzer handling
M servers/gpib_server_lin/src/companalyzer_functions.cpp
M servers/gpib_server_lin/src/companalyzer_functions.h
M servers/gpib_server_lin/src/gpib_conn.cpp
diff --git a/servers/gpib_server_lin/src/companalyzer_functions.cpp b/servers/gpib_server_lin/src/companalyzer_functions.cpp
index 4eda333..9a15521 100644
--- a/servers/gpib_server_lin/src/companalyzer_functions.cpp
+++ b/servers/gpib_server_lin/src/companalyzer_functions.cpp
@@ -38,6 +38,8 @@
 extern char falpha[1024];
 double companalyzer_raw_trace_data[1024];
 
+double companalyzer_frequency;
+
 unsigned long companalyzerTraceLength (const char * companalyzerType) {
 	if (strcmp("HP4191A", companalyzerType) == 0) {
 		return 417;
@@ -80,7 +82,8 @@
 			printf("[DEBG] Writing: %s\n\r", timebuffer);
 			#endif
 			if (gpib_write(gpibDevice, timebuffer) == 0) {
-				return 0;
+				char errorbuf[1000];
+				return companalyzer_set_measurement_frequency(1000000, companalyzerType, gpibDevice, errorbuf);
 			}
 			else {
 				return 2;
@@ -200,14 +203,52 @@
 	}
 }
 
+int companalyzer_get_max_measurement_frequency(double * frequency, const char * companalyzerType, int gpibDevice, char * extendedError) {
+	if ((strcmp("HP4191A", companalyzerType) == 0)) {
+		printf("[INFO] Getting maximum component analyzer measurement frequency\n\r");
+		if (strcmp("HP4191A", companalyzerType) == 0) {
+			*frequency = 1000000000;
+			return 0;
+		}
+		else {
+			sprintf(extendedError, "EXTAn invalid device was selected!��");
+			return 1;
+		}
+	}
+	else {
+		sprintf(extendedError, "EXTAn invalid device was selected!��");
+		return 1;
+	}
+}
+
+int companalyzer_get_min_measurement_frequency(double * frequency, const char * companalyzerType, int gpibDevice, char * extendedError) {
+	if ((strcmp("HP4191A", companalyzerType) == 0)) {
+		printf("[INFO] Getting minimum component analyzer measurement frequency\n\r");
+		if (strcmp("HP4191A", companalyzerType) == 0) {
+			*frequency = 1000000;
+			return 0;
+		}
+		else {
+			sprintf(extendedError, "EXTAn invalid device was selected!��");
+			return 1;
+		}
+	}
+	else {
+		sprintf(extendedError, "EXTAn invalid device was selected!��");
+		return 1;
+	}
+}
+
 int companalyzer_set_measurement_frequency(double frequency, const char * companalyzerType, int gpibDevice, char * extendedError) {
 	if ((strcmp("HP4191A", companalyzerType) == 0)) {
 		printf("[INFO] Setting component analyzer measurement frequency to %eMHz\n\r", frequency);
 		if (strcmp("HP4191A", companalyzerType) == 0) {
 			falpha[0] = 0;
-			
-			if ((frequency >= 1.0) && (frequency <= 1000.0)) {
-				sprintf(falpha, "FR%04.04fEN", frequency);
+
+			double adjusted_frequency = frequency / 1000000.0;
+
+			if ((adjusted_frequency >= 1.0) && (adjusted_frequency <= 1000.0)) {
+				sprintf(falpha, "FR%04.04fEN", adjusted_frequency);
 			}
 			if (strlen(falpha) == 0) {
 				sprintf(extendedError, "EXTAn invalid parameter or combination of parameters was requested��");
@@ -218,6 +259,7 @@
 				printf("[DEBG] Writing: %s\n\r", falpha);
 				#endif
 				if (gpib_write(gpibDevice, falpha) == 0) {
+					companalyzer_frequency = frequency;
 					return 0;
 				}
 				else {
@@ -401,6 +443,7 @@
 						measurement.parameter_b_value = parameter_value;
 					}
 				}
+				measurement.frequency = companalyzer_frequency;
 
 				*retval = measurement;
 			}
diff --git a/servers/gpib_server_lin/src/companalyzer_functions.h b/servers/gpib_server_lin/src/companalyzer_functions.h
index e6aad78..53d9f2d 100644
--- a/servers/gpib_server_lin/src/companalyzer_functions.h
+++ b/servers/gpib_server_lin/src/companalyzer_functions.h
@@ -66,6 +66,7 @@
 	companalyzer_measurement_type::companalyzer_measurement_type parameter_b_type;
 	double parameter_a_value;
 	double parameter_b_value;
+	double frequency;
 } companalyzer_measurements_t;
 
 int companalyzer_set_date(struct tm * datetime, const char * companalyzerType, int gpibDevice);
@@ -74,4 +75,6 @@
 
 int companalyzer_set_measurement_parameters(companalyzer_measurement::companalyzer_measurement_t parameter_a, companalyzer_measurement::companalyzer_measurement_t parameter_b, const char * companalyzerType, int gpibDevice, char * extendedError);
 int companalyzer_set_measurement_frequency(double frequency, const char * companalyzerType, int gpibDevice, char * extendedError);
+int companalyzer_get_max_measurement_frequency(double * frequency, const char * companalyzerType, int gpibDevice, char * extendedError);
+int companalyzer_get_min_measurement_frequency(double * frequency, const char * companalyzerType, int gpibDevice, char * extendedError);
 int companalyzer_get_parameter_measurement (companalyzer_measurements_t * retval, const char * companalyzerType, int gpibDevice);
\ No newline at end of file
diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp
index 3e8777f..2e7079d 100644
--- a/servers/gpib_server_lin/src/gpib_conn.cpp
+++ b/servers/gpib_server_lin/src/gpib_conn.cpp
@@ -1037,10 +1037,12 @@
 										ds << (TQ_UINT32&)measurement.parameter_a;
 										ds << (TQ_UINT32&)measurement.parameter_a_type;
 										ds << measurement.parameter_a_value;
+										ds << measurement.frequency;
 										ds << (TQ_UINT32&)measurement.parameter_b_status;
 										ds << (TQ_UINT32&)measurement.parameter_b;
 										ds << (TQ_UINT32&)measurement.parameter_b_type;
 										ds << measurement.parameter_b_value;
+										ds << measurement.frequency;
 										writeEndOfFrame();
 									}
 									else {
@@ -1050,7 +1052,7 @@
 								}
 								else if (m_instrumentCommand == "SETMEASUREDPARAMETERS") {	// Want to set the measured parameters
 									uint8_t all_ok = 1;
-									uint8_t number_of_parameters;
+									TQ_UINT8 number_of_parameters;
 									companalyzer_measurement::companalyzer_measurement_t parameter_a;
 									companalyzer_measurement::companalyzer_measurement_t parameter_b;
 									ds >> number_of_parameters;
@@ -1074,6 +1076,30 @@
 										writeEndOfFrame();
 									}
 								}
+								else if (m_instrumentCommand == "GETMAXMEASUREMENTFREQUENCY") {	// Want to get the maximum supported measurement frequency
+									double frequency;
+									if (companalyzer_get_max_measurement_frequency(&frequency, m_serverParent->m_companalyzerType.ascii(), m_serverParent->m_companalyzerDeviceSocket, errorbuf) == 0) {
+										ds << TQString("ACK");
+										ds << frequency;
+										writeEndOfFrame();
+									}
+									else {
+										ds << TQString(errorbuf);
+										writeEndOfFrame();
+									}
+								}
+								else if (m_instrumentCommand == "GETMINMEASUREMENTFREQUENCY") {	// Want to get the minimum supported measurement frequency
+									double frequency;
+									if (companalyzer_get_min_measurement_frequency(&frequency, m_serverParent->m_companalyzerType.ascii(), m_serverParent->m_companalyzerDeviceSocket, errorbuf) == 0) {
+										ds << TQString("ACK");
+										ds << frequency;
+										writeEndOfFrame();
+									}
+									else {
+										ds << TQString(errorbuf);
+										writeEndOfFrame();
+									}
+								}
 								else if (m_instrumentCommand == "SETMEASUREMENTFREQUENCY") {	// Want to set the measurement frequency
 									double frequency;
 									ds >> frequency;
a4eb3d14 2015-09-12 19:55:59 Timothy Pearson
Merge branch 'master' of https://scm.trinitydesktop.org/scm/git/remotelaboratory
A clients/tde/src/widgets/sevensegment.cpp
A clients/tde/src/widgets/sevensegment.h
M clients/tde/src/part/fpgaview/Makefile.am
M clients/tde/src/part/fpgaview/layout.ui
M clients/tde/src/part/fpgaview/part.cpp
M clients/tde/src/part/fpgaview/part.h
M clients/tde/src/part/prototerminal/part.cpp
M clients/tde/src/part/prototerminal/part.h
M clients/tde/src/widgets/Makefile.am
M clients/tde/src/widgets/floatspinbox.cpp
M clients/tde/src/widgets/tracewidget.cpp
M clients/tde/src/widgets/tracewidget.h
diff --git a/clients/tde/src/part/fpgaview/Makefile.am b/clients/tde/src/part/fpgaview/Makefile.am
index a3f4d3c..f1efd6a 100644
--- a/clients/tde/src/part/fpgaview/Makefile.am
+++ b/clients/tde/src/part/fpgaview/Makefile.am
@@ -6,6 +6,6 @@
 
 # Part
 kde_module_LTLIBRARIES = libremotelab_fpgaviewer.la
-libremotelab_fpgaviewer_la_LIBADD  = ../../widgets/libtracewidget.la ../../widgets/libfloatspinbox.la $(LIB_KFILE) $(LIB_TDEPARTS) $(LIB_TDEUI) $(LIB_QT) -ltdekrbsocket -ltqtrla
+libremotelab_fpgaviewer_la_LIBADD  = ../../widgets/libtracewidget.la ../../widgets/libfloatspinbox.la ../../widgets/libsevensegment.la $(LIB_KFILE) $(LIB_TDEPARTS) $(LIB_TDEUI) $(LIB_QT) -ltdekrbsocket -ltqtrla
 libremotelab_fpgaviewer_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) $(LIB_TDECORE) $(LIB_TDEUI) -ltdeio -ltdefx -ltdemdi
 libremotelab_fpgaviewer_la_SOURCES = part.cpp layout.ui
diff --git a/clients/tde/src/part/fpgaview/layout.ui b/clients/tde/src/part/fpgaview/layout.ui
index 95328ab..c31612a 100644
--- a/clients/tde/src/part/fpgaview/layout.ui
+++ b/clients/tde/src/part/fpgaview/layout.ui
@@ -452,7 +452,7 @@
 														<property name="margin">
 															<number>2</number>
 														</property>
-														<widget class="FPGA7Segment" row="0" column="0">
+														<widget class="Display7Segment" row="0" column="0">
 															<property name="name">
 																<cstring>LEDOutputDisplayDigit0</cstring>
 															</property>
@@ -463,7 +463,7 @@
 																</size>
 															</property>
 														</widget>
-														<widget class="FPGA7Segment" row="0" column="1">
+														<widget class="Display7Segment" row="0" column="1">
 															<property name="name">
 																<cstring>LEDOutputDisplayDigit1</cstring>
 															</property>
@@ -474,7 +474,7 @@
 																</size>
 															</property>
 														</widget>
-														<widget class="FPGA7Segment" row="0" column="2">
+														<widget class="Display7Segment" row="0" column="2">
 															<property name="name">
 																<cstring>LEDOutputDisplayDigit2</cstring>
 															</property>
@@ -485,7 +485,7 @@
 																</size>
 															</property>
 														</widget>
-														<widget class="FPGA7Segment" row="0" column="3">
+														<widget class="Display7Segment" row="0" column="3">
 															<property name="name">
 																<cstring>LEDOutputDisplayDigit3</cstring>
 															</property>
@@ -838,6 +838,7 @@
 	<includes>
 		<include location="local" impldecl="in implementation">tracewidget.h</include>
 		<include location="local" impldecl="in implementation">floatspinbox.h</include>
+		<include location="local" impldecl="in implementation">sevensegment.h</include>
 		<include location="local" impldecl="in implementation">part.h</include>
 	</includes>
 	<layoutdefaults spacing="3" margin="6"/>
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index 2e2a615..fd7aec9 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -128,433 +128,6 @@
 	}
 }
 
-FPGA7Segment::FPGA7Segment( TQWidget *parent, const char *name )
-	: TQFrame( parent, name )
-{
-	init();
-}
-
-FPGA7Segment::~FPGA7Segment() {
-	free(m_prevSegments);
-	free(m_currentSegments);
-}
 ** Diff limit reached (max: 250 lines) **