Jump to content

Creating .NET ICollection


Recommended Posts

After a 20 year hiatus, I'm back to writing text code again. Not just any text code, but C# .NET assemblies. After about a day and a half of googling and self teaching, I've hit the wall.

 

I've got a .NET assembly that was provided by a manufacturer that controls some hardware. We are calling the higher level .NET functions from Labview and they work. But we aren't getting acceptable performance for the high level calls, so we are trying to drill down into the lower level calls.

 

One of the .NET methods requires an ICollection<T> input, there in this case T is a channel object that is created elsewhere. The ICollection function is described the in the MSDN article: http://msdn.microsoft.com/en-us/library/92t2ye13

 

For reasons I don't really understand, Labview doesn't apparently support a constructor to ICollection. Something about Labivew not supporting calls to .NET generics, but I'd be lying if I said I understood that. But it seems like it should be possible to create a .NET assembly that creates a reference to an ICollection .NET object that can be passed to Labview. But I can't get it to work.

 

I've written a simple program that contains two methods. The first method GetUInt32 simply returns an input integer and was written as a test to see if I could write and assembly and call it from Labview. It works great.

 

The second method, GetICollection, is a test case to create a collection of UInt32 integers. Should be really simple, but it generates a compiler error. I suspect I'm doing something really basic incorrectly, but I'm at a loss to understand what. Can someone point me in the correct direction?

 

 

 

 

post-7727-0-66918400-1367508522_thumb.pn

Link to comment

The problem is that you can't instantiate an abstract or interface class. The ICollection interface requires you to create a class that implements the ICollection interface. See

 

http://msdn.microsoft.com/en-us/library/ms173156(v=vs.90).aspx

 

For more explanation.

 

I don't have Visual Studio handy or I'd write a brief example. Let me know if you need the example and I'll get to it.

 

Mark

 

 

Link to comment

LabVIEW simply does not support working with any generic data type. See "Which .NET Features Are Not Supported In LabVIEW?" here:

http://digital.ni.com/public.nsf/allkb/DC41DCDA972642CF8625787E00732DDD

 

You will need to create a wrapper (in C# code) around some ICollection class of a concrete instantiation, compile that as an assembly, and then instantiate that in LabVIEW.

Link to comment
  • 7 years later...

Hi Eric,

I was wondering if the hardware you refer to is the OM-DAQ-USB-2401 (thermo couple readings, manufacturer: Omega) (?).
While implementing this piece of hardware in Labview, I encounter this exact problem:

"One of the .NET methods requires an ICollection<T> input, there in this case T is a channel object that is created elsewhere."

I am able to perform a single channel read. However, if I want to scan multiple channels I need this Icollection method, but I do not know how to refer/initiate this.

Does anyone have a solution for this?

Thanks,
Luuk


 

Link to comment
On 5/6/2013 at 4:59 PM, hooovahh said:

I've seen people add LabVIEW to their resume with less experience then that.

Well to be fair, some companies have done the same thing to their employees who have never claimed any experience with a particular item/software/etc..  I've worked a couple of places where it has been: "Oh, you double-clicked the icon for "X" application?  You're now the resident EXPERT!". 

Not too long ago, we had a "Kaizen" event where we had moved a piece of equipment in a production cell.  I knew nothing about said piece of equipment but it was Windows-Based, so I figured I would go ahead and reconnect the keyboard, mouse, monitor and power it up just to make sure that it still booted after the move.  A couple of people had seen me do this and now every time there's an issue with it, I'm called to look into it. 

(Sorry to go OT)

Edited by Bryan
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.