[RESOLVED] [2005] Scriptable Application
I've recently completed an app that controls a heap of test equipment (that does board testing). Using my App, the user sets up tests for different voltages, frequencies, temperatures etc, the App drives the test equipment over GPIB and also captures/plots the results. The user can access the PC using VNC, which saves them having to turn up at the lab to switch the oven temperature over, restart it, view the results or whatever. This all works great.
But... the various tests are currently hardcoded and the user just chooses which ones to run in sequence (from checkboxes in a ListView). It would be really neat to be able to support user written 'scripts' that would look something like this...
For Temp = -40 to +140 step 20
For V1 = 2.5 to 3.5 step 0.1
For F1 = 1M to 100M step log 1 decade
Measure Vout
Next F1
Next V1
Next Temp
Plot (x=F1,y=Vosc,z=V1) etc.
I can hardcode each such test and add it to the existing list of tests, but this needs "me" to do it. Since I effectively have a library of subs/functions that does all the necessary stuff, it would be good if my App could read/run a script. Any suggestions how I could make my App's inner functions scriptable? Users could then code their own tests and I dont need to be summoned every couple of hours to write a new one. (Originally I was told there was a well defined fixed set of tests, hence I assumed hardcoding them was fine. So I'm trying to retrofit a new feature that wasnt requested, yuk!).
I was thinking of adding an edit window and writing a parser which checks the script and then calls the various subs, but this is like writing a compiler and needs error checking galore (lot of work). To avoid exposing my code, I could also create DLL's which the user then calls, but there would be no error checking.
Do I need to do all this or is there a better way? Any advice appreciated.
Re: [2005] Scriptable Application
A couple of pointers for you.
Have a look at System.Reflection and see how you can dynamically call methods and properties.
You haven't mentioned up to what level your users could write scripts. Its more likely that you want users to set start/end values of particular property values. I would suggest showing them how to write these in a specific text file format or you could user XML. You could then read that file and use Reflection to invoke you DLL.
e.g
VB Code:
<?xml version="1.0" ?>
<tests>
<test method="dllname.CheckRange">
<startval></starval>
<endval></endval>
</test>
</tests>
Re: [2005] Scriptable Application
Re: [2005] Scriptable Application
Re: [2005] Scriptable Application
Excellent links guys. Thanks.