10-04-2005 06:15 PM
10-05-2005 02:18 PM
Hello gold,
The problem here is almost sure related to a sub-VI reinitializing/rewriting
the value of the global. I would recommend taking a look at all the code
in your project -- make a list of all of the readers and writers of the value
to make sure there are no places where the global is being updated in an unpredictable
way.
Careful use of globals does have a place in programming, so no harassment here!
Hope this helps,
10-05-2005 03:41 PM
10-07-2005 10:26 AM
Hello,
I believe that the problem is related to the nature of global variables.
When a global variable is no longer in memory, it reverts back to its default
state. All it takes to keep a Global (really just a special type of VI) a
Global in memory is to have 1 VI with a reference open to it. Your remote
machine does not keep any references open to the Global since the scope of that
Global is limited (right now...... 😉 ) to one machine. It sounds like
your server machine might be closing references to the Global when it is not in
use -- thus resetting it to its original state. I would try an experiment
where you have a VI open on your serving machine which does nothing more than
keep the Global in memory.
Thanks for posting, and please let us know if this works!
10-10-2005 10:15 AM
Currently the server side reads the status of the global continuously 4x a second. The remote also reads the global at the same rate. So wouldn't that keep the variable constantly in memory? The only difference is that the remote global gets its data by subscribing to datasocket server, whereas the server/local gets its data from the data acquistion.
When I open the global VI I can see the correct value on the server side, and when I open the global VI on the remote side I can see the correct value initially. Then I can see it change when the subVI is launched.
Another mystery is that I actually have 2 servers (both running the identical app), the remote can select between the data from server1 or server2. I am only seeing this behaviour on #2.
IF you care here's the details of how I select between the two servers: I have two sets of globals (on the remote), each set are identical except for the name of the vi. They each will subscribe over datasocket server (DSS) to their server ie....globals1 to server1 and globals2 to server 2. The remote will then display the global data from globals1 or globals2 depending on the operator selection.
gold
10-18-2005 10:05 AM - edited 10-18-2005 10:05 AM
Message Edited by Support on 10-18-2005 12:31 PM
10-18-2005 10:50 AM
For those of you who may be interested and look at my code and ask, what the heck is this.......
To see the error/problem I am having you must do the following.
FINALLY.....with no other action you will see (on the remote, datasocket reader.vi) the value of the boolean #2 revert back to its default value. This is an unexpected behavior. If you continue and Initialize another DCM, the value of #2 will change back to its "proper" value. But the next time the administration is selected the remote will again revert back to default.
I know this seems complicated, but its a problem that I have been hacking at for 2+ weeks now so anyone with ideas is welcome. I have enlisted NI tech support so I'm not alone but we can always use more brains!
Thanks
10-18-2005 11:48 AM
Sorry I forgot to put a wait in my administation.vi, so it will tend to hog your processor. Either add a wait ms or download this new one.
This set has the fix
10-18-2005 01:56 PM
Hi Gold,
It will be hard to help without beating you up about using globals but I will try.
An "interesting feature" of arrays stored in globals can be observed when the array is updated from more than one chunk of code.
Here goes.
1) App starts up and writes a global array of booleans to all false.
2) The app starts running and two VI's A & B will try to set the boolean that reflects their state in the global.
3) A reads the array from the global and a copy of what was in the global gets put one of its wires for use latter. Lets say it goes first so itt find an array with all the booleans clear.
4) B wants to do the same some it reads the global and just like A gets a copy of what is in the global. Because A has not written yet, it sees all cleared booleans.
5) A does a replace array subset on the copy it read and then writes the data to the global.
6) Looking at the global at this time, everything looks OK.
7) Meanwhile B does its replace and writes to the global BUT it does not "know" that A had set its boolean. It updates the global and wipes out what A had done.
Semaphores can be sued to prevent this situation but there is an easier way.
If the boolean array was in a shift register of a functional global, the two VI A & B could invoke and action that sets their bit. Since the functional global is NOT re-entrant, B will be forced until A is done and the data in the shit register is updated.
Trying to help,
Ben
10-18-2005 02:26 PM - edited 10-18-2005 02:26 PM
Message Edited by gold on 10-18-2005 02:37 PM