LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Community Nugget 1/29/2007

Solved!
Go to solution


Can it be made platform independent? When I try to open it on my Mac it asks for LabVIEW.exe.

Can you try the attached version of the package if it works on your mac. I don't have a mac so I cannot test it. I removed the .exe and it seems to work still on my PC.

Tomi


--
Tomi Maila
Message 31 of 66
(4,617 Views)
Tomi,

This one works fine on the Mac. Thanks.

Lynn
Message 32 of 66
(4,613 Views)
Jimi: Thanks for updating the code -- I figured that there were still some loose ends.  Also, it can be made platform independent by changing the library link from "LabVIEW.exe" to just "LabVIEW" (I forgot to do that before posting).

Ben: I learned this trick from Jean-Pierre Drolet and Rolf Kalbermatter in an email thread on the OpenG Toolkit Developers mailing list (see quoted thread, below).


> From: Jim Kring
> Sent: Thursday, December 18, 2003 12:37 AM
> To: opengtoolkit-developers
> Subject: RE: 'Occurrence' OpenGOOP Object
>
> Rolf,
>
> I was able to get AllocOccur, Occur, and DeallocOccur. They seem to work great. I also noticed the following functions exported by LabVIEW.exe (LV70), which look interesting.
>
> AllocOccurHdlr
> OccurAtTime
> OnOccurrence
> OnOccurrenceWithTimeout
> InterruptSafeOccur
>
> I would presume that 'OnOccurrenceWithTimeout' is analagous to the 'Wait on Occurrence' primitive... is this right?
>
> -Jim
>
>
> > -----Original Message-----
> > From: Rolf Kalbermatter
> > Sent: Thursday, December 18, 2003 12:21 AM
> > To: opengtoolkit-developers
> > Subject: RE: 'Occurrence' OpenGOOP Object
> >
> >
> > Jean-Pierre,
> >
> > You are right, but use "LabVIEW" instead. "LabVIEW.exe" will
> > only work on Windows as LabVIEW will just do a LoadLibrary on
> > that name and it does not have an exe extension on all
> > platforms. But the "LabVIEW" keyword is apparently trapped in
> > the CLN function and directly redirected to its own export
> > function table without using the platform specifc LoadLibrary call.
> >
> > You can see that when using "LabVIEW" you don't get any
> > functions listed in the Function name drop box as LabVIEW
> > does aparently not support enumerating directly the export
> > table but you can get all the names if you enter exactly the
> > path the to LabVIEW.exe file, as LabVIEW then just enumerates
> > the export section of the executable image, which is exactly
> > the same for Win32 DLLs as it is for Win32 EXEs.
> >
> > So you first enter the full path to LabVIEW.exe, then select
> > the appropriate function and then change the path to
> > "LabVIEW". Now you just need to know the exact prototypes 😉
> >
> > /* This is the same as the NotARefnum constant in LabVIEW */
> > #define kNonOccurrence 0
> >
> > /* Basically the same as a LVRefNum, an opaque pointer to a
> > LabVIEW private data structure, which you should never try to
> > assume anything about as it may completely change between
> > versions. I think current LabVIEW actually uses here a so
> > called cookie which is a 32 bit number only meaningful to the
> > instance who created it. */ Private(Occurrence);
> >
> > Occurrence AllocOccur(void);
> > MgErr Occur(Occurrence occ);
> > MgErr DeallocOccur(Occurrence o);
> >
> > Rolf Kalbermatter
> >
> > > -----Original Message-----
> > > From: Jean-Pierre Drolet
> > > Sent: Wed, December 17, 2003 2:21 PM
> > > To: opengtoolkit-developers
> > > Subject: Re: 'Occurrence' OpenGOOP Object
> > >
> > >
> > > Jim,
> > >
> > > I think that by using CLNs within labview.exe to functions
> > > like AllocOccur and DeallocOccur you can create (new at
> > each call) and
> > > destroy occurences. However, I don't know how platform
> > > (in)dependant it is. I'm sure Rolf has more to say about this...
> > >
> > > Jean-Pierre
> > >
> > >
> > > ----- Message d'origine -----
> > > De : "Jim Kring"
> > > À : "'OpenGToolkit-Developers'"
> > > Envoyé : 16 décembre, 2003 23:06
> > > Objet : 'Occurrence' OpenGOOP Object
> > >
> > >
> > > Hello All,
> > >
> > > One thing that I have found bothersome about occurrences is
> > that the
> > > 'Generate Occurrence' function is more of an Occurrence "constant"
> > > than a "generator". Each call to an instance of 'Generate
> > > Occurrence' will return
> > > the same occurrence. So, I wrapped the occurrence primitives
> > > in a stripped
> > > down OpenGOOP Class. The data store contains only an
> > > occurrence, and there
> > > is one unique occurrence per object instance (since the
> > data core is a
> > > reentrant LV2 global, called by reference). Another added
> > > benefit of having
> > > OpenGOOP wrapper VIs around the occurrence primitives is that
> > > they have
> > > error IO, which makes data flow sequencing possible without
> > > the classic
> > > one-frame sequence structure.
> > >
> > > So, I have a few questions:
> > >
> > > Does it make sense to augment the default behavior of
> > > occurrences? If so,
> > > what features and behaviors should be implemented? Is this
> > > tool useful?
> > >
> > > Regards,
> > >
> > > -Jim




