mirror of https://github.com/nymea/nymea.git
add means to find a device from a signal
parent
29217b9aff
commit
c46403b4c0
|
|
@ -1,7 +1,9 @@
|
|||
#include "device.h"
|
||||
|
||||
Device::Device(QObject *parent):
|
||||
QObject(parent)
|
||||
Device::Device(const QUuid &deviceClassId, QObject *parent):
|
||||
QObject(parent),
|
||||
m_id(QUuid::createUuid()),
|
||||
m_deviceClassId(deviceClassId)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -10,3 +12,18 @@ QUuid Device::id() const
|
|||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QUuid Device::deviceClassId() const
|
||||
{
|
||||
return m_deviceClassId;
|
||||
}
|
||||
|
||||
QString Device::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void Device::setName(const QString &name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,18 @@ class Device: public QObject
|
|||
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||
|
||||
public:
|
||||
Device(QObject *parent = 0);
|
||||
Device(const QUuid &deviceClassId, QObject *parent = 0);
|
||||
|
||||
QUuid id() const;
|
||||
QUuid deviceClassId() const;
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
QUuid m_deviceClassId;
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,9 +25,26 @@ QList<DeviceClass> DeviceManager::supportedDevices()
|
|||
return m_supportedDevices;
|
||||
}
|
||||
|
||||
QList<Device *> DeviceManager::devices() const
|
||||
void DeviceManager::createDevice(const DeviceClass &deviceClass)
|
||||
{
|
||||
return m_devices;
|
||||
Device *device = new Device(deviceClass.id(), this);
|
||||
device->setName(deviceClass.name());
|
||||
}
|
||||
|
||||
QList<Device *> DeviceManager::configuredDevices() const
|
||||
{
|
||||
return m_configuredDevices;
|
||||
}
|
||||
|
||||
QList<Device *> DeviceManager::findConfiguredDevices(const DeviceClass &deviceClass)
|
||||
{
|
||||
QList<Device*> ret;
|
||||
foreach (Device *device, m_configuredDevices) {
|
||||
if (device->deviceClassId() == deviceClass.id()) {
|
||||
ret << device;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Radio433 *DeviceManager::radio433() const
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@ public:
|
|||
|
||||
QList<DeviceClass> supportedDevices();
|
||||
|
||||
QList<Device*> devices() const;
|
||||
void createDevice(const DeviceClass &deviceClass);
|
||||
|
||||
QList<Device*> configuredDevices() const;
|
||||
|
||||
QList<Device*> findConfiguredDevices(const DeviceClass &deviceClass);
|
||||
|
||||
Radio433 *radio433() const;
|
||||
|
||||
|
|
@ -28,7 +32,7 @@ private slots:
|
|||
|
||||
private:
|
||||
QList<DeviceClass> m_supportedDevices;
|
||||
QList<Device*> m_devices;
|
||||
QList<Device*> m_configuredDevices;
|
||||
QList<DevicePlugin*> m_devicePlugins;
|
||||
|
||||
Radio433* m_radio433;
|
||||
|
|
|
|||
|
|
@ -74,4 +74,6 @@ QString RfSwitch::pluginName() const
|
|||
void RfSwitch::dataReceived(QList<int> rawData)
|
||||
{
|
||||
qDebug() << "data received from Radio433" << rawData;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue