Xm lets you build virtual machines made of electric, logical and physical parts. The entire machine setup can be defined in an XML document. The rationale behind Xm is to provide a simulation engine to demonstrate the functionality of electromechanical machines, and, in a second stage, for hydraulic and pneumatic parts. It is not intended to provide support for realistic mechanical simulations like articulated structures, transmission gears or 3D simulations. There is support for simple particle animations and other animated parts, but this is mainly used to enhance the machine user interface.
At its current state, you can already use Xm to write logical circuit simulations and animations using particles, obstacles and other animation elements.
Xm is written and maintained by Ulrich Höhne at arxio GmbH, Karlsruhe, Germany.
Technically, Xm is a component for Mozilla and derived browers like Firebird. It manages the whole internals of the machine functionality and is adressed by a JavaScript interface while the browser manages the machine user interface. In case you haven't heard of Mozilla and Firebird yet, or need more information, follow the links above or see under Support.
Xm loads and parses machine descriptions written in XML. The machine is built up inside the Xm component and accessed via the Xm component JavaScript interface. The visible machine surface, its controls and other GUI elements are defined in a XUL file and managed entirely by the browser. The 'glue' between the machine controls in the browser window and the machine parts is provided by JavaScript functions. When a user event occurs, a JavaScript function passes the event to Xm. Also, the machine state is accessed by other JavaScript functions who use the information to update the GUI by setting attributes of the XUL elements.
Xm is written in C++, so machines can get pretty big and still run very fast. The limiting speed factor is, in fact, the Mozilla GUI, but as you can see in the machine samples that use animation, it does a pretty good job.
Instead of a 'Hello world' application, the first demo machine for Xm is a simple logic circuit. If you have ever worked with logic circuits, you can probably guess at a glance what it does.
As you may notice, one of the biggest advantages of Mozilla is that you can configure its aspect entirely by defining an XUL file, which is great for creating 'stand-alone' simulations. Of course, Xm machines can also be displayed in a 'normal' browser window.
Here is the XML description file for the simple logic circuit:
<?xml version="1.0" ?>
<!--
Xm sample "simplelogic.xml".
Simple logic network demonstration.
All part elements are included in a <machine> element.
-->
<machine
id="machine"
name="Simple logic circuit demo"
author="ulrich.hoehne@arxio.de"
version= "1.2 - 22.09.2003">
<!--
Inports connect the machine to the JavaScript side of your program.
Use method "setBoolean(partId, value)" of the Xm component to set
the value of a logical inport. You can only set the values
of inports, you can not set the values of other machine parts.
-->
<logInport id="input1"/>
<logInport id="input2"/>
<logInport id="input3"/>
<logInport id="input4"/>
<!--
Logical circuit parts.
Use method "getBoolean(partId, connectorId)" of the Xm component to get
the boolean output value (false or true) of a logXXX part.
You can also use "getInteger(partId, connectorId)" to get the output's
integer value (0 or 1). You can get the values of all parts of a machine.
-->
<logAnd id="and">
<!-- Wire connects an output from another part to an input of this part. -->
<wire from="input1.out" to="in_0"/>
<wire from="input2.out" to="in_1"/>
</logAnd>
<logOr id="or">
<wire from="input3.out" to="in_0"/>
<wire from="input4.out" to="in_1"/>
</logOr>
<logXor id="xor">
<wire from="and.out" to="in_0"/>
<wire from="or.out" to="in_1"/>
</logXor>
</machine>
Xm is a XPCOM component that plugs into Mozilla or other Mozilla-derived browsers like Firebird. So, in order to do anything at all with Xm, you need Mozilla on your system first. Xm will not be available for other Browsers as long as they lack support for XPCOM. It is theoretically possible to integrate Xm with C++ and Java, and maybe this will be supported one day.
The downloadable Xm package contains the XPCOM component and a few demo machines. Xm uses XPI to install itself as Mozilla component. For online documentation, see under Support.