3 #include "qcepmutexlocker.h"
6 #include "qcepproperty.h"
10 QcepSettingsSaverWPtr saver,
16 m_DeviceType(saver, this,
"deviceType", deviceType,
"Device Type"),
19 m_DeviceName(saver, this,
"deviceName", deviceName,
"Device Name"),
20 m_RunState(QcepSettingsSaverWPtr(), this,
"runState", 0,
"Run State"),
21 m_PollingInterval(saver, this,
"pollingInterval", pollIntervalMsec/1000.0,
"Polling Interval (sec)"),
22 m_TimeoutInterval(saver, this,
"timeoutInterval", timeoutMsec/1000.0,
"Timeout Interval (sec)"),
27 connect(prop_RunState(), SIGNAL(valueChanged(
int,
int)),
this, SLOT(
changeRunState(
int)));
28 connect(prop_PollingInterval(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changePollingInterval(
double)));
29 connect(prop_TimeoutInterval(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeTimeoutInterval(
double)));
34 connect(cntrl->prop_GraphInterval(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeGraphingInterval(
double)));
35 connect(cntrl->logger()->prop_UpdateInterval(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeLoggingInterval(
double)));
38 if (qcepDebug(DEBUG_CONSTRUCTORS)) {
39 printf(
"QPidDevice::QPidDevice(%p)\n",
this);
45 if (qcepDebug(DEBUG_CONSTRUCTORS)) {
46 printf(
"QPidDevice::~QPidDevice(%p)\n",
this);
93 res =
"Watlow 988 Series Controller";
97 res =
"Stanford PTC10 Controller";
101 res =
"Lakeshore Cryogenics LS3xx Controller";
105 res =
"Oxford Cryostream Controller";
109 res =
"Eurotherm 2400 Series Controller";
129 printMessage(tr(
"QPidDevice::changeRunState(%1)").arg(state));
144 connect(ctrl->prop_SetPoint(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeSetPoint(
double)));
145 connect(ctrl->prop_RampRate(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeRampRate(
double)));
146 connect(ctrl->prop_Proportional(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeProportional(
double)));
147 connect(ctrl->prop_Integral(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeIntegral(
double)));
148 connect(ctrl->prop_Derivative(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeDerivative(
double)));
149 connect(ctrl->prop_Enabled(), SIGNAL(valueChanged(
bool,
int)),
this, SLOT(
enable(
bool)));
150 connect(ctrl->prop_LoopEnabled(), SIGNAL(valueChanged(
bool,
int)),
this, SLOT(
loopEnable(
bool)));
159 if (get_PollingInterval() > 0) {
166 if (get_TimeoutInterval() > 0) {
172 if (ctrl && ctrl->get_GraphInterval() > 0) {
181 if (logger && logger->get_UpdateInterval() > 0) {
194 disconnect(ctrl->prop_SetPoint(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeSetPoint(
double)));
195 disconnect(ctrl->prop_RampRate(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeRampRate(
double)));
196 disconnect(ctrl->prop_Proportional(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeProportional(
double)));
197 disconnect(ctrl->prop_Integral(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeIntegral(
double)));
198 disconnect(ctrl->prop_Derivative(), SIGNAL(valueChanged(
double,
int)),
this, SLOT(
changeDerivative(
double)));
199 disconnect(ctrl->prop_Enabled(), SIGNAL(valueChanged(
bool,
int)),
this, SLOT(
enable(
bool)));
200 disconnect(ctrl->prop_LoopEnabled(), SIGNAL(valueChanged(
bool,
int)),
this, SLOT(
loopEnable(
bool)));
205 if (get_PollingInterval() > 0) {
212 if (get_TimeoutInterval() > 0) {
218 if (ctrl && ctrl->get_GraphInterval() > 0) {
226 if (logger && logger->get_UpdateInterval() > 0) {
236 printMessage(tr(
"Polling interval changed to %1 seconds").arg(interval));
239 if (get_RunState()) {
246 }
else if (interval > 0) {
255 printMessage(tr(
"Timeout interval changed to %1 seconds").arg(interval));
258 if (get_RunState()) {
266 printMessage(tr(
"Graphing interval changed to %1 seconds").arg(interval));
269 if (get_RunState()) {
276 }
else if (interval > 0) {
285 printMessage(tr(
"Logging interval changed to %1 seconds").arg(interval));
288 if (get_RunState()) {
295 }
else if (interval > 0) {
326 ctl->printMessage(msg, ts);
335 ctl->updateConnected(newConnected);
344 ctl->updateTemperature(newTemperature);
353 ctl->updateRampPoint(newRampPoint);
362 ctl->updateOutputLevel(newOutputLevel);
372 QcepProperty::writeSettings(
this, &staticMetaObject, section, set);
381 QcepProperty::readSettings(
this, &staticMetaObject, section, set);
537 return commPort()->waitForReadyRead(tmout);
542 return commPort()->bytesAvailable();
static int deviceTypeCount()
virtual bool replyExpected() const =0
virtual void changeLoggingInterval(double interval)
QString deviceLongTypeName
virtual void write(QString cmd)
virtual void readoutTimeout()=0
QPidControllerWPtr controller() const
QPidDeviceCommandQueue m_CommandQueue
virtual void writeSettings(QSettings *set, QString section)
QWeakPointer< QPidController > QPidControllerWPtr
QSharedPointer< QPidLogger > QPidLoggerPtr
QSharedPointer< QPidController > QPidControllerPtr
virtual void changeGraphingInterval(double interval)
virtual void readoutPolling()=0
virtual int canReadLine()
void updateRampPoint(double newRampPoint)
virtual bool processReply(QString reply)=0
virtual int waitForReadyRead(int tmout=0)
virtual void enable(bool on)=0
virtual void changeRampRate(double rate)=0
virtual void changeIntegral(double integ)=0
QPidDevice(QPidControllerWPtr ctrl, QcepSettingsSaverWPtr saver, int deviceType, QString deviceName, int pollIntervalMsec, int timeoutMsec)
virtual void onLoggingTimeout()
virtual void loopEnable(bool on)
virtual void readoutInitial()=0
virtual int bytesAvailable()
QPidControllerWPtr m_Controller
QPidCommPortPtr commPort()
virtual void issueCommand()=0
double degC2K(double degC)
virtual void changeDerivative(double deriv)=0
virtual void changeTimeoutInterval(double interval)
virtual void readSettings(QSettings *set, QString section)
void updateOutputLevel(double newOutputLevel)
void updateTemperature(double newTemperature)
virtual QString readLine(int sz=0)
virtual void changeRunState(int state)
virtual void changeSetPoint(double setPoint)=0
void completeCommand(QByteArray response)
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())
void updateConnected(double newConnected)
virtual void changeProportional(double prop)=0
virtual void changePollingInterval(double interval)
void pushCommand(QPidDeviceCommandPtr cmd)
virtual void onGraphingTimeout()
QPidCommPortPtr m_CommPort
QSharedPointer< QPidCommPort > QPidCommPortPtr