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
class <name>(...): ... def initialize(): #Assign variable values #Initialize data ... def execute(): #Retrieve components #Consider ready to receive calls (Change states if appropriate) ... def cleanUp(): #Release components #Release resources ... def aboutToAbort(): #Do any critical clean up #Continue with less critical stuff such as releasing components and other activities similar to cleanUp ... ... |
Java
public class <name> ... { ... public void initialize() { //Assign variable values //Initialize data ... } public void execute() { //Retrieve components //Consider ready to receive calls (Change states if appropriate) ... } public void cleanUp() { //Release components //Release resources ... } public void aboutToAbort() { //Do any critical clean up //Continue with less critical stuff such as releasing components and other activities similar to cleanUp ... } ... } |
C++
class <name> : ... { ... void initialize(); void execute(); void cleanUp(); void aboutToAbort(); ... }; |
void <name>::initialize() { //Assign variable values //Initialize data ... } void <name>::execute() { //Retrieve components //Consider ready to receive calls (Change states if appropriate) ... } void <name>::cleanUp() { //Release components //Release resources ... } void <name>::aboutToAbort() { //Do any critical clean up //Continue with less critical stuff such as releasing components and other activities similar to cleanUp ... } |