[Qt-interest] Implementing a dynamic expression at runtime

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


Hi Alex,

Creating a GUI with drop downs of each sensor available and setting the
comparison expression graphically are my intentions. But I want it savable
to file for the next time the device turns on so I need to keep the state
some way or just export it like the string I have there and then parse it
and re construct it properly so it can integrate into QtScript.

But by looks of it, QtScript is the path to take alright.

It says in the docs it only available for Desktop and Open Source editions.
I am using Qt/Embedded but I seem
to have the module and am able to compile and execute some of the QtScript
sample code.

Thanks,

Donal

On Thu, Mar 5, 2009 at 1:40 PM, Alexandre Beraud <aberaud at infflux.com>wrote:

> 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
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090305/1c734b78/attachment.html 


More information about the Qt-interest-old mailing list