INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
orcaice Namespace ReferencelibOrcaIce customizes Ice to simplify writing Orca components. More...
Detailed DescriptionlibOrcaIce customizes Ice to simplify writing Orca components. This namespace is part of a library which aims at simplifying Orca component development. It provides several helper classes to use and derive from and several functions to use. In doing so we make unavoidable assumptions about how Ice is going to be used in Orca components. If your component cannot live with these constraints you can always go back to using Ice directly (it's not much more work).
Enumeration Type DocumentationThis enum type is used to describe the policy of activating the component's adapter.
This enum type is used to describe which standard interfaces the component will provide. Flags can be combined. For example to initialize Home and Status but not Tracer. orcaice::ComponentInterfaceFlag flag = orcaice::HomeInterface | orcaice::StatusInterface;
Function Documentation
Tries to activate the adapter (by calling Context::activate(). If fails, sleeps for Nothing is done if retryNumber=0. If a non-empty subsystem name is supplied, sends a Status heartbeat after every attempt (
If a non-empty subsystem name is supplied, sends a Status heartbeat at every iteration (
Catches the following types results in status fault: {std::exception, std::string, char*, "..."}. Catching the following types and ignores them: {Ice::CommunicatorDestroyedException, orcaice::ComponentDeactivatingException}. Do not call this function outside of a catch block! In this case, there will be no exception to re-throw and terminate() will be called, resulting in abort(). Returns problem description. Example: try { // do something } catch ( ... ) { orcaice::catchExceptions( context_.tracer(), "initializing hardware driver" ); }
Same as catchExceptions() but also sleeps for specified number of milliseconds before returning. Use this function to slow execution down in case of a persistent error. Default sleep interval is 1000ms. Example: while ( !isStopping() ) { try { // do something } catch ( ... ) { orcaice::catchExceptionsWithSleep( context_.tracer(), "initializing hardware driver", 2000 ); // possibly do something else, e.g. re-initialize your hardware driver } }
Same as catchExceptions() but also changes subsystem's health to newHealth. All status health types are allowed. Default new health is gbxutilacfr::SubsystemFault. Example: while ( !isStopping() ) { try { // do something } catch ( ... ) { // will issue a status Warning instead of the default Fault. orcaice::catchExceptionsWithSleep( "initializing hardware driver", health(), gbxutilacfr::SubsystemWarning ); } }
Same as catchExceptionsWithStatus() but also sleeps for specified number of milliseconds before returning. Use this function to slow execution down in case of a persistent error. This function is normally called from inside the catch block of the component's main loop, i.e. inside SubsystemThread::run() function. Example: while ( !isStopping() ) { try { // do your stuff } catch ( ... ) { orcaice::catchExceptionsWithStatusAndSleep( "initializing hardware driver", health() ); } }
Convenience function which is equivalent to catchExceptionsWithStatusAndSleep( "running in main loop", health(), gbxutilacfr::SubsystemFault );
template<class InterfaceType , class InterfaceProxyType >
Special connect function to be used with interfaces hosted as facets of component's Admin interface. Not all objects can be added to the admin interface, see toAdminFacet() for the list of supported interfaces. Before making any connections, the fully-qualified component name is checked and platform 'local' is replaced with current hostname. In the event of a failed connection, adds an interpretive message and re-throws a NetworkException. Example 1. Connect to your own Status. orca::StatusPrx statusPrx; orcaice::connectToAdminInterface<orca::Status,orca::StatusPrx>( context_, statusPrx, context_.name() );
Example 2. Connect to a remote Process. Ice::ProcessPrx processPrx; orca::FQComponentName fqName; fqName.platform = "papa"; fqName.component = "murphy"; orcaice::connectToAdminInterface<Ice::Process,Ice::ProcessPrx>( context_, processPrx, fqName ); References getComponentAdmin(), resolveLocalPlatform(), and toAdminFacet().
template<class ProxyType >
Convenience function. Tries to connect to the specified remote interface until successful, the number of retries is exceeded (default -1, i.e. infinite), or the Nothing is done if retryNumber=0. If a non-empty subsystem name is supplied, sends a Status heartbeat after every attempt (
We catch orcaice::NetworkException, sleep for We do NOT catch a possible orcaice::TypeMismatchException because this condition is unlikely to change. Example: MyInterfacePrx myInterfacePrx; try { orcaice::connectToInterfaceWithString<MyInterfacePrx>( context_, myInterfacePrx, "iface@platform/component", (gbxutilacfr::Stoppable*)this ); } catch ( const orcaice::TypeMismatchException& e ) { // what do we do? } References connectToInterfaceWithString(), orcaice::Context::status(), and orcaice::Context::tracer().
template<class InterfaceType >
Create an Ice proxy Throws TypeMismatchException if fails to connect to the remote interface or if it is of the wrong type. In the event of a failed connection, adds an interpretive message and re-throws a NetworkException. Example: to connect to interface of type MyInterface, use MyInterfacePrx myInterfacePrx; orcaice::connectToInterfaceWithString( context_, myInterfacePrx, "iface@platform/component" ); References orcaice::Context::communicator(), and resolveLocalPlatform(). Referenced by connectToInterfaceWithString(), connectToInterfaceWithTag(), getDescriptionWithString(), and orcaifaceimpl::ConsumerImpl< orca::RangeScanner2d, orca::RangeScanner2dConsumer, orca::RangeScanner2dDataPtr >::subscribeWithString().
template<class ProxyType >
Convenience function. Tries to connect to the specified remote interface until successful, the number of retries is exceeded (default -1, i.e. infinite), or the Nothing is done if retryNumber=0. If a non-empty subsystem name is supplied, sends a Status heartbeat after every attempt (
We catch orcaice::NetworkException, sleep for We do NOT catch a possible orcaice::TypeMismatchException because this condition is unlikely to change. We do NOT catch a possible orcaice::ConfigFileException exception. Example: MyInterfacePrx myInterfacePrx; try { orcaice::connectToInterfaceWithTag<MyInterfacePrx>( context_, myInterfacePrx, "MyInterface", (gbxutilacfr::Stoppable*)this ); } catch ( const orcaice::TypeMismatchException& e ) { // what do we do? } catch ( const orcaice::ConfigFileException& e ) { // what do we do? } References orcaice::Context::status(), and orcaice::Context::tracer().
template<class InterfaceType >
Convenience function, behaves like connectToInterfaceWithString but the proxy information comes from the configuration file and the MyInterfacePrx myInterfacePrx; orcaice::connectToInterfaceWithTag( context_, myInterfacePrx, "MyInterface" ); Throws ConfigFileException if the interface name cannot be read for some reason. References connectToInterfaceWithString(), and getRequiredInterfaceAsString(). Referenced by getDescriptionWithTag().
template<class ConsumerProxyType >
Convenience function. Tries to connect to the specified topic by calling connectToTopicWithString() until successful, the number of retries is exceeded (default -1, i.e. infinite), or the If unsuccesful for any reason, an empty topic proxy is returned. Nothing is done if retryNumber=0. If a non-empty subsystem name is supplied, sends a Status heartbeat after every attempt (
We catch all orcaice::NetworkException, sleep for All other exceptions are not likely to be resolved over time so we don't catch them. References orcaice::Context::status(), and orcaice::Context::tracer().
template<class ConsumerProxyType >
This function is used by potential publishers of information. It returns a proxy to the IceStorm topic and sets proxy to the topic's The address of IceStorm server is looked up in the Raises NetworkException if the server cannot be reached or Exception if there is any other problem. Set localReportingOnly to true when calling this function from classes which deal with error reporting, such as Tracer and Status. Otherwise, potential connection problems will lead to infinite multiplication of fault messages. References orcaice::Context::communicator(). Referenced by connectToTopicWithTag().
template<class ConsumerProxyType >
Convenience function. Tries to connect to the specified topic by calling connectToTopicWithTag() until successful, the number of retries is exceeded (default -1, i.e. infinite), or the If unsuccesful for any reason, an empty topic proxy is returned. Nothing is done if retryNumber=0. If a non-empty subsystem name is supplied, sends a Status heartbeat after every attempt (
We catch all orcaice::NetworkException, sleep for All other exceptions are not likely to be resolved over time so we don't catch them. References orcaice::Context::status(), and orcaice::Context::tracer().
template<class ConsumerProxyType >
Convenience function, behaves like connectToTopicWithString but the proxy information comes from the configuration file and the Throws ConfigFileException if the interface name cannot be read for some reason. References connectToTopicWithString(), getProvidedTopicWithTag(), toString(), and orcaice::Context::tracer().
Adds the Not all objects can be added to the admin interface, see toAdminFacet() for the list of supported interfaces. Before creating the interface, the fully-qualified component name is checked and platform 'local' is replaced with current hostname. This funciton may throw Ice::AlreadyRegisteredException. We don't catch it internally because this is a specialized function which only used in internal code. If successful, registers the interface with Home under the name which is the same as the Admin facet. Ice::ObjectPtr obj = new MyObjectI; orcaice::createAdminInterface( context_, obj, context_.name() );
template<class ConsumerProxyType >
Adds an object to the adapter and returns a direct proxy to the object. A globally unique name is supplied. This function is useful for creating 'consumer' objects, i.e. you subscribe for information to be pushed into them by specifying the direct proxy to them. This is a local operation. It normally does not throw any exceptions. The only case when an exception, orcaice::ComponentDeactivatingException, is thrown is when the adapter is deactivated. This does not happen right after a component is created because the initial state of an adapter is Holding. Ice::ObjectPtr consumer = new Odometry2dConsumerI; orca::Odometry2dConsumerPrx consumerPrx = orcaice::createConsumerInterface<orca::Odometry2dConsumerPrx>( context(), consumer ); This function returns a two-way proxy. You can change the proxy type with standard Ice functions (search the manual for "proxy factory methods"). consumerPrx = consumerPrx->ice_oneway(); References orcaice::Context::adapter(), and orcaice::Context::tracer().
Convenience function. Tries to setup the specified interface until is successful, the number of retries is exceeded (default -1, i.e. infinite), or the Nothing is done if retryNumber=0. Status warnings are set between retries if subsystem name is specified (
We catch gbxutilacfr::Exception, sleep for Example: Ice::ObjectPtr obj = new MyObjectI; orcaice::createInterfaceWithString( context_, obj, "coolname", (gbxutilacfr::Stoppable*)this );
Adds the Throws gbxutilacfr::Exception if fails to register the new object. Ice::ObjectPtr obj = new MyObjectI; orcaice::createInterfaceWithString( context(), obj, "coolname" ); Referenced by orcaifaceimpl::VelocityControl2dImpl::initInterface(), orcaifaceimpl::ProviderWithDescriptionImpl< ProviderType, ConsumerType, DataType, DescriptionType >::initInterface(), orcaifaceimpl::ProviderImpl< ProviderType, ConsumerType, DataType >::initInterface(), orcaifaceimpl::PropertiesImpl::initInterface(), orcaifaceimpl::PathFollower2dImpl::initInterface(), orcaifaceimpl::EStopImpl::initInterface(), orcaifaceimpl::DriveBicycleImpl::initInterface(), orcaifaceimpl::ButtonImpl::initInterface(), and orcaifaceimpl::BinarySwitchImpl::initInterface().
Convenience function. Tries to setup the specified interface until successful, the number of retries is exceeded (default -1, i.e. infinite), or the Nothing is done if retryNumber=0. Status warnings are set between retries if subsystem name is specified (
We catch gbxutilacfr::Exception, sleep for We do NOT catch a possible orcaice::ConfigFileException exception. Ice::ObjectPtr obj = new MyObjectI; try { orcaice::createInterfaceWithTag( context_, obj, "InterfaceTag", (gbxutilacfr::Stoppable*)this ); } catch ( const orcaice::ConfigFileException& e ) { // what do we do? }
Convenience function, behaves like createInterfaceWithString but the proxy information is looked up in the Throws ConfigFileException if the interface name cannot be read from the config file for some reason. Ice::ObjectPtr obj = new MyObjectI; orcaice::createInterfaceWithTag( context(), obj, "InterfaceTag" );
Checks if the property
Contacts the default Query interface of the Registry and looks up all registered admin proxies.
Contacts the default Locator interface of the Registry and looks up component admin proxy. Before creating the interface, the fully-qualified component name is checked and platform 'local' is replaced with current hostname. Referenced by connectToAdminInterface().
Parses properties to build static component information. Interfaces which are not in the config file will not appear here, e.g. Home, Tracer, Status.
Returns a proxy to the default Query object, based on the default Locator of communicator. Returns null proxy on failure.
template<class InterfacePrxType , typename DescriptionType >
Connects to the interface and gets the description. Relies on standard naming: "getDescription()". References connectToInterfaceWithString().
template<class InterfacePrxType , typename DescriptionType >
Connects to the interface and gets the description. Relies on standard naming: "getDescription()". References connectToInterfaceWithTag().
Convenience function. Tries to connect to the specified interface by calling getInterfaceIdWithString() until successful, the number of retries is exceeded (default -1, i.e. infinite), or the If unsuccesful for any reason, an empty string is returned. Nothing is done if retryNumber=0. If a non-empty subsystem name is supplied, sends a Status heartbeat after every attempt (
We catch all orcaice::NetworkException, sleep for
Tries to connect the interface described in the config file and gets its ID (Slice object type). Throws NetworkException if the interface is unreachable.
Convenience function. Tries to connect to the specified interface by calling getInterfaceIdWithString() until successful, the number of retries is exceeded (default -1, i.e. infinite), or the If unsuccesful for any reason, an empty string is returned. Nothing is done if retryNumber=0. If a non-empty subsystem name is supplied, sends a Status heartbeat after every attempt (
We catch all orcaice::NetworkException, sleep for All other exceptions are not likely to be resolved over time so we don't catch them.
Tries to connect the interface described in the config file and gets its ID (Slice object type). Throws NetworkException if the interface is unreachable. Throws ConfigFileException if there's a problem with reading from the config file.
Returns current time. Time comparisons for orca::Time are autogenerated by Ice and they happen to work correctly (this tested by libOrcaIce test programs). Usage: orca::Time t1,t2; // set t1 and t2 values if ( t1 < t2 ) { ... } Referenced by orcalog::SnapshotLogBuffer< ObjectType, LogWriterType >::addItem(), and orcalog::GenericAutoLogger< orca::Gps, orca::GpsConsumer, orca::GpsData, GpsLogWriter >::dataEvent().
Returns: 0 = property found (and its value is not empty), non-zero = property not found (or is defined but left empty). Note that the Ice PropertiesI::load() method has a line size limitation of 1024 characters but quietly fails so there is no way of knowing if you have exceeded this limitation
Returns: 0 = property found (and its value is not empty), non-zero = property not found (or is defined but left empty). Throws a gbxutilacfr::Exception if the key is found but the value cannot be converted to the desired type.
Parses the value into a vector of doubles assuming empty space delimeters. Elements will continue to be added to the end of the vector until the end of the line is reached. Returns: 0 = property found (and its value is not empty), non-zero = property not found (or is defined but left empty). Note that the Ice PropertiesI::load() method has a line size limitation of 1024 characters but quietly fails so there is no way of knowing if you have exceeded this limitation. Throws a gbxutilacfr::Exception if the key is found but the value cannot be converted to the desired type.
Returns the default value if key is not found. Throws a gbxutilacfr::Exception if the key is found but the value cannot be converted to the desired type.
Returns the default value if key is not found. Throws a gbxutilacfr::Exception if the key is found but the value cannot be converted to the desired type.
Returns: 0 = property found (and its value is not empty), non-zero = property not found (or is defined but left empty). Throws a gbxutilacfr::Exception if the key is found but the value cannot be converted to the desired type.
Parses the value into a vector of ints assuming empty space delimeters. Elements will continue to be added to the end of the vector until the end of the line is reached. Returns: 0 = property found (and its value is not empty), non-zero = property not found (or is defined but left empty). Note that the Ice PropertiesI::load() method has a line size limitation of 1024 characters. but quietly fails so there is no way of knowing if you have exceeded this limitation Throws a gbxutilacfr::Exception if the key is found but the value cannot be converted to the desired type.
Returns the default value if key is not found. Throws a gbxutilacfr::Exception if the key is found but the value cannot be converted to the desired type.
Parses the value into a vector of strings using the given delimiter Returns: 0 = property found (and set in value), non-zero = property not found or parsing failed.
Reads properties contained in the context and returns the fully-qualified name of the provided interface corresponding to interfaceTag. Throws ConfigFileException if the interface name cannot be read for some reason.
For components with variable number of interfaces it may be useful to get a listing of all provided interfaces described in the configuration file. See getRequiredTags() for the usage of
Convenience function which behaves like getProvidedTopicWithString() but the interface name is looked up in the config file using the interfaceTag. Throws ConfigFileException if the interface name cannot be read for some reason. Referenced by connectToTopicWithTag().
Reads properties contained in the context and returns the stringified proxy to the required interface corresponding to the interface tag. The proxy can be direct or indirect. Throws ConfigFileException if the interface name cannot be read for some reason. Referenced by connectToInterfaceWithTag(), and orcaifaceimpl::ConsumerSubscriber::subscribeWithTag().
For components with variable number of interfaces it may be useful to get a listing of all required interfaces described in the configuration file. You may have a group of permanent required interfaces and group of variable or optional ones. To separate the two groups you may want to start all optional tags with a certain pattern. For example, your config file may look like this: MyComponent.Requires.Locolise2d.Proxy=something MyComponent.Requires.LaserScanner2dFront.Proxy=something MyComponent.Requires.LaserScanner2dBack.Proxy=something In this case you would get a list of "laser" required interfaces by supplying the pattern="LaserScanner2d" or pattern="Laser" or pattern="La". For example: std::vector<std::string> laserTags; laserTags = orcaice::getRequiredTags( context_, "Laser" ); The default empty string pattern will match all required interfaces.
Tries to ice_ping() the remote Admin interface specified with a fully-qualified component name and the interface facet name. Returns TRUE if the ping was successful and FALSE if not. Writes diagnostic information into Before making any connections, the fully-qualified component name is checked and platform 'local' is replaced with current hostname. The interface type must be specified fully, including the module name, e.g. "::orca::Home". Not all objects can be added to the admin interface, see toAdminFacet() for the list of supported interfaces. Catches all exceptions. Does not throw.
Tries to reach the remote interface specified with proxyString by calling ice_ping() function. Returns TRUE if the ping was successful and FALSE if not. Writes diagnostic information into Catches all exceptions. Does not throw. Implementation note: this function does not need to be templated because ice_ping() is implemented by all Ice objects regardless of type.
Return TRUE if the property is defined and contains a non-null value. Note that Ice properties do not distinguish between undefined and null properties. I.e. an empty string is returned in both cases:
Tries to ping the default Locator and, based on success or the exceptions it catches, determines if the registry is reachable.
For indirect proxies with platform name set to local, returns a new proxy string with
For fully-qualified component names with platform name set to local, returns a new component name string with Referenced by connectToAdminInterface(), and connectToInterfaceWithString().
Converts an orca::Time to a double in seconds. Time can be negative, but remember that seconds and microseconds are added to together. e.g. -10s:-100000us and -11s:900000us will both translate to -10.1s
Returns the difference between two time values (ie: t1-t2) The result is negative if t1 is earlier than t2.
Returns the difference between two time values as a double (in seconds) (ie: t1-t2) The result is negative if t1 is earlier than t2. Referenced by orcalog::SnapshotLogBuffer< ObjectType, LogWriterType >::addItem().
Orca convention for naming admin interface facets. The reason for encoding the platform and component name in the facet name: to allow sharing of Communicator inside the IceBox by multiple components (all of them will try to add their admin facets to the same Communicator). The following admin interfaces are currently supported
The fully-qualified component name is checked and platform 'local' is replaced with current hostname. Throws bxutilacfr::Exception when called with unsupported object type. Referenced by connectToAdminInterface().
Extracts the fully-qualified component name. No checks are performed.
Parses a string to extract a fully qualified component name. This is the inverse of toString(). Expects an input string in the form of
Parses category of the identity to extract a fully qualified component name. This is the inverse of toIdentityCategory(); Expects an input string in the form of
Matches IceUtil::Time::toDateTime function: converts to human-readable date/time string. References toIceTime().
Returns the fully-qualified interface name. No checks are performed. Referenced by orcasystemstatusutil::StatusConsumerImpl::subscribe().
Parses a string to extract a fully qualified interface name Expects an input string in the form of Referenced by orcaifaceimpl::ConsumerImpl< orca::RangeScanner2d, orca::RangeScanner2dConsumer, orca::RangeScanner2dDataPtr >::subscribeWithString().
Converts from Ice standard time format to orca::Date. Unlike IceUtil::Time::toDateTime(), we use UTC time and not local time.
Converts from number of seconds to orca::Time. Time can be negative, in which case both seconds and microseconds are returned as negatives, e.g. -10.1s will translate to -10s:-100000us, not -11s:900000us.
Converts from Ice standard time format to orca::TimeOfDay. Unlike IceUtil::Time::toDateTime(), we use UTC time and not local time.
Returns string in human readable format: MM/DD/YY HH:MM:SS.sss.
Converts fully executable name to a string. i.e. executable
Converts fully qualified topic name to a string. i.e. interface/topic@platform/component
Converts fully qualified interface name to a string. e.i. interface@platform/component
Converts fully qualified component name to a string. e.i. platform/component
Referenced by connectToTopicWithTag(), orcaqcm::OcmModel::customEvent(), and orcasystemstatusutil::StatusConsumerImpl::subscribe().
For durations less than 24hrs returns string HH:MM:SS.sss. Otherwise, DD:HH:MM:SS.sss Negative times are supported but only if seconds and microseconds are both negative.
Parses result of the correspondinng toString(). Returns: 0 = parsing successful, non-zero = parsing failed. Negative durations are supported, but only if the very first character of the string is '-'.
Returns the fully-qualified topic name. No checks are performed.
Returns the fully-qualified topic name. No checks are performed.
Same as above but returns a string. Equivalent to calling: orcaice::toString( orcaice::toTopic( component, ifaceName, subtopic ) );
template<class ConsumerPrxType , class DataType >
Tries to push to IceStorm. If fails tries to reconnect to IceStorm once. If reconnects successfully, pushes the data, if not, ignores the problem until the next time. Catches all exceptions. Works only for ConsumerPrxType which has a function setData( DataType ). For non-standard consumers, copy and modify this implementation. (In this case you probably do not need this function to be templated). References orcaice::Context::communicator(), and orcaice::Context::tracer().
Remove the interface from the adapter if possible. If something goes wrong, fails silently.
Returns standardized text which warns that certain information is missing because a configuration property is not defined or is null. If
Returns standardized text which warns that a configuration property is not defined or is null. If
Returns standardized text which warns that certain information is missing because a configuration property is not defined or is null. Also informs that the specified default value is used instead.
Returns standardized text which warns that a configuration property is not defined or is null. Also informs that the specified default value is used instead. |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)