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 )
223 static std::shared_ptr<UNetExchange>
init_unetexchange(
int argc,
const char*
const argv[],
224 uniset::ObjectId shmID,
const std::shared_ptr<SharedMemory>& ic = 0,
const std::string& prefix =
"unet" );
227 static void help_print(
int argc,
const char* argv[] ) noexcept;
229 bool checkExistTransport(
const std::string& transportID ) noexcept;
231 inline std::shared_ptr<LogAgregator> getLogAggregator() noexcept
235 inline std::shared_ptr<DebugStream> log() noexcept
246 std::string s_fvalue;
248 std::shared_ptr<SMInterface> shm;
249 void step() noexcept;
254 void askSensors( UniversalIO::UIOCommand cmd );
256 void receiverEvent(
const std::shared_ptr<UNetReceiver>& r,
UNetReceiver::Event ev ) noexcept;
263 void termReceivers();
265 void initMulticastTransport(
UniXML::iterator nodes,
const std::string& n_field,
const std::string& n_fvalue,
const std::string& prefix );
268 void initUDPTransport(
UniXML::iterator nodes,
const std::string& n_field,
const std::string& n_fvalue,
const std::string& prefix);
269 void initIterators() noexcept;
270 void startReceivers();
279 timeout_t initPause = { 0 };
284 timeout_t maxHeartBeat = { 10 };
285 IOController::IOStateList::iterator itHeartBeat;
288 timeout_t steptime = { 1000 };
290 std::atomic_bool activated = {
false };
291 std::atomic_bool cancelled = {
false };
292 timeout_t activateTimeout = { 20000 };
296 ReceiverInfo() noexcept: r1(
nullptr), r2(
nullptr),
298 respondInvert(
false),
303 ReceiverInfo(
const std::shared_ptr<UNetReceiver>& _r1,
const std::shared_ptr<UNetReceiver>& _r2 ) noexcept:
306 respondInvert(
false),
311 std::shared_ptr<UNetReceiver> r1;
312 std::shared_ptr<UNetReceiver> r2;
314 void step(
const std::shared_ptr<SMInterface>& shm,
const std::string& myname, std::shared_ptr<DebugStream>& log ) noexcept;
316 inline void setRespondID(
uniset::ObjectId id,
bool invert =
false ) noexcept
319 respondInvert = invert;
332 sidChannelSwitchCount = id;
335 inline void initIterators(
const std::shared_ptr<SMInterface>& shm ) noexcept
337 shm->initIterator(itLostPackets);
338 shm->initIterator(itRespond);
339 shm->initIterator(itChannelNum);
340 shm->initIterator(itChannelSwitchCount);
349 IOController::IOStateList::iterator itRespond;
350 bool respondInvert = {
false };
352 IOController::IOStateList::iterator itLostPackets;
354 IOController::IOStateList::iterator itChannelNum;
356 long channelSwitchCount = { 0 };
358 IOController::IOStateList::iterator itChannelSwitchCount;
361 typedef std::deque<ReceiverInfo> ReceiverList;
362 ReceiverList recvlist;
364 bool no_sender = {
false };
365 std::shared_ptr<UNetSender> sender;
366 std::shared_ptr<UNetSender> sender2;
368 std::shared_ptr<LogAgregator> loga;
369 std::shared_ptr<DebugStream> unetlog;
370 std::shared_ptr<LogServer> logserv;
371 std::string logserv_host = {
""};
372 int logserv_port = {0};
Пассивный таймер
Definition: PassiveTimer.h:94
Definition: MessageType.h:127
Definition: MessageType.h:171
Definition: MessageType.h:214
Definition: UNetExchange.h:217
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
Definition: UNetUDP/UNetExchange.cc:535
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации)
Definition: UNetUDP/UNetExchange.cc:519
static void help_print(int argc, const char *argv[]) noexcept
Definition: UNetUDP/UNetExchange.cc:601
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: UNetUDP/UNetExchange.cc:639
Event
Definition: UNetReceiver.h:154
Definition: UniSetObject.h:80
Definition: VMonitor.h:117
Definition: CommonEventLoop.h:15
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:70
long ObjectId
Definition: UniSetTypes_i.idl:30
Definition: UniSetTypes_i.idl:65