LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Datasocket bug or limitation?

Ben, I very much wished that you try to run those two programs - with execution highlight on and off, and that would give you the insight of DS and my desired behaviour. 

 

But I suppose I have made you clear about both of these.

Vaibhav
0 Kudos
Message 11 of 18
(2,551 Views)

@Vaibhav wrote:
...

2) Yes, that I forgot to ask you. What is AE?


I was waiting for you to ask that question. Smiley Wink (mawahaha!)

 

An AE is an Action Engine as I wrote in this Nugget.

 

I fyou read that Nugget please think about actions like (open, Write_Yellow_Light, etc) and pay particualr attention to the section about the "Traffic cop behind the scenes" to see how an AE will fix this issue.

 

Take care,

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 18
(2,551 Views)

:manhappy:

Owww... That was an almost guessed term "Action Engine" - I suppose I have already "seen" it (the thread) before. Ok, will try to understand the idea this time. 

 

But what about the point 1? Did you get the idea? And do you think AE is the remedy for this? My application is already too much congested. I was looking for DS settings, rather than creating new wires and objects. But of course, am open to "New Thinking, New Doing" anytime. 😉

Vaibhav
0 Kudos
Message 13 of 18
(2,544 Views)

@Vaibhav wrote:

:manhappy:

Owww... That was an almost guessed term "Action Engine" - I suppose I have already "seen" it (the thread) before. Ok, will try to understand the idea this time. 

 

But what about the point 1? Did you get the idea? And do you think AE is the remedy for this? My application is already too much congested. I was looking for DS settings, rather than creating new wires and objects. But of course, am open to "New Thinking, New Doing" anytime. 😉


Re: point 1

 

As I understand it, you will be depnding on timing to enuse you don't miss anything. I don't see how timing will help with two trying to write at the same time. But I try not to shove my ideas down others' throats so if it works good enough then dont mind me. But... if you run into issues, you will remeber the AE.

 

Note:

Even using an AE to enuse no simulataneous writes, if the reader does not "look up at the light" at the right time, he may miss it completely. That is when we start talking about handshaking (but I have already written too much).

 

Re: AE and more wires.

 

AS I posted in this thread, using AE can actually reduce the numer of wires and simplify your code.

 

Take care,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 14 of 18
(2,534 Views)

 


@Ben wrote:

As I understand it, you will be depnding on timing to enuse you don't miss anything. I don't see how timing will help with two trying to write at the same time. But I try not to shove my ideas down others' throats so if it works good enough then dont mind me. But... if you run into issues, you will remeber the AE.

 

Note:

Even using an AE to enuse no simulataneous writes, if the reader does not "look up at the light" at the right time, he may miss it completely. That is when we start talking about handshaking (but I have already written too much).

 

Re: AE and more wires.

 

AS I posted in this thread, using AE can actually reduce the numer of wires and simplify your code.

 

Take care,

 

Ben


 

No. I won't be missing anything to read due to timing.

Whatever comes to DS item "msgB" will be read sooner or later (depending on the time the previous messages and their following actions inside the loop took). 

At the end of a time out, if there is no new message, the DS reader will give that same old message (as in the previous iteration), and if there is a new message, it will quickly give that out (without having to wait until a time out to occur). 

I hope you got my point.

 

I already started reading AE. Even if I don't use it for this case, it's good to have knowledge. And as you said, AE will actually help reduce the wires. But I am afraid my situation will remain the same. 

I hope my DS explanation in this message was simpler.

 

Vaibhav
0 Kudos
Message 15 of 18
(2,530 Views)

This post contains responses to questions from multiple previous posts from multiple people.  Hopefully it won't get too confusing.

 

Let me try and shed some light on the BufferMaxBytes and BufferMaxPackets properties.  The term packets is a little cryptic, and it's probably easier if you think of packets as the number of elements written through the DataSocket Write VI.  If BufferMaxPackets is set to 10 and you write elements of type double, the client buffer will grow and hold at most 10 doubles.  The BufferMaxBytes property works in conjunction with the BufferMaxPackets property to limit the maximum size of the client buffer.  In effect, they act as a floor function.  Continuing with the previous example, if BufferMaxBytes was set to 72, the client buffer would only be able to hold up to 9 elements instead of 10 since 9 doubles will consume 72 bytes worth of space.  This isn't particularly useful for scalar data types, but it becomes more important for data types like arrays, strings, clusters, and waveform data types.  For these data types, an individual element (or packet) can be very small (1D array of size 2) or very large (1D array of size 1,000,000).  In this case, it's often more convenient to limit the maximum size in terms of bytes rather than packets.  The example VIs located at <LV Dir>\examples\comm\datasktbuf.llb do a reasonable job of demonstrating how these two settings can effect streaming performance and whether or not data gets lost or overwritten.

 

