CoolMon 2 : SDKPrincipals
Understanding the principals
IMHO it would probably be easier for you, to develop the most efficient plugins, if you know how CoolMon 2 ticks.When CM2 starts up, it will load all registered plugins (general as well as visual) into memory. Then it will read through the CML configuration file. Please consider this example.
<form> <parameters> <color>clskyblue</color> <left>10</left> <top>100</top> <width>100</width> <height>25</height> <transparent>no</transparent> </parameters> <content> <visual name="Text"> <parameters> <bold>yes</bold> <top>0</top> <left>0</left> <width>100</width> <height>25</height> <background>clskyblue</background> <font>255</font> <color>clwhite</color> <size>12</size> </parameters> <content> <sensor name="Test.Random Numbers" update="1"> <parameters> <range>1000</range> </parameters> </sensor> </content> </visual> </content> </form>
This is not a complete CML, just a part of it, more specifically a form and it’s contents. We will not go into depths on how the CML syntax is or how it works here because I could probably write an entire paper just on that alone. We will just run through what CM2 does, when it meets certain nodes.
When CM2 hits the form node, it will create the form with the parameters CM2 finds in the parameters block, it will create a pointer to this form and thus linking the form to all sub nodes.
Then when it hits the visual tag it will, using the pointer to the parent form, create a visual object (IE. an instance of the visual plugin desired, in this case the text plugin). When doing this CM2 will pass an hDC to the form on which the plugin will have to draw output. Then it will send the parameters to the plugin.
When the sensor tag is reached, CM2 will create an item in the variable manager which serves as a host for all dynamic values. It will then make sure that the plugin is polled for the desired value when required. When it is polled the variable manager will trigger an event that will cause the visual plugin to update its current value and then redraw accordingly.