24 #include <unordered_map> 25 #include "UniSetObject.h" 28 #include "SMInterface.h" 29 #include "SharedMemory.h" 30 #include "ThreadCreator.h" 31 #include "UDPPacket.h" 32 #include "UNetTransport.h" 72 UNetSender( std::unique_ptr<UNetSendTransport>&& transport,
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 size_t getADataSize()
const 169 inline size_t getDDataSize()
const 176 std::string s_field = {
"" };
177 std::string s_fvalue = {
"" };
178 std::string prop_prefix = {
"" };
180 const std::shared_ptr<SMInterface> shm;
181 std::shared_ptr<DebugStream> unetlog;
183 bool initItem( UniXML::iterator& it );
184 bool readItem(
const std::shared_ptr<UniXML>& xml, UniXML::iterator& it, xmlNode* sec );
186 void readConfiguration();
188 bool createConnection(
bool throwEx );
193 std::unique_ptr<UNetSendTransport> transport;
195 std::string myname = {
"" };
196 timeout_t sendpause = { 150 };
197 timeout_t packsendpause = { 5 };
198 int packsendpauseFactor = { 1 };
199 timeout_t writeTimeout = { 1000 };
200 std::atomic_bool activated = {
false };
201 PassiveTimer ptCheckConnection;
203 typedef std::unordered_map<sendfactor_t, std::vector<PackMessage>> Packs;
208 std::unordered_map<sendfactor_t, size_t> packs_anum;
209 std::unordered_map<sendfactor_t, size_t> packs_dnum;
211 size_t packetnum = { 1 };
212 uint16_t lastcrc = { 0 };
213 UniSetUDP::UDPPacket s_msg;
215 size_t maxAData = { UniSetUDP::MaxACount };
216 size_t maxDData = { UniSetUDP::MaxDCount };
218 std::unique_ptr< ThreadCreator<UNetSender> > s_thr;
220 size_t ncycle = { 0 };
226 #endif // UNetSender_H_ Definition: CommonEventLoop.h:14
Definition: UNetSender.h:87
Definition: UNetSender.h:69
void askSensors(UniversalIO::UIOCommand cmd)
Definition: UNetSender.cc:536
void updateSensor(uniset::ObjectId id, long value)
Definition: UNetSender.cc:161
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:69
Definition: UDPPacket.h:106
void updateFromSM()
Definition: UNetSender.cc:134
Definition: UNetSender.h:115
void updateItem(UItem &it, long value)
Definition: UNetSender.cc:172
void initIterators()
Definition: UNetSender.cc:530
long ObjectId
Definition: UniSetTypes_i.idl:30