Tools for Domain-Specific Modeling, Dr. Dobb's Journal, September 2004


Original Eclipse GEF implementation: GEFLogic.zip
-------------------------------------============
Requirements: Eclipse 3.0, GEF 3.0 (from http://www.eclipse.org)

This zip contains the example and a zip of its source code (logicsrc.zip).
The zip also contains the small Flow application and source (flowsrc.zip).
The version is that used for the article, Release Candidate 1, i.e.
GEF-examples-I20040603.zip from the Eclipse site.


MetaEdit+ implementation: ME+Logic.zip
--------------------------============
Requirements: MetaEdit+ 4.0 (evaluation from http://www.metacase.com)

This zip contains a MetaEdit+ database with the Logic Gate language
and an example model. Building these took one hour.

1) Unzip the ME+Logic.zip into your MetaEdit+ directory
2) Start MetaEdit+
3) Press the 'down arrow' button to expand the MetaEdit+ Startup Launcher
4) Press Roots Browser
5) Press Add..., and enter the name (logic) and path (logic)
6) Press Save and Close
7) Press Login and choose the 'logic' database
8) Enter the user name (sysadmin) and password (sysadmin)

The model can be opened by double-clicking "fourBitAdder: Logic" in the
Graph Browser tab. Create Objects by clicking their icon on the toolbar,
then clicking in the diagram. Create Connection relationships by clicking
the 'Con' button on the toolbar, clicking an Out port on an object, and
clicking an In port on another object. Ports are shown as black squares;
note that a black square on a Circuit object has an In port on its top
edge, and an Out port on its bottom edge.

The elements of the Logic language - its Graph type,
Object types, Relationship types etc. - can be seen in the Metamodel 
Browser tab and the Type Browser tab. Double-click a type to open it, 
e.g. the "Logic" Graph type opens in a Graph Tool. 

In the Graph Tool, the Types button shows the Object, Role and 
Relationship types in this Graph type; the Bindings button shows
the legal ways of building connections between Objects; and the
Constraints buttons shows additional constraints on connections.

A Connection relationship has two Wire roles, each of which connects
to a Logic Port on a Logic Element (which is the supertype of And, 
Or, Xor and most other Object types). To see the ports on an Object
type, open the type in an Object Tool by double-clicking it in the
Types list, and open its symbol with the Symbol button. A port is 
shown there as a crosshair. Selecting a crosshair and pressing
Enter shows its properties, including the Port. Double-clicking the
Port shows whether it is an 'In' or 'Out' Port. The constraint in
this language specifies that this Direction property must be different
on the Ports at either end of a binding, i.e. you cannot connect from
an 'In' Port to another 'In' Port, only to an 'Out' Port.

The definition of the Logic port can be seen by double-clicking it
in the Bindings list from the Graph Tool. It has two properties,
a Port name and a Direction. The Direction property type definition
can be seen by double-clicking it in the Properties list. Direction
is a String property, which is entered by the user by choosing values
from a Fixed List widget - a pull-down list where the user cannot
add new values. The values are 'in' (the default) and 'out'.

Only the Logic port, Label and LED Object types have properties here,
presumably since the original example was built in Eclipse to demonstrate
GEF, rather than EMF. Types in MetaEdit+ can have far more complicated
properties, including properties whose values are themselves other 
objects. See for instance the definition of the "Class [UML]" Object
type in the MetaEdit+ demo database (logout of here and login to demo,
and open the UML and Tutorial projects). 

To learn about building your own DSM language, try the Tutorial
from the MetaEdit+ Help. To look at a larger example of DSM,
including full code generation, see the Watch Example in the Help.

If you have any questions, feel free to contact me at
steven.kelly@metacase.com