### Step 3: Package your components

###

Brief Introduction to CosMIC:

The Component Synthesis using Model Integrated Computing (CoSMIC) project is a MDA toolset being developed by the Institute for Software Integrated Systems (ISIS) at Vanderbilt University to:

1. Model and analyze distributed real-time and embedded application functionality and QoS requirements.

2. Synthesize CCM-specific deployment metadata required to deliver end-to-end QoS to DRE applications.

The CoSMIC toolsuite provides modeling of DRE systems, their QoS requirements, and QoS adaptation policies used for DRE application QoS management. The component behavior, their interactions, and QoS requirements are modeled using a domain specific modeling language that adheres to the OMG Deployment & Configuration (D&C) specification (ptc/2003-07-08). CoSMIC enables modeling the standards-based CCM components.

Hand-writing the required XML descriptors to configure our components is tedious and error prone. We therefore utilize CosMIC (we specifically use a subset of CosMIC called PICML, which stands for Platform-Independent Component Modeling Language) to generate the bulk of descriptors for us.

For more information on CosMIC, please refer to the following article:

CoSMIC: An MDA Generative Tool for Distributed Real-time and Embedded Applications.

Importing IDL to PICML
To quick start our Stock Quoter modeling process in GME, CoSMIC introduces `idl_to_picml` , which is an executable program that imports the IDL files you just created into PICML.

1. Make sure `%COSMIC_ROOT%\bin` is included in the PATH variable, e.g., c:\Program Files\ISIS\CoSMIC\bin.
2. Open a command prompt, run VCVARS32.BAT from the MSVC .NET folder if you haven't done so. It will set the environment for using Microsoft Visual Studio .NET tools so that idl_to_picml works properly.
   in my machine, VCVARS32.bat is in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin
3. In the same command prompt, change directory to `Quoter\Simple`, and type the following command:
   > `idl_to_picml -x Quoter -r .`
   `idl_to_picml` will parse your IDL files and generated a `Quoter.xme` file in the `Quoter` directory. Note that if -x option is not used, the default xme file name will be `PICML_default_xme_file.xme.`
   When this command is run a second time, be sure to delete all E.idl files first!
4. Start GME, select File | Import xml..., and choose the xme file just generated. You should be able to see an imported PICML model similar to the one shown in Figure 2.

Figure 2

In the Browser of the generated model, the `PredefinedTypes` folder contains a bunch of atomic datatype elements that will be referenced by other modeling parts later. You don't have to worry about them for now. The models in `InterfaceDefinitions` folder are the PICML representations of the IDL files you just imported. Double-click to open `StockBroker`, it will show you a yellow box-shaped entity representing a <<Package>> instance. Its equivalent representation in IDL is "module". Figure 3 gives you a clear view of GME representation of all the 3 IDL files created. We will cover the other folders in the next section.

Figure 3

Now we are ready to model the rest of the Stock Quoter systems.

### Building Stock Quoter System in PICML

This section describes modeling the Quoter application using PICML. If you have trouble producing a functioning model from this tutorial, please see the, pre-built Quoter model which is provided for your reference. This model contains all elements created as part of this tutorial.

Note: To import an XML file in GME, select File | Import XML... from GME and choose your XML model

The PICML paradigm is designed for the OMG Deployment & Configuration (D&C) specification (ptc/2003-07-08), so the modeling process is straightforward if you are familiar with the specification. Please see the DAnCE project for more information. For those who hate specifications (including me, :-)), an overview of D&C and as well as a tutorial of D&C and CCM can help to reduce the learning curve. In addition, it is also helpful to read through documentation which originally came from the TAO's Developer's Guide 1.4a (CIAO and CCM) which thoroughly describes the various descriptors required for a component (*.iad, *.ccd, *.cid, etc). This chapter is available here.

### Table of Contents

- ImplementationArtifacts
- ComponentImplementations
- Targets
- DeploymentPlan

The complete PICML Quoter model consists of modeling elements distributed across various folders. If you used `idl_to_picml` to generate the initial model, you will see that it has created all these folders and some of the tedious boilerplate modeling for us. The rest of the section will explain the purpose of each folder as well as the modeling entities contained in these folders. We will also show how to model some of the folders that have to be done by hand.

Important: The interpreters that generate deployment artifacts expect very strict constraints in the model. When you finish your model, and any time you wish to generate anything, it is a good idea to check constraints by clicking on Tools | Constraints | Check All in GME. This will help you find many logic errors in your model.

### ImplementationArtifacts

This folder contains implementation artifacts associated with components. `idl_to_picml` has created these artifacts for us to ensure the are named correctly when associated with their target implementation. Figure 4 shows the Implementation Artifacts for the `StockBroker` implementation.

Figure 4.

### ComponentImplementation

This folder contains models that describe the implementations of component interfaces. In the Quoter example, we will have two monolithic component implementations - named `Stock_StockDistributorImpl` and `Stock_StockBrokerImpl` - and an assembly component implementation named `StockQuoter`, which is an assembly of `Stock_StockDistributorImpl` and `Stock_StockBrokerImpl`. `idl_to_picml` has created the monolithic component implementations for us, as shown in Figure 5.

