[Qt-interest] Implementing a dynamic expression at runtime

Alexandre Beraud aberaud at infflux.com
Thu Mar 5 14:40:27 CET 2009


Hi,

QtScript is very powerfull and can easily call the C++ functions but... 
then the user will have to write his/her file in the javascript 
language. If you need to let the user write something like "If 010C < 40 
AND 010D > 60" then I think that you will have to parse the file and 
create some kind of very basic programming language. Otherwise, why not 
make a graphical configuration tool instead ? The user could chose the 
sensor, the value to compare to, and the operator to apply.

Best regards,

Alex


Donal a écrit :
> 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
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
BERAUD Alexandre
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com





More information about the Qt-interest-old mailing list