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->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
}
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->private_loadCashAgentLib("")) {
return;
}
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_Err()), this, SLOT(onPrintFinishedERR()), Qt::QueuedConnection);
@ -61,9 +79,6 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
dynamic_cast<QObject*>(hw)->moveToThread(hwThread);
hwThread->start();
QString persistentDataFile = "/mnt/system_data/dc_persistentData.dat";
this->persistentData = new PersistentData(persistentDataFile);
this->diag = new DeviceControllerDiag(this->persistentData, this);
connect(this->diag, &DeviceControllerDiag::newVoltage, this, &ATBDeviceControllerPlugin::onNewVoltage);
@ -75,19 +90,7 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
this->currentCashState = CASH_STATE::CACHE_EMPTY;
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) {
@ -227,20 +230,20 @@ void ATBDeviceControllerPlugin::reset()
// Handle Mode-Changes --------------------------------------------------------
void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
{
{
hw->dc_autoRequest(true);
hw->rtc_setDateTime();
hw->mdb_switchWake(0); // wakeup MDB components
}
void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE()
{
{
hw->dc_autoRequest(true);
hw->mdb_switchWake(0); // wakeup MDB components
}
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
{
{
hw->dc_autoRequest(true);
this->diag->diagRequest();
hw->mdb_switchWake(1);