Message Edited by Jim Kring on 01-31-2007 07:21 AM

Message 33 of 66
(4,606 Views)

@Jim Kring wrote:

Jimi: Thanks for updating the code -- I figured that there were still some loose ends.  Also, it can be made platform independent by changing the library link from "LabVIEW.exe" to just "LabVIEW" (I forgot to do that before posting).

You must be getting old, you are commenting to someone called Jimi... Smiley Very Happy I don't recall anybody with such name having participated this thread. Smiley Wink

Tomi
--
Tomi Maila
0 Kudos
Message 34 of 66
(4,656 Views)

Jim,

Your reply warrents 50 stars!

Is there any wonder why I list JPD and Rolf as a two of my mentors. After reading that message I turned to my wife and said,

"When I grow-up, I want be able to understand everything that Rolf says."

This prompts me to throw out the Q for anyone that thinks they are up to this mini-challenge.

Jim has taken the information from Rolf and used that to develop his code.

Can anyone "connect the dots" between Rolf's words and Jim's code?

Again, thank you Jim!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 35 of 66
(4,568 Views)


@Ben wrote:

Can anyone "connect the dots" between Rolf's words and Jim's code?



> > /* Basically the same as a LVRefNum, an opaque pointer to a
> > LabVIEW private data structure, which you should never try to
> > assume anything about as it may completely change between
> > versions. I think current LabVIEW actually uses here a so
> > called cookie which is a 32 bit number only meaningful to the
> > instance who created it. */ Private(Occurrence);
> >
> > Occurrence AllocOccur(void);
> > MgErr Occur(Occurrence occ);
> > MgErr DeallocOccur(Occurrence o);

Basically, Rolf said that there are C functions which are exported from the LabVIEW executable which you can call to do these things. You can see the list of these function (on Windows) by dropping a CLF node and pointing it to the LabVIEW.exe file, but you must provide the full path. Some of the function names are fairly clear (like AllocOccur), so all you need to know is which parameters they recieve and what they return and that's what Rolf supplied.

The AllocOccur function recieves a void (i.e. nothing) and returns an occurence, which is basically an I32 value. Since you need to use it as an occurence, Jim type cast it into an occurence.

The same goes for the other two functions mentioned here (although I don't know what Occur does. Maybe it returns an error if the occurence passed to it is invalid?).

What I am really wondering about is whether or not these OpenG functions will work in an executable, as they rely on a function found inside the LabVIEW executable. Perhaps the RTE holds these as well somewhere.


___________________
Try to take over the world!
Message 36 of 66
(4,552 Views)


What I am really wondering about is whether or not these OpenG functions will work in an executable, as they rely on a function found inside the LabVIEW executable. Perhaps the RTE holds these as well somewhere.




This is very good point, I didn't think of either. I took a look. lvrt.dll has also these functions. I created an executable application with LabVIEW 8.20 and it still worked ok when I renamed the LabVIEW.exe to LabVIEW.bak. So the application didn't rely on the LabVIEW.exe, at least not the LV 8.20 version of it. It seems that lvrt.dll provides the same C API that LabVIEW.exe, at least under Windows XP and LV 8.20.

Tomi
--
Tomi Maila
Message 37 of 66
(4,538 Views)
I am working on something similar, but did not use occurrences. Is there an advantage to using occurrences rather than "user events" to pass info/triggers between executing instances? User events seem to be a bit more flexible in that you can register and unregister them as well as creating and destroying them. I think that you can create user events in a loop as well and destribute them to sub-vis.

-Scott

LabVIEW ChampionLabVIEW Channel Wires

Message 38 of 66
(4,533 Views)
tst: I'd need to double-check, but I'm pretty sure that that MgErr Occur(Occurrence occ) function is equvalent to the Set Occurrence primitive.  Also, I haven't actually checked, but I'm about 99.9% confident that this will work in a built app.

Message Edited by Jim Kring on 02-01-2007 09:24 AM

Message 39 of 66
(4,521 Views)
Jim, fully agree.
 
Occur also can be called from DLL and its fully equivalent to the SetOccurence. Very useful for providing occurence to LabVIEW from callback functions called within DLL.
 
Andrey.
 
Message 40 of 66
(4,521 Views)