NI Home > Community > NI Discussion Forums

LabVIEW

Reply
Active Participant
Tomi_Maila
Posts: 419

Re: Community Nugget 1/29/2007



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
Proven Zealot
johnsold
Posts: 9,799

Re: Community Nugget 1/29/2007

Tomi,

This one works fine on the Mac. Thanks.

Lynn
Active Participant
Jim_Kring
Posts: 1,744

Re: Community Nugget 1/29/2007

[ Edited ]
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

Thinking in G
Active Participant
Tomi_Maila
Posts: 419
0 Kudos

Re: Community Nugget 1/29/2007


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... :smileyvery-happy: I don't recall anybody with such name having participated this thread. :smileywink:

Tomi
--
Tomi Maila
Knight of NI
Knight of NI
Ben
Posts: 16,133
0 Kudos

Re: Community Nugget 1/29/2007

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

Ben Rayner
Who is NOT John Galt... yet... just building Rayner's Ridge
Scheduled to close on the new ridge next week!
Knight of NI
Knight of NI
tst
Posts: 10,799

Re: Community Nugget 1/29/2007



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!
Active Participant
Tomi_Maila
Posts: 419

Re: Community Nugget 1/29/2007



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
Active Participant sth
Active Participant
sth
Posts: 929

Re: Community Nugget 1/29/2007

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


Active Participant
Jim_Kring
Posts: 1,744

Re: Community Nugget 1/29/2007

[ Edited ]
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

Thinking in G
Active Participant
Andrey_Dmitriev
Posts: 1,535

Re: Community Nugget 1/29/2007

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.