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",
"");
173 "Password that is used for the weak authentication",
176 "Path to the file containing the private key " 177 "for strong authentication.",
200 void setPassword(
const boost::optional<std::string>& passwd);
209 void setKey(
const boost::optional<std::string>& str);
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);
230 "How many threads are used for communication", 1);
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);
240 "The maximum time before a connection is assumed as dead " 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",
255 std::vector<std::string> tmpFWs;
256 r.member(
"KnownFrameworks", tmpFWs,
"",
259 foreach (
const std::string& a, tmpFWs) {
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));
445 bool legacyBinaryFormat,
455 bool autoReconnect =
false);
465 bool autoReconnect =
false);
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
void setAuthPassword(const std::string &password)
Enables the weak password based authentication mode and sets the password.
AuthMode getMode() const
Definition: RemoteModule.h:181
void stop()
Stops the remote framework.
static Duration invalid()
Returns an invalid duration.
Definition: Time.h:249
ConnectionList mPendingOutgoingConnections
Definition: RemoteModule.h:663
void setNoAuth()
Resets passwords and keys, and sets authentication to "none".
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.
void unpublishService(const std::string &service)
Unpublishes a service to all connected remote frameworks.
PerformanceStatistics mOutgoingStats
Definition: RemoteModule.h:647
std::size_t getIncomingBytesPerSecond() const
Type trait that evaluates to true if a type is copy assignable, false otherwise.
Definition: IsCopyAssignable.h:71
void storeConnection(RemoteConnectionProxy iConnection)
Add a connection to our internal map of connections (and update the property node).
boost::shared_ptr< RemoteModule > RemoteModulePtr
Typedef for a pointer to RemoteModule.
Definition: RemoteModule.h:683
Duration mExitOnDisconnectTimeout
Definition: RemoteModule.h:670
void startDisconnectTimeout()
const UUID & getID() const
Returns the unique ID of the remote framework.
Definition: RemoteModule.h:399
ServiceLevel by channel name.
Definition: ServiceLevel.h:102
void setPassword(const boost::optional< std::string > &passwd)
Sets a password.
Manages connections to other remote frameworks.
Definition: RemoteModule.h:126
uint32 mOutgoingData
Definition: RemoteModule.h:649
uint16 getPort() const
Returns the port we listen on for incoming connections.
uint16 mIOThreadCount
Definition: RemoteModule.h:659
void publishAuthority(const AuthorityDescription &authority)
Publishes an authority to all connected remote frameworks.
ServiceLevel getServiceLevel(const std::string &channelID, const Typename &channelType)
Get the level of service for given channel.
Definition of a RSA key (public or private)
Definition: RSAKey.h:71
Connection class for incoming connections.
Definition: RemoteConnection.h:854
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:230
void eraseConnection(ConnectionMap::iterator it)
Remove a connection from our internal map of connections (and update the property node)...
RemoteConnectionProxy & addPendingOutgoingConnection(RemoteConnectionProxy &&proxy, bool start=true)
Move a connection to the list of pending outgoing connections.
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void reflect(Reflector &r)
Definition: RemoteModule.h:224
void subscribeChannel(const std::string &channelID)
Notify all connected remote frameworks about the fact that we have a subscriber for the given channel...
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
void publishChannel(const std::string &channelID, const Typename &type)
Notify all connected remote frameworks about the fact that we have a publisher for the given channel...
void removePendingOutgoingConnection(RemoteConnection *connection)
If there is a proxy for connection in the list of pending outgoing connections, remove it...
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:716
void updateOutgoingStats(std::size_t size)
Update statistics about outgoing data.
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:902
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:66
std::list< KnownFramework > KnownFrameworkList
Definition: RemoteModule.h:134
RemoteConnectionProxy createIncomingConnection()
Duration getPingInterval() const
Return the ping interval.
Definition: RemoteModule.h:347
void publishService(const std::string &service)
Publishes a service to all connected remote frameworks.
Definition: RemoteModule.h:151
std::size_t getOutgoingBytesPerSecond() const
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:418
This is the descriptive part of an authority.
Definition: AuthorityDescription.h:61
ScopedAccess< const ConnectionMap, boost::recursive_mutex > getConnections() const
Returns the map of connections.
const std::string & getPassword() const
Returns the authentication password.
void setAuthGroup(const std::string &group)
Sets the working group for this framework.
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
RemoteConnectionProxy & addPendingIncomingConnection(RemoteConnectionProxy &&proxy, bool start=true)
Move a connection to the list of pending incoming connections.
const AuthSettings & getAuthSettings() const
Returns the current authentication settings.
void start()
Start the remote framework.
void stopDisconnectTimeout()
bool onIncomingConnected(RemoteIncomingConnection *iConnection)
Called whenever a client connects to our server.
Duration mPingTimeout
Definition: RemoteModule.h:658
void setAuthKeyFile(const std::string &keyfile)
Enables the strong RSA key based authentication mode and sets the key file.
void updateIncomingStats(std::size_t size)
Update statistics about incoming data.
This class extends threads by the ability to execute an operation repeatedly in an defined interval...
Definition: CyclicRunnable.h:82
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
void onIncomingDisconnected(RemoteIncomingConnection *iConnection)
Called whenever a client disconnects from our server.
A proxy object that represents a connection.
Definition: RemoteConnectionPool.h:53
DiscoverServicePtr mDiscoverService
Definition: RemoteModule.h:652
void unpublishAuthority(const AuthorityDescription &authority)
Unpublishes an authority to all connected remote frameworks.
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:280
Use this class to represent time durations.
Definition: Time.h:106
void reflect(Reflector &r)
Definition: RemoteModule.h:168
void onRemoteFrameworkDiscovered(const std::string &host, uint16 port, UUID id)
Called when a new remote framework was discovered (e.g.
bool mEnablePTPSync
Definition: RemoteModule.h:655
TypeServiceLevelMap mChannelTypeServiceLevels
Definition: RemoteModule.h:676
void clearAuth()
Clears authentication settings.
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
void setKey(const boost::optional< std::string > &str)
Sets a key.
Duration cycleTime
The cycle time, this cyclic runnable calls its assigned function.
Definition: CyclicRunnable.h:146
void onOutgoingDisconnected(RemoteOutgoingConnectionBase *iConnection)
Called whenever one of our client disconnects from a remote server.
void setAuthKey(const std::string &key)
Enables the strong RSA key based authentication mode and sets the key.
Base class of connections between frameworks.
Definition: RemoteConnection.h:277
boost::shared_ptr< DiscoverService > DiscoverServicePtr
Definition: DiscoverService.h:95
uint32 mIncomingData
Definition: RemoteModule.h:648
std::map< std::string, ServiceLevel > ServiceLevelMap
Definition: RemoteModule.h:136
bool mEnablePingTimeout
Definition: RemoteModule.h:656
bool checkDisconnectTimeout()
Definition: RemoteModule.h:150
static uint32 getCurrentVersion()
Returns the version of the communication protocol, that is supported by THIS framework.
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.
void removePendingIncomingConnection(RemoteConnection *connection)
If there is a proxy for connection in the list of pending incoming connections, remove it...
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
Definition: RemoteModule.h:149
std::map< Typename, TypeServiceLevel > TypeServiceLevelMap
Definition: RemoteModule.h:138
boost::uuids::uuid UUID
Shorter name for boost uuid.
Definition: UUID.h:69
void setKeyFile(const boost::optional< std::string > &file)
Sets a key file.
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
bool onOutgoingConnected(RemoteOutgoingConnectionBase *iConnection)
Called whenever we connect to a remote server.
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
void unsubscribeChannel(const std::string &channelID)
Notify all connected remote frameworks that we no longer have a subscriber on the given channel...
ConnectionList mPendingIncomingConnections
Definition: RemoteModule.h:664
void process()
The main process method of the remote module.
Connection pool that holds the ownership for RemoteConnections.
Owner of every RemoteConnection.
Definition: RemoteConnectionPool.h:115
const RSAKey & getKey() const
Returns the authentication key.
void unpublishChannel(const std::string &channelID)
Notify all connected remote frameworks about the fact that we have no longer a publisher for the give...
TypeServiceLevelList mTypeServiceLevels
Definition: RemoteModule.h:674
ConnectionMap mConnections
Definition: RemoteModule.h:665