98 if (Details.contains(QStringLiteral(
"inputs")))
100 QVariantMap inputs = Details.
value(QStringLiteral(
"inputs")).toMap();
101 QVariantMap::const_iterator it = inputs.constBegin();
102 for ( ; it != inputs.constEnd(); ++it)
104 if (it.key() == QStringLiteral(
"device"))
106 m_inputName = it.value().toString().trimmed();
107 m_customData.insert(QStringLiteral(
"inputname"), m_inputName);
108 m_customData.insert(QStringLiteral(
"name"),
userName);
114 if (Details.contains(QStringLiteral(
"triggerlow")))
116 m_triggerHigh =
false;
120 if (Details.contains(QStringLiteral(
"references")))
122 QVariantMap references = Details.value(QStringLiteral(
"references")).toMap();
123 QVariantMap::const_iterator it = references.constBegin();
124 for ( ; it != references.constEnd(); ++it)
126 if (it.key() == QStringLiteral(
"device"))
127 m_references.append(it.value().toString().trimmed());
134 QMutexLocker locker(&
lock);
135 return UniqueId == m_inputName;
141 return QStringList() << tr(
"Trigger 0 to 1");
142 return QStringList() << tr(
"Trigger 1 to 0");
153 foreach (
TorcDevice *device, m_referenceDevices)
154 Data->append(QStringLiteral(
" \"%1\"->\"%2\" [style=dashed]\r\n").arg(device->
GetUniqueId(),
uniqueId));
157 Data->append(QStringLiteral(
" \"%1\"->\"%2\"\r\n").arg(
uniqueId, notifier->
GetUniqueId()));
165 if (input && (input == m_input))
167 if ((Value > 0.0 && m_lastValue <= 0.0 && m_triggerHigh) ||
168 (Value <= 0.0 && m_lastValue > 0.0 && !m_triggerHigh))
171 foreach (
TorcDevice* device, m_referenceDevices)
181 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"TriggerNotifiction '%1' signalled from unknown input").arg(
uniqueId));
191 if (m_inputName.isEmpty())
198 if (!m_inputName.isEmpty() &&
gDeviceList->contains(m_inputName))
204 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Failed to find input '%1' for trigger notification '%2'").arg(m_inputName,
uniqueId));
212 foreach (QString reference, m_references)
215 if (!reference.isEmpty() &&
gDeviceList->contains(reference))
216 m_referenceDevices.append(
gDeviceList->value(reference));
224 TorcNotification* Create(
const QString &Type,
const QVariantMap &Details)
override 226 if (Type == QStringLiteral(
"trigger") && Details.contains(QStringLiteral(
"inputs")))
virtual bool Setup(void) override
Finalise the notification.
QStringList m_notifierNames
void ValueChanged(double Value)
QStringList GetDescription(void) override
static QMutex * gDeviceListLock
static QHash< QString, TorcDevice * > * gDeviceList
void InputValueChanged(double Value)
TorcTriggerNotification(const QVariantMap &Details)
QList< TorcNotifier * > m_notifiers
TorcTriggerNotificationFactory TorcTriggerNotificationFactory
#define LOG(_MASK_, _LEVEL_, _STRING_)
QVariantMap SetNotificationText(const QString &Title, const QString &Body, const QMap< QString, QString > &Custom)
void Notify(const QVariantMap &Message)
bool IsKnownInput(const QString &UniqueId) override
void Graph(QByteArray *Data) override
static TorcNotify * gNotify
QString GetUniqueId(void)