summaryrefslogtreecommitdiffstats
path: root/servers/gpib_server_lin/src/gpib_conn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/gpib_server_lin/src/gpib_conn.cpp')
-rw-r--r--servers/gpib_server_lin/src/gpib_conn.cpp102
1 files changed, 101 insertions, 1 deletions
diff --git a/servers/gpib_server_lin/src/gpib_conn.cpp b/servers/gpib_server_lin/src/gpib_conn.cpp
index ec36aa6..86ca4a8 100644
--- a/servers/gpib_server_lin/src/gpib_conn.cpp
+++ b/servers/gpib_server_lin/src/gpib_conn.cpp
@@ -46,6 +46,7 @@
#include "scope_functions.h"
#include "signal_functions.h"
#include "commanalyzer_functions.h"
+#include "companalyzer_functions.h"
#include "gpib_conn.h"
@@ -192,6 +193,9 @@ void GPIBSocket::commandLoop() {
if (m_serverParent->m_commanalyzerType != "") {
deviceList.append("COMMUNICATIONS ANALYZER");
}
+ if (m_serverParent->m_companalyzerType != "") {
+ deviceList.append("COMPONENT ANALYZER");
+ }
ds << deviceList;
writeEndOfFrame();
}
@@ -1016,6 +1020,73 @@ void GPIBSocket::commandLoop() {
printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
}
}
+ else if (m_activeDeviceType == 5) {
+ // Component analyzer
+ char errorbuf[1000];
+ if (m_instrumentCommand == "GETMEASUREMENT") { // Want a new component measurement with the configured parameters
+ TQ_UINT8 number_of_parameters = 2;
+ companalyzer_measurements_t measurement;
+ int retcode = companalyzer_get_parameter_measurement(&measurement, m_serverParent->m_companalyzerType.ascii(), m_serverParent->m_companalyzerDeviceSocket);
+ if (retcode == 0) {
+ ds << TQString("ACK");
+ ds << number_of_parameters;
+ ds << (TQ_UINT32&)measurement.parameter_a_status;
+ ds << (TQ_UINT32&)measurement.parameter_a;
+ ds << (TQ_UINT32&)measurement.parameter_a_type;
+ ds << measurement.parameter_a_value;
+ 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;
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString("NCK");
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "SETMEASUREDPARAMETERS") { // Want to set the measured parameters
+ uint8_t all_ok = 1;
+ uint8_t number_of_parameters;
+ companalyzer_measurement::companalyzer_measurement_t parameter_a;
+ companalyzer_measurement::companalyzer_measurement_t parameter_b;
+ ds >> number_of_parameters;
+ if (number_of_parameters == 2) {
+ ds >> (TQ_UINT32&)parameter_a;
+ ds >> (TQ_UINT32&)parameter_b;
+ if (companalyzer_set_measurement_parameters(parameter_a, parameter_b, m_serverParent->m_companalyzerType.ascii(), m_serverParent->m_companalyzerDeviceSocket, errorbuf) != 0) {
+ all_ok = false;
+ }
+ }
+ else {
+ sprintf(errorbuf, "EXTInvalid number of parameters provided°");
+ all_ok = false;
+ }
+ if (all_ok) {
+ ds << TQString("ACK");
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString(errorbuf);
+ writeEndOfFrame();
+ }
+ }
+ else if (m_instrumentCommand == "SETMEASUREMENTFREQUENCY") { // Want to set the measurement frequency
+ double frequency;
+ ds >> frequency;
+ if (companalyzer_set_measurement_frequency(frequency, m_serverParent->m_companalyzerType.ascii(), m_serverParent->m_companalyzerDeviceSocket, errorbuf) == 0) {
+ ds << TQString("ACK");
+ writeEndOfFrame();
+ }
+ else {
+ ds << TQString(errorbuf);
+ writeEndOfFrame();
+ }
+ }
+ else {
+ printf("[WARNING] Received unknown command %s from host %s\n\r", m_instrumentCommand.ascii(), m_remoteHost.ascii()); fflush(stdout);
+ }
+ }
else {
// Unknown
transferred_data = true;
@@ -1064,7 +1135,7 @@ int GPIBSocket::enterCommandLoop() {
*/
GPIBServer::GPIBServer(TQObject* parent, int port, KSimpleConfig* config) :
TQServerSocket( port, 1, parent ), m_config(config), m_numberOfConnections(0),
- m_scopeDeviceSocket(-1), m_funcgenDeviceSocket(-1), m_commanalyzerDeviceSocket(-1) {
+ m_scopeDeviceSocket(-1), m_funcgenDeviceSocket(-1), m_commanalyzerDeviceSocket(-1), m_companalyzerDeviceSocket(-1) {
if ( !ok() ) {
printf("[ERROR] Failed to bind to port %d\n\r", port);
@@ -1139,6 +1210,13 @@ int GPIBServer::readConfig() {
m_commanalyzerBoard = m_config->readNumEntry("board", 0);
m_commanalyzerDevice = m_config->readNumEntry("device", 0);
+ // Component analyzer
+ m_config->setGroup("Component Analyzer");
+ m_companalyzerType = m_config->readEntry("type", "");
+ m_companalyzerConnection = m_config->readEntry("connection", "gpib");
+ m_companalyzerBoard = m_config->readNumEntry("board", 0);
+ m_companalyzerDevice = m_config->readNumEntry("device", 0);
+
if (m_serialDevice != "") {
struct termios oldtio, newtio;
@@ -1235,5 +1313,27 @@ int GPIBServer::readConfig() {
}
}
+ if (m_companalyzerType != "") {
+ printf("[INFO] Component analyzer conjectured to be on GPIB address %d:%d\n\r", m_companalyzerBoard, m_companalyzerDevice);
+ m_companalyzerDeviceSocket = open_gpib_device(m_companalyzerBoard, m_companalyzerDevice);
+ if (m_companalyzerDeviceSocket < 0) {
+ //return 1;
+ }
+ else {
+ time_t rawtime;
+ struct tm * timeinfo;
+ time ( &rawtime );
+ timeinfo = localtime ( &rawtime );
+ printf("[INFO] Configuring %s component analyzer\n\r", companalyzerLongDescription(m_companalyzerType.ascii()));
+ if (companalyzer_set_time(timeinfo, m_companalyzerType.ascii(), m_companalyzerDeviceSocket) == 0) {
+ companalyzer_set_date(timeinfo, m_companalyzerType.ascii(), m_companalyzerDeviceSocket);
+ printf("[INFO] Communication verified\n\r");
+ }
+ else {
+ printf("[WARN] Communication failed!\n\r");
+ }
+ }
+ }
+
return 0;
} \ No newline at end of file