3 #include <QWaitCondition>
29 strncpy(data, qPrintable(
m_Replies.takeFirst()), maxlen);
47 printMessage(tr(
"QPTC10Simulator::writeData %1, %2, %3").arg(data).arg(strlen(data)).arg(len));
50 if (cmd ==
"\"Control.PID.Mode?\"\n") {
52 }
else if (cmd ==
"\"Control.PID.Setpoint?\"\n") {
54 }
else if (cmd ==
"\"Control.PID.RampT?\"\n") {
56 }
else if (cmd ==
"\"Control.PID.Ramp?\"\n") {
58 }
else if (cmd ==
"outputEnable?\n") {
60 }
else if (cmd ==
"\"Control?\"\n") {
62 }
else if (cmd ==
"\"TC?\"\n") {
64 }
else if (cmd ==
"getOutput\n") {
66 }
else if (cmd ==
"getOutput.names\n") {
67 reply(
"Control, TC, Chan C, Chan D");
68 }
else if (cmd ==
"getOutput.units\n") {
69 reply(
"%, degC, V, W");
70 }
else if (cmd ==
"system.com.verbose medium\n") {
71 }
else if (cmd ==
"\"TC.PID.Mode?\"\n") {
72 reply(
"Error: non-exist");
73 }
else if (cmd ==
"\"Chan C.PID.Mode?\"\n") {
74 reply(
"Error: non-exist");
75 }
else if (cmd ==
"\"Chan D.PID.Mode?\"\n") {
78 QRegExp regex(
"\"Control\\.PID\\.Setpoint\"\\s+(\\S*)\\n");
80 if (regex.exactMatch(cmd)) {
85 QRegExp regex(
"\"Control\\.PID\\.Ramp\"\\s+(\\S*)\\n");
87 if (regex.exactMatch(cmd)) {
92 QRegExp regex(
"\"Control\\.PID\\.Mode\"\\s+(\\S*)\\n");
94 if (regex.exactMatch(cmd)) {
99 QRegExp regex(
"outputEnable\\s+(\\S*)\\n");
101 if (regex.exactMatch(cmd)) {
110 printMessage(tr(
"Unrecognized PTC10 Command %1").arg(cmd));
112 reply(tr(
"Error: %1").arg(cmd));
121 printMessage(tr(
"QPTC10Simulator::reply %1").arg(rply));
143 QWaitCondition waitCondition;
146 waitCondition.wait(&mutex, msecs);
157 dev->printMessage(msg, ts);
QWeakPointer< QPTC10Device > QPTC10DeviceWPtr
qint64 writeData(const char *data, qint64 len)
bool waitForReadyRead(int msecs)
QPTC10Simulator(QPTC10DeviceWPtr device)
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime()) const
QSharedPointer< QPTC10Device > QPTC10DevicePtr
qint64 readLineData(char *data, qint64 maxlen)
virtual ~QPTC10Simulator()
qint64 readData(char *data, qint64 maxlen)
QPTC10DeviceWPtr m_Device