Support inverted IO connections
This commit is contained in:
parent
3a5711aeb9
commit
2ca8f05b65
@ -233,7 +233,8 @@ void DeviceManager::notificationReceived(const QVariantMap &data)
|
|||||||
QUuid inputStateTypeId = connectionMap.value("inputStateTypeId").toUuid();
|
QUuid inputStateTypeId = connectionMap.value("inputStateTypeId").toUuid();
|
||||||
QUuid outputThingId = connectionMap.value("outputThingId").toUuid();
|
QUuid outputThingId = connectionMap.value("outputThingId").toUuid();
|
||||||
QUuid outputStateTypeId = connectionMap.value("outputStateTypeId").toUuid();
|
QUuid outputStateTypeId = connectionMap.value("outputStateTypeId").toUuid();
|
||||||
IOConnection *ioConnection = new IOConnection(id, inputThingId, inputStateTypeId, outputThingId, outputStateTypeId);
|
bool inverted = connectionMap.value("inverted").toBool();
|
||||||
|
IOConnection *ioConnection = new IOConnection(id, inputThingId, inputStateTypeId, outputThingId, outputStateTypeId, inverted);
|
||||||
m_ioConnections->addIOConnection(ioConnection);
|
m_ioConnections->addIOConnection(ioConnection);
|
||||||
} else if (notification == "Integrations.IOConnectionRemoved") {
|
} else if (notification == "Integrations.IOConnectionRemoved") {
|
||||||
QUuid connectionId = data.value("params").toMap().value("ioConnectionId").toUuid();
|
QUuid connectionId = data.value("params").toMap().value("ioConnectionId").toUuid();
|
||||||
@ -712,13 +713,14 @@ int DeviceManager::executeBrowserItemAction(const QUuid &deviceId, const QString
|
|||||||
return m_jsonClient->sendCommand("Actions.ExecuteBrowserItemAction", data, this, "executeBrowserItemActionResponse");
|
return m_jsonClient->sendCommand("Actions.ExecuteBrowserItemAction", data, this, "executeBrowserItemActionResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
int DeviceManager::connectIO(const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId)
|
int DeviceManager::connectIO(const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId, bool inverted)
|
||||||
{
|
{
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
data.insert("inputThingId", inputThingId);
|
data.insert("inputThingId", inputThingId);
|
||||||
data.insert("inputStateTypeId", inputStateTypeId);
|
data.insert("inputStateTypeId", inputStateTypeId);
|
||||||
data.insert("outputThingId", outputThingId);
|
data.insert("outputThingId", outputThingId);
|
||||||
data.insert("outputStateTypeId", outputStateTypeId);
|
data.insert("outputStateTypeId", outputStateTypeId);
|
||||||
|
data.insert("inverted", inverted);
|
||||||
return m_jsonClient->sendCommand("Integrations.ConnectIO", data, this, "connectIOResponse");
|
return m_jsonClient->sendCommand("Integrations.ConnectIO", data, this, "connectIOResponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,7 +748,8 @@ void DeviceManager::getIOConnectionsResponse(const QVariantMap ¶ms)
|
|||||||
QUuid inputStateTypeId = connectionMap.value("inputStateTypeId").toUuid();
|
QUuid inputStateTypeId = connectionMap.value("inputStateTypeId").toUuid();
|
||||||
QUuid outputThingId = connectionMap.value("outputThingId").toUuid();
|
QUuid outputThingId = connectionMap.value("outputThingId").toUuid();
|
||||||
QUuid outputStateTypeId = connectionMap.value("outputStateTypeId").toUuid();
|
QUuid outputStateTypeId = connectionMap.value("outputStateTypeId").toUuid();
|
||||||
IOConnection *ioConnection = new IOConnection(id, inputThingId, inputStateTypeId, outputThingId, outputStateTypeId);
|
bool inverted = connectionMap.value("inverted").toBool();
|
||||||
|
IOConnection *ioConnection = new IOConnection(id, inputThingId, inputStateTypeId, outputThingId, outputStateTypeId, inverted);
|
||||||
m_ioConnections->addIOConnection(ioConnection);
|
m_ioConnections->addIOConnection(ioConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,7 +103,7 @@ public:
|
|||||||
Q_INVOKABLE int executeBrowserItem(const QUuid &deviceId, const QString &itemId);
|
Q_INVOKABLE int executeBrowserItem(const QUuid &deviceId, const QString &itemId);
|
||||||
Q_INVOKABLE int executeBrowserItemAction(const QUuid &deviceId, const QString &itemId, const QUuid &actionTypeId, const QVariantList ¶ms = QVariantList());
|
Q_INVOKABLE int executeBrowserItemAction(const QUuid &deviceId, const QString &itemId, const QUuid &actionTypeId, const QVariantList ¶ms = QVariantList());
|
||||||
|
|
||||||
Q_INVOKABLE int connectIO(const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId);
|
Q_INVOKABLE int connectIO(const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId, bool inverted);
|
||||||
Q_INVOKABLE int disconnectIO(const QUuid &ioConnectionId);
|
Q_INVOKABLE int disconnectIO(const QUuid &ioConnectionId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -30,13 +30,14 @@
|
|||||||
|
|
||||||
#include "ioconnection.h"
|
#include "ioconnection.h"
|
||||||
|
|
||||||
IOConnection::IOConnection(const QUuid &id, const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId, QObject *parent):
|
IOConnection::IOConnection(const QUuid &id, const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId, bool inverted, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_id(id),
|
m_id(id),
|
||||||
m_inputThingId(inputThingId),
|
m_inputThingId(inputThingId),
|
||||||
m_inputStateTypeId(inputStateTypeId),
|
m_inputStateTypeId(inputStateTypeId),
|
||||||
m_outputThingId(outputThingId),
|
m_outputThingId(outputThingId),
|
||||||
m_outputStateTypeId(outputStateTypeId)
|
m_outputStateTypeId(outputStateTypeId),
|
||||||
|
m_inverted(inverted)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -65,3 +66,8 @@ QUuid IOConnection::outputStateTypeId() const
|
|||||||
{
|
{
|
||||||
return m_outputStateTypeId;
|
return m_outputStateTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IOConnection::inverted() const
|
||||||
|
{
|
||||||
|
return m_inverted;
|
||||||
|
}
|
||||||
|
|||||||
@ -42,15 +42,17 @@ class IOConnection : public QObject
|
|||||||
Q_PROPERTY(QUuid inputStateTypeId READ inputStateTypeId CONSTANT)
|
Q_PROPERTY(QUuid inputStateTypeId READ inputStateTypeId CONSTANT)
|
||||||
Q_PROPERTY(QUuid outputThingId READ outputThingId CONSTANT)
|
Q_PROPERTY(QUuid outputThingId READ outputThingId CONSTANT)
|
||||||
Q_PROPERTY(QUuid outputStateTypeId READ outputStateTypeId CONSTANT)
|
Q_PROPERTY(QUuid outputStateTypeId READ outputStateTypeId CONSTANT)
|
||||||
|
Q_PROPERTY(bool inverted READ inverted CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit IOConnection(const QUuid &id, const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId, QObject *parent = nullptr);
|
explicit IOConnection(const QUuid &id, const QUuid &inputThingId, const QUuid &inputStateTypeId, const QUuid &outputThingId, const QUuid &outputStateTypeId, bool inverted, QObject *parent = nullptr);
|
||||||
|
|
||||||
QUuid id() const;
|
QUuid id() const;
|
||||||
QUuid inputThingId() const;
|
QUuid inputThingId() const;
|
||||||
QUuid inputStateTypeId() const;
|
QUuid inputStateTypeId() const;
|
||||||
QUuid outputThingId() const;
|
QUuid outputThingId() const;
|
||||||
QUuid outputStateTypeId() const;
|
QUuid outputStateTypeId() const;
|
||||||
|
bool inverted() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUuid m_id;
|
QUuid m_id;
|
||||||
@ -58,6 +60,7 @@ private:
|
|||||||
QUuid m_inputStateTypeId;
|
QUuid m_inputStateTypeId;
|
||||||
QUuid m_outputThingId;
|
QUuid m_outputThingId;
|
||||||
QUuid m_outputStateTypeId;
|
QUuid m_outputStateTypeId;
|
||||||
|
bool m_inverted = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IOCONNECTION_H
|
#endif // IOCONNECTION_H
|
||||||
|
|||||||
@ -52,6 +52,8 @@ QVariant IOConnections::data(const QModelIndex &index, int role) const
|
|||||||
return m_list.at(index.row())->outputThingId();
|
return m_list.at(index.row())->outputThingId();
|
||||||
case RoleOutputStateTypeId:
|
case RoleOutputStateTypeId:
|
||||||
return m_list.at(index.row())->outputStateTypeId();
|
return m_list.at(index.row())->outputStateTypeId();
|
||||||
|
case RoleInverted:
|
||||||
|
return m_list.at(index.row())->inverted();
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -63,6 +65,7 @@ QHash<int, QByteArray> IOConnections::roleNames() const
|
|||||||
roles.insert(RoleInputStateTypeId, "inputStateTypeId");
|
roles.insert(RoleInputStateTypeId, "inputStateTypeId");
|
||||||
roles.insert(RoleOutputThingId, "outputThingId");
|
roles.insert(RoleOutputThingId, "outputThingId");
|
||||||
roles.insert(RoleOutputStateTypeId, "outputStateTypeId");
|
roles.insert(RoleOutputStateTypeId, "outputStateTypeId");
|
||||||
|
roles.insert(RoleInverted, "inverted");
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,8 @@ public:
|
|||||||
RoleInputThingId,
|
RoleInputThingId,
|
||||||
RoleInputStateTypeId,
|
RoleInputStateTypeId,
|
||||||
RoleOutputThingId,
|
RoleOutputThingId,
|
||||||
RoleOutputStateTypeId
|
RoleOutputStateTypeId,
|
||||||
|
RoleInverted
|
||||||
};
|
};
|
||||||
Q_ENUM(Roles)
|
Q_ENUM(Roles)
|
||||||
|
|
||||||
|
|||||||
@ -130,7 +130,7 @@ SettingsPageBase {
|
|||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
Label {
|
Label {
|
||||||
text: qsTr("Type")
|
text: qsTr("Type:")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
@ -329,6 +329,8 @@ SettingsPageBase {
|
|||||||
property IOInputConnectionWatcher inputWatcher: null
|
property IOInputConnectionWatcher inputWatcher: null
|
||||||
property IOOutputConnectionWatcher outputWatcher: null
|
property IOOutputConnectionWatcher outputWatcher: null
|
||||||
|
|
||||||
|
readonly property bool isInput: ioConnectionDialog.ioStateType.ioType == Types.IOTypeDigitalInput || ioConnectionDialog.ioStateType.ioType == Types.IOTypeAnalogInput
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr("Connect \"%1\" to:").arg(ioConnectionDialog.ioStateType.displayName)
|
text: qsTr("Connect \"%1\" to:").arg(ioConnectionDialog.ioStateType.displayName)
|
||||||
@ -408,6 +410,16 @@ SettingsPageBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Inverted")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: invertCheckBox
|
||||||
|
checked: ioConnectionDialog.isInput ? ioConnectionDialog.inputWatcher.ioConnection.inverted : ioConnectionDialog.outputWatcher.ioConnection.inverted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@ -421,6 +433,7 @@ SettingsPageBase {
|
|||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("Disconnect")
|
text: qsTr("Disconnect")
|
||||||
|
enabled: ioConnectionDialog.isInput ? ioConnectionDialog.inputWatcher.ioConnection != null : ioConnectionDialog.outputWatcher.ioConnection != null
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (ioConnectionDialog.ioStateType.ioType == Types.IOTypeDigitalInput
|
if (ioConnectionDialog.ioStateType.ioType == Types.IOTypeDigitalInput
|
||||||
@ -435,6 +448,7 @@ SettingsPageBase {
|
|||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("Connect")
|
text: qsTr("Connect")
|
||||||
|
enabled: ioThingComboBox.currentIndex >= 0 && ioStateComboBox.currentIndex >= 0
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var inputThingId;
|
var inputThingId;
|
||||||
@ -453,9 +467,10 @@ SettingsPageBase {
|
|||||||
outputThingId = root.device.id;
|
outputThingId = root.device.id;
|
||||||
outputStateTypeId = ioConnectionDialog.ioStateType.id;
|
outputStateTypeId = ioConnectionDialog.ioStateType.id;
|
||||||
}
|
}
|
||||||
|
var inverted = invertCheckBox.checked
|
||||||
|
|
||||||
print("connecting", inputThingId, inputStateTypeId, outputThingId, outputStateTypeId)
|
print("connecting", inputThingId, inputStateTypeId, outputThingId, outputStateTypeId, inverted)
|
||||||
engine.deviceManager.connectIO(inputThingId, inputStateTypeId, outputThingId, outputStateTypeId);
|
engine.deviceManager.connectIO(inputThingId, inputStateTypeId, outputThingId, outputStateTypeId, inverted);
|
||||||
|
|
||||||
ioConnectionDialog.accept();
|
ioConnectionDialog.accept();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user