LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LVOOP Factory Pattern with PPL in a Labview DLL

Solved!
Go to solution

Hi All,

 

I am experimenting with trying out a LVOOP Factory Pattern with PPL plugins and trying to build the top parent into a DLL. Getting advice from this forum, I am using DVRs as a wrapper to hide my LVClass terminals since DLL compiler won't deal with LVClass terminals and I cast the DVR references into U32 Int to avoid having to deal with LVREFNUM datatype in the DLL. I wrote a test Parent, Child LVOOP project where the sole function is to popup a dialog box indicating which Child was called.

 

I tried the PPLs and factory out in a tester vi in Labview and it works.

 

However, I am hitting a wall with the factory as "get lv class default value.vi" is returning an error 1498 when calling from Python (I am assuming the return code from the DLL is a LV error code). For the DLL, only the parent project and it's factory function were built into a DLL, the Children are left as PPLs. 

 

Is what I am trying to do even something that is possible with a Labview DLL?

 

Attached is the LV and Python code and also some screen shots. LV Code is in 2018, if it needs to be saved in an earlier version, please let me know.

 

Factory_Snippet.png

Factory.vi

 

createObjRef_Snippet.png

Look for lvclass path inside PPL, then pass to factory, then wrap in DVR and cast DVR Reference into U32 (broken wire is only in snippet, not in actual code)

 

Works in the tester!Works in the tester!

Works in the tester

 

Python_LV_DLL_Call.png

Not in Python

 

Thank you!

Mike

 

Download All
0 Kudos
Message 1 of 6
(3,214 Views)
Solution
Accepted by topic author Mikejj

Your parent needs to be in a PPL and then all of your child classes need to inherit from the PPL version of the parent.  Your DLL should then also reference the PPL version of the parent.

 

The reason for this is all about context and namespaces.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 6
(3,181 Views)

Thanks crossrulz...after sitting on your info for a bit I figured out what was wrong. I was approaching this the wrong way...I was thinking that the whole Parent PPL could be replaced by the DLL, and it would just be the DLL interacting with the Children.

 

I created a separate library that just calls the EXT APIs (basically the DVR wrappers plus factory.vi) inside the parent PPL and made this new library into the DLL and it worked...kind of a wrapper of a wrapper. The built DLL includes a "data" folder with the Parent PPL inside it.

 

tree.png

Project with new DLL library, which has 2 VIs that just calls the EXT API VI's inside the Parent PPL

 

WrapperOfWrapper.png

Inside of the EXTcreateObjRef.vi of the DLL.lvlib, which just calls the createObjRef of the Parent PPL

 

WorksInPython.png

Works inside Python with ctypes module!

 

Thanks a bunch,

Mike

Message 3 of 6
(3,139 Views)

One update to this.

 

I found out I can skip the extra layer of wrapper by disabling the DVR restriction in the Parent.lvclass properties:

 

DVR_Settings.png

Uncheck "Restrict references of this class type to member VIs of this class"

 

Now I can use create DVR wrappers in the DLL project instead of making them in the Parent PPL:

EXT_API_Moved.png

Compare it to my previous post, EXT API and it's VIs have now been moved from the Parent library to the DLL library.

 

Regards,

Mike

 

 

Message 4 of 6
(3,134 Views)

Could you share updated files?

0 Kudos
Message 5 of 6
(443 Views)

Hi piZviZ,

 

You are in luck, I somehow managed not to delete this little proof of concept. I believe this should be the file that matches the last post I made.

 

Regards,

Mike

0 Kudos
Message 6 of 6
(394 Views)