Compare commits

...

5 Commits
1.0.5 ... 1.1.0

3 changed files with 1422 additions and 445 deletions

File diff suppressed because it is too large Load Diff

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();
// open serial port if (this->isMaster) {
hw->dc_openSerial(5, "115200", this->serialPortName, 1); // open serial port
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";
@@ -362,7 +368,7 @@ void ATBDeviceControllerPlugin::onVaultDoorOpened()
// this is started here because we want to keep ptu awake in order to get // this is started here because we want to keep ptu awake in order to get
// coin box removed / inserted etc. // coin box removed / inserted etc.
// BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS! // BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS!
this->dbus->startBackgroundTask("ACCOUNT"); this->dbus->startBackgroundTask("DOOR_OPEN");
// do not: emit this->requestModeSERVICE(); // do not: emit this->requestModeSERVICE();
} }
@@ -371,6 +377,9 @@ void ATBDeviceControllerPlugin::onCoinBoxRemoved()
{ {
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxRemoved()"; qCritical() << "ATBDeviceControllerPlugin::onCoinBoxRemoved()";
// BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS!
this->dbus->startBackgroundTask("ACCOUNT");
QTimer::singleShot(4000, this, SLOT(private_startAccount())); QTimer::singleShot(4000, this, SLOT(private_startAccount()));
} }
@@ -379,19 +388,31 @@ void ATBDeviceControllerPlugin::onCoinBoxInserted()
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()"; qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()";
} }
/**
* This is called, when all CoinBox is inserted and all doors
* are closed.
*/
void ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed() void ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()
{ {
qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()"; qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()";
QTimer::singleShot(2000, this, SIGNAL(requestModeIDLE())); QTimer::singleShot(2000, this, SIGNAL(requestModeIDLE()));
this->dbus->finishedBackgroundTask("DOOR_OPEN");
} }
/**
* This is called, when all no coinbox is inserted and all doors are
* closed.
*/
void ATBDeviceControllerPlugin::onAllDoorsClosed() void ATBDeviceControllerPlugin::onAllDoorsClosed()
{ {
qCritical() << "ATBDeviceControllerPlugin::onAllDoorsClosed()"; qCritical() << "ATBDeviceControllerPlugin::onAllDoorsClosed()";
emit this->requestModeIDLE(); emit this->requestModeIDLE();
this->dbus->finishedBackgroundTask("DOOR_OPEN");
// TODO: check for errors and create a machine event
} }
void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage) void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage)
@@ -912,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) {
@@ -938,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;