#include <qpidcommport.h>
Definition at line 14 of file qpidcommport.h.
Enumerator |
---|
NoPort |
|
LocalSerialPort |
|
NetworkSocket |
|
EpicsPV |
|
Definition at line 21 of file qpidcommport.h.
Definition at line 8 of file qpidcommport.cpp.
10 m_CommPortType(saver,
this,
"commPortType", 0,
"Comm Port Type"),
11 m_SerialPortName(saver,
this,
"serialPortName",
"",
"Serial Port Name"),
12 m_SerialPortBaud(saver,
this,
"serialPortBaud", 0,
"Serial Port Baud Rate"),
13 m_SerialPortBits(saver,
this,
"serialPortBits", 1,
"Serial Port Data Bits"),
14 m_SerialPortParity(saver,
this,
"serialPortParity", 0,
"Serial Port Parity"),
15 m_SerialPortStopBits(saver,
this,
"serialPortStopBits", 0,
"Serial Port Stop Bits"),
16 m_SerialPortFlowControl(saver,
this,
"serialPortFlowControl", 0,
"Serial Port Flow Control"),
17 m_SocketHostAddress(saver,
this,
"socketHostAddress",
"",
"Socket Host Address"),
18 m_SocketPortNumber(saver,
this,
"socketPortNumber", 0,
"Socket Port Number"),
19 m_SocketTimeout(saver,
this,
"socketTimeout", 5000,
"Socket timeout (msec)"),
20 m_EpicsPVName(saver,
this,
"epicsPVName",
"",
"Epics PV Name"),
21 m_Connected(QcepSettingsSaverWPtr(),
this,
"connected", 0,
"Is comm port connected"),
22 m_Successful(QcepSettingsSaverWPtr(),
this,
"successful", 0,
"Successful communication taken place"),
25 if (qcepDebug(DEBUG_CONSTRUCTORS)) {
26 printf(
"QPidCommPort::QPidCommPort(%p)\n",
this);
QPidControllerWPtr m_Controller
QPidCommPort::~QPidCommPort |
( |
| ) |
|
|
virtual |
Definition at line 30 of file qpidcommport.cpp.
32 if (qcepDebug(DEBUG_CONSTRUCTORS)) {
33 printf(
"QPidCommPort::~QPidCommPort(%p)\n",
this);
BaudRateType QPidCommPort::baudRate |
( |
int |
idx | ) |
|
|
slot |
int QPidCommPort::bytesAvailable |
( |
| ) |
|
int QPidCommPort::canReadLine |
( |
| ) |
|
QStringList QPidCommPort::commPortBaudRates |
( |
| ) |
|
|
slot |
QStringList QPidCommPort::commPortDataBits |
( |
| ) |
|
|
slot |
QStringList QPidCommPort::commPortFlowControls |
( |
| ) |
|
|
slot |
QStringList QPidCommPort::commPortParitys |
( |
| ) |
|
|
slot |
QStringList QPidCommPort::commPortStopBits |
( |
| ) |
|
|
slot |
QStringList QPidCommPort::commPortTypes |
( |
| ) |
|
|
slot |
DataBitsType QPidCommPort::dataBits |
( |
int |
idx | ) |
|
|
slot |
FlowType QPidCommPort::flowControl |
( |
int |
idx | ) |
|
|
slot |
bool QPidCommPort::isWritable |
( |
| ) |
|
bool QPidCommPort::openIfNeeded |
( |
| ) |
|
|
private |
Definition at line 439 of file qpidcommport.cpp.
References DEBUG_SERIAL, DEBUG_SOCKET, LocalSerialPort, NetworkSocket, openLocalSerialPort(), openNetworkSocket(), and printMessage().
Referenced by bytesAvailable(), canReadLine(), isWritable(), read(), readAll(), readLine(), waitForBytesWritten(), waitForReadyRead(), and write().
441 if (get_Connected()) {
446 switch (get_CommPortType()) {
459 printMessage(tr(
"Socket opened: connected = %1").arg(res));
bool openLocalSerialPort()
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())
bool QPidCommPort::openLocalSerialPort |
( |
| ) |
|
|
private |
Definition at line 370 of file qpidcommport.cpp.
References baudRate(), dataBits(), DEBUG_LEVEL1, DEBUG_SERIAL, flowControl(), m_IODevice, parity(), printMessage(), and stopBits().
Referenced by openIfNeeded().
374 QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
376 QString portName = get_SerialPortName();
379 for (
int i=0; i<ports.count(); i++) {
380 QextPortInfo port = ports.value(i);
382 QString aPortName = port.portName;
384 if (portName == aPortName) {
385 deviceName = port.physName;
389 QextSerialPort *dev =
new QextSerialPort(deviceName, QextSerialPort::Polling);
391 dev->setBaudRate(
baudRate(get_SerialPortBaud()));
392 dev->setDataBits(
dataBits(get_SerialPortBits()));
393 dev->setStopBits(
stopBits(get_SerialPortStopBits()));
394 dev->setFlowControl(
flowControl(get_SerialPortFlowControl()));
395 dev->setParity(
parity(get_SerialPortParity()));
397 res = dev->open(QIODevice::ReadWrite);
400 printMessage(tr(
"New serial port on device %1, port name %2").arg(deviceName).arg(portName));
403 printMessage(tr(
"Baud:%1 Bits:%2 Parity:%3 Stop:%4 HShake:%5")
404 .arg(dev->baudRate())
405 .arg(dev->dataBits())
407 .arg(dev->stopBits())
408 .arg(dev->flowControl()));
415 printMessage(tr(
"Serial Port open failed %1").arg(dev->errorString()));
DataBitsType dataBits(int idx)
QPointer< QIODevice > m_IODevice
BaudRateType baudRate(int idx)
StopBitsType stopBits(int idx)
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())
FlowType flowControl(int idx)
ParityType parity(int idx)
bool QPidCommPort::openNetworkSocket |
( |
| ) |
|
|
private |
Definition at line 423 of file qpidcommport.cpp.
References m_IODevice, and printMessage().
Referenced by openIfNeeded().
427 QTcpSocket *sock =
new QTcpSocket();
428 sock->connectToHost(get_SocketHostAddress(), get_SocketPortNumber());
429 res = sock->waitForConnected(get_SocketTimeout());
433 printMessage(tr(
"Socket connection failed %1").arg(sock->errorString()));
QPointer< QIODevice > m_IODevice
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())
ParityType QPidCommPort::parity |
( |
int |
idx | ) |
|
|
slot |
void QPidCommPort::printMessage |
( |
QString |
msg, |
|
|
QDateTime |
ts = QDateTime::currentDateTime() |
|
) |
| |
|
slot |
Definition at line 193 of file qpidcommport.cpp.
References m_Controller.
Referenced by bytesAvailable(), canReadLine(), isWritable(), openIfNeeded(), openLocalSerialPort(), openNetworkSocket(), read(), readAll(), readLine(), waitForBytesWritten(), waitForReadyRead(), and write().
198 ctl->printMessage(msg, ts);
QSharedPointer< QPidController > QPidControllerPtr
QPidControllerWPtr m_Controller
QByteArray QPidCommPort::read |
( |
int |
sz | ) |
|
QByteArray QPidCommPort::readAll |
( |
| ) |
|
QByteArray QPidCommPort::readLine |
( |
int |
maxlen = 0 | ) |
|
void QPidCommPort::readSettings |
( |
QSettings * |
set, |
|
|
QString |
section |
|
) |
| |
|
virtual |
Definition at line 207 of file qpidcommport.cpp.
209 QcepProperty::readSettings(
this, &staticMetaObject, section, set);
void QPidCommPort::readyRead |
( |
| ) |
|
|
signal |
StopBitsType QPidCommPort::stopBits |
( |
int |
idx | ) |
|
|
slot |
bool QPidCommPort::successfullyConnected |
( |
| ) |
|
int QPidCommPort::waitForBytesWritten |
( |
int |
tmout = 0 | ) |
|
int QPidCommPort::waitForReadyRead |
( |
int |
tmout = 0 | ) |
|
void QPidCommPort::write |
( |
QByteArray |
msg | ) |
|
void QPidCommPort::writeSettings |
( |
QSettings * |
set, |
|
|
QString |
section |
|
) |
| |
|
virtual |
Definition at line 202 of file qpidcommport.cpp.
204 QcepProperty::writeSettings(
this, &staticMetaObject, section, set);
QPointer<QIODevice> QPidCommPort::m_IODevice |
|
private |
Definition at line 109 of file qpidcommport.h.
Referenced by bytesAvailable(), canReadLine(), isWritable(), openLocalSerialPort(), openNetworkSocket(), read(), readAll(), readLine(), waitForBytesWritten(), waitForReadyRead(), and write().
int QPidCommPort::commPortType |
|
readwrite |
int QPidCommPort::connected |
|
readwrite |
QString QPidCommPort::epicsPVName |
|
readwrite |
int QPidCommPort::serialPortBaud |
|
readwrite |
int QPidCommPort::serialPortBits |
|
readwrite |
int QPidCommPort::serialPortFlowControl |
|
readwrite |
QString QPidCommPort::serialPortName |
|
readwrite |
int QPidCommPort::serialPortParity |
|
readwrite |
int QPidCommPort::serialPortStopBits |
|
readwrite |
QString QPidCommPort::socketHostAddress |
|
readwrite |
int QPidCommPort::socketPortNumber |
|
readwrite |
int QPidCommPort::socketTimeout |
|
readwrite |
int QPidCommPort::successful |
|
readwrite |
The documentation for this class was generated from the following files: