24 #include <unordered_map> 25 #include "UniSetObject.h" 28 #include "SMInterface.h" 29 #include "SharedMemory.h" 30 #include "ThreadCreator.h" 32 #include "UDPPacket.h" 72 UNetSender(
const std::string& host,
const int port,
const std::shared_ptr<SMInterface>& smi
73 ,
bool nocheckConnection =
false 74 ,
const std::string& s_field =
"" 75 ,
const std::string& s_fvalue =
"" 76 ,
const std::string& prop_prefix =
"unet" 77 ,
const std::string& prefix =
"unet" 78 ,
size_t maxDCount = UniSetUDP::MaxDCount
79 ,
size_t maxACount = UniSetUDP::MaxACount );
83 typedef size_t sendfactor_t;
85 static const long not_specified_value = { std::numeric_limits<long>::max() };
90 iotype(UniversalIO::UnknownIOType),
96 UniversalIO::IOType iotype;
98 IOController::IOStateList::iterator ioit;
101 sendfactor_t pack_sendfactor = { 0 };
102 long undefined_value = { not_specified_value };
103 friend std::ostream& operator<<( std::ostream& os,
UItem& p );
106 typedef std::unordered_map<uniset::ObjectId, UItem> UItemMap;
108 size_t getDataPackCount()
const;
113 void send() noexcept;
137 inline void setSendPause(
int msec )
141 inline void setPackSendPause(
int msec )
143 packsendpause = msec;
146 void setCheckConnectionPause(
int msec );
149 void askSensors( UniversalIO::UIOCommand cmd );
154 inline std::shared_ptr<DebugStream> getLog()
159 virtual const std::string getShortInfo()
const;
161 inline std::string getAddress()
const 165 inline int getPort()
const 170 inline size_t getADataSize()
const 174 inline size_t getDDataSize()
const 181 std::string s_field = {
"" };
182 std::string s_fvalue = {
"" };
183 std::string prop_prefix = {
"" };
185 const std::shared_ptr<SMInterface> shm;
186 std::shared_ptr<DebugStream> unetlog;
188 bool initItem( UniXML::iterator& it );
189 bool readItem(
const std::shared_ptr<UniXML>& xml, UniXML::iterator& it, xmlNode* sec );
191 void readConfiguration();
193 bool createConnection(
bool throwEx );
198 std::unique_ptr<UDPSocketU> udp;
201 std::string s_host = {
"" };
202 Poco::Net::SocketAddress saddr;
204 std::string myname = {
"" };
205 timeout_t sendpause = { 150 };
206 timeout_t packsendpause = { 5 };
207 timeout_t writeTimeout = { 1000 };
208 std::atomic_bool activated = {
false };
209 PassiveTimer ptCheckConnection;
211 typedef std::unordered_map<sendfactor_t, std::vector<PackMessage>> Packs;
216 std::unordered_map<sendfactor_t, size_t> packs_anum;
217 std::unordered_map<sendfactor_t, size_t> packs_dnum;
219 size_t packetnum = { 1 };
220 uint16_t lastcrc = { 0 };
221 UniSetUDP::UDPPacket s_msg;
223 size_t maxAData = { UniSetUDP::MaxACount };
224 size_t maxDData = { UniSetUDP::MaxDCount };
226 std::unique_ptr< ThreadCreator<UNetSender> > s_thr;
228 size_t ncycle = { 0 };
234 #endif // UNetSender_H_ Definition: CommonEventLoop.h:14
Definition: UNetSender.h:87
Definition: UNetSender.h:69
void askSensors(UniversalIO::UIOCommand cmd)
Definition: UNetSender.cc:540
void updateSensor(uniset::ObjectId id, long value)
Definition: UNetSender.cc:182
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:69
Definition: UDPPacket.h:106
void updateFromSM()
Definition: UNetSender.cc:155
Definition: UNetSender.h:115
void updateItem(UItem &it, long value)
Definition: UNetSender.cc:193
void initIterators()
Definition: UNetSender.cc:534
long ObjectId
Definition: UniSetTypes_i.idl:30