17 #ifndef UNetExchange_H_ 18 #define UNetExchange_H_ 24 #include "UniSetObject.h" 27 #include "SMInterface.h" 28 #include "SharedMemory.h" 29 #include "ThreadCreator.h" 30 #include "UNetReceiver.h" 31 #include "UNetSender.h" 32 #include "LogServer.h" 33 #include "DebugStream.h" 34 #include "UNetLogSugar.h" 35 #include "LogAgregator.h" 39 #define vmonit( var ) vmon.add( #var, var ) 217 static std::shared_ptr<UNetExchange>
init_unetexchange(
int argc,
const char*
const argv[],
218 uniset::ObjectId shmID,
const std::shared_ptr<SharedMemory>& ic = 0,
const std::string& prefix =
"unet" );
221 static void help_print(
int argc,
const char* argv[] ) noexcept;
223 bool checkExistTransport(
const std::string& transportID ) noexcept;
225 inline std::shared_ptr<LogAgregator> getLogAggregator() noexcept
229 inline std::shared_ptr<DebugStream> log() noexcept
240 std::string s_fvalue;
242 std::shared_ptr<SMInterface> shm;
243 void step() noexcept;
248 void askSensors( UniversalIO::UIOCommand cmd );
250 void receiverEvent(
const std::shared_ptr<UNetReceiver>& r,
UNetReceiver::Event ev ) noexcept;
257 void termReceivers();
259 void initMulticastTransport(
UniXML::iterator nodes,
const std::string& n_field,
const std::string& n_fvalue,
const std::string& prefix );
260 void initMulticastReceiverForNode(
UniXML::iterator n_it,
const std::string& prefix );
262 void initUDPTransport(
UniXML::iterator nodes,
const std::string& n_field,
const std::string& n_fvalue,
const std::string& prefix);
263 void initIterators() noexcept;
264 void startReceivers();
273 timeout_t initPause = { 0 };
278 timeout_t maxHeartBeat = { 10 };
279 IOController::IOStateList::iterator itHeartBeat;
282 timeout_t steptime = { 1000 };
284 std::atomic_bool activated = {
false };
285 std::atomic_bool cancelled = {
false };
286 timeout_t activateTimeout = { 20000 };
290 ReceiverInfo() noexcept: r1(
nullptr), r2(
nullptr),
292 respondInvert(
false),
297 ReceiverInfo(
const std::shared_ptr<UNetReceiver>& _r1,
const std::shared_ptr<UNetReceiver>& _r2 ) noexcept:
300 respondInvert(
false),
305 std::shared_ptr<UNetReceiver> r1;
306 std::shared_ptr<UNetReceiver> r2;
308 void step(
const std::shared_ptr<SMInterface>& shm,
const std::string& myname, std::shared_ptr<DebugStream>& log ) noexcept;
310 inline void setRespondID(
uniset::ObjectId id,
bool invert =
false ) noexcept
313 respondInvert = invert;
326 sidChannelSwitchCount = id;
329 inline void initIterators(
const std::shared_ptr<SMInterface>& shm ) noexcept
331 shm->initIterator(itLostPackets);
332 shm->initIterator(itRespond);
333 shm->initIterator(itChannelNum);
334 shm->initIterator(itChannelSwitchCount);
343 IOController::IOStateList::iterator itRespond;
344 bool respondInvert = {
false };
346 IOController::IOStateList::iterator itLostPackets;
348 IOController::IOStateList::iterator itChannelNum;
350 long channelSwitchCount = { 0 };
352 IOController::IOStateList::iterator itChannelSwitchCount;
355 typedef std::deque<ReceiverInfo> ReceiverList;
356 ReceiverList recvlist;
358 bool no_sender = {
false };
359 std::shared_ptr<UNetSender> sender;
360 std::shared_ptr<UNetSender> sender2;
362 std::shared_ptr<LogAgregator> loga;
363 std::shared_ptr<DebugStream> unetlog;
364 std::shared_ptr<LogServer> logserv;
365 std::string logserv_host = {
""};
366 int logserv_port = {0};
373 #endif // UNetExchange_H_ Пассивный таймер
Definition: PassiveTimer.h:92
static std::shared_ptr< UNetExchange > init_unetexchange(int argc, const char *const argv[], uniset::ObjectId shmID, const std::shared_ptr< SharedMemory > &ic=0, const std::string &prefix="unet")
Definition: unetexchange.cc:653
Definition: CommonEventLoop.h:14
Definition: UNetExchange.h:209
Definition: MessageType.h:170
Definition: UniSetObject.h:73
static void help_print(int argc, const char *argv[]) noexcept
Definition: unetexchange.cc:611
Definition: VMonitor.h:116
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:69
Event
Definition: UNetReceiver.h:150
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации)
Definition: unetexchange.cc:529
Definition: MessageType.h:126
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
Definition: unetexchange.cc:545
Definition: MessageType.h:213
Definition: UniSetTypes_i.idl:64
long ObjectId
Definition: UniSetTypes_i.idl:30