Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

The CDB Simulated Components are a quick way to make a component available for development and testing. They could be used to prototype basic functionality and to mock-up components in order to prepare module tests which need to interact with other components.

Preparations

Create a module for the tests that are going to be performed:

Code Block
languagebash
linenumberstrue
collapsetrue
> getTemplateForDirectory MODROOT_WS sim_comp
> cd sim_comp

...

Code Block
languagecpp
titlesim_comp/idl/MountExample.idl
linenumberstrue
collapsetrue
#ifndef _MOUNT_EXAMPLE_IDL_
#define _MOUNT_EXAMPLE_IDL_

#include <acscomponent.idl>

#pragma prefix "alma"

module ACS_COURSEworkshop
{
    interface MountExample : ACS::ACSComponent {
        void objfix (in double az, in double elev);
    };    
};

#endif

...

Code Block
languagexml
titlesim_comp/test/CDB/MACI/Managers/Manager/Manager.xml
linenumberstrue
collapsetrue
<Manager xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns="urn:schemas-cosylab-com:Manager:1.0" xmlns:log="urn:schemas-cosylab-com:LoggingConfig:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Timeout="50.0" ContainerPingInterval="20.0">
    <Startup> </Startup>
    <ServiceComponents>
        <cdb:e string="Log"/>
        <cdb:e string="LogFactory"/>
        <cdb:e string="NotifyEventChannelFactory"/>
        <cdb:e string="MC_NotifyEventChannelFactory" />
        <cdb:e string="LoggingNotifyEventChannelFactory" />
        <cdb:e string="MC_LoggingNotifyEventChannelFactory" />
        <cdb:e string="LoggingChannel@LOGGING.channels"/>
        <cdb:e string="ArchivingChannel@ARCHIVING.channels"/>
        <cdb:e string="AlarmNotifyEventChannelFactory" />
        <cdb:e string="MC_AlarmNotifyEventChannelFactory" />
        <cdb:e string="InterfaceRepository"/>
        <cdb:e string="AlarmChannel" />
        <cdb:e string="CDB"/>
        <cdb:e string="ACSLogSvc"/>
        <cdb:e string="AcsAlarmService"/>
    </ServiceComponents>
    <LoggingConfig>
        <log:e Name="jacorb@Manager" minLogLevel="5" minLogLevelLocal="5"/>
    </LoggingConfig>
</Manager>

...

Code Block
languagexml
titlesim_comp/test/CDB/MACI/Components/Components.xml
linenumberstrue
collapsetrue
<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="MOUNT" Code="Acssim.Servants.Simulator" 
   Type="IDL:alma/ACS_COURSE/MountExample:1.0"
   Container="pyContainer"
   ImplLang="py"/>
</Components>

Prepare the Makefile:

Code Block
linenumbers
languagebashtrue
collapsetrue
> cp src/Makefile test/Makefile

Add the following to IDL entry:

Code Block
titlesim_comp/test/Makefile
linenumberstrue
collapsetrue
...
# 
# IDL Files and flags
# 
IDL_FILES = MountExample
TAO_IDLFLAGS =
USER_IDL =
MountExampleStubs_LIBS = acscomponentStubs
...

Generate code stubs and skeletons:

Code Block
languagebash
linenumberstrue
collapsetrue
> cd test
> make all

Simulated Component

The simulation code needs to be put in the CDB:

Code Block
languagexml
titlesim_comp/test/CDB/alma/simulated/MOUNT/MOUNT.xml
linenumberstrue
collapsetrue
<SimulatedComponent xmlns="urn:schemas-cosylab-com:SimulatedComponent:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pythonImports>
from acstime import Duration
</pythonImports>
<initialize>
logger=parameters[0].getLogger()
logger.logInfo("Component initialized!")
</initialize>
<cleanUp>
print('Simulated component cleaning up')
</cleanUp>
<_corbaMethod Name="objfix" Timeout="0">
print("objfix\nobjfix called with params ", parameters, "\n")
</_corbaMethod>
</SimulatedComponent>

