DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

data loss in Script DAC Driver?

Hello,

currently I’m experiencing some problems with the Script DAC Driver. It seems to me, that if the DAC scheme and the VBS script get a bit more extensive, the content of variables inside the script gets lost arbitrarily. They’re empty.

For example the following code saves a value into an array if a certain ChannelNumberP is processed. Any time later I can access this value Variable(42) and use it. Normally this works.

 

dim Variable(50)

 

Sub SFD_ProcessChannel( ChannelNumberP, InputListV, ParamP, DataP, ErrorP )

 

' ... some extensive code ...

 

if ChannelNumberP <= 5 then Variable(42) = 5

 

' ... some extensive code ...

 

if ChannelNumberP = 27 then DataP = Variable(42)

 

' ... some extensive code ...

 

end sub

 

 

But under some unknown conditions, it returns empty and not five. Just like the channel isn’t processed or the space in memory is erased.

 

 

If I change the script in the following way…

 

dim Variable(50)

 

Sub SFD_ProcessChannel( ChannelNumberP, InputListV, ParamP, DataP, ErrorP )

 

' ... some extensive code ...

 

Variable(42) = 5

 

' ... some extensive code ...

 

if ChannelNumberP = 27 then DataP = Variable(42)

 

' ... some extensive code ...

 

end sub

 

 

…it always works. Unfortunately this causes a huge disadvantage because lots of code is executed everytime SFD_ProcessChannel is repeated. When the code is more complicated than

Variable(42) = 5

it might even slow down the computer.

 

Has anyone else had a problem like this?

0 Kudos
Message 1 of 6
(5,074 Views)

Hi,

 

I haven't seen this before but my best guess is that the condition that sets Variable(42) to 5 was never matched before. Have you initialized the "Variable" variable before? If not I would suggest to initialize the entire "Variable" vector to e.g. NoValue in SFD_Init.

 

 

Rainer

 

0 Kudos
Message 2 of 6
(5,051 Views)

Hello,

thanks for this answer. I assign values to each variable in a subroutine which is executed before SFD_ProcessChannel is run for the first time.

 

Now I tried the first initialization using SFD_Init but it made no change.

 

When I let my script run on DIAdem 2014 SP1 it’s even worse than with 2012 SP1. Then more variables are empty.

I tried out synchronous, asynchronous and interrupt mode and used different clock rates, without success too.

0 Kudos
Message 3 of 6
(4,996 Views)

Hi,

 

if that is some kind of unpredictable behavior, have you tried not using an array variable?

 

I gues that in" ...some extensive code" you use more then one indices as you allocate 50. But, for testing , could you replace variable(42) with a normal single value variable? Does that change the behavior in any way?

 

Regards

René

0 Kudos
Message 4 of 6
(4,982 Views)

Hi,

 

I have tried to reproduce your problem with two simple scripts but I could not reproduce the loss of data. I have attached the two scripts and the two DAC schemes I used for testing. In VBTest1 the values of the variable 'TestArray' are incremented every time when 'SFD_ProcessChannel()' is called while in 'VBTest2' the data are incremented every time when 'SFD_ProcessScan()' is called.

Both exampled did not show any loss of data.

Do you have a simple example that I can use to reproduce the problem?

 

Regards

 

Rainer

 

0 Kudos
Message 5 of 6
(4,979 Views)

Thanks a lot for your answers.

 

@reschri
That’s an interesting idea. I’ll try that.

 

@RainerH
The error only occurs when I use this particular script in a complicated DAC scheme. This DAC scheme is used to control processes in our company and is unfortunately strictly confidential.
As soon as I can get some time again, I’ll try to create a DAC scheme to reproduce the error and to put it here.

0 Kudos
Message 6 of 6
(4,824 Views)