28 TorcDevice::TorcDevice(
bool Valid,
double Value,
double Default,
29 const QString &ModelId,
const QVariantMap &Details)
34 defaultValue(Default),
36 uniqueId(QStringLiteral(
"")),
37 userName(QStringLiteral(
"")),
38 userDescription(QStringLiteral(
"")),
39 lock(QMutex::Recursive),
42 if (!Details.contains(QStringLiteral(
"name")))
44 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Device has no <name> - THIS WILL NOT WORK"));
48 QMutexLocker locker(gDeviceListLock);
49 uniqueId = Details.value(QStringLiteral(
"name")).toString();
50 setObjectName(uniqueId);
52 if (!uniqueId.isEmpty() && !gDeviceList->contains(uniqueId))
54 gDeviceList->insert(uniqueId,
this);
55 LOG(VB_GENERAL, LOG_DEBUG, QStringLiteral(
"New device id: %1").arg(uniqueId));
59 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Device id '%1' already in use - THIS WILL NOT WORK").arg(uniqueId));
63 if (Details.contains(QStringLiteral(
"username")))
64 userName = Details.value(QStringLiteral(
"username")).toString();
65 if (Details.contains(QStringLiteral(
"userdescription")))
66 userDescription = Details.value(QStringLiteral(
"userdescription")).toString();
72 QMutexLocker locker(gDeviceListLock);
74 LOG(VB_GENERAL, LOG_INFO, QStringLiteral(
"Device id: %1 removed").arg(uniqueId));
75 gDeviceList->remove(uniqueId);
79 QStringList TorcDevice::GetDescription(
void)
88 void TorcDevice::Start(
void)
96 void TorcDevice::Stop(
void)
103 QMutexLocker locker(&lock);
112 emit ValidChanged(valid);
117 QMutexLocker locker(&lock);
127 if (qFuzzyCompare(Value + 1.0f, value + 1.0f))
132 emit ValueChanged(value);
137 QMutexLocker locker(&lock);
144 QMutexLocker locker(&lock);
151 QMutexLocker locker(&lock);
170 QMutexLocker locker(&lock);
177 QMutexLocker locker(&lock);
179 return userDescription;
QString GetUserName(void)
double GetDefaultValue(void)
virtual void SetValid(bool Valid)
A reference counting implementation.
QString GetUserDescription(void)
static QMutex * gDeviceListLock
static QHash< QString, TorcDevice * > * gDeviceList
virtual void SetValue(double Value)
#define LOG(_MASK_, _LEVEL_, _STRING_)
QString GetUniqueId(void)