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"
33#include "DebugStream.h"
34#include "UNetLogSugar.h"
35#include "LogAgregator.h"
39#define vmonit( var ) vmon.add( #var, var )
233 virtual ~UNetExchange();
236 static std::shared_ptr<UNetExchange>
init_unetexchange(
int argc,
const char*
const argv[],
237 uniset::ObjectId shmID,
const std::shared_ptr<SharedMemory>& ic = 0,
const std::string& prefix =
"unet" );
240 static void help_print(
int argc,
const char* argv[] )
noexcept;
242 bool checkExistTransport(
const std::string& transportID )
noexcept;
244 inline std::shared_ptr<LogAgregator> getLogAggregator() noexcept
248 inline std::shared_ptr<DebugStream> log() noexcept
259 std::string s_fvalue;
261 std::shared_ptr<SMInterface> shm;
262 void step() noexcept;
264 void sysCommand( const
uniset::SystemMessage* msg ) override;
265 void sensorInfo( const
uniset::SensorMessage* sm ) override;
266 void timerInfo( const
uniset::TimerMessage* tm ) override;
267 void askSensors( UniversalIO::UIOCommand cmd );
269 void receiverEvent( const
std::shared_ptr<UNetReceiver>& r, UNetReceiver::Event ev ) noexcept;
276 void termReceivers();
278 void initMulticastTransport( UniXML::iterator nodes, const
std::
string& n_field, const
std::
string& n_fvalue, const
std::
string& prefix );
279 void initMulticastReceiverForNode( UniXML::iterator root, UniXML::iterator n_it, const
std::
string& prefix );
281 void initUDPTransport(UniXML::iterator nodes, const
std::
string& n_field, const
std::
string& n_fvalue, const
std::
string& prefix);
282 void initIterators() noexcept;
283 void startReceivers();
292 timeout_t initPause = { 0 };
295 PassiveTimer ptHeartBeat;
297 timeout_t maxHeartBeat = { 10 };
298 IOController::IOStateList::iterator itHeartBeat;
301 timeout_t steptime = { 1000 };
303 std::atomic_bool activated = {
false };
304 std::atomic_bool cancelled = {
false };
305 timeout_t activateTimeout = { 20000 };
309 ReceiverInfo() noexcept: r1(
nullptr), r2(
nullptr),
311 respondInvert(false),
316 ReceiverInfo(
const std::shared_ptr<UNetReceiver>& _r1,
const std::shared_ptr<UNetReceiver>& _r2 )
noexcept:
319 respondInvert(
false),
324 std::shared_ptr<UNetReceiver> r1;
325 std::shared_ptr<UNetReceiver> r2;
327 void step(
const std::shared_ptr<SMInterface>& shm,
const std::string& myname, std::shared_ptr<DebugStream>& log )
noexcept;
329 inline void setRespondID(
uniset::ObjectId id,
bool invert =
false ) noexcept
332 respondInvert = invert;
345 sidChannelSwitchCount = id;
348 inline void initIterators(
const std::shared_ptr<SMInterface>& shm )
noexcept
350 shm->initIterator(itLostPackets);
351 shm->initIterator(itRespond);
352 shm->initIterator(itChannelNum);
353 shm->initIterator(itChannelSwitchCount);
362 IOController::IOStateList::iterator itRespond;
363 bool respondInvert = {
false };
365 IOController::IOStateList::iterator itLostPackets;
367 IOController::IOStateList::iterator itChannelNum;
369 long channelSwitchCount = { 0 };
371 IOController::IOStateList::iterator itChannelSwitchCount;
374 typedef std::deque<ReceiverInfo> ReceiverList;
375 ReceiverList recvlist;
377 bool no_sender = {
false };
378 std::shared_ptr<UNetSender> sender;
379 std::shared_ptr<UNetSender> sender2;
381 std::shared_ptr<LogAgregator> loga;
382 std::shared_ptr<DebugStream> unetlog;
383 std::shared_ptr<LogServer> logserv;
384 std::string logserv_host = {
""};
385 int logserv_port = {0};
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
Definition Calibration.h:27
const ObjectId DefaultObjectId
Definition UniSetTypes.h:71
long ObjectId
Definition UniSetTypes_i.idl:30
Definition UniSetTypes_i.idl:65