Simple CIAO tutorial
Note:
CoSMIC tools are not used in this tutorial.
This is only a GENERAL way of building up a CIAO application. The user could always change the process in his own way. For example: the IDL file content, the project structure etc.
To download the code please refer to the CVS repository at $CIAO_ROOT/examples/Hello
.
If you just want to try the example you could jump to the Make then the Run section.
Example Description
This Hello example is contructed in the following ways:
1. There are 2 components in the system: Sender and Receiver
2. The Sender will send out the timeout event to the Receiver.
3. Upon receiving the timeout event, the Receiver will go and fetch data from the Sender.
4. The user could deploy multiple instances of the Receiver without changing any C++/idl source code.
Step-By-Step
Hello_Base
- 1. Write an IDL file (
Hello_Base.idl
) which contains all the interfaces and events common to all the components. The reason we do this is becuse the generated lib of this idl file will be linked in by all the components in the system. To reduce the size of the component lib we have to include only the necesary part. In this example, we have an eventtype timeout
and an interface ReadMessage
, which are used by both the Sender and the Receiver, so we put both of them in Hello.idl.
- 2. Look at the
Hello_Base.mpc
file to get an idea how the Hello_Base_stub and Hello_Base_svnt projects are organized. MPC is a utility we used to generate makefiles or VC project/solution files for all ACE, TAO and CIAO libraries.
For Every Components
- 1. Use:
$CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Sender
$$CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Receiver
Note:
- I have different directories for
"Hello_Base", "Sender", "Receiver"
respectively.
- For every
_stub
project, add:
"libs += Hello_Base_stub"
- 2. Use the export script to generate the export files. (3 files per component).
- 3. Write an idl file for every compoent. Here you can put the component specific IDL definitions in this file. In this example we have a interface
trigger
specific to the Sender. Please note that the Sender component "supports"
(IDL keyword) this interface.
- 4. Write the CIDL file for every component.
- 5. Write
_exec.h
and _exec.cpp
files which actually implement the component.
Writing all those files could be troublesome to a new CCM user. The best way of learning this is to read the example source code. If you are familliar with CORBA programming, it should not take too much time before you can declare yourself as a CCM programmer.
The Entry Point
After both components are implemented we still need a small program to initialize the process. In Sender.idl there is a Sender specific interface with a single method in it created for this purpose. Hence there is a CORBA client application called starter
. The starter
will make a invocation on a supported interface called trigger
on the Sender component to get the whole distributed application started. The starter
will first the Sender component object reference through the ior string. Please see the the last part of Hello/Sender/Sender.mpc
file for details.
Make
- Go to the directory
$CIAO_ROOT/examples/Hello
and do:
$ACE_ROOT/bin/mwc.pl
(use -type option if you are using a compiler/IDE other than gnuace -which by default generates GNU makefiles)
For example, using $ACE_ROOT/bin/mwc.pl -type vc71
if you are using Visual C++ 7.1 IDE.
- Look at the generated Makefile(*unx) , Solution/workspace files(Windows) and you got it.
Assemble
Now we can step forward to build the assembly. Here we are going to build the simplest case only, which is 1 Receiver and 1 Sender. If you are interested in CIAO you could try 1 Sender with multiple Receiver. However, you need to change the Sender.idl to make it publishes timeout event instead of emits event.
- 1. Make a new directory with name descriptors in your workspace
- 2. Construct the CIAO_Installation_Data.ini file. You can use
uuidgen
to generate the UUIDs
- 3. For every component generate the .csd and .ssd files. Follow the example carefully and make sure that you use the right UUIDs
- 4. Write the .cad file which describes the assembly. You can choose to use CADML to generate the file.
Note: Please pay attention to the inter-relationship among different files, especially the relationship between the .cad file and idl file.
Run
Finally you are ready to test the application you have made.
1. Run the example with a single CIAO_Daemon
In ./descriptors
directory: ./run_test_default.pl
dose the following for you.
- 1.
${CIAO_ROOT}/tools/Daemon/CIAO_Daemon -ORBEndpoint iiop://localhost:20000 -n ${CIAO_ROOT}/tools/ComponentServer/ComponentServer
- 2.
${CIAO_ROOT}/tools/Assembly_Deployer/Assembly_Manager -o ior -c test.dat
- 3.
${CIAO_ROOT}/tools/Assembly_Deployer/Assembly_Deployer -k file://ior -a default.cad
- 4.
../Sender/starter
Note: you can repeat this step.
If you want to get debug information from the component server, please see run_test_debug.pl which adds debug flag while running the component server.
2. Run the example with 2 CIAO_Daemons but on the same machine.
In ./descriptors
directory: ./run_test_remote.pl
dose the following for you.
- 1.
${CIAO_ROOT}/tools/Daemon/CIAO_Daemon -ORBEndpoint iiop://localhost:20000 -n ${CIAO_ROOT}/tools/ComponentServer/ComponentServer
- 2.
${CIAO_ROOT}/tools/Daemon/CIAO_Daemon -ORBEndpoint iiop://localhost:12000 -n ${CIAO_ROOT}/tools/ComponentServer/ComponentServer
- 3.
${CIAO_ROOT}/tools/Assembly_Deployer/Assembly_Manager -o ior -c test.dat
- 4.
${CIAO_ROOT}/tools/Assembly_Deployer/Assembly_Deployer -k file://ior -a remote.cad
- 5.
../Sender/starter
Note: you can repeat this step.
3. Run the example with 2 CIAO_Daemons on two different hosts.
In ./descriptors
directory:
Here you have to open the remote.dat and fill in the right URL for your hosts. You can change the port number as well, of course you will have to use the corresponding right address in your -ORBEndpoint option in the following step1 and 2.
- 1. On host "Default"
${CIAO_ROOT}/tools/Daemon/CIAO_Daemon -ORBEndpoint iiop://URL:20000 -n ${CIAO_ROOT}/tools/ComponentServer/ComponentServer
- 2. On host "Remote"
${CIAO_ROOT}/tools/Daemon/CIAO_Daemon -ORBEndpoint iiop://URL:12000 -n ${CIAO_ROOT}/tools/ComponentServer/ComponentServer
For step 3 and step4 it doesn't matter where they are executed.
- 3.
${CIAO_ROOT}/tools/Assembly_Deployer/Assembly_Manager -o ior -c test.dat
- 4.
${CIAO_ROOT}/tools/Assembly_Deployer/Assembly_Deployer -k file://ior -a remote.cad
Step5 must be executed on the same host where the Sender is deployed. If you are using my remote.cad file then the host is the Default
one.
- 5.
../Sender/starter
Note: you can repeat this step.
4. Run the example with 2 receivers deployed on the same ComponentServer.
In ./descriptors
directory: ./run_test_multirecv.pl
Email: ciao-users@cse.wustl.edu