BPS C++ API  2.24.4
BpsLabeler Class Referenceabstract

Labeler interface. More...

#include <bpslabeler.h>

+ Inheritance diagram for BpsLabeler:

Public Types

enum  { DataPackage , DataSum1 , DataSum2 , DataSumJob }
 Data type identifiers. More...
 
enum  Entity { Collection , All }
 Clearing entities. More...
 
enum  Feature { CanPrint , CanSave , CanStartStop , CanClearCollection , CanClearAll , CanEmitDataPackage , CanEmitDataSum1 , CanEmitDataSum2 , CanEmitDataSumJob }
 Feature identifiers. More...
 

Signals

void dataReceived (int aDataType, const QVariant &aCount, const QVariant &aWeight, const QVariant &aPrice)
 Emitted when data is received from labeler. More...
 
void error (const QString &aMessage)
 Emitted for fatal messages, for example failed operations. More...
 
void hideProgress ()
 Emitted after the operation is completed (or failed or was aborted). More...
 
void info (const QString &aMessage)
 Emitted for informational messages. More...
 
void showProgress (int aMaximum, const QString &aLabel)
 Emitted at start of operation to begin showing the progress indicator. More...
 
void updateProgressLabel (const QString &aLabel)
 Emitted to update the progress label text. More...
 
void updateProgressMaximum (int aMaximum)
 Emitted to change the highest tick value. More...
 
void updateProgressValue (int aValue)
 Emitted when progress reaches next value to update the progress indicator. More...
 
void warning (const QString &aMessage)
 Emitted for non-fatal messages, for example reception of unexpected records. More...
 

Public Member Functions

 BpsLabeler (BpsDatastore *aDatastore, const QString &aLabelerId, QObject *aParent=0)
 
virtual void clear (Entity aEntity, const QVariant &aKey, volatile bool *aCancelFlag=nullptr)
 Delete articles from the labelers internal database. More...
 
void clearCache ()
 Clear the cached global and settings data. More...
 
virtual void close (volatile bool *aCancelFlag=nullptr)=0
 Close the device and release it for manual operation. More...
 
virtual void control (int aOp, const QVariantMap &aInput, QVariantMap &aOutput, volatile bool *aCancelFlag=nullptr)
 Execute labeler specific operations. More...
 
BpsDatastoredatastore () const
 
virtual bool hasFeature (Feature aFeature)
 Query information about available features. More...
 
virtual bool isOpen () const =0
 
virtual bool isStarted () const
 Get the start/stop status. More...
 
QString labelerId () const
 
virtual void load (const QVariant &aArticle, const QVariantMap &aParams, volatile bool *aCancelFlag=nullptr)=0
 Load an article into the working memory so it is ready to start labeling. More...
 
virtual void open (int aLineNo, const QString &aLineName, const QMap< QString, QString > &aConfig, volatile bool *aCancelFlag=nullptr)=0
 Open the device and do general initializations (setting the current date for example). More...
 
virtual void print (volatile bool *aCancelFlag=nullptr)
 Print a single label with the article previously loaded into the working memory. More...
 
virtual void processEvents ()
 Process pending events from labeler. More...
 
virtual void save (const QVariant &aArticle, const QVariantMap &aParams, volatile bool *aCancelFlag=nullptr)
 Save an article to the labelers internal database for emergency or offline operation. More...
 
virtual void saveLoad (const QVariant &aArticle, const QVariantMap &aParams, volatile bool *aCancelFlag=nullptr)
 Load an article into the working memory and conditionally also save it to the labelers internal database. More...
 
void setCustomData (const QString &aSettingsData, const QString &aGlobalData)
 Makes the labeler use custom data instead of the regular data. More...
 
virtual void start (volatile bool *aCancelFlag=nullptr)
 Start labeling, if supported by the device. More...
 
virtual void stop (volatile bool *aCancelFlag=nullptr)
 Stop labeling, if supported by the device. More...
 
virtual ~BpsLabeler ()
 Virtual default destructor.
 
- Public Member Functions inherited from QObject
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
 QObject (QObject *parent)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

virtual int checkReplacement (const QString &aText, const QVariant &aCheckInfo)
 Function called by processPlaceholdes() before any character is added to the produced text. More...
 