Figure 5

We also need to specify the connections between a `Stock_StockDistributorImpl` and a `Stock_StockBrokerImpl` in order to construct a Quoter system. We therefore we need to create the mentioned StockQuoter component assemby.

Assembly components provide a boundary for the composition of monolithic components and even other assemblies. Assembly components do not provide actual implementations for their interface, it is a virtual component that delegates its ports and attributes to one or more of the entities it contains. There are slight differences between modeling an assembly and modeling a monolithic component. Since the assembly is a virtual component, it is not necessary to model a `MonolithicImplementation`. Instead, instances of other components are placed within the assembly and connected. Let's try to assemble the `StockQuoter`.

1. Right click the ComponentImplementations folder, choose Insert Model->ComponentImplementationContainer, rename it as "StockQuoterImplementation" in the Attribute Panel. Double click to open it.
2. From the Part Browser, drag a <<ComponentAssembly>> to the modeling window, name it "StockQuoter". Double click to open it.
3. Now we will create two instances for interfaces `StockBroker` and `StockDistributor`. To do that, first add a <<ComponentInstance>> element to the model, select the Stock_StockBrokerImpl from the pop-up dialog, and change the name of the <<ComponentInstance>> to "StockBroker".
4. Repeat the same process for the `StockDistributor` component instance. Figure 6 show the model of the both the `StockBroker` and `StockDistributor` component instances.

Figure 6

5. Now assemble the components together according to Figure 1 (make sure you change to connect mode ) and the resulting assembly model should look like Figure 7.
6. With ComponentIOR, one could configure the name of the IOR file. This can be done by dragging two <<SimpleProperty>> items from the part browser onto the window, one for StockBroker and one for StockDistributor, and setting to reference the <<String>> predefined type. Now it's time to configure the name and value of both <<SimpleProperty>> items.
   - The name of each <<SimpleProperty>> should be "ComponentIOR"
   - One of the values should be "StockBroker.ior" and the other should be "StockDistributor.ior"

Figure 7

### Targets

This folder contains domain-specific models capturing information about the target environment in which component-based application will be deployed. In this Quoter example, we can either deploy the two components into ONE host, or into TWO different host. We will deploy the Quoter into two different host.

1. In the folder Targets, insert a new <<Domain>> named "Domain"; double click to open it.
2. From the Part Browser, add two <<Node>>s, named "Broker" and "Distributor" respectively.

Now we are ready to deploy our Components to the actual physical environment.

### Deployment Plan

This folder contains a plan model that captures information about the assignment of component to nodes.

1. In the folder DeploymentPlan, insert a model <<DeploymentPlan>>; name it "Plan". Double click to open it.
2. From the PartBrowser, add the following:
   - Two <<NodeReference>> named "Node_Broker" and "Node_Distributor" respectively, refering to `Quoter/Targets/Domain/Broker` and `Quoter/Targets/Domain/Distributor` respectively.
     A <<CollationGroup>>, named "DefaultGroup", is added automatically when adding a <<NodeReference>>.
   - Two <<ComponentInstanceRef>> named "StockBroker" and "StockDistributor" respectively, refering to `Quoter/ComponentImplementations/StockQuoterImplementation/StockQuoter/StockBroker` and `Quoter/ComponentImplementations/StockQuoterImplementation/StockQuoter/StockDistributor` respectively.

   The model should look like this:

Figure 10.

4. Now we need to associate <<ComponentInstanceRef>> StockBroker to the <<CollocationGroup>> running on the <<NodeReference>> Node_Broker, and <<ComponentInstanceRef>> StockDistributor to the <<CollocationGroup>> running on the <<NodeReference>> Node_Distributor. To do that, switch the Edit Mode Bar to Set Mode (), and move the cursor to the <<CollocationGroup>> running on <<NodeReference>> Node_Distributor, right-click on it. You will find the cursor is changed to set mode cursor, and only the <<CollocationGroup>> you clicked in is highlighted, as shown in Figure 11.

Figure 11

Now move your cursor to <<ComponentInstanceRef>> StockDistributor, and left-click it, so that it looks like Figure 12.

Figure 12

This operation associates StockDistributor component to the <<CollocationGroup>> running on `Distributor` node. To do the same with Broker, just right-click on the associate <<CollocationGroup>>, and left-click on StockBroker <<CollocationGroup>> which is then highlighted.

Up to this point, we are basically done with the modeling part. Before we generate anything from this model though, please DO remember to check the constraints of the model as we mentioned earlier.

After we are done with the modeling, the Deploymentplan interpreter that comes along with PICML will help us to generate a Plan.cdp file. Please make sure you generate this file to Quoter/descriptors. Note that to get the example working,a Node Map xml file (NodeMap.cdd) in Quoter/descriptors should be created to map logical nodes to NodeManager object references.

Previous Next

$Id: 03.html 94063 2011-05-13 18:00:45Z hillj $