QXRD  0.11.16
Public Slots | Public Member Functions | Private Member Functions | Private Attributes | List of all members
QxrdDetectorPilatusRemote Class Reference

#include <qxrddetectorpilatusremote.h>

Inheritance diagram for QxrdDetectorPilatusRemote:
Inheritance graph
[legend]
Collaboration diagram for QxrdDetectorPilatusRemote:
Collaboration graph
[legend]

Public Slots

void connectToRemote (QString sshCmd)
 
void executeRemote (QString cmd)
 
void onReadyRead ()
 
- Public Slots inherited from QcepObject
virtual void printLine (QString line)
 
virtual void printMessage (QString msg, QDateTime dt=QDateTime::currentDateTime()) const
 
virtual void criticalMessage (QString msg, QDateTime ts=QDateTime::currentDateTime()) const
 
virtual void statusMessage (QString msg, QDateTime ts=QDateTime::currentDateTime()) const
 
virtual QString settingsScript ()
 
QString scriptValueLiteral (QVariant v)
 

Public Member Functions

 QxrdDetectorPilatusRemote (QcepObject *owner)
 
- Public Member Functions inherited from QcepObject
 QcepObject (QString name, QcepObject *parent)
 
virtual ~QcepObject ()
 
virtual void writeSettings (QSettings *set, QString section)
 
virtual void readSettings (QSettings *set, QString section)
 
QString get_Name () const
 
void set_Name (QString name)
 

Private Member Functions

void interpretLine (QString line)
 

Private Attributes

QProcess m_Process
 
QByteArray m_Buffer
 
int m_FileTransferSize
 
QByteArray m_TransferredFile
 

Additional Inherited Members

- Static Public Member Functions inherited from QcepObject
static int allocatedObjects ()
 
static int deletedObjects ()
 
static QSet< QcepObject * > allocatedObjectsSet ()
 
static QString addSlashes (QString str)
 
- Properties inherited from QcepObject
QString name
 

Detailed Description

Definition at line 8 of file qxrddetectorpilatusremote.h.

Constructor & Destructor Documentation

QxrdDetectorPilatusRemote::QxrdDetectorPilatusRemote ( QcepObject owner)

Definition at line 5 of file qxrddetectorpilatusremote.cpp.

References m_Process, onReadyRead(), and QcepObject::printMessage().

6  : QcepObject("pilatusRemote", owner),
8 {
9  printMessage("Constructed Pilatus Remote Object");
10 
11  connect(&m_Process, &QProcess::readyRead, this, &QxrdDetectorPilatusRemote::onReadyRead);
12 }
QcepObject(QString name, QcepObject *parent)
Definition: qcepobject.cpp:16
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime()) const
Definition: qcepobject.cpp:84

Here is the call graph for this function:

Member Function Documentation

void QxrdDetectorPilatusRemote::connectToRemote ( QString  sshCmd)
slot

Definition at line 14 of file qxrddetectorpilatusremote.cpp.

References m_Process, and QcepObject::printMessage().

15 {
16  printMessage(tr("Connect to %1").arg(sshCmd));
17 
18  m_Process.setProcessChannelMode(QProcess::MergedChannels);
19  m_Process.start(sshCmd);
20 }
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime()) const
Definition: qcepobject.cpp:84

Here is the call graph for this function:

void QxrdDetectorPilatusRemote::executeRemote ( QString  cmd)
slot

Definition at line 22 of file qxrddetectorpilatusremote.cpp.

References m_Process, and QcepObject::printMessage().

23 {
24  printMessage(tr("Exceute %1").arg(cmd));
25 
26  m_Process.write(qPrintable(cmd+"\n"));
27 }
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime()) const
Definition: qcepobject.cpp:84

Here is the call graph for this function:

void QxrdDetectorPilatusRemote::interpretLine ( QString  line)
private

Definition at line 71 of file qxrddetectorpilatusremote.cpp.

References m_FileTransferSize, and QcepObject::printMessage().

Referenced by onReadyRead().

72 {
73  printMessage(tr("QxrdDetectorPilatusRemote::interpretLine(\"%1\")").arg(line));
74 
75  if (line.startsWith("transfer:")) {
76  QStringList fields = line.split(QRegExp("\\s+"));
77 
78  printMessage(tr("transfer: %1 args").arg(fields.count()));
79 
80  foreach(QString f, fields) {
81  printMessage(tr("Arg:%1").arg(f));
82  }
83 
84  m_FileTransferSize = fields.value(4).toInt();
85 
86  printMessage(tr("Transfer %1 bytes").arg(m_FileTransferSize));
87  }
88 }
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime()) const
Definition: qcepobject.cpp:84

Here is the call graph for this function:

Here is the caller graph for this function:

void QxrdDetectorPilatusRemote::onReadyRead ( )
slot

Definition at line 29 of file qxrddetectorpilatusremote.cpp.

References DEBUG_PILATUS, interpretLine(), m_Buffer, m_FileTransferSize, m_Process, m_TransferredFile, QcepObject::printMessage(), and qcepDebug().

Referenced by QxrdDetectorPilatusRemote().

30 {
31  printMessage(tr("Remote On ready read (%1 bytes available)").arg(m_Process.bytesAvailable()));
32 
33  m_Buffer.append(m_Process.readAll());
34 
35  while (1) {
36  if (m_FileTransferSize > 0) { // Doing a file transfer
37  if (m_Buffer.count() >= m_FileTransferSize) {
39 
40  QByteArray hash = QCryptographicHash::hash(m_TransferredFile, QCryptographicHash::Md5);
41 
42  printMessage(tr("%1 byte file transferred, md5sum %2")
43  .arg(m_FileTransferSize)
44  .arg(QString(hash.toHex())));
45 
46  m_Buffer.remove(0, m_FileTransferSize);
47 
49  } else {
50  return;
51  }
52  } else {
53  int ind = m_Buffer.indexOf('\n');
54 
55  if (ind >= 0) {
56  QString line = m_Buffer.left(ind); // Don't include newline
57  m_Buffer.remove(0, ind+1);
58 
59  if (qcepDebug(DEBUG_PILATUS)) {
60  printMessage(tr("(%1) : \"%2\"").arg(line.count()).arg(QString(line)));
61  }
62 
63  interpretLine(line);
64  } else { // No new lines when expected
65  return;
66  }
67  }
68  }
69 }
qint64 qcepDebug(int cond)
Definition: qcepdebug.cpp:26
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime()) const
Definition: qcepobject.cpp:84

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

QByteArray QxrdDetectorPilatusRemote::m_Buffer
private

Definition at line 27 of file qxrddetectorpilatusremote.h.

Referenced by onReadyRead().

int QxrdDetectorPilatusRemote::m_FileTransferSize
private

Definition at line 28 of file qxrddetectorpilatusremote.h.

Referenced by interpretLine(), and onReadyRead().

QProcess QxrdDetectorPilatusRemote::m_Process
private
QByteArray QxrdDetectorPilatusRemote::m_TransferredFile
private

Definition at line 29 of file qxrddetectorpilatusremote.h.

Referenced by onReadyRead().


The documentation for this class was generated from the following files: