[Qt-interest] Implementing a dynamic expression at runtime

Donal donaloconnor at gmail.com
Thu Mar 5 14:15:22 CET 2009


Hi There,

I posted here originally posing the idea of my final year project, using QT
in an embedded ARM device to build
a car monitoring device. It reads sensor values in real time, lets you know
of diagnostic codes if they occur etc.

Now this is coming a long very well but I have a question:

I have many sensors reading in real time, such as engine coolant temperature
and engine RPM. These are QObject derived types that have signals
implemented to signal sensor value changes.

I want to enable a user to choose rules dynamically, for example if the
Coolant Temperature and Engine RPM
are monitored in real time (4 samples a second), I want to allow the user to
say produce an alert
when for example, "If coolantTemp < 40 AND engineRPM > 4500" alert the user
with a dialog message.

So I am wondering which is the best way to implement such dynamic logic. As
far as I know C++ doesn't allow you to evaluate
dynamic code at run time.
I have looked at QtScript and it seems to be able to interact with objects
of QObject derived type.

My idea is to construct a string such as "If 010C < 40 AND 010D > 60", where
the 01n are the identifiers for the sensors.
Then parse this string and construct some qscript logic from it to evaluate
to true or false.
Reason I'd like to store as QString is to allow the storing of rules to a
file.

You think I'm going down the right path or is there something else more
suitable in QT.

Hope this makes sense.

Thanks.

Donal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090305/94b9c08d/attachment.html 


More information about the Qt-interest-old mailing list