Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Single Writer NV

I'm using Measurement Studio  8.1 with a VB.net application.  I need to prevent two instances of the same application from writing to certain NVs at the same time. I am having a problem getting  the "single writer" concept would work.  This particular NV does not have buffering enabled.  I originally had buffering enabled, but the results were not any better.

When the application starts it connects to an particular NV.   The application never does a "disconnect" from this NV until the user exits (or moves to a different screen).

When two instances are running at the same time both can write to the NV and both can read changes made to that NV.  This is not what I thought would happen since the NV is single writer.   I thought the first instance which connected to the NV would be the only instance which has the abiity to write to the NV. I would not expect the second instance to be able to write to the NV until the first instance released the NV (by performing a disconnect or by exiting).  I have read the following articles but they do not seem to address the problem I'm seeing.
 
  
 
http://zone.ni.com/reference/en-XX/help/371361D-01/lvdialog/variable_page/

Also, it seems like multiple reads from either client will result in a "timeout" exception.  I can't understand why multiple reads would result in a timeout exception.

Any suggestions would be helpful.  Thank you.
0 Kudos
Message 1 of 4
(3,084 Views)
Hi Steve,

I tried to duplicate what you are seeing by running two instances of the following code at the same time:
           
            NetworkVariableBufferedWriter<double> test2 = new NetworkVariableBufferedWriter<double>(
                @"\\localhost\test\test");

     test2.Connect();

     for (double i = 0; i < 5; i++)
     {
         test2.WriteData(new NetworkVariableData<double>(i));
         System.Threading.Thread.Sleep(1000);
     }

     test2.Disconnect();


I made a double type network variable named "test" in group called "test". If I check Single Writer, I see the following exception:
Error Code: -6391 "A general access denied error occurred"

Is there something else I need to do to reproduce your setup?

Regards,

0 Kudos
Message 2 of 4
(3,061 Views)
Interesting... can you define what you mean by running the code "at the same time"?   I would expect that once the disconnect happens then the other instance would be able to write with no problem.

By "at the same time", I mean that there are two instances of the app running but they may not be accessing the NV exactly at the same time.  In our app, once an NV is conntected to the NV is not disconnected until that app is done with it.  It may hold the NV for several minutes.

Also, we were running multiple apps on the same PC.  We noticed different results if the apps were on different PCs.  

We did at times receive that "general access denied" error you mentioned, but it didn't seem consistent.  However, I did discover a bug that was causing a disconnect when it should not have been.  This has been fixed and we're currently retesting.

So, currently we are trying to figure out:

1. Does it makes a difference if the apps are run on the same PC or different PCs?
2. Once an app disconnects (by calling disconnect) from a single writer NV, can another app get control of that NV?

0 Kudos
Message 3 of 4
(3,055 Views)
Hi Steve,

I also had two instances of my app running at the same time (and I tried it on two different computers and it makes not difference). I extended the code to be more reliable about executing "at the same time". Find my project attached. I allow the user to connect as many NVs from the same program by clicking "Connect". Clicking "Write" will always attempt to write using the last NV added to the stack. Clicking "Disconnect" will pop them off the stack and disconnect each. If you run the app twice, click "Connect" on the first instance. Then, click "Connect" on the second instance. If you then click "Write" on the second instance, it will give you the general access error. Please let me know if behaves differently for you.

Regards,

Message Edited by James M on 08-31-2007 11:49 AM

0 Kudos
Message 4 of 4
(3,052 Views)