bool init (const QVariant &aArticle, const QVariantMap &aParams, const QString &aType=QString())
 Initialize the internal data for processing placeholders. More...
 
QString labelData () const
 The label data belonging to the latest article init() was called for. More...
 
QString labelerData () const
 The labeler data is independent of the distinct setting and taken from table t_labelers. More...
 
QVariant labelerKey () const
 The labeler key from t_labelers. More...
 
QVariant labelKey () const
 The label key from t_labels belonging to the latest article init() was called for. More...
 
QString processPlaceholders (const QString &aText, const QVariant &aCheckInfo=QVariant())
 Replace the placeholders in the given text. More...
 
virtual QString processReplacement (const QString &aText)
 After the substitute content for a single placeholder has been created, this method gets called to post-process it. More...
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Labeler interface.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Data type identifiers.

Enumerator
DataPackage 

Single package.

DataSum1 

Sum 1 (TU)

DataSum2 

Sum 2 (LU)

DataSumJob 

Job sum.

◆ Entity

Clearing entities.

Enumerator
Collection 

Clear articles of a collection (by given collection).

All 

Clear all stored articles.

◆ Feature

Feature identifiers.

Enumerator
CanPrint 

Supports print().

CanSave 

Supports save().

CanStartStop 

Supports start() and stop().

CanClearCollection 

Supports clearing the articles of a collection.

CanClearAll 

Supports clearing all stored articles.

CanEmitDataPackage 

Can emit single package records.

CanEmitDataSum1 

Can emit sum 1 records.

CanEmitDataSum2 

Can emit sum 2 records.

CanEmitDataSumJob 

Can emit job sum records.

Constructor & Destructor Documentation

◆ BpsLabeler()

BpsLabeler::BpsLabeler ( BpsDatastore aDatastore,
const QString aLabelerId,
QObject aParent = 0 
)
Parameters
aDatastoreThe datastore to use.
aLabelerIdThe labeler ID, for example "generic" or "lm2000".
aParentThe parent object.

Member Function Documentation

◆ checkReplacement()

virtual int BpsLabeler::checkReplacement ( const QString aText,
const QVariant aCheckInfo 
)
protectedvirtual

Function called by processPlaceholdes() before any character is added to the produced text.

A typical use is to limit line lengths when proportional fonts are used. The default implementation always returns 0.

Parameters
aTextThe text how it would be after adding the character. Lines breaks are represented by a newline character.
aCheckInfoThe check info passed into processPlaceholders().
Returns
0=ok, 1=force end of line, 2=stop processing.

◆ clear()

virtual void BpsLabeler::clear ( Entity  aEntity,
const QVariant aKey,
volatile bool *  aCancelFlag = nullptr 
)
virtual

Delete articles from the labelers internal database.

The default implementation does nothing.

Parameters
aEntityThe entity to clear.
aKeyThe collection key when aEntity is BpsLabeler::Collection. Unused when aEntity is BpsLabeler::All.
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ clearCache()

void BpsLabeler::clearCache ( )

Clear the cached global and settings data.

Any previous setCustomData() action is reverted and regular data gets used again.

◆ close()

virtual void BpsLabeler::close ( volatile bool *  aCancelFlag = nullptr)
pure virtual

Close the device and release it for manual operation.

Parameters
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ control()

virtual void BpsLabeler::control ( int  aOp,
const QVariantMap &  aInput,
QVariantMap &  aOutput,
volatile bool *  aCancelFlag = nullptr 
)
virtual

Execute labeler specific operations.

See documentation of the respective labeler interfaces for details. The default implementation does noting.

Parameters
aOpOperation command.
aInputInput data.
aOutputOutput data.
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ dataReceived

void BpsLabeler::dataReceived ( int  aDataType,
const QVariant aCount,
const QVariant aWeight,
const QVariant aPrice 
)
signal

Emitted when data is received from labeler.

Parameters
aDataTypeType of the received data.
aCountNumber of packages (BpsDecimal when known, invalid when unknown).
aWeightWeight in kilo (BpsDecimal when known, invalid when unknown).
aPricePrice (BpsDecimal when known, invalid when unknown).

◆ datastore()

BpsDatastore* BpsLabeler::datastore ( ) const
Returns
The datastore object.

