Invoke Node

From LabVIEW Wiki
Jump to: navigation, search

The Invoke Node is used to perform a method on a VI using VI Server, very similar to the Call By Reference Node. Invoke Node, however, does not need a strictly typed reference and as such is not bound to the VI's connector pane and is free to call any VI. On the other hand, as the connector pane of the callee is unknown at editing time, one must use several calls to Invoke Node in order to set control values, run the VI and retrieve its results.

When using the Invoke Node it is very common to stumble upon an error:

VI is not in appropriate state for the invoke node

This is a known behaviour, but I wouldn't call it an error. It's just how LabVIEW works. A lot of the methods for a VI reference can not be executed for VIs which are either in a reserved state or already running. When a VI is running is rather obvious but a reserved state means that the VI is either part of a running hierarchy of VIs (usually your application) or a strict typedefed VI reference is open to it. The reasons for this are not so simple but it comes down to protecting the VI from influences from different caller types. The Run method of the Invoke Node (amongst others) is asynchronous as it starts the VI but not necessarily waits for termination of the VI. An implicit reference to the VI as an icon in your block diagram or an explicit one in the form of a strict typedef to be used with the Call by Reference Node are synchronous as far as the caller is concerned.

If you are unable to resolve that error message, you may eventually try to use the Call by Reference Node instead. If you need for whatever reasons to use the Run method you MUST make sure that the VI is not an explicit part of your application by not adding its icon anywhere in your app (and not opening a strict typedefed reference to it either).