04-20-2020 04:39 AM
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.vi
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
Not in Python
Thank you!
Mike
Solved! Go to Solution.
04-20-2020 06:50 AM
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.
04-20-2020 08:24 PM
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.
Project with new DLL library, which has 2 VIs that just calls the EXT API VI's inside the Parent PPL
Inside of the EXTcreateObjRef.vi of the DLL.lvlib, which just calls the createObjRef of the Parent PPL
Works inside Python with ctypes module!
Thanks a bunch,
Mike
04-20-2020 09:24 PM
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:
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:
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
02-05-2024 03:37 AM
Could you share updated files?
02-05-2024 10:56 PM
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