Add dbus interface for SystemController

This commit is contained in:
Siegfried Siegert 2023-07-20 08:15:03 +02:00
parent 33445c1249
commit f790d327e9
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
6 changed files with 155 additions and 0 deletions

View File

@ -77,6 +77,7 @@ HEADERS += \
src/ATBAPP/ATBMachineEvent.h \ src/ATBAPP/ATBMachineEvent.h \
src/ATBAPP/ATBDeviceControllerPlugin.h \ src/ATBAPP/ATBDeviceControllerPlugin.h \
src/ATBAPP/Utils.h \ src/ATBAPP/Utils.h \
src/ATBAPP/support/DBusControllerInterface.h \
src/ATBAPP/support/JSON.h src/ATBAPP/support/JSON.h
SOURCES += \ SOURCES += \
@ -85,6 +86,7 @@ SOURCES += \
src/ATBAPP/ATBDeviceControllerPlugin.cpp \ src/ATBAPP/ATBDeviceControllerPlugin.cpp \
src/ATBAPP/DeviceControllerDiag.cpp \ src/ATBAPP/DeviceControllerDiag.cpp \
src/ATBAPP/Utils.cpp \ src/ATBAPP/Utils.cpp \
src/ATBAPP/support/DBusControllerInterface.cpp \
src/ATBAPP/support/JSON.cpp src/ATBAPP/support/JSON.cpp
DISTFILES += \ DISTFILES += \

View File

@ -3,6 +3,7 @@
#include "src/ATBAPP/ATBMachineEvent.h" #include "src/ATBAPP/ATBMachineEvent.h"
#include "src/ATBAPP/Utils.h" #include "src/ATBAPP/Utils.h"
#include "src/ATBAPP/support/JSON.h" #include "src/ATBAPP/support/JSON.h"
#include "src/ATBAPP/support/DBusControllerInterface.h"
#include <QTimer> #include <QTimer>
#include <QThread> #include <QThread>
@ -31,6 +32,9 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
return; return;
} }
this->init_sc_dbus();
//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);
@ -911,6 +915,46 @@ bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
/***********************************************************************************************
* dbus
*/
int ATBDeviceControllerPlugin::init_sc_dbus()
{
#if defined (ARCH_PTU4)
this->dbus = new DBusControllerInterface("eu.atb.ptu", "/systemcontrol", QDBusConnection::systemBus(), 0);
#elif defined (ARCH_PTU5)
this->dbus = new DBusControllerInterface("eu.atb.ptu.systemcontrol", "/systemcontrol", QDBusConnection::systemBus(), 0);
#else
this->dbus = new DBusControllerInterface("eu.atb.ptu", "/systemcontrol", QDBusConnection::sessionBus(), 0);
#endif
if (!dbus->isValid()) {
QString errorString = QDBusError::errorString(dbus->lastError().type());
qCritical() << errorString;
if (dbus->lastError().isValid()){
qCritical() << "last error is valid.";
}
qCritical() << "message: " << dbus->lastError().message();
qCritical() << "SystemController is not valid.";
return 0;
}
if (!dbus->connection().isConnected()) {
qCritical() << "SystemController is not connected.";
return 0;
}
connect(this->dbus, SIGNAL(wokeUpFrom(uchar)), this, SLOT(onWokeUp(uchar)));
return 1;
}
/************************************************************************************************ /************************************************************************************************
* Mandatory plugin methods * Mandatory plugin methods
* *

View File

@ -16,6 +16,7 @@
#include <unistd.h> #include <unistd.h>
class DBusControllerInterface;
class QTextCodec; class QTextCodec;
@ -97,6 +98,8 @@ private:
QObject* eventReceiver; QObject* eventReceiver;
DBusControllerInterface* dbus;
hwinf* hw; hwinf* hw;
DeviceControllerDiag* diag; DeviceControllerDiag* diag;
@ -113,6 +116,8 @@ private:
// counts failed hw->log_chkIfVaultRecordAvailable() // counts failed hw->log_chkIfVaultRecordAvailable()
int accountCheckCounter; int accountCheckCounter;
// dbus
int init_sc_dbus();
private slots: private slots:
// printer // printer

View File

@ -0,0 +1,14 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="eu.atb.ptu.systemcontrol">
<signal name="wokeUpFrom">
<arg name="source" type="y" direction="out"/>
</signal>
<method name="startBackgroundTask">
<arg name="id" type="s" direction="in"/>
</method>
<method name="finishedBackgroundTask">
<arg name="id" type="s" direction="in"/>
</method>
</interface>
</node>

View File

@ -0,0 +1,26 @@
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p DBusControllerInterface -c DBusControllerInterface DBusController.xml
*
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "DBusControllerInterface.h"
/*
* Implementation of interface class DBusControllerInterface
*/
DBusControllerInterface::DBusControllerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
{
}
DBusControllerInterface::~DBusControllerInterface()
{
}

View File

@ -0,0 +1,64 @@
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -p DBusControllerInterface -c DBusControllerInterface DBusController.xml
*
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef DBUSCONTROLLERINTERFACE_H
#define DBUSCONTROLLERINTERFACE_H
#include <QtCore/QObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtDBus/QtDBus>
/*
* Proxy class for interface eu.atb.ptu.systemcontrol
*/
class DBusControllerInterface: public QDBusAbstractInterface
{
Q_OBJECT
public:
static inline const char *staticInterfaceName()
{ return "eu.atb.ptu.systemcontrol"; }
public:
DBusControllerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
~DBusControllerInterface();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<> finishedBackgroundTask(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QLatin1String("finishedBackgroundTask"), argumentList);
}
inline QDBusPendingReply<> startBackgroundTask(const QString &id)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(id);
return asyncCallWithArgumentList(QLatin1String("startBackgroundTask"), argumentList);
}
Q_SIGNALS: // SIGNALS
void wokeUpFrom(uchar source);
};
namespace eu {
namespace atb {
namespace ptu {
typedef ::DBusControllerInterface systemcontrol;
}
}
}
#endif