EricLarsen Posted May 2, 2013 Report Posted May 2, 2013 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? Quote
Mark Smith Posted May 2, 2013 Report Posted May 2, 2013 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 Quote
Aristos Queue Posted May 5, 2013 Report Posted May 5, 2013 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. Quote
EricLarsen Posted May 6, 2013 Author Report Posted May 6, 2013 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. Quote
Popular Post hooovahh Posted May 6, 2013 Popular Post Report Posted May 6, 2013 I'm up to 2 whole days of programming .NET. Time to add .NET programmer to my resume. I've seen people add LabVIEW to their resume with less experience then that. 1 2 Quote
laltenburg Posted July 14, 2020 Report Posted July 14, 2020 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 Quote
Bryan Posted July 15, 2020 Report Posted July 15, 2020 (edited) 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 July 15, 2020 by Bryan Quote
Phillip Brooks Posted July 15, 2020 Report Posted July 15, 2020 (edited) 12 years experience required for something that has existed for 6. https://twitter.com/bobtoovey/status/1283393442471653376?s=20 Edited July 15, 2020 by Phillip Brooks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.