47 #ifndef _MIRA_REMOTEMODULE_H_ 48 #define _MIRA_REMOTEMODULE_H_ 51 #include <serialization/adapters/std/list> 52 #include <serialization/adapters/boost/optional.hpp> 167 template<
typename Reflector>
170 r.member(
"Group", group,
171 "The workgroup, this framework belongs to",
"");
172 r.member(
"Password", mPassword,
setter(&AuthSettings::setPassword,
this),
173 "Password that is used for the weak authentication",
175 r.member(
"Key", mKeyFile,
setter(&AuthSettings::setKeyFile,
this),
176 "Path to the file containing the private key " 177 "for strong authentication.",
185 return AUTH_PASSWORD;
197 const std::string& getPassword()
const;
200 void setPassword(
const boost::optional<std::string>& passwd);
206 const RSAKey& getKey()
const;
209 void setKey(
const boost::optional<std::string>& str);
212 void setKeyFile(
const boost::optional<std::string>&
file);
216 boost::optional<std::string> mPassword;
217 boost::optional<std::string> mKeyFile;
218 boost::optional<RSAKey> mKey;
223 template<
typename Reflector>
227 r.member(
"Port", mPort,
228 "The port where the framework server runs on. 0 means auto port", 0);
229 r.member(
"IOThreadCount", mIOThreadCount,
230 "How many threads are used for communication", 1);
231 r.member(
"CycleTime", mCyclicRunnable.cycleTime,
232 "The cycle time of remote framework thread that observes connections",
235 r.property(
"EnablePTPSync", mEnablePTPSync,
"Enable/Disable synchronization of clocks via PTP (effective for new connections)",
true);
236 r.property(
"EnablePingTimeout", mEnablePingTimeout,
"Enable/Disable ping timeout (effective for new connections)",
false);
237 r.member(
"PingInterval", mPingInterval,
239 r.member(
"PingTimeout", mPingTimeout,
240 "The maximum time before a connection is assumed as dead " 243 r.member(
"ExitOnDisconnectTimeout", mExitOnDisconnectTimeout,
244 "Exits/Closes the framework if any connection could not be established or is closed for a certain time",
247 r.member(
"Authentication", mAuthSettings,
"Authentication Settings",
251 r.member(
"KnownFrameworks", mKnownFrameworks,
255 std::vector<std::string> tmpFWs;
256 r.member(
"KnownFrameworks", tmpFWs,
"",
258 mKnownFrameworks.clear();
259 foreach (
const std::string& a, tmpFWs) {
260 mKnownFrameworks.emplace_back();
261 mKnownFrameworks.back().address = a;
265 r.member(
"ServiceLevels", mServiceLevels,
267 r.member(
"ServiceLevelsByType", mTypeServiceLevels,
270 r.property(
"FrameworkConnections", mConnections,
273 r.interface(
"IRemoteModule");
275 "Requests a unit from an other framework to migrate into this framework",
276 "id",
"id of the unit to migrate",
"/navigation/Pilot");
278 "Returns if a framework with ID is connected to this framework",
279 "frameworkID",
"framework ID to check",
"Framework_81ab60d5-0e9a-43d6-aced-7e33a3cd875a");
281 "Returns if a framework with address is connected to this framework",
282 "address",
"address to check",
"127.0.0.1:1234");
284 "Disconnects a framework with ID (if connected)",
285 "frameworkID",
"framework ID to disconnect",
"Framework_81ab60d5-0e9a-43d6-aced-7e33a3cd875a",
286 "autoReconnect",
"if true, keep as known framework (thus try reconnecting)",
false);
288 "Disconnects from a framework with address",
289 "address",
"address to disconnect",
"127.0.0.1:1234",
290 "autoReconnect",
"if true, keep as known framework (thus try reconnecting)",
false);
291 r.method(
"connectTo",
293 "Add an address to the list of known remote frameworks and try to connect",
294 "address",
"Address of the remote framework as Host:Port",
"127.0.0.1:1234");
295 r.method(
"connectTo",
297 "Add an address to the list of known remote frameworks and try to connect",
298 "address",
"Address of the remote framework as Host:Port",
"127.0.0.1:1234",
299 "forcePTP",
"Force PTP time sync",
false,
300 "legacyBinaryFormat",
"Use legacy binary serializer to encode data (connect to legacy framework)",
false,
301 "monitorOnly",
"Do not publish local channels, services and authorities to remote",
false,
302 "delayConnect",
"Wait for this duration before trying to connect",
Duration::seconds(1));
309 static uint32 getCurrentVersion();
321 uint16 getPort()
const;
359 void setAuthGroup(
const std::string& group);
370 void setAuthPassword(
const std::string& password);
376 void setAuthKey(
const std::string& key);
382 void setAuthKeyFile(
const std::string& keyfile);
387 const AuthSettings& getAuthSettings()
const;
428 void addKnownFramework(
const std::string& address);
443 void addKnownFramework(
const std::string& address,
445 bool legacyBinaryFormat,
454 void disconnectFramework(
const std::string& frameworkID,
455 bool autoReconnect =
false);
464 void disconnectFrom(
const std::string& address,
465 bool autoReconnect =
false);
470 bool isFrameworkConnected(
const std::string& frameworkID)
const;
476 bool isConnectedTo(
const std::string& address)
const;
487 void migrateUnitToThisFramework(
const std::string&
id);
508 void publishService(
const std::string& service);
513 void unpublishService(
const std::string& service);
522 void publishChannel(
const std::string& channelID,
const Typename&
type);
530 void unpublishChannel(
const std::string& channelID);
539 void subscribeChannel(
const std::string& channelID);
546 void unsubscribeChannel(
const std::string& channelID);
551 void updateIncomingStats(std::size_t size);
553 void updateOutgoingStats(std::size_t size);
555 std::size_t getIncomingBytesPerSecond()
const;
556 std::size_t getOutgoingBytesPerSecond()
const;
591 void onRemoteFrameworkDiscovered(
const std::string&
host, uint16 port,
UUID id);
605 void eraseConnection(ConnectionMap::iterator it);
640 void startDisconnectTimeout();
641 void stopDisconnectTimeout();
642 bool checkDisconnectTimeout();
Service that discovers other frameworks within a network using multicast.
This object can use object tracking internally, but the object tracking system's state remains unchan...
Definition: ReflectControlFlags.h:82
std::list< ServiceLevel > ServiceLevelList
Definition: RemoteModule.h:135
QoS management informations.
void addKnownFramework(const std::string &address)
Adds the address of a framework to the list of known remote frameworks.
PerformanceStatistics mIncomingStats
Definition: RemoteModule.h:646
AuthMode getMode() const
Definition: RemoteModule.h:181
static Duration invalid()
Returns an invalid duration.
Definition: Time.h:247
ConnectionList mPendingOutgoingConnections
Definition: RemoteModule.h:663
void setExitOnDisconnectTimeout(Duration timeout)
Sets the timeout to exit on disconnect, closes the framework if a connection is closed or can not be ...
Definition: RemoteModule.h:394
Connection classes representing connections between frameworks.
PerformanceStatistics mOutgoingStats
Definition: RemoteModule.h:647
Type trait that evaluates to true if a type is copy assignable, false otherwise.
Definition: IsCopyAssignable.h:71
boost::shared_ptr< RemoteModule > RemoteModulePtr
Typedef for a pointer to RemoteModule.
Definition: RemoteModule.h:683
Duration mExitOnDisconnectTimeout
Definition: RemoteModule.h:670
const UUID & getID() const
Returns the unique ID of the remote framework.
Definition: RemoteModule.h:399
ServiceLevel by channel name.
Definition: ServiceLevel.h:102
Manages connections to other remote frameworks.
Definition: RemoteModule.h:126
uint32 mOutgoingData
Definition: RemoteModule.h:649
uint16 mIOThreadCount
Definition: RemoteModule.h:659
Definition of a RSA key (public or private)
Definition: RSAKey.h:71
Connection class for incoming connections.
Definition: RemoteConnection.h:853
PropertyHint file(const std::string &filters=std::string(), bool save=false)
Tells the property editor that the path is for a file, and that it should show a "File Open"/"File Sa...
Definition: Path.h:247
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void reflect(Reflector &r)
Definition: RemoteModule.h:224
bool isFrameworkConnected(const std::string &frameworkID) const
Returns if a framework with given ID is connected with us.
std::string Typename
Definition: Typename.h:60
bool isConnectedTo(const std::string &address) const
Returns if a framework with given address is connected to us.
void migrateUnitToThisFramework(const std::string &id)
Requests that the unit with the given id migrates to this framework.
RemoteConnectionPool mRemoteConnectionPool
Definition: RemoteModule.h:667
Server class handling incoming connections from remote frameworks.
Definition: RemoteServer.h:66
BinaryIosBase & host(BinaryIosBase &stream)
Manipulator that sets a binary input/output stream into host byte order mode and can be used to reset...
Definition: BinaryStream.h:712
Setter< T > setter(void(*f)(const T &))
Creates a Setter for global or static class methods taking the argument by const reference.
Definition: GetterSetter.h:443
Grants thread-safe access to an object (the Protectee) that should be protected from concurrent acces...
Definition: ScopedAccess.h:119
Connection class for outgoing connections.
Definition: RemoteConnection.h:901
void disconnectFrom(const std::string &address, bool autoReconnect=false)
Disconnects framework with given address (if it is connected).
std::string group
Definition: RemoteModule.h:165
Service that is used to discover other running frameworks in the same network using multicast on...
Definition: DiscoverService.h:68
std::list< KnownFramework > KnownFrameworkList
Definition: RemoteModule.h:134
Duration getPingInterval() const
Return the ping interval.
Definition: RemoteModule.h:347
uint8 VersionType
Definition: ReflectorInterface.h:72
RemoteServerPtr mServer
Definition: RemoteModule.h:661
CyclicRunnable mCyclicRunnable
Definition: RemoteModule.h:651
ServiceLevelList mServiceLevels
Definition: RemoteModule.h:673
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:416
This is the descriptive part of an authority.
Definition: AuthorityDescription.h:61
boost::recursive_mutex mConnectionMutex
Definition: RemoteModule.h:677
Time mDisconnectedSince
Definition: RemoteModule.h:671
std::list< RemoteConnectionProxy > ConnectionList
Definition: RemoteModule.h:131
Marker for indicating parameters that should be ignored if they are missing in the config file...
Definition: IgnoreMissing.h:73
void enablePTPSync(bool enable=true)
Enable/Disable synchronization of clocks via PTP.
Definition: RemoteModule.h:327
Duration mPingTimeout
Definition: RemoteModule.h:658
This class extends threads by the ability to execute an operation repeatedly in an defined interval...
Definition: CyclicRunnable.h:82
#define MIRA_FRAMEWORK_EXPORT
Definition: FrameworkExports.h:61
Server that accepts connections from remote frameworks.
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
A proxy object that represents a connection.
Definition: RemoteConnectionPool.h:53
DiscoverServicePtr mDiscoverService
Definition: RemoteModule.h:652
Duration mPingInterval
Definition: RemoteModule.h:657
std::map< UUID, RemoteConnectionProxy > ConnectionMap
Definition: RemoteModule.h:132
sec_type seconds() const
Returns normalized number of seconds (0..59)
Definition: Time.h:278
Use this class to represent time durations.
Definition: Time.h:104
void reflect(Reflector &r)
Definition: RemoteModule.h:168
bool mEnablePTPSync
Definition: RemoteModule.h:655
TypeServiceLevelMap mChannelTypeServiceLevels
Definition: RemoteModule.h:676
void enablePingTimeout(bool enable=true)
Enable/Disable the ping timeout.
Definition: RemoteModule.h:337
uint16 mPort
Definition: RemoteModule.h:654
AuthMode
Authentication mode.
Definition: RemoteModule.h:147
bool isPTPSyncEnabled() const
Returns true if PTP clock synchronization is enabled.
Definition: RemoteModule.h:332
KnownFrameworkList mKnownFrameworks
Definition: RemoteModule.h:672
Base class of connections between frameworks.
Definition: RemoteConnection.h:276
boost::shared_ptr< DiscoverService > DiscoverServicePtr
Definition: DiscoverService.h:97
uint32 mIncomingData
Definition: RemoteModule.h:648
std::map< std::string, ServiceLevel > ServiceLevelMap
Definition: RemoteModule.h:136
bool mEnablePingTimeout
Definition: RemoteModule.h:656
void disconnectFramework(const std::string &frameworkID, bool autoReconnect=false)
Disconnects framework with given ID (if it is connected).
Runnable concept that executes an operation repeatedly in an defined interval.
Typedefs and serialization support for uuids.
boost::shared_ptr< RemoteServer > RemoteServerPtr
Definition: RemoteModule.h:129
boost::thread mThread
Definition: RemoteModule.h:653
ServiceLevelMap mChannelServiceLevels
Definition: RemoteModule.h:675
Contains the authentication settings.
Definition: RemoteModule.h:163
std::map< Typename, TypeServiceLevel > TypeServiceLevelMap
Definition: RemoteModule.h:138
boost::uuids::uuid UUID
Shorter name for boost uuid.
Definition: UUID.h:66
void setPort(uint16 port)
Set the port of our TCP server.
Definition: RemoteModule.h:316
bool isPingTimeoutEnabled() const
Returns true if ping timeout is enabled.
Definition: RemoteModule.h:342
Duration getPingTimeout() const
Return the ping timeout.
Definition: RemoteModule.h:352
std::list< TypeServiceLevel > TypeServiceLevelList
Definition: RemoteModule.h:137
UUID mID
Definition: RemoteModule.h:660
AuthSettings mAuthSettings
Definition: RemoteModule.h:669
ConnectionList mPendingIncomingConnections
Definition: RemoteModule.h:664
Connection pool that holds the ownership for RemoteConnections.
Owner of every RemoteConnection.
Definition: RemoteConnectionPool.h:115
TypeServiceLevelList mTypeServiceLevels
Definition: RemoteModule.h:674
ConnectionMap mConnections
Definition: RemoteModule.h:665