◆ error

void BpsLabeler::error ( const QString aMessage)
signal

Emitted for fatal messages, for example failed operations.

Parameters
aMessageThe message.

◆ hasFeature()

virtual bool BpsLabeler::hasFeature ( Feature  aFeature)
virtual

Query information about available features.

The default implementation returns false for any feature. Overload this method to return true in case.

Parameters
aFeatureThe feature to check.
Returns
True if labeler has the feature.

◆ hideProgress

void BpsLabeler::hideProgress ( )
signal

Emitted after the operation is completed (or failed or was aborted).

The progress indicator should get hidden.

◆ info

void BpsLabeler::info ( const QString aMessage)
signal

Emitted for informational messages.

Parameters
aMessageThe message.

◆ init()

bool BpsLabeler::init ( const QVariant aArticle,
const QVariantMap &  aParams,
const QString aType = QString() 
)
protected

Initialize the internal data for processing placeholders.

Usually this will get called by implementations of load() and save() before replacing the placeholders.

Parameters
aArticleKey of the article to load.
aParamsOverride values for the placeholders as key/value pairs. All placeholders except a_barcode may be overridden.
aTypeSub-type name for generic labelers.
Returns
True when successfully loaded, false if not labeler settings found.
Exceptions
BpsExceptionon errors.

◆ isOpen()

virtual bool BpsLabeler::isOpen ( ) const
pure virtual
Returns
True if the labeler is opened.

◆ isStarted()

virtual bool BpsLabeler::isStarted ( ) const
virtual

Get the start/stop status.

The default implementation returns true if labeler is open and false if not open.

Returns
True if labeling was started.

◆ labelData()

QString BpsLabeler::labelData ( ) const
protected

The label data belonging to the latest article init() was called for.

For performance reasons the settings data of formerly loaded articles are cached, however it is possible to force reloading by calling clearCache() in advance.

Returns
The settings data.
Exceptions
BpsExceptionon errors.

◆ labelerData()

QString BpsLabeler::labelerData ( ) const
protected

The labeler data is independent of the distinct setting and taken from table t_labelers.

For performance reasons the labeler data is cached, however it is possible to force reloading by calling clearCache() in advance.

Returns
The labeler data.
Exceptions
BpsExceptionon errors.

◆ labelerId()

QString BpsLabeler::labelerId ( ) const
Returns
The labeler ID.

◆ labelerKey()

QVariant BpsLabeler::labelerKey ( ) const
protected

The labeler key from t_labelers.

Returns
The labeler key.
Exceptions
BpsExceptionon errors.

◆ labelKey()

QVariant BpsLabeler::labelKey ( ) const
protected

The label key from t_labels belonging to the latest article init() was called for.

Note
In case setCustomData() was used, the returned key will have a negative value instead of a real existing key in t_labels.
Returns
The label key.

◆ load()

virtual void BpsLabeler::load ( const QVariant aArticle,
const QVariantMap &  aParams,
volatile bool *  aCancelFlag = nullptr 
)
pure virtual

Load an article into the working memory so it is ready to start labeling.

If the device does not support start/stop labeling, this may also start the labeling process.

Parameters
aArticleKey of the article to load.
aParamsOverride values for the placeholders as key/value pairs. All placeholders except a_barcode may be overridden.
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ open()

virtual void BpsLabeler::open ( int  aLineNo,
const QString aLineName,
const QMap< QString, QString > &  aConfig,
volatile bool *  aCancelFlag = nullptr 
)
pure virtual

Open the device and do general initializations (setting the current date for example).

Parameters
aLineNoThe packing line number, usually the folder Central System Settings/Terminals/TERMINAL/Packlines/LINENO.
aLineNameThe packing line name, usually the value Central System Settings/Terminals/TERMINAL/Packlines/LINENO/Name.
aConfigThe labeler configuration, usually the values in Central System Settings/Terminals/TERMINAL/Packlines/LINENO/Labeler.
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ print()

virtual void BpsLabeler::print ( volatile bool *  aCancelFlag = nullptr)
virtual

Print a single label with the article previously loaded into the working memory.

Overload this method for non-automatic labelers such as plain printers, where the label print is triggered by an external signal. The default implementation does nothing.

Parameters
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ processEvents()

