diff --git a/plugins/deviceplugins/eq-3/eq-3.pro b/plugins/deviceplugins/eq-3/eq-3.pro index ac7c4e53..40033fe2 100644 --- a/plugins/deviceplugins/eq-3/eq-3.pro +++ b/plugins/deviceplugins/eq-3/eq-3.pro @@ -10,7 +10,8 @@ SOURCES += \ maxcube.cpp \ maxdevice.cpp \ room.cpp \ - livemessage.cpp + wallthermostat.cpp \ + radiatorthermostat.cpp HEADERS += \ deviceplugineq-3.h \ @@ -18,5 +19,6 @@ HEADERS += \ maxcube.h \ maxdevice.h \ room.h \ - livemessage.h + wallthermostat.h \ + radiatorthermostat.h diff --git a/plugins/deviceplugins/eq-3/maxcube.cpp b/plugins/deviceplugins/eq-3/maxcube.cpp index 1620b9b3..ecca6171 100644 --- a/plugins/deviceplugins/eq-3/maxcube.cpp +++ b/plugins/deviceplugins/eq-3/maxcube.cpp @@ -26,6 +26,7 @@ MaxCube::MaxCube(QObject *parent, QString serialNumber, QHostAddress hostAdress, connect(this,SIGNAL(connected()),this,SLOT(connected())); connect(this,SIGNAL(disconnected()),this,SLOT(disconnected())); + connect(this,SIGNAL(readyRead()),this,SLOT(readData())); connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(error(QAbstractSocket::SocketError))); @@ -82,26 +83,6 @@ void MaxCube::setPort(const quint16 &port) m_port = port; } -QByteArray MaxCube::httpConnectionId() const -{ - return m_httpConnectionId; -} - -void MaxCube::setHttpConnectionId(const QByteArray &httpConnectionId) -{ - m_httpConnectionId = httpConnectionId; -} - -int MaxCube::freeMemorySlots() const -{ - return m_freeMemorySlots; -} - -void MaxCube::setFreeMemorySlots(const int &freeMemorySlots) -{ - m_freeMemorySlots = freeMemorySlots; -} - QDateTime MaxCube::cubeDateTime() const { return m_cubeDateTime; @@ -117,9 +98,14 @@ bool MaxCube::portalEnabeld() const return m_portalEnabeld; } -QList MaxCube::deviceList() +QList MaxCube::wallThermostatList() { - return m_deviceList; + return m_wallThermostatList; +} + +QList MaxCube::radiatorThermostatList() +{ + return m_radiatorThermostatList; } QList MaxCube::roomList() @@ -153,28 +139,25 @@ void MaxCube::decodeHelloMessage(QByteArray data) m_rfAddress = list.at(1); m_firmware = list.at(2).toInt(); - qDebug() << "===================================================="; - qDebug() << " HELLO message:"; - qDebug() << "===================================================="; - qDebug() << " serial number | " << list.at(0); - qDebug() << " RF address (hex) | " << list.at(1); - qDebug() << " firmware | " << QString::number(list.at(2).toInt()); - qDebug() << " HTTP connection id | " << list.at(4); - qDebug() << " duty cycle (hex) | " << list.at(5); - qDebug() << " free memory slots (hex) | " << list.at(6); - qDebug() << " Cube date | " << m_cubeDateTime.date().toString("dd.MM.yyyy"); - qDebug() << " Cube time | " << m_cubeDateTime.time().toString("HH:mm"); - qDebug() << " State Cube Time | " << list.at(9); - qDebug() << " NTP counter | " << list.at(10); +// qDebug() << "===================================================="; +// qDebug() << " HELLO message:"; +// qDebug() << "===================================================="; +// qDebug() << " serial number | " << m_serialNumber; +// qDebug() << " RF address (hex) | " << m_rfAddress; +// qDebug() << " firmware | " << m_firmware; +// qDebug() << " Cube date | " << m_cubeDateTime.date().toString("dd.MM.yyyy"); +// qDebug() << " Cube time | " << m_cubeDateTime.time().toString("HH:mm"); +// qDebug() << " State Cube Time | " << list.at(9); +// qDebug() << " NTP counter | " << list.at(10); } void MaxCube::decodeMetadataMessage(QByteArray data) { QList list = data.left(data.length()-2).split(','); QByteArray dataDecoded = QByteArray::fromBase64(list.at(2)); - qDebug() << "===================================================="; - qDebug() << " METADATA message:"; - qDebug() << "===================================================="; +// qDebug() << "===================================================="; +// qDebug() << " METADATA message:"; +// qDebug() << "===================================================="; // parse room list int roomCount = dataDecoded.toHex().mid(4,2).toInt(0,16); @@ -191,58 +174,89 @@ void MaxCube::decodeMetadataMessage(QByteArray data) m_roomList.append(room); roomRawData = roomRawData.right(roomRawData.length() - ((roomNameLength*2) + 10)); } - qDebug() << "-------------------------|-------------------------"; - qDebug() << "found " << m_roomList.count() << "rooms"; - qDebug() << "-------------------------|-------------------------"; +// qDebug() << "-------------------------|-------------------------"; +// qDebug() << "found " << m_roomList.count() << "rooms"; +// qDebug() << "-------------------------|-------------------------"; - foreach (Room *room, m_roomList) { - qDebug() << " Room Name | " << room->roomName(); - qDebug() << " Room ID | " << room->roomId(); - qDebug() << " Group RF Address | " << room->groupRfAddress(); - qDebug() << "-------------------------|-------------------------"; - } +// foreach (Room *room, m_roomList) { +// qDebug() << " Room Name | " << room->roomName(); +// qDebug() << " Room ID | " << room->roomId(); +// qDebug() << " Group RF Address | " << room->groupRfAddress(); +// qDebug() << "-------------------------|-------------------------"; +// } // parse device list int deviceCount = roomRawData.left(2).toInt(0,16); QByteArray deviceRawData = roomRawData.right(roomRawData.length() - 2); +// qDebug() << "-------------------------|-------------------------"; +// qDebug() << "found " << deviceCount << "devices"; +// qDebug() << "-------------------------|-------------------------"; + for(int i = 0; i < deviceCount; i++){ - MaxDevice* device = new MaxDevice(this); - device->setDeviceType(deviceRawData.left(2).toInt(0,16)); - device->setRfAddress(deviceRawData.mid(2,6)); - device->setSerialNumber(QByteArray::fromHex(deviceRawData.mid(8,20))); - int deviceNameLenght = deviceRawData.mid(28,2).toInt(0,16); - device->setDeviceName(QByteArray::fromHex(deviceRawData.mid(30,deviceNameLenght*2))); - device->setRoomId(deviceRawData.mid(30 + deviceNameLenght*2,2).toInt(0,16)); + int deviceType = deviceRawData.left(2).toInt(0,16); + switch (deviceType) { + case MaxDevice::DeviceRadiatorThermostat:{ + RadiatorThermostat* device = new RadiatorThermostat(this); + device->setDeviceType(deviceType); + device->setRfAddress(deviceRawData.mid(2,6)); + device->setSerialNumber(QByteArray::fromHex(deviceRawData.mid(8,20))); + int deviceNameLenght = deviceRawData.mid(28,2).toInt(0,16); + device->setDeviceName(QByteArray::fromHex(deviceRawData.mid(30,deviceNameLenght*2))); + device->setRoomId(deviceRawData.mid(30 + deviceNameLenght*2,2).toInt(0,16)); + deviceRawData = deviceRawData.right(deviceRawData.length() - (32 + deviceNameLenght*2)); - deviceRawData = deviceRawData.right(deviceRawData.length() - (32 + deviceNameLenght*2)); - m_deviceList.append(device); - } - - qDebug() << "-------------------------|-------------------------"; - qDebug() << "found " << m_deviceList.count() << "devices"; - qDebug() << "-------------------------|-------------------------"; - - foreach (MaxDevice *device, m_deviceList) { - qDebug() << " Device Name | " << device->deviceName(); - qDebug() << " Serial Number| " << device->serialNumber(); - qDebug() << " Device Type String | " << device->deviceTypeString(); - qDebug() << " RF address (hex) | " << device->rfAddress(); - qDebug() << " Room ID | " << device->roomId(); - qDebug() << "-------------------------|-------------------------"; - } - - // set room data for each device - foreach (MaxDevice *device, m_deviceList) { - foreach (Room * room, m_roomList) { - if(device->roomId() == room->roomId()){ - device->setRoomName(room->roomName()); + // set room data for each device + foreach (Room * room, m_roomList) { + if(device->roomId() == room->roomId()){ + device->setRoomName(room->roomName()); + } } + m_radiatorThermostatList.append(device); + +// qDebug() << " Device Name | " << device->deviceName(); +// qDebug() << " Serial Number| " << device->serialNumber(); +// qDebug() << " Device Type String | " << device->deviceTypeString(); +// qDebug() << " RF address (hex) | " << device->rfAddress(); +// qDebug() << " Room ID | " << device->roomId(); +// qDebug() << " Room Name | " << device->roomName(); +// qDebug() << "-------------------------|-------------------------"; + break; + } + case MaxDevice::DeviceWallThermostat:{ + WallThermostat* device = new WallThermostat(this); + device->setDeviceType(deviceType); + device->setRfAddress(deviceRawData.mid(2,6)); + device->setSerialNumber(QByteArray::fromHex(deviceRawData.mid(8,20))); + int deviceNameLenght = deviceRawData.mid(28,2).toInt(0,16); + device->setDeviceName(QByteArray::fromHex(deviceRawData.mid(30,deviceNameLenght*2))); + device->setRoomId(deviceRawData.mid(30 + deviceNameLenght*2,2).toInt(0,16)); + deviceRawData = deviceRawData.right(deviceRawData.length() - (32 + deviceNameLenght*2)); + + // set room data for each device + foreach (Room * room, m_roomList) { + if(device->roomId() == room->roomId()){ + device->setRoomName(room->roomName()); + } + } + m_wallThermostatList.append(device); + +// qDebug() << " Device Name | " << device->deviceName(); +// qDebug() << " Serial Number| " << device->serialNumber(); +// qDebug() << " Device Type String | " << device->deviceTypeString(); +// qDebug() << " RF address (hex) | " << device->rfAddress(); +// qDebug() << " Room ID | " << device->roomId(); +// qDebug() << " Room Name | " << device->roomName(); +// qDebug() << "-------------------------|-------------------------"; + break; + } + default: + break; } } - emit deviceListReady(m_deviceList); m_cubeInitialized = true; + emit deviceListsReady(); } void MaxCube::decodeConfigMessage(QByteArray data) @@ -253,7 +267,7 @@ void MaxCube::decodeConfigMessage(QByteArray data) } QByteArray rfAddress = list.at(0); QByteArray dataRaw = QByteArray::fromBase64(list.at(1)).toHex(); - int lengthData = dataRaw.left(2).toInt(0,16); + //int lengthData = dataRaw.left(2).toInt(0,16); if(rfAddress != dataRaw.mid(2,6)){ qDebug() << "ERROR: rf addresses not equal!"; } @@ -261,88 +275,95 @@ void MaxCube::decodeConfigMessage(QByteArray data) //QByteArray unknown = dataRaw.mid(12,6); QByteArray serialNumber = QByteArray::fromHex(dataRaw.mid(16,20)); - qDebug() << "===================================================="; - qDebug() << " CONFIG message:"; - qDebug() << "===================================================="; - qDebug() << " Serial Number | " << serialNumber; - qDebug() << " device Type | " << deviceTypeString(deviceType); - qDebug() << " RF address (hex) | " << rfAddress; - qDebug() << " data length | " << lengthData; - qDebug() << "-------------------------|-------------------------"; +// qDebug() << "===================================================="; +// qDebug() << " CONFIG message:"; +// qDebug() << "===================================================="; +// qDebug() << " Serial Number | " << serialNumber; +// qDebug() << " device Type | " << deviceTypeString(deviceType); +// qDebug() << " RF address (hex) | " << rfAddress; +// qDebug() << " data length | " << lengthData; +// qDebug() << "-------------------------|-------------------------"; switch (deviceType) { case MaxDevice::DeviceCube:{ m_portalEnabeld = (bool)dataRaw.mid(36,2).toInt(0,16); - qDebug() << " portal enabled | " << m_portalEnabeld; - qDebug() << " portal URL | " << QString(QByteArray::fromHex(dataRaw.mid(170,68))); - qDebug() << " time zone | " << QString(QByteArray::fromHex(dataRaw.mid(428,6))); - qDebug() << " summer/winter time | " << QString(QByteArray::fromHex(dataRaw.mid(452,8))); +// qDebug() << " portal enabled | " << m_portalEnabeld; +// qDebug() << " portal URL | " << QString(QByteArray::fromHex(dataRaw.mid(170,68))); +// qDebug() << " time zone | " << QString(QByteArray::fromHex(dataRaw.mid(428,6))); +// qDebug() << " summer/winter time | " << QString(QByteArray::fromHex(dataRaw.mid(452,8))); + emit cubeConfigReady(); break; } case MaxDevice::DeviceRadiatorThermostat:{ - int roomId = dataRaw.mid(10,2).toInt(0,16); - int firmware = dataRaw.mid(12,2).toInt(0,16); - double confortTemp = (double)dataRaw.mid(36,2).toInt(0,16) / 2.0; - double ecoTemp = (double)dataRaw.mid(38,2).toInt(0,16) / 2.0; - double maxSetPointTemp = (double)dataRaw.mid(40,2).toInt(0,16) / 2.0; - double minSetPointTemp = (double)dataRaw.mid(42,2).toInt(0,16) / 2.0; - double offsetTemp = (double)(dataRaw.mid(44,2).toInt(0,16) / 2.0 ) - 3.5; - double windowOpenTemp = (double)dataRaw.mid(46,2).toInt(0,16)/2.0; - int windowOpenDuration = dataRaw.mid(48,2).toInt(0,16); - // boost code - QByteArray boostDurationCode = fillBin(QByteArray::number(dataRaw.mid(50,2).toInt(0,16),2),8); - int boostDuration = boostDurationCode.left(3).toInt(0,2) * 5; - int valveValue = boostDurationCode.right(5).toInt(0,2) * 5; + foreach (RadiatorThermostat* device, m_radiatorThermostatList) { + if(device->rfAddress() == rfAddress){ - // day of week an time - QByteArray dowTime = fillBin(QByteArray::number(dataRaw.mid(52,2).toInt(0,16),2),8); - QString weekDay = weekDayString(dowTime.left(3).toInt(0,2)); - QTime time = QTime(dowTime.right(5).toInt(0,2),0); + //int roomId = dataRaw.mid(10,2).toInt(0,16); + //int firmware = dataRaw.mid(12,2).toInt(0,16); + device->setConfortTemp((double)dataRaw.mid(36,2).toInt(0,16) / 2.0); + device->setEcoTemp((double)dataRaw.mid(38,2).toInt(0,16) / 2.0); + device->setMaxSetPointTemp((double)dataRaw.mid(40,2).toInt(0,16) / 2.0); + device->setMinSetPointTemp((double)dataRaw.mid(42,2).toInt(0,16) / 2.0); + device->setOffsetTemp((double)(dataRaw.mid(44,2).toInt(0,16) / 2.0 ) - 3.5); + device->setWindowOpenTemp((double)dataRaw.mid(46,2).toInt(0,16)/2.0); + device->setWindowOpenDuration(dataRaw.mid(48,2).toInt(0,16)); + // boost code + QByteArray boostDurationCode = fillBin(QByteArray::number(dataRaw.mid(50,2).toInt(0,16),2),8); + device->setBoostDuration(boostDurationCode.left(3).toInt(0,2) * 5); + device->setBoostValveValue(boostDurationCode.right(5).toInt(0,2) * 5); - double valveMaximumSettings = (double)dataRaw.mid(54,2).toInt(0,16)*(double)100.0/255.0; - double valveOffset = (double)dataRaw.mid(56,2).toInt(0,16)*100.0/255.0; + // day of week an time + QByteArray dowTime = fillBin(QByteArray::number(dataRaw.mid(52,2).toInt(0,16),2),8); + device->setDiscalcingWeekDay(weekDayString(dowTime.left(3).toInt(0,2))); + device->setDiscalcingTime(QTime(dowTime.right(5).toInt(0,2),0)); - qDebug() << " Room ID | " << roomId; - qDebug() << " firmware | " << firmware; - qDebug() << " Confort Temp. | " << confortTemp << "C"; - qDebug() << " Eco Temp. | " << ecoTemp << "C"; - qDebug() << " Max. Set Point Temp. | " << maxSetPointTemp << "C"; - qDebug() << " Min. Set Point Temp. | " << minSetPointTemp << "C"; - qDebug() << " Temp. Offset | " << offsetTemp << "C"; - qDebug() << " Window Open Temp. | " << windowOpenTemp << "C"; - qDebug() << " Window Open Duration | " << windowOpenDuration << "min"; - qDebug() << " Boost code | " << boostDurationCode; - qDebug() << " Boost Duration | " << boostDuration << "min"; - qDebug() << " Valve value | " << valveValue << "%"; - qDebug() << " dow code | " << dowTime; - qDebug() << " disclaiming run day | " << weekDay; - qDebug() << " disclaiming run time | " << time.toString("HH:mm"); - qDebug() << " Valve Maximum Settings | " << valveMaximumSettings << "%"; - qDebug() << " Valve Offset | " << valveOffset << "%"; - parseWeeklyProgram(dataRaw.right(dataRaw.length() - 58)); + device->setValveMaximumSettings((double)dataRaw.mid(54,2).toInt(0,16)*(double)100.0/255.0); + device->setValveOffset((double)dataRaw.mid(56,2).toInt(0,16)*100.0/255.0); +// qDebug() << " Room ID | " << device->roomId(); +// qDebug() << " firmware | " << firmware; +// qDebug() << " Confort Temp. | " << device->confortTemp() << "C"; +// qDebug() << " Eco Temp. | " << device->ecoTemp() << "C"; +// qDebug() << " Max. Set Point Temp. | " << device->maxSetPointTemp() << "C"; +// qDebug() << " Min. Set Point Temp. | " << device->minSetPointTemp() << "C"; +// qDebug() << " Temp. Offset | " << device->offsetTemp() << "C"; +// qDebug() << " Window Open Temp. | " << device->windowOpenTemp() << "C"; +// qDebug() << " Window Open Duration | " << device->windowOpenDuration() << "min"; +// qDebug() << " Boost Duration | " << device->boostDuration() << "min"; +// qDebug() << " Valve value | " << device->boostValveValue() << "%"; +// qDebug() << " disclaiming run day | " << device->discalcingWeekDay(); +// qDebug() << " disclaiming run time | " << device->discalcingTime().toString("HH:mm"); +// qDebug() << " Valve Maximum Settings | " << device->valveMaximumSettings() << "%"; +// qDebug() << " Valve Offset | " << device->valveOffset() << "%"; + parseWeeklyProgram(dataRaw.right(dataRaw.length() - 58)); + } + } break; } case MaxDevice::DeviceRadiatorThermostatPlus: break; case MaxDevice::DeviceWallThermostat:{ - int roomId = dataRaw.mid(10,2).toInt(0,16); - int firmware = dataRaw.mid(12,2).toInt(0,16); - double confortTemp = (double)dataRaw.mid(36,2).toInt(0,16) / 2.0; - double ecoTemp = (double)dataRaw.mid(38,2).toInt(0,16)/2.0; - double maxSetPointTemp = (double)dataRaw.mid(40,2).toInt(0,16)/2.0; - double minSetPointTemp = (double)dataRaw.mid(42,2).toInt(0,16)/2.0; + foreach (WallThermostat* device, m_wallThermostatList) { + if(device->rfAddress() == rfAddress){ + //int roomId = dataRaw.mid(10,2).toInt(0,16); + //int firmware = dataRaw.mid(12,2).toInt(0,16); + device->setConfortTemp((double)dataRaw.mid(36,2).toInt(0,16) / 2.0); + device->setEcoTemp((double)dataRaw.mid(38,2).toInt(0,16)/2.0); + device->setMaxSetPointTemp((double)dataRaw.mid(40,2).toInt(0,16)/2.0); + device->setMinSetPointTemp((double)dataRaw.mid(42,2).toInt(0,16)/2.0); - qDebug() << " Room ID | " << roomId; - qDebug() << " firmware | " << firmware; - qDebug() << " Confort Temp. | " << confortTemp; - qDebug() << " Eco Temp. | " << ecoTemp; - qDebug() << " Max. Set Point Temp. | " << maxSetPointTemp; - qDebug() << " Min. Set Point Temp. | " << minSetPointTemp; +// qDebug() << " Room ID | " << device->roomId(); +// qDebug() << " firmware | " << firmware; +// qDebug() << " Confort Temp. | " << device->confortTemp(); +// qDebug() << " Eco Temp. | " << device->ecoTemp(); +// qDebug() << " Max. Set Point Temp. | " << device->maxSetPointTemp(); +// qDebug() << " Min. Set Point Temp. | " << device->minSetPointTemp(); - parseWeeklyProgram(dataRaw.right(dataRaw.length() - 44)); + parseWeeklyProgram(dataRaw.right(dataRaw.length() - 44)); + } + } break; } case MaxDevice::DeviceEcoButton: @@ -357,136 +378,121 @@ void MaxCube::decodeConfigMessage(QByteArray data) void MaxCube::decodeDevicelistMessage(QByteArray data) { - qDebug() << "===================================================="; - qDebug() << " LIVE message:"; - qDebug() << "===================================================="; - //qDebug() << data; - QByteArray rawDataAll = QByteArray::fromBase64(data).toHex(); - qDebug() << rawDataAll; +// qDebug() << "===================================================="; +// qDebug() << " LIVE message:"; +// qDebug() << "===================================================="; + QByteArray rawDataAll = QByteArray::fromBase64(data).toHex(); QList deviceMessageList = splitMessage(rawDataAll); foreach (QByteArray rawData, deviceMessageList) { - LiveMessage message; - message.setRfAddress(rawData.mid(0,6)); + QByteArray rfAddress = rawData.mid(0,6); + int deviceType = deviceTypeFromRFAddress(rfAddress); - MaxDevice *device = getDeviceTypeFromRFAddress(message.rfAddress()); - - switch (device->deviceType()) { + switch (deviceType) { case MaxDevice::DeviceWallThermostat:{ - QByteArray unknown = rawData.mid(6,2); + foreach (WallThermostat* device, m_wallThermostatList) { + if(device->rfAddress() == rfAddress){ - QByteArray initCode = fillBin(QByteArray::number(rawData.mid(8,2).toInt(0,16),2),8); - message.setInformationValid((bool)initCode.mid(3,1).toInt()); - message.setErrorOccured((bool)initCode.mid(4,1).toInt()); - message.setIsAnswereToCommand((bool)initCode.mid(5,1).toInt()); - message.setInitialized((bool)initCode.mid(6,1).toInt()); + // init/valid code + QByteArray initCode = fillBin(QByteArray::number(rawData.mid(8,2).toInt(0,16),2),8); + device->setInformationValid((bool)initCode.mid(3,1).toInt()); + device->setErrorOccured((bool)initCode.mid(4,1).toInt()); + device->setIsAnswereToCommand((bool)initCode.mid(5,1).toInt()); + device->setInitialized((bool)initCode.mid(6,1).toInt()); - QByteArray statusCode = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8); - message.setBatteryLow((bool)statusCode.mid(0,1).toInt()); - message.setLinkStatusOK(!(bool)statusCode.mid(1,1).toInt()); - message.setPanelLocked((bool)statusCode.mid(2,1).toInt()); - message.setGatewayKnown((bool)statusCode.mid(3,1).toInt()); - message.setDtsActive((bool)statusCode.mid(4,1).toInt()); - message.setDeviceMode(statusCode.right(2).toInt(0,2)); + // status code + QByteArray statusCode = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8); + device->setBatteryLow((bool)statusCode.mid(0,1).toInt()); + device->setLinkStatusOK(!(bool)statusCode.mid(1,1).toInt()); + device->setPanelLocked((bool)statusCode.mid(2,1).toInt()); + device->setGatewayKnown((bool)statusCode.mid(3,1).toInt()); + device->setDtsActive((bool)statusCode.mid(4,1).toInt()); + device->setDeviceMode(statusCode.right(2).toInt(0,2)); - message.setValvePosition((double)rawData.mid(12,2).toInt(0,16)); + // calculate current temperature and setpoint temperature + QByteArray tempCode = fillBin(QByteArray::number(rawData.mid(14,2).toInt(0,16),2),8); + device->setSetpointTemperatre((double)tempCode.right(6).toInt(0,2) / 2.0); + if(tempCode.left(2) == "10"){ + device->setCurrentTemperatre(((double)rawData.right(2).toInt(0,16) / 10.0) + 25.6); + }else{ + device->setCurrentTemperatre((double)rawData.right(2).toInt(0,16) / 10.0); + } - // calculate current temperature and setpoint temperature - // 00 00 00 00 - // 10 - QByteArray tempCode = fillBin(QByteArray::number(rawData.mid(14,2).toInt(0,16),2),8); - message.setSetpointTemperatre((double)tempCode.right(6).toInt(0,2) / 2.0); - double currentTemperature; - if(tempCode.left(2) == "10"){ - currentTemperature = ((double)rawData.right(2).toInt(0,16) / 10.0) + 25.6; - }else{ - currentTemperature = (double)rawData.right(2).toInt(0,16) / 10.0; +// qDebug() << " raw data | " << rawData; +// qDebug() << " device type | " << device->deviceTypeString(); +// qDebug() << " device name | " << device->deviceName(); +// qDebug() << " RF address (hex) | " << device->rfAddress(); +// qDebug() << " initCode | " << initCode; +// qDebug() << " information valid | " << device->informationValid(); +// qDebug() << " error occured | " << device->errorOccured(); +// qDebug() << " is answere to a command | " << device->isAnswereToCommand(); +// qDebug() << " initialized | " << device->initialized(); +// qDebug() << " battery low | " << device->batteryLow(); +// qDebug() << " link status OK | " << device->linkStatusOK(); +// qDebug() << " panel locked | " << device->panelLocked(); +// qDebug() << " gateway known | " << device->gatewayKnown(); +// qDebug() << " DST settings active | " << device->dtsActive(); +// qDebug() << " device mode | " << device->deviceModeString(); +// qDebug() << " Temperatur Setpoint | " << device->setpointTemperature(); +// qDebug() << " Current Temp | " << device->currentTemperature(); +// qDebug() << "-------------------------|-------------------------"; + } } - - qDebug() << " raw data | " << rawData; - qDebug() << " device type | " << device->deviceTypeString(); - qDebug() << " device name | " << device->deviceName(); - qDebug() << " RF address (hex) | " << message.rfAddress(); - qDebug() << " unknown | " << unknown; - qDebug() << " initCode | " << initCode; - qDebug() << " information valid | " << message.informationValid(); - qDebug() << " error occured | " << message.errorOccured(); - qDebug() << " is answere to a command | " << message.isAnswereToCommand(); - qDebug() << " initialized | " << message.initialized(); - qDebug() << " statusCode | " << statusCode; - qDebug() << " battery low | " << message.batteryLow(); - qDebug() << " link status OK | " << message.linkStatusOK(); - qDebug() << " panel locked | " << message.panelLocked(); - qDebug() << " gateway known | " << message.gatewayKnown(); - qDebug() << " DST settings active | " << message.dtsActive(); - qDebug() << " device mode | " << message.deviceModeString(); - qDebug() << " temp Code | " << tempCode; - qDebug() << " Temperatur Setpoint | " << message.setpointTemperature(); - qDebug() << " Current Temp | " << currentTemperature; - qDebug() << " unknown | " << rawData.right(rawData.length() - 12); - qDebug() << "-------------------------|-------------------------"; - - - - emit liveMessageReady(message); break; } case MaxDevice::DeviceRadiatorThermostat:{ - QByteArray unknown = rawData.mid(6,2); + foreach (RadiatorThermostat* device, m_radiatorThermostatList) { + if(device->rfAddress() == rfAddress){ - QByteArray initCode = fillBin(QByteArray::number(rawData.mid(8,2).toInt(0,16),2),8); - message.setInformationValid((bool)initCode.mid(3,1).toInt()); - message.setErrorOccured((bool)initCode.mid(4,1).toInt()); - message.setIsAnswereToCommand((bool)initCode.mid(5,1).toInt()); - message.setInitialized((bool)initCode.mid(6,1).toInt()); + QByteArray initCode = fillBin(QByteArray::number(rawData.mid(8,2).toInt(0,16),2),8); + device->setInformationValid((bool)initCode.mid(3,1).toInt()); + device->setErrorOccured((bool)initCode.mid(4,1).toInt()); + device->setIsAnswereToCommand((bool)initCode.mid(5,1).toInt()); + device->setInitialized((bool)initCode.mid(6,1).toInt()); - QByteArray statusCode = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8); - message.setBatteryLow((bool)statusCode.mid(0,1).toInt()); - message.setLinkStatusOK(!(bool)statusCode.mid(1,1).toInt()); - message.setPanelLocked((bool)statusCode.mid(2,1).toInt()); - message.setGatewayKnown((bool)statusCode.mid(3,1).toInt()); - message.setDtsActive((bool)statusCode.mid(4,1).toInt()); - message.setDeviceMode(statusCode.right(2).toInt(0,2)); + QByteArray statusCode = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8); + device->setBatteryLow((bool)statusCode.mid(0,1).toInt()); + device->setLinkStatusOK(!(bool)statusCode.mid(1,1).toInt()); + device->setPanelLocked((bool)statusCode.mid(2,1).toInt()); + device->setGatewayKnown((bool)statusCode.mid(3,1).toInt()); + device->setDtsActive((bool)statusCode.mid(4,1).toInt()); + device->setDeviceMode(statusCode.right(2).toInt(0,2)); - message.setValvePosition((double)rawData.mid(12,2).toInt(0,16)); - message.setSetpointTemperatre((double)rawData.mid(14,2).toInt(0,16)/ 2.0); - message.setDateTime(calculateDateTime(rawData.mid(18,4), rawData.mid(22,2))); + device->setValvePosition((double)rawData.mid(12,2).toInt(0,16)); + device->setSetpointTemperatre((double)rawData.mid(14,2).toInt(0,16)/ 2.0); - qDebug() << " raw data | " << rawData; - qDebug() << " device type | " << device->deviceTypeString(); - qDebug() << " device name | " << device->deviceName(); - qDebug() << " RF address (hex) | " << message.rfAddress(); - qDebug() << " unknown | " << unknown; - qDebug() << " information valid | " << message.informationValid(); - qDebug() << " error occured | " << message.errorOccured(); - qDebug() << " is answere to a command | " << message.isAnswereToCommand(); - qDebug() << " initialized | " << message.initialized(); - qDebug() << " battery low | " << message.batteryLow(); - qDebug() << " link status OK | " << message.linkStatusOK(); - qDebug() << " panel locked | " << message.panelLocked(); - qDebug() << " gateway known | " << message.gatewayKnown(); - qDebug() << " DST settings active | " << message.dtsActive(); - qDebug() << " device mode | " << message.deviceModeString(); - qDebug() << " valve position | " << message.valvePosition() << "%"; - qDebug() << " Temperatur Setpoint | " << message.setpointTemperature() << " deg C"; - qDebug() << " unknown | " << rawData.right(rawData.length() - 12); - qDebug() << "-------------------------|-------------------------"; - - emit liveMessageReady(message); +// qDebug() << " device type | " << device->deviceTypeString(); +// qDebug() << " device name | " << device->deviceName(); +// qDebug() << " RF address (hex) | " << device->rfAddress(); +// qDebug() << " information valid | " << device->informationValid(); +// qDebug() << " error occured | " << device->errorOccured(); +// qDebug() << " is answere to a command | " << device->isAnswereToCommand(); +// qDebug() << " initialized | " << device->initialized(); +// qDebug() << " battery low | " << device->batteryLow(); +// qDebug() << " link status OK | " << device->linkStatusOK(); +// qDebug() << " panel locked | " << device->panelLocked(); +// qDebug() << " gateway known | " << device->gatewayKnown(); +// qDebug() << " DST settings active | " << device->dtsActive(); +// qDebug() << " device mode | " << device->deviceModeString(); +// qDebug() << " valve position | " << device->valvePosition() << "%"; +// qDebug() << " Temperatur Setpoint | " << device->setpointTemperature() << " deg C"; +// qDebug() << "-------------------------|-------------------------"; + } + } break; } case MaxDevice::DeviceWindowContact:{ QByteArray windowOpenRawData = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8); - bool windowOpen = (bool)windowOpenRawData.mid(5,1).toInt(); + //bool windowOpen = (bool)windowOpenRawData.mid(5,1).toInt(); - qDebug() << " raw data | " << rawData; - qDebug() << " device type | " << device->deviceTypeString(); - qDebug() << " device name | " << device->deviceName(); - qDebug() << " RF address (hex) | " << message.rfAddress(); - qDebug() << " window open code | " << windowOpenRawData; - qDebug() << " window open | " << windowOpen; +// qDebug() << " raw data | " << rawData; +// qDebug() << " device type name | " << "Window Contact"; +// qDebug() << " RF address (hex) | " << rfAddress; +// qDebug() << " window open code | " << windowOpenRawData; +// qDebug() << " window open | " << windowOpen; +// qDebug() << "-------------------------|-------------------------"; break; } default: @@ -502,18 +508,16 @@ void MaxCube::parseWeeklyProgram(QByteArray data) //qDebug() << weekDayString(i); for(int i = 0; i < 52; i+=4){ QByteArray element = fillBin(QByteArray::number(dayData.mid(i,4).toInt(0,16),2),16); - int minutes = element.right(9).toInt(0,2) * 5; - int hours = (minutes / 60) % 24; - minutes = minutes % 60; - QTime time = QTime(hours,minutes); + //int minutes = element.right(9).toInt(0,2) * 5; + //int hours = (minutes / 60) % 24; + //minutes = minutes % 60; + //QTime time = QTime(hours,minutes); //qDebug() << (double)element.left(7).toInt(0,2) / 2 << "\t" << "deg. until" << "\t" << time.toString("HH:mm"); } - - data = data.right(data.length() - 52); } if(!data.isEmpty()){ - qDebug() << " ? | " << data; + //qDebug() << " ? | " << data; } } @@ -523,10 +527,10 @@ void MaxCube::decodeNewDeviceFoundMessage(QByteArray data) return; } - qDebug() << "===================================================="; - qDebug() << " NEW DEVICE message:"; - qDebug() << "===================================================="; - qDebug() << " Serial Number | " << QByteArray::fromBase64(data); +// qDebug() << "===================================================="; +// qDebug() << " NEW DEVICE message:"; +// qDebug() << "===================================================="; +// qDebug() << " Serial Number | " << QByteArray::fromBase64(data); } @@ -623,31 +627,41 @@ QList MaxCube::splitMessage(QByteArray data) messageList.append(data.mid(2,length)); data = data.right(data.length() - (length+2)); } - qDebug() << messageList; + //qDebug() << messageList; return messageList; } -MaxDevice *MaxCube::getDeviceTypeFromRFAddress(QByteArray rfAddress) +int MaxCube::deviceTypeFromRFAddress(QByteArray rfAddress) { - foreach (MaxDevice *device, m_deviceList){ + foreach (WallThermostat* device, m_wallThermostatList) { if(device->rfAddress() == rfAddress){ - return device; + return device->deviceType(); } } - return NULL; + + foreach (RadiatorThermostat* device, m_radiatorThermostatList) { + if(device->rfAddress() == rfAddress){ + return device->deviceType(); + } + } + return -1; } -void MaxCube::connected() +void MaxCube::connectionStateChanged(const QAbstractSocket::SocketState &socketState) { - qDebug() << "-> connected to cube " << m_serialNumber << m_hostAddress.toString(); - emit cubeConnectionStatusChanged(true); -} - -void MaxCube::disconnected() -{ - m_cubeInitialized = false; - qDebug() << "-> disconnected from cube " << m_serialNumber << m_hostAddress.toString(); - emit cubeConnectionStatusChanged(false); + switch (socketState) { + case QAbstractSocket::ConnectedState: + qDebug() << "-> connected to cube " << m_serialNumber << m_hostAddress.toString(); + emit cubeConnectionStatusChanged(true); + break; + case QAbstractSocket::UnconnectedState: + m_cubeInitialized = false; + qDebug() << "-> disconnected from cube " << m_serialNumber << m_hostAddress.toString(); + emit cubeConnectionStatusChanged(false); + break; + default: + break; + } } void MaxCube::error(QAbstractSocket::SocketError error) diff --git a/plugins/deviceplugins/eq-3/maxcube.h b/plugins/deviceplugins/eq-3/maxcube.h index 6afe3f58..72b36de6 100644 --- a/plugins/deviceplugins/eq-3/maxcube.h +++ b/plugins/deviceplugins/eq-3/maxcube.h @@ -26,7 +26,8 @@ #include "maxdevice.h" #include "room.h" -#include "livemessage.h" +#include "wallthermostat.h" +#include "radiatorthermostat.h" class MaxCube : public QTcpSocket { @@ -60,18 +61,14 @@ public: quint16 port() const; void setPort(const quint16 &port); - QByteArray httpConnectionId() const; - void setHttpConnectionId(const QByteArray &httpConnectionId); - - int freeMemorySlots() const; - void setFreeMemorySlots(const int &freeMemorySlots); - QDateTime cubeDateTime() const; void setCubeDateTime(const QDateTime &cubeDateTime); bool portalEnabeld() const; - QList deviceList(); + QList wallThermostatList(); + QList radiatorThermostatList(); + QList roomList(); void connectToCube(); @@ -86,13 +83,12 @@ private: int m_firmware; QHostAddress m_hostAddress; quint16 m_port; - QByteArray m_httpConnectionId; - int m_freeMemorySlots; QDateTime m_cubeDateTime; bool m_portalEnabeld; QList m_roomList; - QList m_deviceList; + QList m_wallThermostatList; + QList m_radiatorThermostatList; bool m_cubeInitialized; @@ -109,18 +105,21 @@ private: QByteArray fillBin(QByteArray data, int dataLength); QList splitMessage(QByteArray data); - MaxDevice *getDeviceTypeFromRFAddress(QByteArray rfAddress); + int deviceTypeFromRFAddress(QByteArray rfAddress); signals: void cubeDataAvailable(const QByteArray &data); void cubeACK(); void cubeConnectionStatusChanged(const bool &connected); - void deviceListReady(QList maxDeviceList); - void liveMessageReady(const LiveMessage &liveMessage); + + // when things are parsed + void deviceListsReady(); + void cubeConfigReady(); + void wallThermostatConfigReady(); + void radiatorThermostatConfigReady(); private slots: - void connected(); - void disconnected(); + void connectionStateChanged(const QAbstractSocket::SocketState &socketState); void error(QAbstractSocket::SocketError error); void readData(); void processCubeData(const QByteArray &data); diff --git a/plugins/deviceplugins/eq-3/maxdevice.h b/plugins/deviceplugins/eq-3/maxdevice.h index bc27f061..557c96af 100644 --- a/plugins/deviceplugins/eq-3/maxdevice.h +++ b/plugins/deviceplugins/eq-3/maxdevice.h @@ -38,6 +38,13 @@ public: DeviceEcoButton = 5 }; + enum DeviceMode{ + Auto = 0, + Manual = 1, + Temporary = 2, + Boost = 3 + }; + int deviceType() const; void setDeviceType(const int &deviceType); diff --git a/plugins/deviceplugins/eq-3/radiatorthermostat.cpp b/plugins/deviceplugins/eq-3/radiatorthermostat.cpp new file mode 100644 index 00000000..a5bf454d --- /dev/null +++ b/plugins/deviceplugins/eq-3/radiatorthermostat.cpp @@ -0,0 +1,298 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "radiatorthermostat.h" + +RadiatorThermostat::RadiatorThermostat(QObject *parent) : + MaxDevice(parent) +{ +} + +double RadiatorThermostat::confortTemp() const +{ + return m_confortTemp; +} + +void RadiatorThermostat::setConfortTemp(const double &confortTemp) +{ + m_confortTemp = confortTemp; +} + +double RadiatorThermostat::ecoTemp() const +{ + return m_ecoTemp; +} + +void RadiatorThermostat::setEcoTemp(const double &ecoTemp) +{ + m_ecoTemp = ecoTemp; +} + +double RadiatorThermostat::maxSetPointTemp() const +{ + return m_maxSetPointTemp; +} + +void RadiatorThermostat::setMaxSetPointTemp(const double &maxSetPointTemp) +{ + m_maxSetPointTemp = maxSetPointTemp; +} + +double RadiatorThermostat::minSetPointTemp() const +{ + return m_minSetPointTemp; +} + +void RadiatorThermostat::setMinSetPointTemp(const double &minSetPointTemp) +{ + m_minSetPointTemp = minSetPointTemp; +} + +double RadiatorThermostat::windowOpenTemp() const +{ + return m_windowOpenTemp; +} + +void RadiatorThermostat::setWindowOpenTemp(const double &windowOpenTemp) +{ + m_windowOpenTemp = windowOpenTemp; +} + +double RadiatorThermostat::offsetTemp() const +{ + return m_offsetTemp; +} + +void RadiatorThermostat::setOffsetTemp(const double &offsetTemp) +{ + m_offsetTemp = offsetTemp; +} + +int RadiatorThermostat::windowOpenDuration() const +{ + return m_windowOpenDuration; +} + +void RadiatorThermostat::setWindowOpenDuration(const int &windowOpenDuration) +{ + m_windowOpenDuration = windowOpenDuration; +} + +int RadiatorThermostat::boostDuration() const +{ + return m_boostDuration; +} + +void RadiatorThermostat::setBoostDuration(const int &boostDuration) +{ + m_boostDuration = boostDuration; +} + +int RadiatorThermostat::boostValveValue() const +{ + return m_boostValveValue; +} + +void RadiatorThermostat::setBoostValveValue(const int &boostValveValue) +{ + m_boostValveValue = boostValveValue; +} + +QString RadiatorThermostat::discalcingWeekDay() const +{ + return m_discalcWeekDay; +} + +void RadiatorThermostat::setDiscalcingWeekDay(const QString &discalcingWeekDay) +{ + m_discalcWeekDay = discalcingWeekDay; +} + +QTime RadiatorThermostat::discalcingTime() const +{ + return m_discalcTime; +} + +void RadiatorThermostat::setDiscalcingTime(const QTime &discalcingTime) +{ + m_discalcTime = discalcingTime; +} + +double RadiatorThermostat::valveMaximumSettings() const +{ + return m_valveMaximumSettings; +} + +void RadiatorThermostat::setValveMaximumSettings(const double &valveMaximumSettings) +{ + m_valveMaximumSettings = valveMaximumSettings; +} + +double RadiatorThermostat::valveOffset() const +{ + return m_valveOffset; +} + +void RadiatorThermostat::setValveOffset(const double &valveOffset) +{ + m_valveOffset = valveOffset; +} + +bool RadiatorThermostat::informationValid() const +{ + return m_informationValid; +} + +void RadiatorThermostat::setInformationValid(const bool &informationValid) +{ + m_informationValid = informationValid; +} + +bool RadiatorThermostat::errorOccured() const +{ + return m_errorOccured; +} + +void RadiatorThermostat::setErrorOccured(const bool &errorOccured) +{ + m_errorOccured = errorOccured; +} + +bool RadiatorThermostat::isAnswereToCommand() const +{ + return m_isAnswerToCommand; +} + +void RadiatorThermostat::setIsAnswereToCommand(const bool &isAnswereToCommand) +{ + m_isAnswerToCommand = isAnswereToCommand; +} + +bool RadiatorThermostat::initialized() const +{ + return m_initialized; +} + +void RadiatorThermostat::setInitialized(const bool &initialized) +{ + m_initialized = initialized; +} + +bool RadiatorThermostat::batteryLow() const +{ + return m_batteryLow; +} + +void RadiatorThermostat::setBatteryLow(const bool &batteryLow) +{ + m_batteryLow = batteryLow; +} + +bool RadiatorThermostat::linkStatusOK() const +{ + return m_linkStatusOK; +} + +void RadiatorThermostat::setLinkStatusOK(const bool &linkStatusOK) +{ + m_linkStatusOK = linkStatusOK; +} + +bool RadiatorThermostat::panelLocked() const +{ + return m_panelLocked; +} + +void RadiatorThermostat::setPanelLocked(const bool &panelLocked) +{ + m_panelLocked = panelLocked; +} + +bool RadiatorThermostat::gatewayKnown() const +{ + return m_gatewayKnown; +} + +void RadiatorThermostat::setGatewayKnown(const bool &gatewayKnown) +{ + m_gatewayKnown = gatewayKnown; +} + +bool RadiatorThermostat::dtsActive() const +{ + return m_dtsActive; +} + +void RadiatorThermostat::setDtsActive(const bool &dtsActive) +{ + m_dtsActive = dtsActive; +} + +int RadiatorThermostat::deviceMode() const +{ + return m_deviceMode; +} + +void RadiatorThermostat::setDeviceMode(const int &deviceMode) +{ + m_deviceMode = deviceMode; + + switch (deviceMode) { + case Auto: + m_deviceModeString = "Auto"; + break; + case Manual: + m_deviceModeString = "Manuel"; + break; + case Temporary: + m_deviceModeString = "Temporary"; + break; + case Boost: + m_deviceModeString = "Boost"; + break; + default: + m_deviceModeString = "-"; + break; + } +} + +QString RadiatorThermostat::deviceModeString() const +{ + return m_deviceModeString; +} + +int RadiatorThermostat::valvePosition() const +{ + return m_valvePosition; +} + +void RadiatorThermostat::setValvePosition(const int &valvePosition) +{ + m_valvePosition = valvePosition; +} + +double RadiatorThermostat::setpointTemperature() const +{ + return m_setpointTemperature; +} + +void RadiatorThermostat::setSetpointTemperatre(const double &setpointTemperature) +{ + m_setpointTemperature = setpointTemperature; +} + diff --git a/plugins/deviceplugins/eq-3/radiatorthermostat.h b/plugins/deviceplugins/eq-3/radiatorthermostat.h new file mode 100644 index 00000000..c1b419ca --- /dev/null +++ b/plugins/deviceplugins/eq-3/radiatorthermostat.h @@ -0,0 +1,144 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * Guh is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, version 2 of the License. * + * * + * Guh 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef RADIATORTHERMOSTAT_H +#define RADIATORTHERMOSTAT_H + +#include +#include + +#include "maxdevice.h" + +class RadiatorThermostat : public MaxDevice +{ + Q_OBJECT +public: + explicit RadiatorThermostat(QObject *parent = 0); + + double confortTemp() const; + void setConfortTemp(const double &confortTemp); + + double ecoTemp() const; + void setEcoTemp(const double &ecoTemp); + + double maxSetPointTemp() const; + void setMaxSetPointTemp(const double &maxSetPointTemp); + + double minSetPointTemp() const; + void setMinSetPointTemp(const double &minSetPointTemp); + + double windowOpenTemp() const; + void setWindowOpenTemp(const double &windowOpenTemp); + + double offsetTemp() const; + void setOffsetTemp(const double &offsetTemp); + + int windowOpenDuration() const; + void setWindowOpenDuration(const int &windowOpenDuration); + + int boostDuration() const; + void setBoostDuration(const int &boostDuration); + + int boostValveValue() const; + void setBoostValveValue(const int &boostValveValue); + + QString discalcingWeekDay() const; + void setDiscalcingWeekDay(const QString &discalcingWeekDay); + + QTime discalcingTime() const; + void setDiscalcingTime(const QTime &discalcingTime); + + double valveMaximumSettings() const; + void setValveMaximumSettings(const double &valveMaximumSettings); + + double valveOffset() const; + void setValveOffset(const double &valveOffset); + + bool informationValid() const; + void setInformationValid(const bool &informationValid); + + bool errorOccured() const; + void setErrorOccured(const bool &errorOccured); + + bool isAnswereToCommand() const; + void setIsAnswereToCommand(const bool &isAnswereToCommand); + + bool initialized() const; + void setInitialized(const bool &initialized); + + bool batteryLow() const; + void setBatteryLow(const bool &batteryLow); + + bool linkStatusOK() const; + void setLinkStatusOK(const bool &linkStatusOK); + + bool panelLocked() const; + void setPanelLocked(const bool &panelLocked); + + bool gatewayKnown() const; + void setGatewayKnown(const bool &gatewayKnown); + + bool dtsActive() const; + void setDtsActive(const bool &dtsActive); + + int deviceMode() const; + void setDeviceMode(const int &deviceMode); + + QString deviceModeString() const; + + int valvePosition() const; + void setValvePosition(const int &valvePosition); + + double setpointTemperature() const; + void setSetpointTemperatre(const double &setpointTemperature); + +private: + double m_confortTemp; + double m_ecoTemp; + double m_maxSetPointTemp; + double m_minSetPointTemp; + double m_windowOpenTemp; + double m_offsetTemp; + int m_windowOpenDuration; + int m_boostDuration; + int m_boostValveValue; + QString m_discalcWeekDay; + QTime m_discalcTime; + double m_valveMaximumSettings; + double m_valveOffset; + bool m_informationValid; + bool m_errorOccured; + bool m_isAnswerToCommand; + bool m_initialized; + bool m_batteryLow; + bool m_linkStatusOK; + bool m_panelLocked; + bool m_gatewayKnown; + bool m_dtsActive; + int m_deviceMode; + QString m_deviceModeString; + int m_valvePosition; + double m_setpointTemperature; + +signals: + +public slots: + +}; + +#endif // RADIATORTHERMOSTAT_H diff --git a/plugins/deviceplugins/eq-3/livemessage.cpp b/plugins/deviceplugins/eq-3/wallthermostat.cpp similarity index 53% rename from plugins/deviceplugins/eq-3/livemessage.cpp rename to plugins/deviceplugins/eq-3/wallthermostat.cpp index 0fddc524..93c9749c 100644 --- a/plugins/deviceplugins/eq-3/livemessage.cpp +++ b/plugins/deviceplugins/eq-3/wallthermostat.cpp @@ -16,119 +16,149 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "livemessage.h" +#include "wallthermostat.h" -LiveMessage::LiveMessage(QObject *parent) : - QObject(parent) +WallThermostat::WallThermostat(QObject *parent) : + MaxDevice(parent) { } -QByteArray LiveMessage::rfAddress() const +double WallThermostat::confortTemp() const { - return m_rfAddress; + return m_confortTemp; } -void LiveMessage::setRfAddress(const QByteArray &rfAddress) +void WallThermostat::setConfortTemp(const double &confortTemp) { - m_rfAddress = rfAddress; + m_confortTemp = confortTemp; } -bool LiveMessage::informationValid() const +double WallThermostat::ecoTemp() const +{ + return m_ecoTemp; +} + +void WallThermostat::setEcoTemp(const double &ecoTemp) +{ + m_ecoTemp = ecoTemp; +} + +double WallThermostat::maxSetPointTemp() const +{ + return m_maxSetPointTemp; +} + +void WallThermostat::setMaxSetPointTemp(const double &maxSetPointTemp) +{ + m_maxSetPointTemp = maxSetPointTemp; +} + +double WallThermostat::minSetPointTemp() const +{ + return m_minSetPointTemp; +} + +void WallThermostat::setMinSetPointTemp(const double &minSetPointTemp) +{ + m_minSetPointTemp = minSetPointTemp; +} + +bool WallThermostat::informationValid() const { return m_informationValid; } -void LiveMessage::setInformationValid(const bool &informationValid) +void WallThermostat::setInformationValid(const bool &informationValid) { m_informationValid = informationValid; } -bool LiveMessage::errorOccured() const +bool WallThermostat::errorOccured() const { return m_errorOccured; } -void LiveMessage::setErrorOccured(const bool &errorOccured) +void WallThermostat::setErrorOccured(const bool &errorOccured) { m_errorOccured = errorOccured; } -bool LiveMessage::isAnswereToCommand() const +bool WallThermostat::isAnswereToCommand() const { return m_isAnswerToCommand; } -void LiveMessage::setIsAnswereToCommand(const bool &isAnswereToCommand) +void WallThermostat::setIsAnswereToCommand(const bool &isAnswereToCommand) { m_isAnswerToCommand = isAnswereToCommand; } -bool LiveMessage::initialized() const +bool WallThermostat::initialized() const { return m_initialized; } -void LiveMessage::setInitialized(const bool &initialized) +void WallThermostat::setInitialized(const bool &initialized) { m_initialized = initialized; } -bool LiveMessage::batteryLow() const +bool WallThermostat::batteryLow() const { return m_batteryLow; } -void LiveMessage::setBatteryLow(const bool &batteryLow) +void WallThermostat::setBatteryLow(const bool &batteryLow) { m_batteryLow = batteryLow; } -bool LiveMessage::linkStatusOK() const +bool WallThermostat::linkStatusOK() const { return m_linkStatusOK; } -void LiveMessage::setLinkStatusOK(const bool &linkStatusOK) +void WallThermostat::setLinkStatusOK(const bool &linkStatusOK) { m_linkStatusOK = linkStatusOK; } -bool LiveMessage::panelLocked() const +bool WallThermostat::panelLocked() const { return m_panelLocked; } -void LiveMessage::setPanelLocked(const bool &panelLocked) +void WallThermostat::setPanelLocked(const bool &panelLocked) { m_panelLocked = panelLocked; } -bool LiveMessage::gatewayKnown() const +bool WallThermostat::gatewayKnown() const { return m_gatewayKnown; } -void LiveMessage::setGatewayKnown(const bool &gatewayKnown) +void WallThermostat::setGatewayKnown(const bool &gatewayKnown) { m_gatewayKnown = gatewayKnown; } -bool LiveMessage::dtsActive() const +bool WallThermostat::dtsActive() const { return m_dtsActive; } -void LiveMessage::setDtsActive(const bool &dtsActive) +void WallThermostat::setDtsActive(const bool &dtsActive) { m_dtsActive = dtsActive; } -int LiveMessage::deviceMode() const +int WallThermostat::deviceMode() const { return m_deviceMode; } -void LiveMessage::setDeviceMode(const int &deviceMode) +void WallThermostat::setDeviceMode(const int &deviceMode) { m_deviceMode = deviceMode; @@ -149,40 +179,29 @@ void LiveMessage::setDeviceMode(const int &deviceMode) m_deviceModeString = "-"; break; } - } -QString LiveMessage::deviceModeString() const +QString WallThermostat::deviceModeString() const { return m_deviceModeString; } -int LiveMessage::valvePosition() const -{ - return m_valvePosition; -} - -void LiveMessage::setValvePosition(const int &valvePosition) -{ - m_valvePosition = valvePosition; -} - -double LiveMessage::setpointTemperature() const +double WallThermostat::setpointTemperature() const { return m_setpointTemperature; } -void LiveMessage::setSetpointTemperatre(const double &setpointTemperature) +void WallThermostat::setSetpointTemperatre(const double &setpointTemperature) { m_setpointTemperature = setpointTemperature; } -QDateTime LiveMessage::dateTime() const +double WallThermostat::currentTemperature() const { - return m_dateTime; + return m_currentTemperature; } -void LiveMessage::setDateTime(const QDateTime dateTime) +void WallThermostat::setCurrentTemperatre(const double ¤tTemperature) { - m_dateTime = dateTime; + m_currentTemperature = currentTemperature; } diff --git a/plugins/deviceplugins/eq-3/livemessage.h b/plugins/deviceplugins/eq-3/wallthermostat.h similarity index 78% rename from plugins/deviceplugins/eq-3/livemessage.h rename to plugins/deviceplugins/eq-3/wallthermostat.h index 6e25f9e0..04c2b137 100644 --- a/plugins/deviceplugins/eq-3/livemessage.h +++ b/plugins/deviceplugins/eq-3/wallthermostat.h @@ -16,27 +16,29 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef LIVEMESSAGE_H -#define LIVEMESSAGE_H +#ifndef WALLTHERMOSTAT_H +#define WALLTHERMOSTAT_H #include -#include +#include "maxdevice.h" -class LiveMessage : public QObject +class WallThermostat : public MaxDevice { Q_OBJECT public: - explicit LiveMessage(QObject *parent = 0); + explicit WallThermostat(QObject *parent = 0); - enum DeviceMode{ - Auto = 0, - Manual = 1, - Temporary = 2, - Boost = 3 - }; + double confortTemp() const; + void setConfortTemp(const double &confortTemp); - QByteArray rfAddress() const; - void setRfAddress(const QByteArray & rfAddress); + double ecoTemp() const; + void setEcoTemp(const double &ecoTemp); + + double maxSetPointTemp() const; + void setMaxSetPointTemp(const double &maxSetPointTemp); + + double minSetPointTemp() const; + void setMinSetPointTemp(const double &minSetPointTemp); bool informationValid() const; void setInformationValid(const bool &informationValid); @@ -76,13 +78,15 @@ public: double setpointTemperature() const; void setSetpointTemperatre(const double &setpointTemperature); - QDateTime dateTime() const; - void setDateTime(const QDateTime dateTime); - + double currentTemperature() const; + void setCurrentTemperatre(const double ¤tTemperature); private: + double m_confortTemp; + double m_ecoTemp; + double m_maxSetPointTemp; + double m_minSetPointTemp; - QByteArray m_rfAddress; bool m_informationValid; bool m_errorOccured; bool m_isAnswerToCommand; @@ -96,7 +100,7 @@ private: QString m_deviceModeString; int m_valvePosition; double m_setpointTemperature; - QDateTime m_dateTime; + double m_currentTemperature; signals: @@ -104,4 +108,4 @@ public slots: }; -#endif // LIVEMESSAGE_H +#endif // WALLTHERMOSTAT_H