Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/05/2022 in all areas

  1. You could do this. It may be a lot easier handling a contiguous array in your DLL than a LabVIEW array of clusters (but that is possible too). Instead of creating 1000 pointer arrays of 256 (uint64s?) just pass a single 1D pointer of an array of 256,000 elements and pars it out as above.
    1 point
  2. LabVIEW clusters can actually be passed by value, given that the values are structs. For classes, you need to construct the class before you pass it to the method.
    1 point
  3. That's hardly efficient as you actually copy the memory buffer at least twice (but most likely three times), likely once in the .Net function you call, then with memcpy() in your C++/CLI wrapper and then again with your GetValueByPointer.xnode. Basically you created a complicated solution to supposedly make something performant, but made it anything but performant. If your C++/CLI DLL instead provides a function where the caller can pass in the pre-allocated array as an actual array (of bytes, integers, doubles, apples or whatever) and request to have the data copied into it, you are already done. Without pointer voodoo on the LabVIEW diagram and at least one memory copy less.
    1 point
  4. So far it's all guessing. You haven't shown us an example of what you want to do nor the according C# code that would do the same. It depends a lot on how this mysterious array data pointer by reference is actually defined in the .Net method. Is it a full .Net Object, or an IntPtr?
    1 point
  5. It sounds as if you want to pass a .NET Array type by ref to your method. This should be possible by constructing an array in LabVIEW, for example, by using the To .NET Object function, and passing the instance by reference to your method (assuming that your method signature is by ref). If you want to avoid generics, you can also initialize your own array as illustrated below.
    1 point
  6. It's definitely a hack. But if it works it works, it may just be a really nasty surprise for anyone having to maintain that code after you move on. It would figure very high on my list of obscure coding. The solution of Shaun is definitely a lot cleaner, without abusing an IMAQ image to achieve your goal. But!!! Is this pointer passed inside a structure (cluster)? If it is directly passed as a function parameter, there really is no reason to try to outsmart LabVIEW. Simply allocate an array of the correct size and pass it as an Array (correct data type), Pass as: Array Data Pointer and you are done. If you want to keep this array in memory to avoid having LabVIEW allocate and deallocate it repeatedly just keep it in a shift register (or feedback node) and loop it through the Call Library Node. The LabVIEW optimizer will then always attempt to reuse that buffer whenever possible (and if you don't branch that wire anywhere out of the VI or to functions that want to modify it, this is ALWAYS).
    1 point
  7. DSNewPointer can create a pointer to an array. It's in VIlib\Utility\importsl. You can then use the GetValueByPointer XNode to retrieve the array (or Moveblock if you need speed).
    1 point
×
×
  • Create New...

Important Information

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