Jump to content

BryCoBat

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by BryCoBat

  1. Alas, no. I'll post a more detailed outline for this year here once I get a draft together.
  2. needs to finish his NIWeek 09 slides...

  3. Greetings! I'm from Tennessee, USA, live in Alabama, work in Tennessee. Hour and a half commute, but little to no traffic if I get up early. Been using and abusing LabVIEW since version 6 or so. <shameless plug> I'll be at NIWeek 09, if you're interested in mixing LabVIEW and .Net, I'm presenting on just that topic Tuesday morning. (TS-1387) </shameless plug>
  4. Looks like I'll be giving a redux of my presentation on mixing .Net and LabVIEW this year. I'm planning on three sections so far: 1) Simple Demo 2) Tools & Utilities 3) Hosting the DLR Are there any specific examples you'd like to see or questions you'd like answered, either during the presentation or as demos in the hallway? Thanks! Bryan
  5. Without knowing the exact values, my best guess is that the problem is with the "ref" part of the function definition. Pull that out so you're passing the string by value instead of by reference. (The definition will be "public void TestFunction_LoadImageFile(string filepath)".) Passing by reference means you're handing .NET a reference to a string, instead of just handing it the actual string. The glue that allows LabVIEW to call .NET code doesn't create .NET instances for LV values, it just creates the value. (At least, to my knowledge...)
  6. It depends on how you're doing calls between LV and .Net. Check out Brian Tyler's blog (http://detritus.blogs.com/lycangeek/) for info on working with .Net and LabVIEW. Basically, .Net and LabVIEW can communicate via the ActiveX server, or via .Net calls in the block diagram. Clusters in LabVIEW get converted to Object[] in .Net. You have to know what the cluster looks like in order to get the data out, but it can be done. (In your case you have 5 strings, so that's not too bad, and it might be easier to drop a convert cluster to array down and just pass the String[] to .Net...) Also check out the vi.lib/dotnet.llb's To Object and To Variant vi's for passing complicated things like clusters into .Net. Hope this helps! bryancbates@gmail.com Edit: forgot about dotnet.llb in vi.lib
  7. Is there some sort of setup that I need to do before I can call vi.Run()? I can use Call and Call2, but my vi really needs to just run in the background, and let me pick up values occasionally with GetControlValue(). Right now I do the following (not all in one place, it's a C# 2.0 WinForm app): // In classLabVIEW.Application lv;LabVIEW.VirtualInstrument vi;// In constructorlv = new LabVIEW.ApplicationClass();string vipath = @"PATH TO MY VI";vi = lv.GetVIReference(vipath, "", true, 0);vi.ShowFPOnLoad = true;// On a button click eventvi.Run(true); // Get an Exception here, error 6500. Call and Call2 work, but Run does not. This is all from the CallLV example code.
  8. Any idea if horizontal scrolling support was added? (i.e. tilt wheel, and *not* "go find the scroll bar, hover over it, and use the regular scroll wheel) I don't have it in my notes from the "Core LabVIEW Strategies" session, but I may have missed it being rattled off.
  9. There's a bug in the DAQmx stuff, you can't do simultaneous AO and AI ops, or it will (eventually) crash. You'll have to ensure that you don't attempt simultaneous ops on your own, through a semaphore or something.
  10. Found a solution to the root problem, we're just gonna use the Datalogging & Supervisory Control to act as the server for our data. It does what we want it to do, and without all this ActiveX fuss.
  11. Made a little progress. I'm getting an E_INVALIDARG from SafeArrayGetElement, whether my last argument is a _bstr_t, BSTR, char* or VARIANT. The question is: what is the proper last argument? SafeArrayGetElement just says it's void* pvData, which...is just about useless (hooray for systems hungarian notation), and I guess the actual definition of the function is in a .dll somewhere, 'cause it's sure not in any .cpp files on my hard drive.
  12. Using LabVIEW 7.1 and VC++ 6.0. I'm having trouble reading data out of an array indicator via ActiveX. I've tried just running the VI, and building it to an .exe, and I'm using a little C++ app (modified from the example code in Calling_LabVIEW_from_C++_Using_ActiveX for now, the real project is something a bit bigger than that) to read the value. I can read scalars just fine using the following code (with appropriate changes). However, the array comes back with the proper type for an array of strings (VT_ARRAY | VT_BSTR), and I get the right dimensions back from SafeArrayGetLBound and SafeArrayGetUBound, but all the elements just point to 0xCCCCCCCC. Is there some extra encoding going on between the LabVIEW array and the ActiveX SafeArray? The app code (tabs have been eaten by the forum monster): #include "stdafx.h"#include "windows.h"#include "stdio.h"#include "conio.h"#include &lt;stdlib.h&gt;#include &lt;string.h&gt;#include &lt;iostream.h&gt;#include &lt;comutil.h&gt;#import "LabVIEW.tlb"#define VIPATH "C:\\LabVIEW\\MyApp\\DIAG\\AI Diagnostics.vi"using namespace MyApp;int main(int argc, char* argv[]){VARIANT sample;int size = 0;char Path[1000],Password[60] = "";// generate a namespace declaration to and identify and assign a name to a declarative region.// In this case we are assigning the LabVIEW._ApplicationPtr pLV;VirtualInstrumentPtr pVI;cout &lt;&lt; "Pre-CoInitialize" &lt;&lt; endl;CoInitialize(NULL);do{VariantInit(&amp;sample);cout &lt;&lt; "Initialized, creating MyApp.Application instance" &lt;&lt; endl;pLV.CreateInstance("MyApp.Application");if (pLV == NULL){printf("LV must be running, exiting ...\n");break;}cout &lt;&lt; "Obtained App instance, creating VI instance" &lt;&lt; endl;pVI.CreateInstance("MyApp.VirtualInstrument");cout &lt;&lt; "Got VI instance" &lt;&lt; endl;strcpy(Path, VIPATH);// assign an object reference to the pVI.VARIANT_BOOL resvForCall = TRUE;long options = 0x0;cout &lt;&lt; "Getting Ref to Desired VI" &lt;&lt; endl;pVI = pLV-&gt;GetVIReference(LPCTSTR(Path), LPCTSTR(Password), resvForCall, options);// configure the VI to show its front panel on Call.pVI-&gt;ShowFPOnCall = TRUE;sample.vt = VT_ARRAY;// Multiple reads to ensure that we don't get the default 0...sample = pVI-&gt;GetControlValue("Count Data");sample = pVI-&gt;GetControlValue("Count Data");// Check dimensions (comes back as 1)long cdim;cdim = SafeArrayGetDim(sample.parray);cout &lt;&lt; "cdim = " &lt;&lt; cdim &lt;&lt; endl;// Check variant type, should be VT_ARRAY | VT_BSTRcout &lt;&lt; "VT: " &lt;&lt; sample.vt &lt;&lt; endl;cout &lt;&lt; "VT_ARRAY | VT_BSTR: " &lt;&lt; (VT_ARRAY | VT_BSTR) &lt;&lt; endl;// Check bounds before iterating over array to print valuesHRESULT he;bool goahead = true;long lbound;long ubound;he = SafeArrayGetLBound(sample.parray, 1, &amp;lbound);if (FAILED(he)) {cout &lt;&lt; "Failed getting lower bound." &lt;&lt; endl;cout &lt;&lt; "Bad Index? " &lt;&lt; (DISP_E_BADINDEX == he) &lt;&lt; endl;goahead = false;}he = SafeArrayGetUBound(sample.parray, 1, &amp;ubound);if (FAILED(he)) {cout &lt;&lt; "Failed getting upper bound." &lt;&lt; endl;cout &lt;&lt; "Bad Index? " &lt;&lt; (DISP_E_BADINDEX == he) &lt;&lt; endl;goahead = false;}cout &lt;&lt; "Lower Bound: " &lt;&lt; lbound &lt;&lt; endl;cout &lt;&lt; "Upper Bound: " &lt;&lt; ubound &lt;&lt; endl;// Print each elementif (goahead) {for (long i = lbound; i &lt; ubound; i++) {VARIANT val;VariantInit(&amp;val);val.vt = VT_BSTR;SafeArrayGetElement(sample.parray, &amp;i, &amp;val);cout &lt;&lt; "Element VT: " &lt;&lt; val.vt &lt;&lt; endl;wprintf(L"(%d) The sample Value is %s\n", i, val.bstrVal);VariantClear(&amp;val);}}// Wait to quitwhile( !kbhit() ) {cout &lt;&lt; "Hit any key to continue\r";fflush( stdin );}pLV-&gt;AutomaticClose=0;VariantClear(&amp;sample);} while (0);CoUninitialize();return (0);}
×
×
  • Create New...

Important Information

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