Use CashAgentLib
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
|
||||
#include <QTimer>
|
||||
#include <QTextCodec>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(parent),
|
||||
@@ -10,7 +14,12 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(
|
||||
{
|
||||
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
|
||||
|
||||
this->hw = new hwapi();
|
||||
if (!this->private_loadCashAgentLib("")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()));
|
||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()));
|
||||
@@ -313,6 +322,46 @@ void ATBDeviceControllerPlugin::onCashPayStopByTimeout()
|
||||
}
|
||||
|
||||
|
||||
bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
|
||||
{
|
||||
if (pluginName == "") {
|
||||
pluginName = "/usr/lib/libCashAgentLib.so";
|
||||
}
|
||||
|
||||
if (!QLibrary::isLibrary(pluginName)) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: can not load CashAgentLib: " << pluginName;
|
||||
this->errorCode = 5;
|
||||
this->errorDescription = "ERROR: can not load CashAgentLib: " + pluginName;
|
||||
return false;
|
||||
}
|
||||
|
||||
QPluginLoader* pluginLoader = new QPluginLoader();
|
||||
pluginLoader->setFileName(pluginName);
|
||||
|
||||
QObject* plugin = pluginLoader->instance();
|
||||
if (!pluginLoader->isLoaded()) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: can not instantiate CashAgentLib: " << pluginName;
|
||||
this->errorCode = 6;
|
||||
this->errorDescription = "ERROR: can not instantiate CashAgentLib: " + pluginName;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin == nullptr) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: plugin is NULL";
|
||||
}
|
||||
|
||||
qCritical() << "ATBDeviceControllerPlugin: instantiate CashAgentLib: " << pluginName;
|
||||
|
||||
this->hw = qobject_cast<hwinf*>(plugin);
|
||||
|
||||
if (this->hw == nullptr) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: hw is NULL";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* Mandatory plugin methods
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
|
||||
#include "hwapi.h"
|
||||
#include "interfaces.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <thread>
|
||||
@@ -114,6 +114,8 @@ private:
|
||||
|
||||
QTextCodec *codec;
|
||||
|
||||
bool private_loadCashAgentLib(QString pluginName);
|
||||
|
||||
private slots:
|
||||
// printer
|
||||
|
||||
|
Reference in New Issue
Block a user