LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview and fortran DLL communication

I work with a group of people that create code in different languages
and one
of my jobs is to tie the results together.

Because of this I am trying to use Labview as a front end to some code
that
was written in Compaq Visual fortran. The fortran code is compiled
into a DLL
and I am using a Call Library function node to execute this code.

I need to be able to abort the fortran DLL from a Labview vi. I have
done
something similar with a Delphi (visual pascal) and fortran DLLs where
Delphi created a thread and would use a shared memory location to
communicate to
the DLL that was running (DLL would monitor the shared memory
occasionally).

I have looked at the ni.com site and several other labview support
forums
on the web and have
seen references to a similar approach but have not
been
able to find any examples. When I have called the DLL from Labview
execution of
the VI that calls the DLL is suspended until the DLL returns.

Does anyone have examples of code that would do this or suggestions on
how to accomplish this

Thanks
Pete
0 Kudos
Message 1 of 2
(2,850 Views)
Peter wrote:

> I have looked at the ni.com site and several other labview support
> forums on the web and have seen references to a similar approach but
> have not been able to find any examples. When I have called the DLL
> from Labview execution of the VI that calls the DLL is suspended until
> the DLL returns.
>
> Does anyone have examples of code that would do this or suggestions on
> how to accomplish this

I really depends on your DLL. If you know that the DLL is basically
thread safe you can set the Call Library Node to use reentrant (the
CLN color will then change from orange to light yellow)

LabVIEW itself is inherently multithreading so you can at a different
position in your program call another DLL function which sets a global
value in the DL
L to tell it to terminate whatever it is doing at that
moment.

If your CLN is set to be non-reentrant it will be executed in the UI
thread and LabVIEW will never execute anything else in the UI thread as
long as the DLL function hasn't returned.

In LabVIEW 7.0 you won't even have to take special precautions once you
have made the DLL calls reentrant as LabVIEW acquires by default several
threads per execution system.

In LabVIEW before version 7.0 it only acquired one thread per execution
system which means that the execution system calling a DLL function will
be suspended anyhow, but you can assign the VI which is supposed to
abort the DLL by calling another DLL function call from another place in
your application which is set to execute in a different execution system
than your main (number crunching) DLL call.

You assign executions systems to VIs in the VI Properties under the
Execution settings.

Rolf K
Message 2 of 2
(2,850 Views)