Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing variables on RIO platform

Hi all,

 

I would like to improve (change) the variables access infrastructure I did about a year ago.

My initial problem was variable access through TCP/IP from WIN PC client to sbRIO.

The RESTRICTION being no LV installation on client PC. Now I would also consider installation of LV although it is not needed on client PC.

It is not needed because I need to import variables into third party application by it's plugin extension infrastructure.

So, there is a DLL providing data to 3rd party application and talking to RIO on the other end through TCP/IP connection. What I need from this connection is a query which would return accessible variables (with their meta data:name, type, size...) and of course read and write access.

 

I ruled shared variables out (can't really remember why - I think because I would need to install LV servers which enable shared variables access).

After finding nothing appropriate on my own I asked local NI guys who could only think of shared variables.

 

Next I did small serialization library to include in RIO design which does the job and is in use now, but I'm not satisfied with it because it is dirty to integrate and complex to maintain.

 

In my search for alternative I talked to the NI guy at NI VIP days and he suggested solution with OPC server.

I remembered the suggestion and now when I caught some time to get into it I'm finding out it is not possible to implement OPC server on RIO. Is this correct? Did we misunderstood each other? Did he think OPC server should me implemented in my DLL? How do I get variables to it then?

 

Now I'm searching answers about OPC... any thoughts?

Also, I would be interested in any other solutions, ideas, thoughts...

 

0 Kudos
Message 1 of 11
(5,132 Views)

hi enTelet.

 

I wll not answer all your questions, but i will try to clarify some parts. To the best of my knowledge, If you need to query shared variables, your application would need to use LabVIEW DSC Module.

 

The second part is, that OPC is based on Microsoft technology (OLE). This means, you are not able to use OPC from RT target.

 

What Is OPC?

 

If you just need to access shared variables, you do not need to install full LabVIEW, but it is enough to create executable which will access them. LabVIEW Run-Time engine with Shared Variable support shoudl be fine.

 

 

Regards,

Martin Stefik

Certified-LabVIEW-Developer_rgb.jpg

0 Kudos
Message 2 of 11
(5,107 Views)

I think using OPC is a layer you don't need in this case. To do that, you would need to publish shared variables from your RIO, then bind them to variables hosted on your PC, then be able to read OPC items from your plugin DLL. If that does not make sense, thats ok because I think it is not the best way to go here.

 

What language are you using to develop the plugin DLL? Shared variables can be accessed from CVI, .NET using Measurement Studio, and from C++ using Datasocket. 

 

So, I would recommend that you host the variables on your RIO (if you have sufficient CPU and memory left over) and then read and write to them from the plugin DLL using one of the above APIs.

0 Kudos
Message 3 of 11
(5,094 Views)

I'm bound to C++ without CLR.

 

So data socket looks interesting... but can I query shared variables with it?

I need to get a list of them and their types at some remote address.

0 Kudos
Message 4 of 11
(5,080 Views)

No, datasocket will not allow you to remotely query, but you can either wrap that functionality up in a DLL to call from C++ on the host or you can make a request to the cRIO, where you do a local query of that information and then return it over datasocket. 

 

With either approach, you can use the programmatic API for variables to do the query: https://www.ni.com/docs/en-US/bundle/labview/page/reading-and-writing-shared-variables-programmatica...

 

 

0 Kudos
Message 5 of 11
(5,069 Views)

Still... how can I implement variables and their type query in dll?

I leaning towards solution which doesn't need extra functionality on RIO.

0 Kudos
Message 6 of 11
(5,025 Views)

Hi enTelet,

 

In general, I believe that if you need to query Share Variables, which you have available, you would need LabVIEW DSC functionality.

 

You could have a look on recomendation here: Accessing Shared Variable with Visual C++.

 

If you need just to read/write values, you can use DataSocket 4.3 or later. I believe you should be able to read and write variables, but you will not be able to create/configure variables.

 

 

regards,

Martin Stefik

Certified-LabVIEW-Developer_rgb.jpg

0 Kudos
Message 7 of 11
(4,903 Views)

Hello again,

 

Thanks for your help. I've looked into DataSocket API and accessing variables with "psp://localhost/[Library]/[VariableName]" is acceptable for me.

The part I'm stuck on is how to get available [Library] options and [VariableName] options and variables types. I don't know what kind of shared variables I will create in the future (nor their names).

The requirement here is no CLR - just plain win c++.

 

Let me ask another way: how can I create shared variable browser?

Like:

 

+---------------------------------------------------+

| Shared variables available at some remote address |

+---------------------------------------------------+

| - shared_var1 (float):  3.4                       |

| - shared_var2 (double): 2.0                       |

| + shared_var3 (cluster)                           |

|    - member_var1 (int): 4                         |

|    - member_var2 (int): 2                         |

| - shared_var4 (double): 2.0                       |

+---------------------------------------------------+

0 Kudos
Message 8 of 11
(4,900 Views)

Did you take a look at the programmatic shared variable API?

https://www.ni.com/docs/en-US/bundle/labview/page/reading-and-writing-shared-variables-programmatica...

 

See the section called "Finding Variables Programmatically"

 

You will need to write the functionality in LabVIEW and build a DLL that you call from your C++ app.

0 Kudos
Message 9 of 11
(4,879 Views)

Hi,

 

I checked out "Finding Variables Programmatically". I would pretty much welcome C++ variant of that article.

 

Anyway, to sum up:

In order to get shared vars info (names and types) available on real time target to native C++ application in Windowz I need:

  - LV runtime environment

  - LV library with query functionality and

  - query functionality in my application to consume LV library.

OR:

  - query functionality done on real time target and results stored under known shared var

 

To access found variables I need:

  - no LV runtime

  - data socket functionality in my app to access found variables in "psp://localhost/[Library]/[VariableName]" manner

 

I'm still concerned with type information. The examples are done with known types as far as I can see.

0 Kudos
Message 10 of 11
(4,875 Views)