Information
We are currently investigating an issue with the editor of some pages. Please save your work and avoid to create new pages until this banner is gone.
On this day we will focus on implementing the logic for our component. By the end of the day, we expect the groups to:
As a guide, we're going to show you sample code for logging, to define exceptions, throw and catch exceptions.
The component details will be presented in the first session from ACS Workshop - Project Details page to describe the interfaces and interactions of the project's components.
The ACS components have a couple of methods associated with its lifecycle that automatically gets executed at different phases of the component initialization and deactivation.
Called after initialize to tell the component that it has to be ready to accept incoming functional calls any time
Called after the last functional call to the component has finished
The component should then orderly release resources etc.
Called when due to some error condition the component is about to be forcefully removed some unknown amount of time later (usually not very much...).
The component should make an effort to die as neatly as possible
Because of its urgency, this method will be called asynchronously to the execution of any other method of the component
Python
Java
C++
During component interaction it will be needed to request and release components. When interacting with components from other components, you need to obtain the container services references to make the request to the Manager. Here we will show how to retrieve two types of components:
Python
Java
C++
ACS Logging has two main benefits:
Python
logger = self.getLogger() logger.logTrace("...") logger.logDebug("...") logger.logInfo("...") logger.logWarning("...") logger.logError("...") #An example logger.info("A real log with a string '%s' and an int (%d)" % ("Log Entry", 3))
Java
m_logger.finer("..."); m_logger.fine("..."); m_logger.info("..."); m_logger.warning("..."); m_logger.severe("..."); #An example m_logger.info("A real log with a string '" + "Log Entry" + "' and an int (" + String.valueOf(3) + ")");
C++
ACS_TRACE("..."); ACS_DEBUG("..."); ACS_SHORT_LOG((LM_INFO, "...")); ACS_SHORT_LOG((LM_WARNING, "...")); ACS_SHORT_LOG((LM_ERROR, "...")); //An example ACS_SHORT_LOG((LM_INFO, "A real log with a string '%s' and an int (%d)", "Log Entry", 3));
Error Handling in ACS Components has 4 pieces:
Error definitions are elements in XML files with the representation for errors and completions. For instance, a simple definition present in the project:
The errors defined in the XML files need to be declared in the IDLs to be used in component comunications:
Throwing exceptions is done in the servant that implements the IDL method that declared the error.
Python
import SYSTEMErrImpl ... raise SYSTEMErrImpl.AlreadyInAutomaticExImpl().getAlreadyInAutomaticEx() ...
Java
import alma.SYSTEMErr.wrappers.AcsJAlreadyInAutomaticEx; ... throw new AcsJAlreadyInAutomaticEx("Some message...").toAlreadyInAutomaticEx(); ...
C++
#include <SYSTEMErr.h> ... throw SYSTEMErr::AlreadyInAutomaticExImpl(__FILE__, __LINE__, "Some message...").getAlreadyInAutomaticEx(); ...
Handling is done in the component or client that calls a component through its stub.
Python
import SYSTEMErr ... try: ... except SYSTEMErr.AlreadyInAutomaticEx as e: ... ...
Java
import alma.SYSTEMErr.AlreadyInAutomaticEx; ... try { ... } catch (AlreadyInAutomaticEx e) { ... } ...
C++
#include <SYSTEMErr.h> ... try { ... } catch(SYSTEMErr::AlreadyInAutomaticEx &_ex) { ... } ...