<!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="org.my.test">
<signal name="signalSent">
<arg name="asignals" type="a(iiii)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="SignalsArray"/>
</signal>
<method name="SetSignal">
<arg name="asignals" type="a(iiii)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="SignalsArray"/>
</method>
</interface>
</node>
/****************************** TxSignal.h *************/
#include <QtDBus>
#include <QtCore/QList>
#include <QtCore/QMetaType>
class TxSignal {
public:
TxSignal();
virtual ~TxSignal();
//Getter
float getValue();
//Setter
void setValue(float Value);
//register Message with the Qt type system
//static void registerMetaType();
public:
double m_Value;
};
typedef QList<TxSignal> SignalsArray;
Q_DECLARE_METATYPE(TxSignal);
Q_DECLARE_METATYPE(SignalsArray);
inline void registerCommType(){
qDBusRegisterMetaType<TxSignal>();
qDBusRegisterMetaType< SignalsArray >();
}
/****************************************** TxSignal.cpp *************************************************/
#include "TxSignal.h"
TxSignal::TxSignal() {
// TODO Auto-generated constructor stub
}
TxSignal::~TxSignal() {
// TODO Auto-generated destructor stub
}
{
argument.beginStructure();
argument << msignals.m_Surname;
argument << msignals.m_Name;
argument << msignals.m_Value;
argument.endStructure();
return argument;
}
{
argument.beginStructure();
argument >> msignals.m_Surname;
argument >> msignals.m_Name;
argument >> msignals.m_Value;
argument.endStructure();
return argument;
}
{
return this->m_Name ;
}
{
return this->m_Surname ;
}
float TxSignal::getValue()
{
return this->m_Value ;
}
void TxSignal
::setName(QString Name
) {
this->m_Name = Name;
}
void TxSignal
::setSurname(QString Surname
) {
this->m_Surname = Surname;
}
void TxSignal::setValue(float Value)
{
this->m_Value = Value;
}
/*************************************** TestSignal.h *********************************************/
#include <QObject>
#include <QStringList>
#include "TxSignal.h"
Q_OBJECT
//Local variables
QList<TxSignal> m_asignals;
Q_CLASSINFO("D-Bus Interface", "org.my.test")
public:
virtual ~TestSignal();
signals:
void signalSent(const SignalsArray &asignals);
public slots:
void SetSignal(const SignalsArray &asignals);
};
/*************************************** TestSignal.cpp *******************************************/
#include <iostream>
using namespace std;
#include "TestSignal.h"
#include "TestSignalAdaptor.h"
#include "TestSignalInterface.h"
TestSignal
::TestSignal(QObject *parent
) { // add our D-Bus interface and connect to D-Bus
new TestsignalAdaptor(this);
org::my::test *iface;
bool ret;
ret = connect(iface, SIGNAL(signalSent(SignalsArray)),this, SLOT(SetSignal(SignalsArray)));
if (ret==TRUE) {
cout<<"\nTRUEEEEE";
fflush(stdout);
}
SignalsArray prova;
TxSignal nuovo;
nuovo.m_Surname = "111222333";
nuovo.m_Name = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA****";
prova.append(nuovo);
int i=0;
for(i=0;i<20;i++);
emit signalSent(prova);
cout<<"\nSent";
}
void TestSignal::TestSignal(const SignalsArray &asignals)
{
cout<<asignals.at(0).m_Surname.toAscii().data();
cout<<"\nMetodo richiamato";
fflush(stdout);
}
TestSignal::~TestSignal() {
// TODO Auto-generated destructor stub
}
Bookmarks