LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can the new Statechart Module be used to build a DLL that can be called externally?

Having used my 3 hour demo session for the new statechart module I realized something I should have tested. The current information about the statechart module is that after developing your statemachine you should repeatedly call the subVI it creates (in a loop for instance) so it will continously update its internal state.

Now provided I have several outputs I wish to examine would it be possible to compile such a VI into a DLL that I could call from C?
0 Kudos
Message 1 of 4
(2,636 Views)
This works like other LabVIEW vis, you can drop the statechart node under a wrapper VI and use the build specification to build DLL from the wrapper VI.
 
I tried this with a simple Statechart that increment 2 counters and build DLL from it. Then I used a labview VI to call back into DLL and it run as expected. I have not tried calling this from c code, but it should work like other DLL build from LabVIEW VI.
 
I attached the output zip of my DLL build, the caller VI, image of the statechart and the wrapper VI  in case anyone wants to try it.
 
Download All
0 Kudos
Message 2 of 4
(2,610 Views)
First, I very much appreciate your help Ortoro. It is very nice of you to make an example for me (saves me money and time).

I tested your VI and it worked correctly. I saw your DLL call and it also appeared as expected.

Then I made a visual studio 2005 project which has a for loop trying to call your DLL repeatedly and varying the input parameter from true to false each iteration. Unfortunately, in my test program the values of A and B remain constant though they are passed by reference to DLLWrapper() which makes me think that DLL wrapper will also change their values.

I've attached a zip of my visual studio project. If you have a moment could you look at my project? I had to add a special path to my include directories list and linker ("C:\Program Files\National Instruments\LabVIEW 8.5\cintools")

Again thank you very much.
0 Kudos
Message 3 of 4
(2,590 Views)
Ok I tried your solution file, it does not work at first but then I got it to work. The issue with the output being 0s all the time is because the vi fail to load under the DLL.
 
If you look at the zip file that contain the dll there is a data directory that contain UseUnderDLL.lvsc. This data directory is needed by the DLL to load the Statechart component.
So when you run you VC project in debugger checkout where it is loading the CallSCAsDLL.dll file Copy the data directory to the same directory where the dll is being loaded, then the function should work.
 
i.e in the zip file you give me I copy the StateChartDLL\StateChartDLL\data directory into StateChartDLL\StateChartDLL\ExternalStateChartCall\ExternalStateChartCall directory.
 
 
 
 
 
 
0 Kudos
Message 4 of 4
(2,578 Views)