8 #include <Poco/JSON/Object.h>
9 #include <Poco/Mutex.h>
10 #include <Poco/Net/HTTPRequest.h>
11 #include <Poco/Net/SocketAddress.h>
12 #include <Poco/SharedPtr.h>
13 #include <Poco/Timespan.h>
15 #include "core/DeviceCache.h"
16 #include "core/PollableDevice.h"
17 #include "model/DeviceDescription.h"
18 #include "model/DeviceID.h"
19 #include "model/GatewayID.h"
20 #include "model/ModuleID.h"
21 #include "model/ModuleType.h"
22 #include "model/RefreshTime.h"
23 #include "model/SensorData.h"
24 #include "net/HTTPEntireResponse.h"
25 #include "util/Loggable.h"
38 typedef Poco::SharedPtr<VPTDevice> Ptr;
40 static const std::vector<std::string> REG_BOILER_OPER_TYPE;
41 static const std::vector<std::string> REG_BOILER_OPER_MODE;
42 static const std::vector<std::string> REG_MAN_ROOM_TEMP;
43 static const std::vector<std::string> REG_MAN_WATER_TEMP;
44 static const std::vector<std::string> REG_MAN_TUV_TEMP;
45 static const std::vector<std::string> REG_MOD_WATER_TEMP;
47 static const std::list<ModuleType> ZONE_MODULE_TYPES;
48 static const std::list<ModuleType> BOILER_MODULE_TYPES;
50 static const int COUNT_OF_ZONES;
68 const Poco::Net::SocketAddress& address,
69 const Poco::Timespan& httpTimeout,
70 const Poco::Timespan& pingTimeout,
73 const DeviceCache::Ptr deviceCache);
78 Poco::Net::SocketAddress address()
const;
79 void setAddress(
const Poco::Net::SocketAddress& address);
80 void setPassword(
const std::string& pwd);
81 Poco::FastMutex& lock();
83 void poll(Distributor::Ptr distributor)
override;
138 static std::string extractNonce(
const std::string& response);
139 static std::string generateHashPassword(
const std::string& pwd,
const std::string& response);
145 void buildDeviceID();
147 void requestSetModBoilerOperationType(
const int zone,
const double value);
148 void requestSetModBoilerOperationMode(
const int zone,
const double value);
149 void requestSetManualRoomTemperature(
const int zone,
const double value);
150 void requestSetManualWaterTemperature(
const int zone,
const double value);
151 void requestSetManualTUVTemperature(
const int zone,
const double value);
152 void requestSetModWaterTemperature(
const int zone,
const double value);
154 std::string parseZoneAttrFromJson(
const std::string& json,
const int zone,
const std::string& key);
156 HTTPEntireResponse prepareAndSendRequest(
const std::string& registr,
const std::string& value);
165 HTTPEntireResponse sendRequest(Poco::Net::HTTPRequest& request,
const Poco::Timespan& timeout)
const;
173 Poco::Net::SocketAddress m_address;
174 std::string m_password;
177 Poco::Timespan m_pingTimeout;
178 Poco::Timespan m_httpTimeout;
181 Poco::FastMutex m_lock;
183 DeviceCache::Ptr m_deviceCache;
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
DeviceID id() const override
Definition: VPTDevice.cpp:128
static DeviceID omitSubdeviceFromDeviceID(const DeviceID &id)
Returns DeviceID of real VPT.
Definition: VPTDevice.cpp:477
Definition: HTTPEntireResponse.h:13
static int extractSubdeviceFromDeviceID(const DeviceID &id)
Extracts subdevice number from DeviceID.
Definition: VPTDevice.cpp:484
Definition: ModuleID.h:12
std::vector< SensorData > requestValues()
Gathers data from all sensors of subdevices.
Definition: VPTDevice.cpp:518
bool operator==(const VPTDevice &other) const
Compares two VPTs based on DeviceID.
Definition: VPTDevice.cpp:223
std::vector< DeviceDescription > descriptions(const RefreshTime &refresh) const
Returns list of new device commands of all subdevices.
Definition: VPTDevice.cpp:532
Definition: Loggable.h:19
void requestModifyState(const DeviceID &id, const ModuleID module, const double value)
Definition: VPTDevice.cpp:242
static DeviceID createSubdeviceID(const int zone, const DeviceID &id)
Creates DeviceID from VPT DeviceID and number of zone.
Definition: VPTDevice.cpp:472
void poll(Distributor::Ptr distributor) override
Perform polling for data and ship them via the given distributor.
Definition: VPTDevice.cpp:163
VPTDevice(const Poco::Net::SocketAddress &address, const Poco::Timespan &httpTimeout, const Poco::Timespan &pingTimeout, const GatewayID &id, const RefreshTime &refresh, const DeviceCache::Ptr deviceCache)
Connects to specified address to fetch information for creating VPT Device. If the device do not resp...
Definition: VPTDevice.cpp:111
std::string generateStamp(const Action action)
Creates a stamp that consists of gateway id, IP address of gateway's interface from whitch the VPT is...
Definition: VPTDevice.cpp:173
RefreshTime refresh() const override
Regular period telling how often to call the method PollableDevice::poll(). The refresh must contain ...
Definition: VPTDevice.cpp:133
Definition: DeviceID.h:17
PollableDevice is a device that is necessary to poll regularly for data. The polling can take some ti...
Definition: PollableDevice.h:18
Definition: GatewayID.h:14
The class represents Thermona Regulator VPT LAN v1.0. It provides functions to control the VPT and to...
Definition: VPTDevice.h:36
void stampVPT(const Action action)
Sends stamp with aciton to the VPT. It serves to verify that the gateway communicates with the VPT...
Definition: VPTDevice.cpp:207