03-13-2008 09:10 AM
03-17-2008 10:33 AM
03-17-2008 11:22 AM
03-17-2008 12:42 PM
I know that some object-oriented features have been added to newer versions of LabVIEW, but I'm not sure that there is an elegant way in LabVIEW to do what I think you are trying to do. It sounds like you want to create a DLL that exports some functions that all operate on some shared data (your globals). In most modern programming languages, you would create an object class with some shared data members and call the methods on the same instance of the object to share the "global" data. To simulate this in LabVIEW, perhaps you could write an abstraction layer (a VI) to unify all of your DLL calls. That way there is always one VI running that keeps all your globals active and provides a way to retrieve and update them as necessary. I'm not sure how you'd go about doing this in LabVIEW and I'm not sure that LabVIEW is really designed for this kind of coding.
Alteratively, maybe you could write an interface for your globals that doesn't stay open the whole time, but instead abstracts away serializing and deserializing the data to a file? You'd have to be careful about race conditions either way.
If anyone else out there knows a good solution to this please chime in. I am curious as well.
Anyway, another thing to consider is whether you really need a DLL - I've seen a lot of people lately trying to make everything into DLLs without a good reason why. What benefit are you trying to get by making it a DLL?
Rob
03-18-2008 03:23 AM
03-18-2008 07:47 AM
I wasn't saying you should use classes. I was just pointing out how software engineers would typically solve this kind of problem given a decent set of development tools. If you do not have the skill, or the tools do not support an elegant solution, I am saying that you should expect the solution to be nothing better than a work-around.
Regarding the "skipping project good lookings", the fact that you have some VIs bundled into LabVIEW libraries, etc, has *nothing* to do with the global variables losing their values between DLL calls. If that is not your concern then you need to be more clear. If you put all of your VIs into one directory and build a new DLL, it will suffer from the same weakness as your current solution.
If you want a relatively easy solution to the problem of your globals losing their values between DLL calls, you will need to consolidate all the code into one function call. Otherwise, the caller will need to keep the LabVIEW runtime alive between calls. I doubt that is a particularly big deal, but it probably would involve a little digging into the LabVIEW application API. Good luck,
Rob
03-18-2008 08:46 AM
It is true it seems that is not depending on Project Explorer.
I expected those variables defined in this Project Explorer to be independent than a function call, because they are special VIs. From a dll perspective I could see that a data memory area that can be changed using interface functions and this area to be lost only together with the ending life of the loaded dll.
I can change it without using the variables, this is the way how I was working till now. But seems that I trusted too much in these variables for this architecture and they are not working as I expected to be linked to the project not to a certain VI.
Thank you for your help and I will update something here if I could see some good work arounds.
Teodor
03-19-2008 02:48 AM
03-19-2008 08:07 AM
03-19-2008 08:48 AM
The test procedure it is simple. Not using any other language only LabVIEW to create and test that DLL. So no other languages involved.
Create some VIs in LabVIEW and test the created DLL using 'Call library node' the same VI. The idea is if it is not working in LabVIEW it will not work also for other purposes.
So I took a small part of the project and tried to save by using a file function a debug information on the disk. What I saw?
The info will be written on the disk only in some cases. So looks that the function will not call everytime this file function inside the DLL only if you do it once in LabVIEW with the same function. So LabVIEW and DLL share the same area, but DLL cannot handle its own area only helped by LabVIEW.
If you want I can send a small part of the project and you will see how it is working. The idea in not to change the architecture. I know I cand do it in four or five ways, the idea is to fix a problem on my project if it is a project related one or to fix the language if the language has a problem.