NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Random locks TestStand

Attached is a small chunk of code that has the ability to lock up TestStand. I have inspected the code and do not see anything fundamentally wrong with the code. It gets the size of an array then randomly indexes a value. It is not going out of range but locking up on this statement:

Parameters.multiGame.gameIndexRandom = Round(Random(0, Parameters.multiGame.gamesDepth-.01,0.0) )

The -.01 is to create a maximum value for the randomizer slightly less than the number of elements in the array. The round function will then round down the value to a whole number. Attached is the code that can lock my system 100% of the time.

Matt
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 1 of 12
(4,574 Views)
Hi,

For the step genGameRandIndex shouldn't expression be 'Parameters.multiGame.gameIndexRandom = Round(Random( Parameters.multiGame.gamesDepth-.01,0),0)'

The Round() this has two parameters as such Round(the number, )
The Random() this also has to parameters as such Random(low, high)

I tried running you example in TS3.0 and it errored on this step. Maybe in TS3.1 there is a problem with one of these functions which is locking up instead of generating an error.


regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 12
(4,563 Views)
Random has three parameters in TS 3.1 (see below)

The command I have is listed below and I am using TS 3.1. The code will run fine for thousands of loops then locks.

Parameters.multiGame.gameIndexRandom = Round(Random(0, Parameters.multiGame.gamesDepth-.01,0.0) )

Low = 0
High = Parameters.multiGame.gamesDepth-.01
Seed = 0.0 (Help says this is a random seed)

For Round I am rounding the random result using the default value (rounds towards zero (the default)). I still don't see anything wrong with this statement syntatically. I am willing to change it but don't see why it wouldn't work.


TS Help Files from 3.1:
Random(low, high, )
This function returns a random number between low and high.
Parameter 1: A number specifying the lower limit for the random number.
Parameter 2: A number specifying the upper limit for the random number.
Parameter 3: An optional number the function uses to determine where in the virtual sequence of random numbers the function obtains its random numbers. When you seed the Random function with the same value, subsequent calls to Random return the same sequence of numbers. If you pass a seed value of 0.0, the function generates a seed value based on the current time. If you do not pass a seed value, the function returns the next number in the current sequence of random numbers.
Returns: The random number.

Round(number, )
This function rounds a number to an integer.
Parameter 1: The number to round.
Parameter 2: An optional parameter: how to round.
Pass 0 to rounds towards zero (the default).
Pass 1 to round away from zero.
Pass 2 to round towards positive infinity.
Pass 3 to round towards negative infinity.
Pass 4 to round to the nearest integer. If the number is exactly between two numbers, rounds to the nearest even integer.
Returns: The rounded number.
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 3 of 12
(4,563 Views)
hi matt,

I had not realised that the random had been changed at TS3.1. But it maybe worth trying not using the third parameter of Random() and see if you still have problems.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 4 of 12
(4,553 Views)
Ray,

Ran fine without the seed for the random number generation. I would suggest someone form NI have a look at it again using the seed as 0.0 as described in the user manual.

Matt
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 5 of 12
(4,540 Views)
Matt,

I am going to take a look at this issue. I will reply on here when I have an update.

Allen P.
TestStand R&D.
0 Kudos
Message 6 of 12
(4,534 Views)
We have reproduced the problem here as well. Right now we are currently identifying where the problem is occuring.

I'll give you an update with what we find as well.

Allen P.
TestStand R&D
0 Kudos
Message 7 of 12
(4,527 Views)
Thanks! Looking forward to hearing the resolution to the issue
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 8 of 12
(4,527 Views)
I've confirmed this is a bug with reseeding whenever reseedValue & 0x3FFF == 0. When you pass 0.0 to reseed using the current time, the hang will happen whenever & 0x3FFF == 0.

This will be fixed in the next version of TestStand. To workaround this always insure that reseed-value & 0x3FFF != 0. For your case, instead of passing 0.0 to reseed from the current time, pass something like (Seconds() * 1000) | 0x1
Message 9 of 12
(4,514 Views)
My last post lost some text because it was in angle brackets. Here is it again with different brackets:

I've confirmed this is a bug with reseeding whenever reseedValue & 0x3FFF == 0. When you pass 0.0 to reseed using the current time, the hang will happen whenever {millisecond-clock-value} & 0x3FFF == 0.

This will be fixed in the next version of TestStand. To workaround this always insure that reseed-value & 0x3FFF != 0. For your case, instead of passing 0.0 to reseed from the current time, pass something like (Seconds() * 1000) | 0x1
Message 10 of 12
(4,511 Views)