Jump to content
EricLarsen

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

Share this post


Link to post
Share on other sites

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

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Ah, I get it now.  Yep, creating an instance of a concrete class did it.  My wrapper code appears to be working.  Thanks!

 

I'm up to 2 whole days of programming .NET.  Time to add .NET programmer to my resume.

Share this post


Link to post
Share on other sites

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


 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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.


  • Similar Content

    • By William Hofmeister
      I need to access Aerotech A3200 data with LabView. The Digital Scope in the A3200 software has the capability to record data at 1kHz for 8 seconds in dedicated batches. We use LabView for all functions surrounding the motion control and have the Aerotech LabView package. Using the LabView vis we can only access data a single data point per call and I don't see how to set up a FIFO to Windows LabView. Someone must have looked at this problem lately. Can anyone steer me in the right direction?  Thanks!!
    • By LogMAN
      So this just happened to me and I'm quite confused by it. As it turns out, the .NET Constructor Node not only provides terminals for error in, error out and the reference, but actually two more "hidden" terminals:

      Notice: I left the error terminals untouched and none of the wires are connected (try it yourself). This never occurred to me. Only now, while hunting a null reference exception I found the constructor node looked "off", like this:

      The strange part is that the terminal doesn't actually carry the reference (which is why I receive the null exception). It only specifies the type. The upper left terminal is a void type input, so the wire is always broken.
      Does anyone know why these extra terminals exist? They don't seem to be part of the specification as far as I can tell.
      Any fancy things we can do with this?
    • By ATE-ENGE
      Edit: I'm asking primarily if there is a reason why/when I should/shouldn't use .net functions in my LabVIEW development. The example below is just to demonstrate a case of my question.
      _________________________________________________________________________________________________________________________________________________________
       
      I recently found a custom library that calculates SHA256 hash algorithms However, in this post I see that the same thing can be done with .net 
       
      My main question is: Is there any reason to build or use a custom library for something where .net functionality already exists? Are there any disadvantages to offloading work to .net ? 
    • By Gribo
      Hello, I am trying to copy multiple cells in LibreOffice, using the UNO API. I encountered an issue in the XCellRangeData object.
      The object's method returns an array of array of any() type. it seems LV can't compile this, even though the wire appears not to be broken. If I try to parse the array of array into a single dimension and then rebuild, the code is broken. See the attached files. Is there a solution for this issue? The alternative would be to copy cells one by one, which is a much slower solution.


    • By P.Carpentier
      Hi Everyone,
      Most of the time I am able to find solutions to my issues just by reading this forum but I wasn't that lucky this time.
      So, i got an issue when i'm trying to install my build.
      I got the following message: "This distribution is built with an older version of winMIF that is not compatible with .NET 4.6.2 upgrade to 17.0"
      When googling this error message or even "winMIF" i can't find anything that match my request
      I tried to uninstall the .NET framework and then reinstall the 4.0 (and 3.5) and I got the same issue. (Exactly the same error even if it's .NET 4.0 or 3.5 ...)

      The computer used to build is a Win7Pro with Labview 16.
      The target computer is a WES7 (but I got the same issue on my dev computer ...)

      In advance thank you, 

      Piet
×
×
  • Create New...

Important Information

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