Archive for February 21st, 2009

Applying Rules to Automon

Today I came up with the idea of creating a monitor type thread in Automon’s kernel. This should allow me to create ‘Rules’ that can be added to the monitor and if the rules are satisfied, they emit a signal. For example, I could make a rule “If CoolantTemp < 50 degree C && RPM > 4000″ or “If carOnTime < 5mins && RPM > 4000″, these state that the car is not warm enough to do such reving, resulting in engine wear. If these signals were to emit, I could have them connected to say a GUI warning slot, that will alert the user/driver of the car that such a state has being satisfied.

However this causes a little problem, how can I make dynamic savable rules like this? Coming from a PHP and Javascript background, I’m well familiar with the eval function. This would be useful as I could pass a string “%1 < 5 && %2 > 6″ and replace the %’s with the sensor’s pointer address, then feed this in as an eval to evaluate the code dynamically. Unfortunately, C++ doesn’t seem to support such a construct. I then realised QT comes with a scripting module, QtScript. This will allow me to create dynamic variables and evaluate a condition. Scripting objects can be connected to real QObjects so this should solve the problem. Hopefully!