Compare commits

...

5 Commits

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)
: pluginState(PLUGIN_STATE::NOT_INITIALIZED)
: isMaster(false)
, pluginState(PLUGIN_STATE::NOT_INITIALIZED)
, eventReceiver(nullptr)
{
this->setParent(parent);
@@ -76,10 +77,11 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
this->serialPortName = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString();
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
// open serial port
hw->dc_openSerial(5, "115200", this->serialPortName, 1);
hw->dc_autoRequest(true);
if (this->isMaster) {
// open serial port
hw->dc_openSerial(5, "115200", this->serialPortName, 1);
hw->dc_autoRequest(true);
}
hw->dc_setNewCustomerNumber(PTUSystem::readCustomerNumber());
hw->dc_setNewMachineNumber(PTUSystem::readMachineNumber());
@@ -105,6 +107,8 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
void ATBDeviceControllerPlugin::startPhysicalLayer()
{
if (!this->isMaster) return;
if (this->pluginState == PLUGIN_STATE::NOT_INITIALIZED)
{
qCritical() << "ATBDeviceControllerPlugin::startPhysicalLayer(): plugin is not initialized";
@@ -119,6 +123,8 @@ void ATBDeviceControllerPlugin::startPhysicalLayer()
void ATBDeviceControllerPlugin::stopPhysicalLayer()
{
if (!this->isMaster) return;
if (this->pluginState == PLUGIN_STATE::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
// coin box removed / inserted etc.
// 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();
}
@@ -371,6 +377,9 @@ void 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()));
}
@@ -379,19 +388,31 @@ void ATBDeviceControllerPlugin::onCoinBoxInserted()
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()";
}
/**
* This is called, when all CoinBox is inserted and all doors
* are closed.
*/
void ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()
{
qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()";
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()
{
qCritical() << "ATBDeviceControllerPlugin::onAllDoorsClosed()";
emit this->requestModeIDLE();
this->dbus->finishedBackgroundTask("DOOR_OPEN");
// TODO: check for errors and create a machine event
}
void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage)
@@ -912,7 +933,8 @@ bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
// search list for plugin (.so) file:
QStringList pluginNameList;
pluginNameList << "/usr/lib/libCAmaster.so"
pluginNameList << "/usr/lib/libCAslave.so"
<< "/usr/lib/libCAmaster.so"
<< "/usr/lib/libCashAgentLib.so";
// using C++11 range based loop:
for (const auto& filename : pluginNameList) {
@@ -938,6 +960,14 @@ bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
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();
pluginLoader->setFileName(pluginName);

View File

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