Use libCAslave

This commit is contained in:
Siegfried Siegert 2023-11-21 11:21:28 +01:00
parent 6fbde29cad
commit 3b32d04bac
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 23 additions and 6 deletions

View File

@ -22,7 +22,8 @@
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
: pluginState(PLUGIN_STATE::NOT_INITIALIZED) : isMaster(false)
, pluginState(PLUGIN_STATE::NOT_INITIALIZED)
, eventReceiver(nullptr) , eventReceiver(nullptr)
{ {
this->setParent(parent); this->setParent(parent);
@ -76,10 +77,11 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
this->serialPortName = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString(); this->serialPortName = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString();
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1(); QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
if (this->isMaster) {
// open serial port // open serial port
hw->dc_openSerial(5, "115200", this->serialPortName, 1); hw->dc_openSerial(5, "115200", this->serialPortName, 1);
hw->dc_autoRequest(true); hw->dc_autoRequest(true);
}
hw->dc_setNewCustomerNumber(PTUSystem::readCustomerNumber()); hw->dc_setNewCustomerNumber(PTUSystem::readCustomerNumber());
hw->dc_setNewMachineNumber(PTUSystem::readMachineNumber()); hw->dc_setNewMachineNumber(PTUSystem::readMachineNumber());
@ -105,6 +107,8 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
void ATBDeviceControllerPlugin::startPhysicalLayer() void ATBDeviceControllerPlugin::startPhysicalLayer()
{ {
if (!this->isMaster) return;
if (this->pluginState == PLUGIN_STATE::NOT_INITIALIZED) if (this->pluginState == PLUGIN_STATE::NOT_INITIALIZED)
{ {
qCritical() << "ATBDeviceControllerPlugin::startPhysicalLayer(): plugin is not initialized"; qCritical() << "ATBDeviceControllerPlugin::startPhysicalLayer(): plugin is not initialized";
@ -119,6 +123,8 @@ void ATBDeviceControllerPlugin::startPhysicalLayer()
void ATBDeviceControllerPlugin::stopPhysicalLayer() void ATBDeviceControllerPlugin::stopPhysicalLayer()
{ {
if (!this->isMaster) return;
if (this->pluginState == PLUGIN_STATE::NOT_INITIALIZED) if (this->pluginState == PLUGIN_STATE::NOT_INITIALIZED)
{ {
qCritical() << "ATBDeviceControllerPlugin::startPhysicalLayer(): plugin is not initialized"; qCritical() << "ATBDeviceControllerPlugin::startPhysicalLayer(): plugin is not initialized";
@ -927,7 +933,8 @@ bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
// search list for plugin (.so) file: // search list for plugin (.so) file:
QStringList pluginNameList; QStringList pluginNameList;
pluginNameList << "/usr/lib/libCAmaster.so" pluginNameList << "/usr/lib/libCAslave.so"
<< "/usr/lib/libCAmaster.so"
<< "/usr/lib/libCashAgentLib.so"; << "/usr/lib/libCashAgentLib.so";
// using C++11 range based loop: // using C++11 range based loop:
for (const auto& filename : pluginNameList) { for (const auto& filename : pluginNameList) {
@ -953,6 +960,14 @@ bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
return false; return false;
} }
if (pluginName.contains("slave", Qt::CaseInsensitive)) {
this->isMaster = false;
}
else
if (pluginName.contains("master", Qt::CaseInsensitive)) {
this->isMaster = true;
}
QPluginLoader* pluginLoader = new QPluginLoader(); QPluginLoader* pluginLoader = new QPluginLoader();
pluginLoader->setFileName(pluginName); pluginLoader->setFileName(pluginName);

View File

@ -95,6 +95,8 @@ private:
bool useDebug; bool useDebug;
bool isMaster;
PLUGIN_STATE pluginState; PLUGIN_STATE pluginState;
QObject* eventReceiver; QObject* eventReceiver;