BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
OZWCommand.h
1 #pragma once
2 
3 #include <Poco/SynchronizedObject.h>
4 #include <Poco/Timespan.h>
5 
6 #pragma GCC diagnostic push
7 #pragma GCC diagnostic ignored "-Wunused-parameter"
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wignored-qualifiers"
10 #include <openzwave/Driver.h>
11 #pragma GCC diagnostic pop
12 #pragma GCC diagnostic pop
13 
14 #include "util/Loggable.h"
15 
16 namespace BeeeOn {
17 
18 class OZWNetwork;
19 
25 class OZWCommand : public Poco::SynchronizedObject, Loggable {
26 public:
27  enum Type {
28  NONE,
29  INCLUSION,
30  REMOVE_NODE,
31  };
32 
33  OZWCommand(OZWNetwork &ozw);
34 
38  Type type() const;
39 
44  bool wasRequested() const;
45 
50  bool isRunning() const;
51 
56  bool isCancelling() const;
57 
65  void request(Type type, uint32_t home);
66 
83  bool cancelIf(Type type, const Poco::Timespan &timeout);
84 
85 protected:
86  void onNormal();
87  void onStarted();
88  void onWaitUser();
89  void onInProgress();
90  void onSleeping();
91  void onCancelled();
92  void onError(OpenZWave::Driver::ControllerError error);
93  void onFailed();
94  void onSuccess();
95  void onNodeOK();
96  void onNodeFailed();
97 
98  static void handle(
99  OpenZWave::Driver::ControllerState state,
100  OpenZWave::Driver::ControllerError error,
101  void *context);
102 
103 private:
104  std::string typeName() const;
105  std::string typeName(Type type) const;
106  void stopCancelling();
107  void running();
108  void terminated();
109 
110 private:
111  Type m_type;
112  bool m_requested;
113  bool m_running;
114  bool m_cancelling;
115  uint32_t m_home;
116  Poco::Event m_event;
117  OZWNetwork &m_ozw;
118 };
119 
120 }
OZWCommand handles OpenZWave command management. It allows to request a command to be executed and ta...
Definition: OZWCommand.h:25
bool wasRequested() const
Definition: OZWCommand.cpp:246
bool cancelIf(Type type, const Poco::Timespan &timeout)
Cancel the current command if it is of the given type. This allows to cancel e.g. INCLUSION without k...
Definition: OZWCommand.cpp:150
OZWNetwork manages the Z-Wave network by using the OpenZWave library (OZW). Its purpose is to handle ...
Definition: OZWNetwork.h:54
bool isCancelling() const
Definition: OZWCommand.cpp:258
bool isRunning() const
Definition: OZWCommand.cpp:252
Type type() const
Definition: OZWCommand.cpp:221
Definition: Loggable.h:19
void request(Type type, uint32_t home)
Request the given type of command to execute in the context of the given Z-Wave home ID...
Definition: OZWCommand.cpp:100