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/DAnCE/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. 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_Base_DnC_stub and Hello_Base_DnC_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_dnc.
- 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_DnC_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.
- 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 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 special trigger interface on the Sender to get the whole process started. The starter program should collocate with Sender because it reads 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 using a compiler/IDE other than gnuace -which by default generates GNU makefiles-)
- 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 wich multiple Receiver. However, you need to change the Sender.idl to make it publishes timeout event instead of emits event.
- You need to create a bunch of XML descriptors which are explained as below.
- Component Interface Descriptor (.ccd)
- Describes the interface, ports, & properties of one component
- Implementation Artifact Descriptor (.iad)
- Describes the implementation artifacts (e.g., DLLs, OS, etc.) of one
component.
- Component Package Descriptor (.cpd)
- Describes multiple alternative implementations of one component.
- Package Configuration Descriptor (.pcd)
- Describes a configuration of a component package
- Top-level Package Descriptor (package.tpd)
- Describes the top-level component package in a package (.cpk)
- Component Implementation Descriptor (.cid)
- Describes a specific implementation of a component interface
Implementation can be either monolithic- or assembly-based
Contains subcomponent instantiations in case of assembly based
implementations
Contains interconnection information between components
- Component Packages (.cpk)
- A component package can contain a single component
A component package can also contain an assembly
- Copy the Deployment.xsd and XMI.xsd files from the Hello/descriptors directory.
- Create the .dat file containing the location of each component instance.
Note: Creating all the descriptors is a tedious and boring job, you can download CoSMIC to assist you in this step.
Run
Finally you are ready to test the application you have made.
- Change into the descriptors directory Start NodeManagers (NodeDameon) by running
basicNodeDaemon.pl
- Start the execution manager:
$CIAO_ROOT/DAnCE/ExecutionManager/Execution_Manager -o EM.ior -i hello.dat
- Start the executor:
$CIAO_ROOT/DAnCE/RepositoryManager/executor -p package.tpd -d Hello.cdp -k file://EM.ior
- After this, components should be deployed successfully. You can run the $CIAO_ROOT/DAnCE/examples/Hello/Sender/starter to start the application.
Please make sure that the component IOR file for the EC component is present when you run this client.
Email: ciao-users@cse.wustl.edu