LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating custom variable I/O container

In reference to: http://zone.ni.com/reference/en-XX/help/371361J-01/lvioscanhelp/blockioaccess/

 

I am attempting to optimize performance when reading/writing I/O variables through the scan engine. Since I have many variables with different data types, I cannot access the variable container directly as in the example above. However, I have variables of identical data types which exist across several variable containers which I would like to access in this method.

 

My question: Is it possible to construct a variable container from muliple variable objects so that I can use the method above for optimization?

0 Kudos
Message 1 of 4
(2,934 Views)

Hi psears,

 

If I understand correctly, you have I/O variables of varying data types that you would like to be able to read/write using the same code.  To do that, you would need to programmatically determine the data type associated with each I/O variable and supply it before the container is accessed.  This is unfortunately not a possibility, because the Scanned Variable Read function requires a data type input, as do all of the shared variable access methods in LabVIEW.  

 

You could, however, programmatically list all I/O variables and "sort" the names of variables with like data types into arrays.  This would require you still needing to know what the data type of each variable is, but if the number and arrangement of variables do not change this may only need to be constructed once.  After you have arrays of like variable names, you could re-use the method you are looking into in an auto-indexed FOR loop to read all like variables.  I agree that this is not the cleanest method that could be conceptualized, but I thought I would offer the idea to see if it could help with your thought process.  

 

Additionally, the NI Distributed System Manager should be able to tell you what the data type for each I/O variable is a fair amount quicker than searching through the hardware in the Project Explorer window of your application.  You may need to ensure that you have the NI System State Publisher installed on your hardware.  

 

Let me know if that helps and whether you have any further questions!

| Zach J. | Systems Engineer, HIL and Test Cells | National Instruments |
0 Kudos
Message 2 of 4
(2,877 Views)

Zach,

 

Your interpretation is along the right lines, but not exactly what I am looking to do. Incidentally, I already use a method similar to what you proposed. The example link I posted above describes a method where you can perform multiple I/O variable reads or writes by passing an array to the scanned variable read/write block. Normally you would pass a single value and a variable object reference, but in this method you supply a variable container reference instead and thus allegedly achieve greater performance than you would by performing an individual read/write for each I/O variable object.

 

It is perfectly acceptable for my application to not programmatically determine the data types of each variable object. However, in order to use the above method I need to group like-data types into separate variable containers. As an example:

 

(3) Slaves (Variable containers) each have the following 3 I/O variables with specified data types:

 

Position (Int16)

Velocity (Int32)

Status (U8)

 

Using these 9 existing I/O variables, I would like to create 3 new variable containers such that:

 

Container1:

Position (Slave 1)

Position (Slave 2)

Position (Slave 3)

 

Container2:

Velocity (Slave 1)
Velocity (Slave 2)

Velocity (Slave 3)

 

Container3:

Status (Slave 1)

Status (Slave 2)

Status (Slave 3)

 

Thanks,

Patrick

0 Kudos
Message 3 of 4
(2,853 Views)

Hi Patrick,

 

This was not something I have ever actually attempted, so I did some checking into the idea you had, then talked with a few of my colleagues to see if they had any ideas.  It appears there is not a method for creating custom containers like you would prefer to have at this time.  It does sound like it could be incredibly useful for an application though, and I would definitely recommend posting this idea over on our LabVIEW Idea Exchange to see if other people might have interest in this.  With every release of LabVIEW, we actively search the Idea Exchange for new ideas our customers would like to see implemented and quite a few become a reality.

 

So, at this point I think the best workaround would be to create arrays of like-data type variable names and go with that style of implementation.  If you come up with a unique solution to the issue you are having, it might be worth re-visiting this topic and posting it so other people that run into this issue can learn from it.  

| Zach J. | Systems Engineer, HIL and Test Cells | National Instruments |
0 Kudos
Message 4 of 4
(2,815 Views)