This tutorial will provide a brief overview of the CoSy Architecture Schema Toolkit (CAST) version 2, and give you enough experience to start writing your own components in either C++ or Java (just do the tutorial in one language or the other unless you want to be really thorough). Even if you've used CAST v1 before you should work through this tutorial to see all of the interface changes that have taken place. The main changes are due to switching from omniORB and Java CORBA to ZeroC's
Ice for the underlying communication middleware, but there have also been changes to the build system and a few interface things (particualarly in C++).
In this tutorial we will write a very simple "Hello World" subarchitecture. This subarchitecture will contain two components: one (called HelloWriter) which will write an object containing a string to working memory, and another (called HelloReader) which will read the object from working memory and print out the string. In this tutorial we will write a system with a single subarchitecture, but the lessons are applicable to systems with mulitple subarchitectures (such as the other example, the comedian subarchitecure).
This tutorial assumes that you have
installed CAST on your system. If this is the case, then we need to create somewhere to put our tutorial code. It is current practice to create subarchitectures in separate directories under a directory called subarchitectures. So, to get started (assuming you're in a directory called $TUTORIAL_ROOT) create a directory to hold future subarchitectures, and a directory within that to contain our tutorial example:
cd $TUTORIAL_ROOT
mkdir -p subarchitectures/hello-world
Within a subarchitecture directory, we place source code under a src directory split into different languages. Let's create these directories next:
cd $TUTORIAL_ROOT
mkdir -p subarchitectures/hello-world/src/slice
mkdir -p subarchitectures/hello-world/src/c++
mkdir -p subarchitectures/hello-world/src/java
All data structures that are to be written to working memory in CAST must first be defined in the
Ice interface definition languagae
Slice. This allows components to exchange information regardless of what language they are written and where they are on a network. For more information on
Ice and Slice start
here. It is also sensible to keep a copy of the
Ice manual handy as it is an excellent reference. Any WM object in CAST must be a Slice
class. For this example we will create a class called
Announcement to contain the message we will pass between our components. This can be done as follows. First create the file
subarchitectures/hello-world/src/slice/HelloWorldData.ice
then edit it to add the following:
#ifndef HWD_ICE
#define HWD_ICE
module helloworld {
class Announcement {
string message;
};
};
#endif
The rest of the tutorial is language specific so pick either Hello World in C++ or Hello World in Java.