Documents > BPS V2 C++ API
BpsScales Class Reference

Scales interface. More...

#include <bpsscales.h>

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

BpsScales::BpsScales ( QObject *  aParent = 0)
Parameters:
[in]aParentThe parent object.

Member Function Documentation

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.

Returns:
True if tare operations are supported.
void BpsScales::clearTareError ( const QString &  aMessage) [signal]

Signal emitted as failure result of a requestClearTare() call.

Parameters:
[in]aMessageInformation about the failure reason (for example "Timeout", "Device not open" etc.)
QMap<QString,QString> BpsScales::config ( ) const
Returns:
The scales configuration with lowercase keys, and trimmed keys and values.
See also:
Bps::lowerKeyStringMap().
void BpsScales::error ( const QString &  aMessage) [signal]

Combined failure signal from readWeightError(), readTareError(), takeTareError() and clearTareError().

Parameters:
[in]aMessageInformation 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.

Parameters:
[in]aMessageInformation 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.

Parameters:
[in]aTareThe current tare weight.
void BpsScales::readWeightError ( const QString &  aMessage) [signal]

Signal emitted as failure result of a requestReadWeight() call.

Parameters:
[in]aMessageInformation 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.

Parameters:
[in]aStatusThe scales status.
[in]aWeightThe current weight in case of StatusStable or StatusDynamic. May be gross or net, depending on tare status.
[in]aTaredTrue 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.

Parameters:
[in]aConfigThe scales configuration.
void BpsScales::takeTareError ( const QString &  aMessage) [signal]

Signal emitted as failure result of a requestTakeTare() call.

Parameters:
[in]aMessageInformation about the failure reason (for example "Timeout", "Device not open" etc.)

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