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 message
, which are used by both the Sender and the Receiver, so we put both of them in Hello.idl.
- 2. Use
$CIAO_ROOT/bin/generate_component_mpc.pl -n Hello_Base
to generate the MPC file for ITS_Base. Note: There are only 2 projects in the mpc file, Hello_stub and Hello_svnt.
- 3. Open the mpc file and follow the instructions below
For the project Hello_Base_svnt
:
- Change the parent prject from
ciao_svnt to ciao_server.
- Delete the
IDL_Files
and CIDL_Files
part.
- Delete all the files in the
Source_File
part except Hello_BaseS.cpp.
Note: These steps are needed because that Hello_Base
is not a component but libs(stub and skel) which will be used by the component libraries. However, since we generate the mpc file using the generate_component_mpc.pl
we have to handcraft the file. The user can hand write this file if he prefer to.
- 4. Follow the instruction from the output of the last step, use the perl script (
generate_export_file.pl
) to generate the Export files.
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 compoennt).
- 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.
- 4. Write the CIDL file for every component.
- 5. Write
_exec.h
and _exec.cpp
files which actually implement the compnent.
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 delcare yourself as a CIAO 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 I created a TAO application called starter. The starter will call on a sepcial trigger interface on the Sender to get the whole process started. The starter program should collocate with Sender because it reads in the ior of the Sender. Please see the the last part of Hello/Sender/Sender.mpc
file for detial.
Make
- Go to the top directory of your workspace and do:
$ACE_ROOT/bin/mwc.pl
(use -type option if you are on Windows)
- Look at the generated Makefile(*inx) , Solution/workspace file(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 wich multiple Receiver. However, you need to change the Sender.idl to make it pulishes 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