7 #include <Poco/Clock.h>
8 #include <Poco/Mutex.h>
9 #include <Poco/Timespan.h>
11 #include "core/DeviceManager.h"
12 #include "model/RefreshTime.h"
13 #include "model/SensorValue.h"
14 #include "util/DelayedAsyncWork.h"
15 #include "zwave/ZWaveMapperRegistry.h"
16 #include "zwave/ZWaveNetwork.h"
17 #include "zwave/ZWaveNode.h"
57 std::string product()
const;
58 std::string vendor()
const;
78 ZWaveMapperRegistry::Mapper::Ptr mapper()
const;
86 std::list<ModuleType>
types()
const;
93 std::string toString()
const;
97 ZWaveMapperRegistry::Mapper::Ptr m_mapper;
101 typedef std::map<DeviceID, Device> DeviceMap;
102 typedef std::map<ZWaveNode::Identity, DeviceMap::iterator> ZWaveNodeMap;
115 void setRegistry(ZWaveMapperRegistry::Ptr registry);
143 void stop()
override;
146 void handleAccept(
const DeviceAcceptCommand::Ptr cmd)
override;
150 const Poco::Timespan &timeout)
override;
155 const Poco::Timespan &timeout)
override;
250 ZWaveNetwork::Ptr m_network;
251 ZWaveMapperRegistry::Ptr m_registry;
252 Poco::Timespan m_dispatchDuration;
253 Poco::Timespan m_pollTimeout;
263 ZWaveNodeMap m_zwaveNodes;
271 std::set<DeviceID> m_recentlyUnpaired;
276 Poco::FastMutex m_lock;
282 DelayedAsyncWork<>::Ptr m_inclusionWork;
void updateNode(const ZWaveNode &node)
Update the underlying ZWaveNode instance by the given one. Their identities must match.
Definition: ZWaveDeviceManager.cpp:60
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
bool resolveMapper(ZWaveMapperRegistry::Ptr registry)
Try to resolve Mapper for this Device based on the ZWaveNode contents unless a mapper is already reso...
Definition: ZWaveDeviceManager.cpp:75
void setNetwork(ZWaveNetwork::Ptr network)
Configure ZWaveNetwork to be used by this manager.
Definition: ZWaveDeviceManager.cpp:128
void setRegistry(ZWaveMapperRegistry::Ptr registry)
Set registry that are able to resolve the Z-Wave devices specific features.
Definition: ZWaveDeviceManager.cpp:133
void dispatchUnpaired()
Dispatch all registered devices that are not paired to the remote server.
Definition: ZWaveDeviceManager.cpp:435
Implementation of the AsyncWork interface that executes a given function once after the the given del...
Definition: DelayedAsyncWork.h:24
void dispatchDevice(const Device &device, bool enabled=true)
Dispatch the given device to the remote server.
Definition: ZWaveDeviceManager.cpp:450
void setDispatchDuration(const Poco::Timespan &duration)
Set maximal time window in which new devices are reported since the start of the inclusion mode...
Definition: ZWaveDeviceManager.cpp:138
Value coming from the Z-Wave network. It holds some data (usually sensor data) and metadata to identi...
Definition: ZWaveNode.h:102
Definition: SensorValue.h:14
void newNode(const ZWaveNode &node, bool dispatch)
If the given node is fully resolvable (we can determine its Mapper instance), it is registered as a n...
Definition: ZWaveDeviceManager.cpp:276
std::list< ModuleType > types() const
Definition: ZWaveDeviceManager.cpp:99
void handleAccept(const DeviceAcceptCommand::Ptr cmd) override
Generic handler of the DeviceAcceptCommand. It might be helpful to override this method in case we ne...
Definition: ZWaveDeviceManager.cpp:403
void dispatch(Poco::AutoPtr< Command > cmd, Poco::AutoPtr< Answer > answer)
AsyncWork is an interface allowing to wait until an asynchronous operation finishes. It is also possible to force-stop it by calling cancel().
Definition: AsyncWork.h:21
SensorValue convert(const ZWaveNode::Value &value) const
Definition: ZWaveDeviceManager.cpp:105
void setPollTimeout(const Poco::Timespan &timeout)
Set poll timeout of the main loop polling the configured ZWaveNetwork instance.
Definition: ZWaveDeviceManager.cpp:146
Definition: ModuleID.h:12
void registerDevice(const Device &device)
Register a device to be available for the BeeeOn system. The device must have a resolved mapper...
Definition: ZWaveDeviceManager.cpp:371
ZWaveNode represents information from the Z-Wave network about a particular node. Each Z-Wave node is...
Definition: ZWaveNode.h:22
std::set< DeviceID > recentlyUnpaired()
Access cached device IDs of the Z-Wave nodes removed by the recent unpair process. The call clears that cache.
Definition: ZWaveDeviceManager.cpp:489
Definition: DeviceManager.h:48
void run() override
Run the loop that receives events from the configured ZWaveNetwork instance. The loop receives inform...
Definition: ZWaveDeviceManager.cpp:154
AsyncWork::Ptr startDiscovery(const Poco::Timespan &duration) override
Starts device discovery process in a technology-specific way. This method is always called inside a c...
Definition: ZWaveDeviceManager.cpp:422
void processValue(const ZWaveNode::Value &value)
Process a Z-Wave value received from the Z-Wave network. If there is a paired device for that value a...
Definition: ZWaveDeviceManager.cpp:221
ZWaveDeviceManager implements the logical layer on top of the ZWaveNetwork interface. It adapts the Z-Wave specifics to the BeeeOn system with the help of ZWaveMapperRegistry::Mapper.
Definition: ZWaveDeviceManager.h:44
void updateNode(const ZWaveNode &node, bool dispatch)
If the given node is already registered, update information about it and if it is not paired...
Definition: ZWaveDeviceManager.cpp:321
AsyncWork< double >::Ptr startSetValue(const DeviceID &id, const ModuleID &module, const double value, const Poco::Timespan &timeout) override
Starts set-value operation in a technology specific way. The method is always called inside a critica...
Definition: ZWaveDeviceManager.cpp:552
void stopInclusion()
Helper method to stop the Z-Wave inclusion mode.
Definition: ZWaveDeviceManager.cpp:522
Device unregisterDevice(ZWaveNodeMap::iterator it)
Unregister the device pointed to by the iterator from being available to the BeeeOn system...
Definition: ZWaveDeviceManager.cpp:385
High-level representation of a Z-Wave device. It enriches the ZWaveNode for information needed by the...
Definition: ZWaveDeviceManager.h:51
void stop() override
Stop the polling loop.
Definition: ZWaveDeviceManager.cpp:213
Definition: DeviceID.h:17
void removeNode(const ZWaveNode &node)
The given node is considered to be unpaired, its cached data is deleted.
Definition: ZWaveDeviceManager.cpp:345
AsyncWork< std::set< DeviceID > >::Ptr startUnpair(const DeviceID &id, const Poco::Timespan &timeout) override
Starts device unpair process in a technology-specific way. This method is always called inside a crit...
Definition: ZWaveDeviceManager.cpp:499
void stopRemoveNode()
Helper method to stop the Z-Wave node removal mode.
Definition: ZWaveDeviceManager.cpp:537