Load/init libCA in plugin init method (not in contructor)

This commit is contained in:
Siegfried Siegert 2024-03-20 11:43:31 +01:00
parent 87d50a05dd
commit 4541699ec3
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03

View File

@ -30,13 +30,31 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
this->setParent(parent); this->setParent(parent);
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str()); this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
if (!this->private_loadCashAgentLib("")) {
return;
} }
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, const QSettings & settings)
{
this->eventReceiver = eventReceiver;
// read variables from setting
this->serialPortName = settings.value("ATBDeviceControllerPlugin/serialPort", "ttymxc2").toString();
QByteArray printerEncoding = settings.value("ATBDeviceControllerPlugin/printerEncoding", "ISO 8859-2").toString().toLatin1();
QString printerLocaleString = settings.value("ATBDeviceControllerPlugin/printerLocale", "de_DE").toString().toLatin1();
this->printerLocale = QLocale(printerLocaleString);
this->init_sc_dbus(); this->init_sc_dbus();
QString persistentDataFile = "/mnt/system_data/dc_persistentData.dat";
this->persistentData = new PersistentData(persistentDataFile);
// setup libCA:
if (!this->private_loadCashAgentLib("")) {
return PLUGIN_STATE::NOT_INITIALIZED;
}
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()), Qt::QueuedConnection); //connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()), Qt::QueuedConnection);
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()), Qt::QueuedConnection); //connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()), Qt::QueuedConnection);
@ -61,9 +79,6 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
dynamic_cast<QObject*>(hw)->moveToThread(hwThread); dynamic_cast<QObject*>(hw)->moveToThread(hwThread);
hwThread->start(); hwThread->start();
QString persistentDataFile = "/mnt/system_data/dc_persistentData.dat";
this->persistentData = new PersistentData(persistentDataFile);
this->diag = new DeviceControllerDiag(this->persistentData, this); this->diag = new DeviceControllerDiag(this->persistentData, this);
connect(this->diag, &DeviceControllerDiag::newVoltage, this, &ATBDeviceControllerPlugin::onNewVoltage); connect(this->diag, &DeviceControllerDiag::newVoltage, this, &ATBDeviceControllerPlugin::onNewVoltage);
@ -75,19 +90,7 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
this->currentCashState = CASH_STATE::CACHE_EMPTY; this->currentCashState = CASH_STATE::CACHE_EMPTY;
this->cashStartAmountInt = 0; this->cashStartAmountInt = 0;
}
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, const QSettings & settings)
{
this->eventReceiver = eventReceiver;
// read variables from setting
this->serialPortName = settings.value("ATBDeviceControllerPlugin/serialPort", "ttymxc2").toString();
QByteArray printerEncoding = settings.value("ATBDeviceControllerPlugin/printerEncoding", "ISO 8859-2").toString().toLatin1();
QString printerLocaleString = settings.value("ATBDeviceControllerPlugin/printerLocale", "de_DE").toString().toLatin1();
this->printerLocale = QLocale(printerLocaleString);
if (this->isMaster) { if (this->isMaster) {