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;
145 inline void setPackSendPauseFactor(
int factor )
147 packsendpauseFactor = factor;
150 void setCheckConnectionPause(
int msec );
153 void askSensors( UniversalIO::UIOCommand cmd );
158 inline std::shared_ptr<DebugStream> getLog()
163 virtual const std::string getShortInfo()
const;
165 inline std::string getAddress()
const 169 inline int getPort()
const 174 inline size_t getADataSize()
const 178 inline size_t getDDataSize()
const 185 std::string s_field = {
"" };
186 std::string s_fvalue = {
"" };
187 std::string prop_prefix = {
"" };
189 const std::shared_ptr<SMInterface> shm;
190 std::shared_ptr<DebugStream> unetlog;
192 bool initItem( UniXML::iterator& it );
193 bool readItem(
const std::shared_ptr<UniXML>& xml, UniXML::iterator& it, xmlNode* sec );
195 void readConfiguration();
197 bool createConnection(
bool throwEx );
202 std::unique_ptr<UDPSocketU> udp;
205 std::string s_host = {
"" };
206 Poco::Net::SocketAddress saddr;
208 std::string myname = {
"" };
209 timeout_t sendpause = { 150 };
210 timeout_t packsendpause = { 5 };
211 int packsendpauseFactor = { 1 };
212 timeout_t writeTimeout = { 1000 };
213 std::atomic_bool activated = {
false };
214 PassiveTimer ptCheckConnection;
216 typedef std::unordered_map<sendfactor_t, std::vector<PackMessage>> Packs;
221 std::unordered_map<sendfactor_t, size_t> packs_anum;
222 std::unordered_map<sendfactor_t, size_t> packs_dnum;
224 size_t packetnum = { 1 };
225 uint16_t lastcrc = { 0 };
226 UniSetUDP::UDPPacket s_msg;
228 size_t maxAData = { UniSetUDP::MaxACount };
229 size_t maxDData = { UniSetUDP::MaxDCount };
231 std::unique_ptr< ThreadCreator<UNetSender> > s_thr;
233 size_t ncycle = { 0 };
239 #endif // UNetSender_H_ Definition: CommonEventLoop.h:14
Definition: UNetSender.h:87
Definition: UNetSender.h:69
void askSensors(UniversalIO::UIOCommand cmd)
Definition: UNetSender.cc:558
void updateSensor(uniset::ObjectId id, long value)
Definition: UNetSender.cc:184
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:69
Definition: UDPPacket.h:106
void updateFromSM()
Definition: UNetSender.cc:157
Definition: UNetSender.h:115
void updateItem(UItem &it, long value)
Definition: UNetSender.cc:195
void initIterators()
Definition: UNetSender.cc:552
long ObjectId
Definition: UniSetTypes_i.idl:30