Client

A simple client could be prepared:

Code Block
languagepy
titlesim_comp/test/client.py
linenumberstrue
collapsetrue
from Acspy.Clients.SimpleClient import PySimpleClient
client = PySimpleClient()
m = client.getComponent("MOUNT")
m.objfix(3,6)

Executing

Start ACS:

Code Block
languagebash
titleConsole 1
linenumberstrue
collapsetrue
> cd sim_comp
> export ACS_CDB=$PWD/test
> export IDL_PATH="-I$PWD/idl $IDL_PATH"
> acsStart

On a different console start pyContainer:

Code Block
languagebash
titleConsole 2
linenumberstrue
collapsetrue
> cd sim_comp
> export PYTHONPATH=$PWD/lib/python/site-packages:$PYTHONPATH
> acsStartContainer -py pyContainer

...

Code Block
languagebash
titleConsole 3
linenumberstrue
collapsetrue
> export PYTHONPATH=$PWD/lib/python/site-packages:$PYTHONPATH
> python test/client.py

The expected behavior is that no error is shown in "Console 3" and "Console 2 shold have the following output:

Code Block
titleConsole 2 Output
linenumberstrue
collapsetrue
2020-07-25T23:2745:1452.390198 INFO [acsStartContainer] Running the container with these arguments: 'ACSStartContainerPy pyContainer -ORBendPoint giop:tcp:127.0.1.1:4000 -m corbaloc::127.0.1.1:3000/Manager'
ContainerStatusMsg: Startup begins
2020-07-25T23:2745:1453.997027 AlarmSystemInterfaceFactory init - Using ACS alarm system
ContainerStatusMsg: ORB initialization begins
ContainerStatusMsg: ORB initialization ends
ContainerStatusMsg: Manager access initialization begins
ContainerStatusMsg: Manager access initialization ends
ContainerStatusMsg: Automatic component loading begins
2020-07-25T23:2745:1553.042077 pyContainer taggedmessage - Info message from the manager: Startup statistics: 0 components queued to be activated.
2020-07-25T23:2745:1553.114079 pyContainer taggedmessage - Info message from the manager: Startup statistics: 0 of 0 components activated.
ContainerStatusMsg: Automatic component loading ends
ContainerStatusMsg: Ready
2020-07-25T23:2745:1553.180168 pyContainer getCDBInfo - No container information found in the CDB
2020-07-25T23:2745:1553.284183 pyContainer __init__ - Container pyContainer waiting for requests
2020-07-25T23:2745:1553.289187 pyContainer __init__ - Container pyContainer used libraries from /home/almamgr/mod/src/../lib/python/site-packages/:/alma/ACS-2020AUG/ACSSW/lib/python/site-packages:
ContainerStatusMsg: Startup ends
2020-07-25T23:2745:1854.076869 pyContainer activate_component_async - Starting async activation of MOUNT(type IDL:alma/workshop/MountExample:1.0)
2020-07-25T23:2745:1854.080871 pyContainer run - Activating MOUNT (type IDL:alma/workshop/MountExample:1.0)
2020-07-25T23:2745:1854.083872 pyContainer aboutToActivate - The container is asking the clearance to activate MOUNT
2020-07-25T23:2745:1854.084873 pyContainer _aboutToProcess - The container is not dealing with MOUNT: the operation can go ahead
2020-07-25T23:2745:1854.111877 pyContainer aboutToActivate - The container has been cleared to activate MOUNT
2020-07-25T23:2745:1855.658075 loggingts -- Successfully loaded component code. [ logName=LOG_CompAct_Loading_OK TimeMillis=538194 CompName=MOUNT ]
2020-07-25T23:2745:1855.974130 loggingts -- Successfully instantiated component. [ logName=LOG_CompAct_Instance_OK TimeMillis=30647 CompName=MOUNT ]
2020-07-25T23:2745:1955.487 Servants.Representations.Dynamic.Dynamic'>(MOUNT) __initialize442 MOUNT stringFunction - Simulated lifecyle methodComponent initialized!
2020-07-25T23:2745:1955.488444 Servants.Executor _execute - initialize return value looks like:None of type:<class 'NoneType'>
2020-07-25T23:2745:1955.489448 EventDispatcher (MOUNT) setupEventDispatching - Setting up event dispatching.
2020-07-25T23:2745:1955.494459 EventDispatcher (MOUNT) setupEventDispatchinghandleFrequencies - No CDBevent entry found. Bailingfrequencies defined.
2020-07-25T23:45:55.463 EventDispatcher (MOUNT) handleResponses - No event frequencies defined.
2020-07-25T23:2745:1955.691508 loggingts -- Successfully activated component with Corba. [ logName=LOG_CompAct_Corba_OK TimeMillis=0 CompName=MOUNT ]
2020-07-25T23:2745:1955.692510 loggingts -- Successfully initialized component. [ logName=LOG_CompAct_Init_OK TimeMillis=0 CompName=MOUNT ]
2020-07-25T23:2745:1955.696560 pyContainer activate_component - Activated component: MOUNT
2020-07-25T23:2745:1955.766571 pyContainer activate_component - Component 'MOUNT' has KeepAliveTime '0'.
2020-07-25T23:2745:1955.771576 pyContainer activated - The container terminated the activation of MOUNT: awakening waiting threads
2020-07-25T23:2745:1955.775579 pyContainer _processTerminated - The container terminated dealing with MOUNT
2020-07-25T23:2745:1955.778582 pyContainer run - Calling maci::CBComponentInfo::done with descOut.id_tag = 1 for 'MOUNT'
2020-07-25T23:2745:1955.889601 pyContainer run - Call to maci::CBComponentInfo::done with descOut.id_tag = 1 for 'MOUNT' completed
2020-07-25T23:27:19.922 Servants.Representations.Dynamic.Dynamic'>(MOUNT) __handleNormalMethod - Method:objfix
2020-07-25T23:27:19.930 Servants.Representations.Dynamic.Dynamic'>(MOUNT) getMethod - retVal looks like:objfix {'Value': [None], 'Timeout': 0.2}
2020-07-25T23:27:20.132 Servants.Executor _executeList - Failed to evaluate the 'None' statement!
objfix called with params  [3.0, 6.0, <Acssim.Servants.Simulator.Simulator_IDL:alma/workshop/MountExample:1.0 object at 0x7f0608194d30>]

2020-07-25T23:2745:2055.132610 Servants.Executor _execute - objfix return value looks like:None of type:<class 'NoneType'>
2020-07-25T23:2745:2055.189689 pyContainer aboutToDeactivate - The container is asking the clearance to deactivate MOUNT
2020-07-25T23:2745:2055.203693 pyContainer _aboutToProcess - The container is not dealing with MOUNT: the operation can go ahead
2020-07-25T23:2745:2055.204696 pyContainer aboutToDeactivate - The container has been cleared to activate MOUNT
2020-07-25T23:2745:2055.204736 pyContainer deactivate_component - Deactivating component: MOUNT
2020-07-25T23:27:20.205 Servants.Representations.Dynamic.Dynamic'>(MOUNT) __cleanUp - Simulated lifecyle methodSimulated component cleaning up
2020-07-25T23:2745:2055.206741 Servants.Executor _execute - cleanUp return value looks like:None of type:<class 'NoneType'>
2020-07-25T23:2745:2055.208747 pyContainer deactivated - The container terminated the deactivation of MOUNT: awakening waiting threads
2020-07-25T23:2745:2055.211749 pyContainer _processTerminated - The container terminated dealing with MOUNT