From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET NXG4 Generic

Dear community

 

As I have read NXG4  is capable of working with .NET I started to migrate my xDocument implementation for fast XML handling in NXG4.

Now it stopped at the following step.

I want to call the .NET method Elements(XName name) which should return the Elements as "system.collection.generic.ienumerable"

The method Elements(XName name) is not existing in the available methods.

 

Is this due to the missing implementation of generics ?? or is there a workaround to solve this problem ?

 

Thank you for your clarification

 

Gernot Hanel
IONICON Analytik Gesellschaft m.b.H.
0 Kudos
Message 1 of 8
(2,969 Views)

Hello nottilie,

 

The issue you are seeing is because we do not support generic parameters on .NET methods. Because the return type is an iEnumerable, we don't create the entry point for that method. In LabVIEW 2019, this method would be supported by returning a reference to the .NET iEnumerable which you could use methods like "Current()" or "MoveNext()" to get individual elements out of the ienumerable.

 

iEnumerable.png

 

However, this is something we are planning on supporting in the near term. Our current plan is that functions that return a closed iEnumerable (like the example you mentioned), would return an array of the elements. This allows LabVIEW users to be able to interact with the data in a more native format.

 

Would this proposed solution solve the current functionality gap that you are describing?

Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 2 of 8
(2,867 Views)

Thank you for your answer.

 

I already have implemented the solution you suggested in LV2019 and it worked perfectly, but I wanted to migrate a few projects to NXG4.

I did not find any good possibility to parse XML strings or files in NXG 4. 

So currently I am a little stucked because of missing XML functionality in NXG4.

 

Best regards

Gernot Hanel
IONICON Analytik Gesellschaft m.b.H.
0 Kudos
Message 3 of 8
(2,853 Views)

@Jon_S. wrote:

Would this proposed solution solve the current functionality gap that you are describing?


What if I just want the first  element from a huge array? Always returning all elements could be a waste of resources.

0 Kudos
Message 4 of 8
(2,842 Views)

wiebe@CARYA wrote:

 

What if I just want the first  element from a huge array? Always returning all elements could be a waste of resources.

You are correct that if you have a large number of iEnumerable and you ONLY wanted the first item, this implementation would use more memory than getting the IEnumerable and accessing the only first element. If you wanted to operate on all of the items, getting the IEnumerable and accessing every element via MoveNext() and GetCurrent() would be slower than iterating through every item via an array and a For Loop.

 

The long term vision of the DNI document is that we can allow users to configure the functions to marshal data differently. We can imagine scenarios where you would want the DNI to marshal directly to arrays or IEnumerable.

Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 5 of 8
(2,820 Views)

@Jon_S. wrote:

wiebe@CARYA wrote:

 

What if I just want the first  element from a huge array? Always returning all elements could be a waste of resources.

You are correct that if you have a large number of iEnumerable and you ONLY wanted the first item, this implementation would use more memory than getting the IEnumerable and accessing the only first element. DNI to marshal directly to arrays or IEnumerable.


Well, in any situation where you want to iterate and stop when an item is found, enumeration could be faster than always returning everything.

 

It doesn't need to be the 1 element. If you want (after iterating) the 100th element out of a 1M array, iterating would still be faster.

 

Getting an array does seem very convenient, BTW. But perhaps it should be an option.

Message 6 of 8
(2,800 Views)
Hi Jon S Is any progress on this "Our current plan is that functions that return a closed iEnumerable (like the example you mentioned), would return an array of the elements. This allows LabVIEW users to be able to interact with the data in a more native format." to support .net Generic class. This became a block issue for us upgrade to LabVIEW NXG. because not support generic class, make us too complexity to worth with lots to C#. net toolkits. Thanks
0 Kudos
Message 7 of 8
(2,650 Views)

Hi Smart_Li,

 

I don't have a specific update on when support for closed IEnumerable will exist in LabVIEW NXG - it is on our roadmap to deliver that in the next year or two, but it will not be in the next couple of versions of LabVIEW NXG. My recommendation is that you stick with LabVIEW until the .NET integration in LabVIEW NXG meets your requirements. We have identified .NET integration as an area we want to make significant improvements in LabVIEW NXG compared to what you can do in LabVIEW 2020 - including better support for generic types, but those improvements are further out.

 

Thanks,

 

Jeff Peacock

Productization Lead for Language in LabVIEW NXG

LabVIEW R&D

0 Kudos
Message 8 of 8
(2,618 Views)