CoolMon 2 : CML14

Understanding CoolMon Markup Language (CML)



The config files are as mentioned above in a custom format of XML. Our little CML system. Our CML is built around some key tags
The CML tag is the base tag for the entire file, it must provide the version of the CML in use. Like this
<CML Version="1.2">
    ......
</CML>

Then we have the display tag, within this tag all output will be written, those are the form, visual and sensor tags.
<CML Version="1.2">
	<display>
		......
	</display>
</CML>

In order to produce any output in CM2 you must use either the Sensor or the text tag, these must be place in a visual tag which in turn must be placed in a form tag.
<CML Version="1.2">
	<display>
		<form>
			......
			<visual>
				......
				<sensor>
				</sensor>
			</visual>
		</form>
	</display>
</CML>

This example is an just to demonstrate how the structure should be, it won’t work in CM2. Since neither tag has any parameters or properties. Let start with looking at the form tag, with some properties/parameters
......
	<form name="MyMainForm">
		<parameters>
			<left>100</left>
			<top>50</top>
			<width>150</width>
			<height>75</height>
			......
		</parameters>
		<content>
			<visual>
				......
			</visual>
		</content>
	</form>
......

As you can clearly see the form tag here is divided into 2 sub tags, “parameters” and “content”. The parameters tag is of course to set parameters which will determine the appearance of the form. The content tag is place all the content which will appear on the form, or in other words all the visual tags you need on the form. The name in the form tag is to allow you to easily find your way around your various forms in a large config. Let’s now take a look at the visual tag.
......
	<visual name="text">
		<parameters>
			<left>0</left>
			<top>0</top>
			<width>150</width>
			<height>50</height>
			......
		</parameters>
		<content>
			<text>A random number: </text>
			<sensor>
				......
			</sensor>
		</content>
	</visual>
......

First the visual tag must be provided with a name, this is the name of the visual plugin that should be used to draw the output. This in turn means that there must be registered visual plugin with the name you use. Then again like the form tag the visual tag also uses the “parameters”/”content” tag system. As for parameters you must always provide the orienting types, (left, top, height and width) followed by the parameters needed to make the plugin operate properly.

The text tag is a tag that can only be used in the content tag of visual. It will give you some static text, it can of course be preceded or proceeded by multiple text and sensor tag. Now for the last tag, the sensor tag
......
	<sensor name="test.random numbers" update="1">
		<parameters>
			......
		</parameters>
	</sensor>
......

The sensor tag must be provided with the name of the plugin you wish to use, followed by a dot “.” then the sensor name, in the above example we are using the test plugin and it’s “random numbers” sensor. The update property will tell CM2 to poll this value every “1” second and of course you can place your sensor parameters in the parameters tag.

Your very first CML Config

If we piece together what we have from above examples we would get this
<CML version="1.2">
	<display>
		<form name="MyMainForm">
			<parameters>
				<left>100</left>
				<top>50</top>
				<width>150</width>
				<height>75</height>
				......
			</parameters>
			<content>
				<visual name="text">
					<parameters>
						<left>0</left>
						<top>0</top>
						<width>150</width>
						<height>50</height>
						......
					</parameters>
					<content>
						<text>A random number: </text>
						<sensor name="test.random numbers" update="1">
							<parameters>
								......
							</parameters>
						</sensor>
					</content>
				</visual>
			</content>
		</form>
	</display>
</CML>

We only need to expand a bit on the parameters to get it to work in CM2. Please notice this example will only work if you have the Visual Plugin "Text" and the General Plugin "Test" installed
<CML version="1.2">
	<display>
		<form name="MyMainForm">
			<parameters>
				<left>100</left>
				<top>50</top>
				<width>150</width>
				<height>75</height>
				<color>clSkyblue</color>
			</parameters>
			<content>
				<visual name="text">
					<parameters>
						<left>0</left>
						<top>0</top>
						<width>150</width>
						<height>50</height>
						<font>arial</font>
						<size>10</size>
						<color>clwhite</color>
						<background>clskyblue</background>
						<bold>yes</bold>
					</parameters>
					<content>
						<text>A random number: </text>
						<sensor name="test.random numbers" update="1">
							<parameters>
								<range>1000</range>
							</parameters>
						</sensor>
					</content>
				</visual>
			</content>
		</form>
	</display>
</CML>

And there you go, your first CML config file.