This tool takes a component's definition in YAML and:
- Creates the source code of its IDL. It also modifies the IDL's Makefile in order to build it and install it.
- Creates part of the component's source code. It also modifies the component's Makefile accordingly.
- Adds your component to the CDB (if it's not already there).
This tool does not implement your component's functions. But still, for simple components you can build and install them right after generated, with no further modifications.
To use the Component Generator Tool you must define your component in a YAML file. Then you can run it with the following parameters:
> create_acs_component --help
Usage: create_acs_component [OPTIONS] COMPONENT_YAML_PATH
Creates an ACS component from a YAML definition.
Options:
-l, --language [python|cpp|java]
Component's implementation language.
[default: python]
--version Show the version and exit.
--help Show this message and exit.
For instance, for the Scheduler component (check the functions the Scheduler must implement in ACS Workshop - Interfaces):
working_dir: /home/developer/workspace
prefix: acsws
module: SCHEDULER_MODULE
component_name: Scheduler
functions:
- 'void start()'
- 'void stop()'
- 'long proposalUnderExecution()'
After executing the Component Generator Tool you should see something like (click on "Expand source"):
> create_acs_component -l python scheduler.yml
2022-08-24 16:15:39 localhost.localdomain __main__[21561] INFO Loading component's YAML definition.
2022-08-24 16:15:39 localhost.localdomain __main__[21561] DEBUG Component's definition: {'working_dir': '/home/developer/workspace', 'prefix': 'acsws', 'module': 'SCHEDULER_MODULE', 'component_name': 'Scheduler', 'functions': ['void start()', 'void stop()', 'long proposalUnderExecution()']}
2022-08-24 16:15:39 localhost.localdomain __main__[21561] INFO Creating IDL's directories
\nCreating/checking Module directory
CREATED >>> |---idlScheduler
CREATED >>> |---bin
CREATED >>> |---include
CREATED >>> |---idl
CREATED >>> |---lib
CREATED >>> |---lib/endorsed
CREATED >>> |---lib/python
CREATED >>> |---lib/ACScomponents
CREATED >>> |---lib/python/site-packages
CREATED >>> |---man
CREATED >>> |---man/man1
CREATED >>> |---man/man2
CREATED >>> |---man/man3
CREATED >>> |---man/man4
CREATED >>> |---man/man5
CREATED >>> |---man/man6
CREATED >>> |---man/man7
CREATED >>> |---man/man8
CREATED >>> |---man/mann
CREATED >>> |---man/manl
CREATED >>> |---doc
CREATED >>> |---object
CREATED >>> |---LOGS
CREATED >>> |---test
CREATED >>> |---src
CREATED >>> |---rtai
CREATED >>> |---config
CREATED >>> |---config/CDB
CREATED >>> |---config/CDB/schemas
CREATED >>> |---ChangeLog
\nCopying Makefile template for WS code
\nCopying Makefile.mk template for WS code
\nCopying module.mk template for WS code
2022-08-24 16:15:39 localhost.localdomain __main__[21561] INFO Creating IDL's content
2022-08-24 16:15:39 localhost.localdomain __main__[21561] DEBUG IDL's content: #ifndef _SCHEDULER_IDL_
#define _SCHEDULER_IDL_
#pragma prefix "acsws"
#include <acscomponent.idl>
module SCHEDULER_MODULE {
interface Scheduler : ACS::ACSComponent {
void start();
void stop();
long proposalUnderExecution();
};
};
#endif
2022-08-24 16:15:39 localhost.localdomain __main__[21561] INFO Editing Makefile
2022-08-24 16:15:39 localhost.localdomain __main__[21561] INFO Adding component to CDB
2022-08-24 16:15:39 localhost.localdomain __main__[21561] DEBUG CDB's content: <?xml version="1.0" encoding="ISO-8859-1"?>
<Components xmlns="urn:schemas-cosylab-com:Components:1.0"
xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0"
xmlns:baci="urn:schemas-cosylab-com:BACI:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<e Name="PBEND_B_01" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="PBUMP_B_01" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="PBUMP_B_02" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_1" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_2" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_3" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_4" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_5" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_6" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_7" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_8" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_9" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_10" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_11" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_12" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_13" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_14" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_15" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_16" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_17" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="TEST_PS_18" Code="acsexmplPowerSupplyImpl"
Type="IDL:alma/PS/PowerSupply:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="MOUNT1" Code="acsexmplMountImpl"
Type="IDL:alma/MOUNT_ACS/Mount:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="MOUNT2" Code="acsexmplMountImpl"
Type="IDL:alma/MOUNT_ACS/Mount:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="MOUNT3" Code="acsexmplMountImpl"
Type="IDL:alma/MOUNT_ACS/Mount:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="MOUNT4" Code="acsexmplMountImpl"
Type="IDL:alma/MOUNT_ACS/Mount:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="MOUNT5" Code="acsexmplMountImpl"
Type="IDL:alma/MOUNT_ACS/Mount:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="MOUNT6" Code="acsexmplMountImpl"
Type="IDL:alma/MOUNT_ACS/Mount:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="LAMP1" Code="acsexmplLampImpl"
Type="IDL:alma/acsexmplLamp/Lamp:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="LAMPWHEEL1" Code="acsexmplLampWheelImpl"
Type="IDL:alma/acsexmplLampWheel/LampWheel:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="FILTERWHEEL1" Code="acsexmplFilterWheelImpl"
Type="IDL:alma/acsexmplFilterWheel/FilterWheel:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="CLOCK1" Code="acsclock"
Type="IDL:alma/acstime/Clock:1.0"
Container="bilboContainer"
Default="true" ImplLang="cpp" />
<e Name="TIMER1" Code="acstimer"
Type="IDL:alma/acstime/Timer:1.0"
Container="bilboContainer"
Default="true" ImplLang="cpp" />
<e Name="FRIDGE1" Code="acsexmplFridgeImpl"
Type="IDL:alma/FRIDGE/FridgeControl:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="HELLODEMO1" Code="alma.demo.HelloDemoImpl.HelloDemoHelper"
Type="IDL:alma/demo/HelloDemo:1.0"
Container="frodoContainer" ImplLang="java" />
<e Name="HELLOLAMP1" Code="alma.demo.LampAccessImpl.LampAccessHelper"
Type="IDL:alma/demo/LampAccess:1.0"
Container="frodoContainer" ImplLang="java" />
<e Name="LAMPACCESS1" Code="alma.demo.LampAccessImpl.LampAccessHelper"
Type="IDL:alma/demo/LampAccess:1.0"
Container="frodoContainer" ImplLang="java" />
<e Name="LAMPCALLBACK1" Code="alma.demo.LampCallbackImpl.LampCallbackHelper"
Type="IDL:alma/demo/LampCallback:1.0"
Container="frodoContainer" ImplLang="java" />
<e Name="XMLCOMP1" Code="alma.demo.XmlComponentImpl.XmlComponentHelper"
Type="IDL:alma/demo/XmlComponent:1.0"
Container="frodoContainer" ImplLang="java" />
<e Name="PYHELLODEMO1"
Code="demoImpl.HelloDemo"
Type="IDL:alma/demo/HelloDemo:1.0"
Container="aragornContainer" ImplLang="py" />
<e Name="ARCHIVE_IDENTIFIER"
Code="alma.archive.helpers.IdentifierHelper"
Type="IDL:alma/xmlstore/Identifier:1.0"
Container="frodoContainer"
Default="true" ImplLang="java" />
<e Name="ARCHIVE_CONNECTION"
Code="alma.archive.helpers.ArchiveConnectionHelper"
Type="IDL:alma/xmlstore/ArchiveConnection:1.0"
Container="frodoContainer"
Default="true" ImplLang="java" />
<e Name="ERRORCOMP_CPP"
Code="acsexmplErrorComponentImpl"
Type="IDL:alma/acsexmplErrorComponent/ErrorComponent:1.0"
Container="bilboContainer" ImplLang="cpp" />
<e Name="ERRORCOMP_JAVA"
Code="alma.acsexmplErrorComponent.ErrorComponentImpl.ErrorComponentHelper"
Type="IDL:alma/acsexmplErrorComponent/ErrorComponent:1.0"
Container="frodoContainer" ImplLang="java" />
<e Name="ERRORCOMP_PY"
Code="acsexmplErrorComponentImpl.ErrorComponent"
Type="IDL:alma/acsexmplErrorComponent/ErrorComponent:1.0"
Container="aragornContainer" ImplLang="py" />
<e Name="SchedulerPython"
Code="SCHEDULER_MODULEImpl.SchedulerImpl"
Type="IDL:acsws/SCHEDULER_MODULE/Scheduler:1.0"
Container="aragornContainer" ImplLang="py" />
</Components>
2022-08-24 16:15:39 localhost.localdomain create_python_component[21561] INFO Creating component's directories.
\nCreating/checking Module directory
CREATED >>> |---pyScheduler
CREATED >>> |---bin
CREATED >>> |---include
CREATED >>> |---idl
CREATED >>> |---lib
CREATED >>> |---lib/endorsed
CREATED >>> |---lib/python
CREATED >>> |---lib/ACScomponents
CREATED >>> |---lib/python/site-packages
CREATED >>> |---man
CREATED >>> |---man/man1
CREATED >>> |---man/man2
CREATED >>> |---man/man3
CREATED >>> |---man/man4
CREATED >>> |---man/man5
CREATED >>> |---man/man6
CREATED >>> |---man/man7
CREATED >>> |---man/man8
CREATED >>> |---man/mann
CREATED >>> |---man/manl
CREATED >>> |---doc
CREATED >>> |---object
CREATED >>> |---LOGS
CREATED >>> |---test
CREATED >>> |---src
CREATED >>> |---rtai
CREATED >>> |---config
CREATED >>> |---config/CDB
CREATED >>> |---config/CDB/schemas
CREATED >>> |---ChangeLog
\nCopying Makefile template for WS code
\nCopying Makefile.mk template for WS code
\nCopying module.mk template for WS code
2022-08-24 16:15:40 localhost.localdomain create_python_component[21561] INFO Creating component's content.
2022-08-24 16:15:40 localhost.localdomain create_python_component[21561] DEBUG Component's content: # Client stubs and definitions, such as structs, enums, etc.
import SCHEDULER_MODULE
# Skeleton infrastructure for server implementation
import SCHEDULER_MODULE__POA
# Base component implementation
from Acspy.Servants.ACSComponent import ACSComponent
# Services provided by the container to the component
from Acspy.Servants.ContainerServices import ContainerServices
# Basic component lifecycle (initialize, execute, cleanUp and aboutToAbort methods)
from Acspy.Servants.ComponentLifecycle import ComponentLifecycle
class SchedulerImpl(SCHEDULER_MODULE__POA.Scheduler, ACSComponent, ContainerServices, ComponentLifecycle):
def __init__(self):
ACSComponent.__init__(self)
ContainerServices.__init__(self)
self._logger = self.getLogger()
def start(self):
raise NotImplementedError("This function should do something")
def stop(self):
raise NotImplementedError("This function should do something")
def proposalUnderExecution(self):
raise NotImplementedError("This function should do something")
2022-08-24 16:15:40 localhost.localdomain create_python_component[21561] INFO Editing Makefile
As you can see, two directories were created: "idlScheduler" and "pyScheduler".
> tree workspace/idlScheduler/
workspace/idlScheduler/
├── bin
├── ChangeLog
├── config
│ └── CDB
│ └── schemas
├── doc
├── idl
│ └── Scheduler.idl
├── include
├── lib
│ ├── ACScomponents
│ ├── endorsed
│ ├── libSchedulerStubs.a
│ ├── libSchedulerStubs.so
│ ├── python
│ │ └── site-packages
│ │ ├── Scheduler_idl.py
│ │ ├── SCHEDULER_MODULE
│ │ │ └── __init__.py
│ │ └── SCHEDULER_MODULE__POA
│ │ └── __init__.py
│ └── Scheduler.jar
├── LOGS
├── man
│ ├── man1
│ ├── man2
│ ├── man3
│ ├── man4
│ ├── man5
│ ├── man6
│ ├── man7
│ ├── man8
│ ├── manl
│ └── mann
├── object
│ ├── SchedulerC.cpp
│ ├── SchedulerC.d
│ ├── SchedulerC.h
│ ├── SchedulerC.inl
│ ├── SchedulerC.o
│ ├── SchedulerS.cpp
│ ├── SchedulerS.d
│ ├── SchedulerS.h
│ └── SchedulerS.o
├── rtai
├── src
│ ├── acsws
│ │ └── SCHEDULER_MODULE
│ │ └── SchedulerImpl
│ │ └── SchedulerComponentHelper.java.tpl
│ ├── Makefile
│ ├── Makefile.mk
│ └── module.mk
└── test
33 directories, 21 files
> tree workspace/pyScheduler/
workspace/pyScheduler/
├── bin
├── ChangeLog
├── config
│ └── CDB
│ └── schemas
├── doc
├── idl
├── include
├── lib
│ ├── ACScomponents
│ ├── endorsed
│ └── python
│ └── site-packages
│ └── SCHEDULER_MODULEImpl
│ ├── __init__.py
│ └── SchedulerImpl.py
├── LOGS
├── man
│ ├── man1
│ ├── man2
│ ├── man3
│ ├── man4
│ ├── man5
│ ├── man6
│ ├── man7
│ ├── man8
│ ├── manl
│ └── mann
├── object
├── rtai
├── src
│ ├── Makefile
│ ├── Makefile.mk
│ ├── module.mk
│ └── SCHEDULER_MODULEImpl
│ ├── __init__.py
│ └── SchedulerImpl.py
└── test
30 directories, 8 files
With the following source code for the IDL and implementation:
#ifndef _SCHEDULER_IDL_
#define _SCHEDULER_IDL_
#pragma prefix "acsws"
#include <acscomponent.idl>
module SCHEDULER_MODULE {
interface Scheduler : ACS::ACSComponent {
void start();
void stop();
long proposalUnderExecution();
};
};
#endif
# Client stubs and definitions, such as structs, enums, etc.
import SCHEDULER_MODULE
# Skeleton infrastructure for server implementation
import SCHEDULER_MODULE__POA
# Base component implementation
from Acspy.Servants.ACSComponent import ACSComponent
# Services provided by the container to the component
from Acspy.Servants.ContainerServices import ContainerServices
# Basic component lifecycle (initialize, execute, cleanUp and aboutToAbort methods)
from Acspy.Servants.ComponentLifecycle import ComponentLifecycle
class SchedulerImpl(SCHEDULER_MODULE__POA.Scheduler, ACSComponent, ContainerServices, ComponentLifecycle):
def __init__(self):
ACSComponent.__init__(self)
ContainerServices.__init__(self)
self._logger = self.getLogger()
def start(self):
raise NotImplementedError("This function should do something")
def stop(self):
raise NotImplementedError("This function should do something")
def proposalUnderExecution(self):
raise NotImplementedError("This function should do something")