Add dbus interface for SystemController
This commit is contained in:
parent
33445c1249
commit
f790d327e9
@ -77,6 +77,7 @@ HEADERS += \
|
||||
src/ATBAPP/ATBMachineEvent.h \
|
||||
src/ATBAPP/ATBDeviceControllerPlugin.h \
|
||||
src/ATBAPP/Utils.h \
|
||||
src/ATBAPP/support/DBusControllerInterface.h \
|
||||
src/ATBAPP/support/JSON.h
|
||||
|
||||
SOURCES += \
|
||||
@ -85,6 +86,7 @@ SOURCES += \
|
||||
src/ATBAPP/ATBDeviceControllerPlugin.cpp \
|
||||
src/ATBAPP/DeviceControllerDiag.cpp \
|
||||
src/ATBAPP/Utils.cpp \
|
||||
src/ATBAPP/support/DBusControllerInterface.cpp \
|
||||
src/ATBAPP/support/JSON.cpp
|
||||
|
||||
DISTFILES += \
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "src/ATBAPP/ATBMachineEvent.h"
|
||||
#include "src/ATBAPP/Utils.h"
|
||||
#include "src/ATBAPP/support/JSON.h"
|
||||
#include "src/ATBAPP/support/DBusControllerInterface.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
@ -31,6 +32,9 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
|
||||
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_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
|
||||
*
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
class DBusControllerInterface;
|
||||
class QTextCodec;
|
||||
|
||||
|
||||
@ -97,6 +98,8 @@ private:
|
||||
|
||||
QObject* eventReceiver;
|
||||
|
||||
DBusControllerInterface* dbus;
|
||||
|
||||
hwinf* hw;
|
||||
|
||||
DeviceControllerDiag* diag;
|
||||
@ -113,6 +116,8 @@ private:
|
||||
// counts failed hw->log_chkIfVaultRecordAvailable()
|
||||
int accountCheckCounter;
|
||||
|
||||
// dbus
|
||||
int init_sc_dbus();
|
||||
|
||||
private slots:
|
||||
// printer
|
||||
|
14
src/ATBAPP/support/DBusController.xml
Normal file
14
src/ATBAPP/support/DBusController.xml
Normal 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>
|
26
src/ATBAPP/support/DBusControllerInterface.cpp
Normal file
26
src/ATBAPP/support/DBusControllerInterface.cpp
Normal 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()
|
||||
{
|
||||
}
|
||||
|
64
src/ATBAPP/support/DBusControllerInterface.h
Normal file
64
src/ATBAPP/support/DBusControllerInterface.h
Normal 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
|
Loading…
Reference in New Issue
Block a user