Filesystem script routines

Discuss issues and ideas you have to configuring displays with PowerVision
dberezowski
Posts: 65
Joined: Wed Sep 08, 2010 4:03 pm

Filesystem script routines

Post by dberezowski » Tue Jun 14, 2011 4:09 pm

I have some questions regarding the return value from certain scripts and how to do error handling as I need to do some extensive file lI/O for a customer. Specifically, I need to prompt a user to insert a USB stick, check if it is inserted, manage files to/from it, prompt user to unmount it, prompt user to remove it, etc. I absolutely need to know if a function call fails as I am dealing with detailed log files ( not simple logging ) of the operation of expensive and large construction equipment.

The functions below send eventID when completed. How does one know if they fail?
deleteFile(), copyFile(), listFiles() and unmountUSB().


The other question I have relates to the ScriptFileAccessDemo that was posted ( thanks by the way ). A number of the routines refer to "ErrorHandler". The "ErrorHandler" script itself is empty with the comment "do some error handling here!". Do you have any examples of how one would use this?

Thanks, David
jpurdum
Enovation Controls Development
Enovation Controls Development
Posts: 153
Joined: Mon Jun 21, 2010 11:19 am

Re: Filesystem script routines

Post by jpurdum » Wed Jun 15, 2011 8:30 am

We've known for a long time this documentation is lacking - also, scripting had not changed much if any from 2.0 through 2.2.

In 2.3, we are hopefully going to show some drastic improvement in this area where scripting documentation can be found in the tool next to the script editor with every function documented.

In the meantime, we will see if we can't produce an interim "preview" document to help you and others out.

jpurdum
ksaenz
Enovation Controls Development
Enovation Controls Development
Posts: 263
Joined: Thu Aug 19, 2010 7:53 am

Re: Filesystem script routines

Post by ksaenz » Wed Jun 15, 2011 8:52 am

If a function doesn't send an event when it fails you can use a timer to send a timeout event if you don't receive a success event.

You are going to need a state with two transitions to exit.
One transition to be fired when the function succeeds.
The other transition to have the timeout timer and to be fired when the timer expires.
On entering the state execute the script and also start the timeout timer.
On exiting the state cancel the timeout timer.

If the function succeeds it will fire the success event and cancel the timeout timer.

If the function doesn't send the success event then the timer will expire and fire the timeout event.