DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Observe functions in DIAdem Script

Hello,

I've written a script in DIAdem Script Editor. Some of the functions I use include loops. Depending on the kind of data I want to analyze, the function's cycle-time is very long. I'd like to observe those functions and terminate them, when the cycle-time is longer than e.g. 5 min. Is there any possibility to do that?

 

Greetings,

Johannes

0 Kudos
Message 1 of 5
(2,550 Views)

Hi Johannes,

 

You can do this, but you'll need to program the exit condition yourself.  I recommend using the Stopwatch...() functions and variables in DIAdem.

Call StopWatchReset(1)
FOR i = 1 TO 10000000
  IF Stopwatch(1) > 3 THEN Exit For
NEXT ' i
MsgBox i

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(2,508 Views)

Hi Brad,

 

thanks for your response.

As far as I understand your code I can only check at the beginning of the loop, whether the exit condition is true. But what if my program is stuck in an endless loop? Then I won't reach the entrance of the loop anymore. In fact, that's the actual problem.

 

Greetings,

Johannes

0 Kudos
Message 3 of 5
(2,495 Views)

Hi Johannes,

 

There is no outside observer that can kill a running VBScript.  Your only option is to put the observation inside your VBScript.  If you want to monitor a particular loop, that observation has to be inside the loop, although it can absolutely happen in multiple places in the loop:

 

Call StopWatchReset(1)
FOR i = 1 TO 10000000
  IF Stopwatch(1) > 3 THEN Exit For
  Call RunTask1()
  IF Stopwatch(1) > 3 THEN Exit For
  Call RunTask2()
  IF Stopwatch(1) > 3 THEN Exit For
  Call RunTask3()
NEXT ' i
MsgBox i

This approach will only work if none of the RunTasks() hang.  If the thing causing your loop to be "endless" is one of the tasks being performed in that loop, then there's nothing we can do.  If, however, your loop is "endless" because of 2 or more things in your loop, then there's a way to observe that and escape the loop.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 5
(2,490 Views)

You might implement an observer pattern using the

ParallelProcessControl

but this will cause overhead because multiple DIAdem processes are used.

The Worker DIAdems can be observerd by the master process.

 

Maybe this can help you. Have a look at the help for examples.

 

0 Kudos
Message 5 of 5
(2,485 Views)