QXRD  0.11.16
qxrdserver.cpp
Go to the documentation of this file.
1 #include "qxrddebug.h"
2 #include "qxrdserver.h"
3 
4 #include <QHostAddress>
5 #include <QVariant>
6 #include <QScriptEngine>
7 #include <QThread>
8 #include "qxrdapplication.h"
10 #include "qcepsettingssaver.h"
11 #include "qcepexperiment.h"
12 #include "qxrdexperiment.h"
13 
15  QSpecServer(doc, name),
16  m_RunSpecServer(saver, this,"runSpecServer", 1, "Run SPEC Server?"),
17  m_SpecServerPort(saver, this,"specServerPort", -1, "Port for SPEC Server")
18 {
20  printf("QxrdServer::QxrdServer(%p)\n", this);
21  }
22 
23  connect(prop_RunSpecServer(), &QcepIntProperty::valueChanged, this, &QxrdServer::runModeChanged);
24  connect(prop_SpecServerPort(), &QcepIntProperty::valueChanged, this, &QxrdServer::serverPortChanged);
25 }
26 
28 {
30  printf("QxrdServer::~QxrdServer(%p)\n", this);
31  }
32 }
33 
34 void QxrdServer::readSettings(QSettings *settings, QString section)
35 {
36  QcepProperty::readSettings(this, settings, section);
37 
39 }
40 
41 void QxrdServer::writeSettings(QSettings *settings, QString section)
42 {
43  QcepProperty::writeSettings(this, settings, section);
44 }
45 
47 {
48  if (QThread::currentThread() != thread()) {
49  QMetaObject::invokeMethod(this, "runModeChanged");
50  } else {
51  if (get_RunSpecServer()) {
52  startServer(QHostAddress::Any, get_SpecServerPort());
53  } else {
54  stopServer();
55  }
56  }
57 }
58 
60 {
61  if (QThread::currentThread() != thread()) {
62  QMetaObject::invokeMethod(this, "serverPortChanged");
63  } else {
64  stopServer();
65 
66  if (get_RunSpecServer()) {
67  startServer(QHostAddress::Any, get_SpecServerPort());
68  }
69  }
70 }
71 
72 QVariant QxrdServer::readProperty(QString name)
73 {
74  QVariant res;
75 
76  if (name=="test") {
77  return 42;
78  }
79 
80  return QSpecServer::readProperty(name);
81 }
82 
84 {
85  close();
86 
87  thread()->exit();
88 }
QxrdServer(QcepSettingsSaverWPtr saver, QxrdExperimentWPtr doc, QString name)
Definition: qxrdserver.cpp:14
static void readSettings(QObject *object, QSettings *settings, QString section)
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
virtual void writeSettings(QSettings *settings, QString section)
Definition: qxrdserver.cpp:41
virtual ~QxrdServer()
Definition: qxrdserver.cpp:27
virtual void readSettings(QSettings *settings, QString section)
Definition: qxrdserver.cpp:34
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
QVariant readProperty(QString name)
Definition: qxrdserver.cpp:72
static void writeSettings(QObject *object, QSettings *settings, QString section)
void serverPortChanged()
Definition: qxrdserver.cpp:59
void shutdown()
Definition: qxrdserver.cpp:83
void valueChanged(int val, int index)
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr
void runModeChanged()
Definition: qxrdserver.cpp:46