diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/gpib_server_lin/src/companalyzer_functions.cpp | 51 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/companalyzer_functions.h | 3 | ||||
-rw-r--r-- | servers/gpib_server_lin/src/gpib_conn.cpp | 28 |
3 files changed, 77 insertions, 5 deletions
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 @@ int companalyzer_set_time(struct tm * datetime, const char * companalyzerType, i 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_set_measurement_parameters(companalyzer_measurement::companalyz } } +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 @@ int companalyzer_set_measurement_frequency(double frequency, const char * compan printf("[DEBG] Writing: %s\n\r", falpha); #endif if (gpib_write(gpibDevice, falpha) == 0) { + companalyzer_frequency = frequency; return 0; } else { @@ -401,6 +443,7 @@ int companalyzer_get_parameter_measurement(companalyzer_measurements_t * retval, 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 @@ typedef struct companalyzer_measurements { 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_lock_local_controls (const char * companalyzerType, int gpibDev 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 @@ void GPIBSocket::commandLoop() { 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 @@ void GPIBSocket::commandLoop() { } 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 @@ void GPIBSocket::commandLoop() { 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; |