virtual void BpsLabeler::processEvents ( )
virtual

Process pending events from labeler.

This might be called by the labeling process by timer in intervals, or at idle times. In case of errors, the signal error() will be emitted.

◆ processPlaceholders()

QString BpsLabeler::processPlaceholders ( const QString aText,
const QVariant aCheckInfo = QVariant() 
)
protected

Replace the placeholders in the given text.

Parameters
aTextThe source text with placeholders to be processed.
aCheckInfoWhen a valid value is given, checkReplacement() is called while processing.
Returns
The text with all placeholders replaced by the final content.
Exceptions
BpsExceptionon errors.

◆ processReplacement()

virtual QString BpsLabeler::processReplacement ( const QString aText)
protectedvirtual

After the substitute content for a single placeholder has been created, this method gets called to post-process it.

The default implementation returns the text unmodified. Re-implement this method to escape certain characters for example. If you need to post-process the whole text, instead of single placeholder substitutes, operate on the text returned by processPlaceholders() instead.

Parameters
aTextThe substitute text that will be used instead of the placeholder.
Returns
The processed text as it shall be inserted.

◆ save()

virtual void BpsLabeler::save ( const QVariant aArticle,
const QVariantMap &  aParams,
volatile bool *  aCancelFlag = nullptr 
)
virtual

Save an article to the labelers internal database for emergency or offline operation.

The default implementation does nothing.

Parameters
aArticleKey of the article to load.
aParamsOverride values for the placeholders as key/value pairs. All placeholders except a_barcode may be overridden.
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ saveLoad()

virtual void BpsLabeler::saveLoad ( const QVariant aArticle,
const QVariantMap &  aParams,
volatile bool *  aCancelFlag = nullptr 
)
virtual

Load an article into the working memory and conditionally also save it to the labelers internal database.

Saving to the database happens conditionally depending on the labeler setting "Savemode". If the device does not support start/stop labeling, this may also start the labeling process. The default implementation calls load().

Parameters
aArticleKey of the article to load.
aParamsOverride values for the placeholders as key/value pairs. All placeholders except a_barcode may be overridden.
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ setCustomData()

void BpsLabeler::setCustomData ( const QString aSettingsData,
const QString aGlobalData 
)

Makes the labeler use custom data instead of the regular data.

This method is used to test unsaved data in labeler settings application.

Parameters
aSettingsDataSettings data to be used in place of c_label.c_data.
aGlobalDataGlobal data to be used in place of c_labeler.c_data.

◆ showProgress

void BpsLabeler::showProgress ( int  aMaximum,
const QString aLabel 
)
signal

Emitted at start of operation to begin showing the progress indicator.

The indicator should have value ticks from 0 to aMaximum, and be set initially to 0.

Parameters
aMaximumHighest tick value, usually the number of processed items.
aLabelLabel to display in the progress indicator. Use QString() to display no label.

◆ start()

virtual void BpsLabeler::start ( volatile bool *  aCancelFlag = nullptr)
virtual

Start labeling, if supported by the device.

The default implementation does nothing.

Parameters
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ stop()

virtual void BpsLabeler::stop ( volatile bool *  aCancelFlag = nullptr)
virtual

Stop labeling, if supported by the device.

The default implementation does nothing.

Parameters
aCancelFlagIf the cancel flag becomes false during operation, the method will throw a BpsException.
Exceptions
BpsExceptionon errors or when operation is canceled.

◆ updateProgressLabel

void BpsLabeler::updateProgressLabel ( const QString aLabel)
signal

Emitted to update the progress label text.

Parameters
aLabelNew label text to display in the progress indicator.

◆ updateProgressMaximum

void BpsLabeler::updateProgressMaximum ( int  aMaximum)
signal

Emitted to change the highest tick value.

Parameters
aMaximumHighest tick value, usually the number of processed items.

◆ updateProgressValue

void BpsLabeler::updateProgressValue ( int  aValue)
signal

Emitted when progress reaches next value to update the progress indicator.

Parameters
aValueThe value tick reached in the range 1...aMaximum, see showProgress().

◆ warning

void BpsLabeler::warning ( const QString aMessage)
signal

Emitted for non-fatal messages, for example reception of unexpected records.

Parameters
aMessageThe message.

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