31 #ifndef LIBHOMEGEAR_BASE_HGDC_H 32 #define LIBHOMEGEAR_BASE_HGDC_H 34 #include "../Systems/Packet.h" 36 #include "../Encoding/BinaryRpc.h" 37 #include "../Encoding/RpcEncoder.h" 38 #include "../Encoding/RpcDecoder.h" 39 #include "../Output/Output.h" 40 #include "../IQueue.h" 42 #include <condition_variable> 50 std::condition_variable conditionVariable;
52 typedef std::shared_ptr<RequestInfo> PRequestInfo;
55 std::atomic_bool finished{
false};
60 typedef std::shared_ptr<RpcResponse> PRpcResponse;
72 std::unique_ptr<TcpSocket> _tcpSocket;
73 std::unique_ptr<Rpc::BinaryRpc> _binaryRpc;
74 std::unique_ptr<Rpc::RpcEncoder> _rpcEncoder;
75 std::unique_ptr<Rpc::RpcDecoder> _rpcDecoder;
77 std::atomic_bool _stopped{
true};
78 std::atomic_bool _stopCallbackThread{
true};
79 std::thread _listenThread;
81 int32_t _currentEventHandlerId = 0;
82 std::mutex _packetReceivedEventHandlersMutex;
83 std::unordered_map<int64_t, std::list<std::pair<int32_t, std::function<void(int64_t, const std::string &, const std::vector<uint8_t> &)>>>> _packetReceivedEventHandlers;
84 std::mutex _moduleUpdateEventHandlersMutex;
85 std::unordered_map<int32_t, std::function<void(const BaseLib::PVariable &)>> _moduleUpdateEventHandlers;
86 std::mutex _reconnectedEventHandlersMutex;
87 std::unordered_map<int32_t, std::function<void()>> _reconnectedEventHandlers;
90 std::mutex _requestInfoMutex;
91 std::map<pthread_t, PRequestInfo> _requestInfo;
92 std::mutex _packetIdMutex;
93 int32_t _currentPacketId = 0;
94 std::mutex _rpcResponsesMutex;
95 std::unordered_map<pthread_t, std::unordered_map<int32_t, PRpcResponse>> _rpcResponses;
99 void processQueueEntry(int32_t index, std::shared_ptr<BaseLib::IQueueEntry> &entry)
override;
118 bool sendPacket(
const std::string &serialNumber,
const std::vector<uint8_t> &packet);
119 bool sendPacket(
const std::string &serialNumber,
const std::vector<char> &packet);
121 bool setMode(
const std::string &serialNumber, uint8_t mode);
126 #endif //LIBHOMEGEAR_BASE_HGDC_H bool sendPacket(const std::string &serialNumber, const std::vector< uint8_t > &packet)
Definition: Hgdc.cpp:378
This is the base library main class.
Definition: BaseLib.h:95
void stop()
Definition: Hgdc.cpp:91
Definition: BaseLib.cpp:34
std::shared_ptr< Array > PArray
Definition: Variable.h:72
void unregisterReconnectedEventHandler(int32_t eventHandlerId)
Definition: Hgdc.cpp:184
Class to print output of different kinds to the standard and error output.
Definition: Output.h:54
void unregisterModuleUpdateEventHandler(int32_t eventHandlerId)
Definition: Hgdc.cpp:156
void start()
Definition: Hgdc.cpp:52
PVariable invoke(const std::string &methodName, const PArray ¶meters, int32_t timeout=10000)
Definition: Hgdc.cpp:299
int32_t registerPacketReceivedEventHandler(int64_t familyId, std::function< void(int64_t, const std::string &, const std::vector< uint8_t > &)> value)
Definition: Hgdc.cpp:105
PVariable value
Definition: UiElements.h:217
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
bool isMaster()
Definition: Hgdc.cpp:468
void unregisterPacketReceivedEventHandler(int32_t eventHandlerId)
Definition: Hgdc.cpp:121
This class implements a queue after the producer-consumer paradigm.
Definition: IQueue.h:52
Hgdc(SharedObjects *bl, uint16_t port)
Definition: Hgdc.cpp:36
int32_t registerModuleUpdateEventHandler(std::function< void(const BaseLib::PVariable &)> value)
Definition: Hgdc.cpp:140
int32_t familyId
Definition: Licensing.h:380
int32_t registerReconnectedEventHandler(std::function< void()> value)
Definition: Hgdc.cpp:168
bool setMode(const std::string &serialNumber, uint8_t mode)
Definition: Hgdc.cpp:445
PVariable getModules(int64_t familyId=-1)
Definition: Hgdc.cpp:482
~Hgdc()
Definition: Hgdc.cpp:48
bool moduleReset(const std::string &serialNumber)
Definition: Hgdc.cpp:424