If you're using waveform data type (WDT) or arrays as your element type, each write constitutes a packet or element of data and packets are never combined.  This means if you write four 1D array elements of size 250, you will always read four 1D array elements of size 250 on the other end.  You can't collapse the packets and read a single 1D array of size 1000.  This is true for both the PSP (Shared Variable) or DSTP protocol.  Collapsing can be accomplished to a degree with network streams since it supports both single element and multi-element reads and writes.  In this case, you would configure the element type of the stream to be a double and use the multi-element read/write to vary the number of elements read and written on each side.  If you set the element type of the stream to 1D array and use the single element read/write, you'll get the same behavior you do with the PSP and DSTP protocol.  However, it still won't work for WDT natively.  To do this, we'd have to track the dt, t0, and number of samples included in each waveform element and make sure the written elements were contiguous such that they could be read out in smaller or larger chunks than they were written into the stream.  This is a pretty expensive operation to perform with each read and write which is why didn't try to support it.  If you know your data is contiguous, it's always going to be more efficient for you to transfer the t0 and dt up front and simply deal with the array portion of the WDT from there on out.

 

You can use the DataSocket VIs to read and write items published by either the PSP or DSTP protocol and enable client side buffering for either protocol.  To do this, you have to remember to set the BufferMaxPackets and BufferMaxBytes properties described above as well as set the appropriate mode on the Open VI to enable buffering for just reads or for both reads and writes on the connection.  If you're using the Dynamic Variable API, you can only read/write points published through the PSP protocol.  In LV 2010, you can now set the size of the client side buffer by using the Open and Verify Variable Connection or Open Variable Connection in Background VIs located on the PSP Variable palette.  In this case, the buffer size is always in units of elements, and both reads and writes are buffered using the same buffer size setting.  Finally, for buffering to be effective, you also have to enable buffering on the server.  For Shared Variables, this is set on the properties page when you right click on the Variable item in the LabVIEW project.  For items published through the DSTM protocol, this is set in the DataSocket Server Manager.  For predefined items, you can uniquely configure the maximum size in bytes and packets for each item.  Non-predefined items all share the same configuration for the maximum size in bytes and packets.  In either case, the default value is 26214400 bytes and 1 packet so double check to make sure the number of packets is larger than 1 if you want to enable buffering on the client connections and have it be effective.  You can get away with no buffering on the server or the writer if you're using synchronous writes (timeout > 0) that complete before timing out.  However, if you're using asynchronous writes, you should at a minimum enable buffering on the server if not both the writer and the server.

 

Some final parting shots: If you end up going down the road of trying to write your own buffer object, you might want to look at <LV DIR>\examples\general\globals.llb\Smart Buffer (DBL).vi.  I think it might already support the functionality you were trying to implement at one time.  If not, it should be a pretty good starting point.  If network streams provide what you want aside from the client/server aspect, you could try writing your own server that you deploy that negotiates with clients and then gives them the information they need to establish the peer to peer connection for the network stream.  I realize it's probably more work than you wanted, but it might still be better than the other options in front of you.  Something to think about...

0 Kudos
Message 16 of 18
(2,470 Views)

Sorry, my browser tabs must have gotten messed up and I accidentally posted under the wrong thread.  Sorry for the confusion.

0 Kudos
Message 17 of 18
(2,458 Views)

 


@reddog wrote:

Sorry, my browser tabs must have gotten messed up and I accidentally posted under the wrong thread.  Sorry for the confusion.


 

Nevermind. I was, in fact, pleasantly surprised that this thread still has some attention. Although the original question of this thread is somewhat answered - that it's a limitation of DS - since then I am on a journey to explore shared variables because I want to do the other tasks with them which I had planned to do with DS.

To keep things simple I would reply to your post in the intended thread only. 

Vaibhav
0 Kudos
Message 18 of 18
(2,447 Views)