Scales interface. More...
#include <bpsscales.h>
Public Types | |
| enum | { StatusStable = 0, StatusDynamic = 1, StatusOverload = 2, StatusUnderload = 3, StatusError = 4 } |
| Read status. | |
Signals | |
| void | clearTareError (const QString &aMessage) |
| Signal emitted as failure result of a requestClearTare() call. | |
| void | clearTareOk () |
| Signal emitted as success result of a requestClearTare() call. | |
| void | error (const QString &aMessage) |
| Combined failure signal from readWeightError(), readTareError(), takeTareError() and clearTareError(). | |
| void | ok () |
| Combined success signal from readWeightOk(), readTareOk(), takeTareOk() and clearTareOk(). | |
| void | readTareError (const QString &aMessage) |
| Signal emitted as failure result of a requestReadTare() call. | |
| void | readTareOk (double aTare) |
| Signal emitted as success result of a requestReadWeight() call. | |
| void | readWeightError (const QString &aMessage) |
| Signal emitted as failure result of a requestReadWeight() call. | |
| void | readWeightOk (int aStatus, double aWeight, bool aTared) |
| Signal emitted as success result of a requestReadWeight() call. | |
| void | takeTareError (const QString &aMessage) |
| Signal emitted as failure result of a requestTakeTare() call. | |
| void | takeTareOk () |
| Signal emitted as success result of a requestTakeTare() call. | |
Public Member Functions | |
| BpsScales (QObject *aParent=0) | |
| virtual bool | canTare () const |
| Information if requestReadTare(), requestTakeTare() and requestClearTare() are supported. | |
| QMap< QString, QString > | config () const |
| virtual void | requestClearTare () |
| Request clearing of the tare, going back to gross weight. | |
| virtual void | requestReadTare () |
| Request reading of the current tare status and weight. | |
| virtual void | requestReadWeight ()=0 |
| Request the reading of a scales status and weight. | |
| virtual void | requestTakeTare () |
| Request taring of the current stable weight, going to net weight. | |
| void | setConfig (const QMap< QString, QString > &aConfig) |
| Set the scales configuration. | |
| virtual | ~BpsScales () |
| Virtual default destructor. | |
Scales interface.
Scales interfaces operate similar as a thread, where commands are given by request calls, and results are returned as signals. Background operations are however implemented with QTimer, so the requesting thread must have an event queue. Overlapped requests are not supported, subsequent requests should be made only after the previous has been answered by a signal.
| BpsScales::BpsScales | ( | QObject * | aParent = 0 | ) |
| [in] | aParent | The parent object. |
| virtual bool BpsScales::canTare | ( | ) | const [virtual] |
Information if requestReadTare(), requestTakeTare() and requestClearTare() are supported.
The default implementation returns false. Overload this method to return true in case.
| void BpsScales::clearTareError | ( | const QString & | aMessage | ) | [signal] |
Signal emitted as failure result of a requestClearTare() call.
| [in] | aMessage | Information about the failure reason (for example "Timeout", "Device not open" etc.) |
| QMap<QString,QString> BpsScales::config | ( | ) | const |
| void BpsScales::error | ( | const QString & | aMessage | ) | [signal] |
Combined failure signal from readWeightError(), readTareError(), takeTareError() and clearTareError().
| [in] | aMessage | Information about the failure reason (for example "Timeout", "Device not open" etc.) |
| void BpsScales::readTareError | ( | const QString & | aMessage | ) | [signal] |
Signal emitted as failure result of a requestReadTare() call.
| [in] | aMessage | Information about the failure reason (for example "Timeout", "Device not open" etc.) |
| void BpsScales::readTareOk | ( | double | aTare | ) | [signal] |
Signal emitted as success result of a requestReadWeight() call.
| [in] | aTare | The current tare weight. |
| void BpsScales::readWeightError | ( | const QString & | aMessage | ) | [signal] |
Signal emitted as failure result of a requestReadWeight() call.
| [in] | aMessage | Information about the failure reason (for example "Timeout", "Device not open" etc.) |
| void BpsScales::readWeightOk | ( | int | aStatus, |
| double | aWeight, | ||
| bool | aTared | ||
| ) | [signal] |
Signal emitted as success result of a requestReadWeight() call.
| [in] | aStatus | The scales status. |
| [in] | aWeight | The current weight in case of StatusStable or StatusDynamic. May be gross or net, depending on tare status. |
| [in] | aTared | True when the scales is known to be tared and the weight is net; false when tare status unknown or scales is not tared and weight is gross. Only valid when StatusStable or StatusDynamic. |
| void BpsScales::setConfig | ( | const QMap< QString, QString > & | aConfig | ) |
Set the scales configuration.
This should be done before making requests.
| [in] | aConfig | The scales configuration. |
| void BpsScales::takeTareError | ( | const QString & | aMessage | ) | [signal] |
Signal emitted as failure result of a requestTakeTare() call.
| [in] | aMessage | Information about the failure reason (for example "Timeout", "Device not open" etc.) |