/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2017 Bernhard Trinnes * * Copyright (C) 2018 Simon Stürz * * * * This file is part of nymea. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; If not, see * * . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef DEVICEPLUGINUNIPI_H #define DEVICEPLUGINUNIPI_H #include "plugin/deviceplugin.h" #include "devicemanager.h" #include #include "plugintimer.h" #include "dimmerswitch.h" class DevicePluginUniPi : public DevicePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "devicepluginunipi.json") Q_INTERFACES(DevicePlugin) public: explicit DevicePluginUniPi(); ~DevicePluginUniPi(); void init() override; DeviceManager::DeviceSetupStatus setupDevice(Device *device) override; void deviceRemoved(Device *device) override; DeviceManager::DeviceError executeAction(Device *device, const Action &action) override; DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override; private: enum GpioType { Relay, DigitalInput, DigitalOutput, AnalogInput, AnalogOutput }; QHash m_usedRelais; QHash m_usedDigitalOutputs; QHash m_usedDigitalInputs; QHash m_usedAnalogOutputs; QHash m_usedAnalogInputs; QHash m_usedTemperatureSensors; QHash m_usedLeds; QHash m_dimmerSwitches; QList m_relais; QList m_digitalOutputs; QList m_digitalInputs; QList m_analogOutputs; QList m_analogInputs; QList m_temperatureSensors; QList m_leds; QWebSocket *m_webSocket = nullptr; PluginTimer *m_refreshTimer = nullptr; void requestAllData(); void setOutput(const QString &circuit, bool value); void connectToEvok(); private slots: void onWebSocketConnected(); void onWebSocketDisconnected(); void onWebSocketTextMessageReceived(const QString &message); void onRefreshTimer(); void onDimmerSwitchPressed(); void onDimmerSwitchLongPressed(); void onDimmerSwitchDoublePressed(); void onDimmerSwitchDimValueChanged(int dimValue); }; #endif // DEVICEPLUGINUNIPI_H