23 #include <unordered_map>
24 #include "UniSetObject.h"
27 #include "SMInterface.h"
28 #include "SharedMemory.h"
29 #include "ThreadCreator.h"
31 #include "UDPPacket.h"
71 UNetSender(
const std::string& host,
const int port,
const std::shared_ptr<SMInterface>& smi,
bool nocheckConnection =
false,
72 const std::string& s_field =
"",
const std::string& s_fvalue =
"",
const std::string& prefix =
"unet",
73 size_t maxDCount = UniSetUDP::MaxDCount,
size_t maxACount = UniSetUDP::MaxACount );
77 typedef size_t sendfactor_t;
82 iotype(UniversalIO::UnknownIOType),
88 UniversalIO::IOType iotype;
90 IOController::IOStateList::iterator ioit;
93 sendfactor_t pack_sendfactor = { 0 };
94 friend std::ostream& operator<<( std::ostream& os,
UItem& p );
97 typedef std::unordered_map<uniset::ObjectId, UItem> UItemMap;
99 size_t getDataPackCount()
const;
104 void send() noexcept;
111 PackMessage() noexcept {}
128 inline void setSendPause(
int msec )
132 inline void setPackSendPause(
int msec )
134 packsendpause = msec;
137 void setCheckConnectionPause(
int msec );
140 void askSensors( UniversalIO::UIOCommand cmd );
145 inline std::shared_ptr<DebugStream> getLog()
150 virtual const std::string getShortInfo()
const;
152 inline std::string getAddress()
const
156 inline int getPort()
const
161 inline size_t getADataSize()
const
165 inline size_t getDDataSize()
const
172 std::string s_field = {
"" };
173 std::string s_fvalue = {
"" };
174 std::string prefix = {
"" };
176 const std::shared_ptr<SMInterface> shm;
177 std::shared_ptr<DebugStream> unetlog;
179 bool initItem( UniXML::iterator& it );
180 bool readItem(
const std::shared_ptr<UniXML>& xml, UniXML::iterator& it, xmlNode* sec );
182 void readConfiguration();
184 bool createConnection(
bool throwEx );
189 std::shared_ptr<UDPSocketU> udp = {
nullptr };
192 std::string s_host = {
"" };
193 Poco::Net::SocketAddress saddr;
195 std::string myname = {
"" };
196 timeout_t sendpause = { 150 };
197 timeout_t packsendpause = { 5 };
198 timeout_t writeTimeout = { 1000 };
199 std::atomic_bool activated = {
false };
200 PassiveTimer ptCheckConnection;
202 typedef std::unordered_map<sendfactor_t, std::vector<PackMessage>> Packs;
207 std::unordered_map<sendfactor_t, size_t> packs_anum;
208 std::unordered_map<sendfactor_t, size_t> packs_dnum;
210 size_t packetnum = { 1 };
211 uint16_t lastcrc = { 0 };
212 UniSetUDP::UDPPacket s_msg;
214 size_t maxAData = { UniSetUDP::MaxACount };
215 size_t maxDData = { UniSetUDP::MaxDCount };
217 std::shared_ptr< ThreadCreator<UNetSender> > s_thr;
219 size_t ncycle = { 0 };
225 #endif // UNetSender_H_