12-08-2017 04:57 AM
Hi folks,
I have a small problem with the dynamic event registration:
There is a stop button in the front panel and I have created a VI Server Reference.
I want to register dynamically for the event "Value Change" of the Button.
In my humble opinion this should work, but it doesn't - the event is not fired. The VI is running in a sub VI.
Please do not tell me, that I can achieve this by a static event, I am aware of this.
Thanks in advance!
Solved! Go to Solution.
12-08-2017 06:05 AM
Are you pressing the Stop button before this subVI is called? If so, it will not be registered for that event when the button was pressed. You will need to press it again while the subVI is waiting at the Event Structure.
12-08-2017 06:07 AM
How is the value changed?
Do you show the front panel of the sub-vi?
12-08-2017 06:10 AM
mthimm wrote:
In my humble opinion this should work, but it doesn't - the event is not fired. The VI is running in a sub VI.
Are you pressing the stop button on the calling VI and expecting this subVI to respond to that button's value change? That will not happen since you have a static reference to a button on the subVI. You will have to pass in a reference to your GUI's stop button and register for that.
Or are you looking to see if a new value was passed into your subVI? An Event Structure will not work for that at all since it does not respond to programmatic value changes, only the user's interaction.
12-08-2017 08:37 AM
Ah okay, thanks a lot.
It seems that I did not describe my problem sufficently. I am not experienced with LabVIEW. I did not want to say "in a sub VI" but "in a sub panel". Sorry for the misleading information.
The VI is not reentrant but started asynchronously as shared clone (0x80, the error out is only a tribute to external requirements and not collected) by an Actor Framework actor which creates the clone. It is embedded into a subpanel which belongs to the calling actor.
Normally I have planned to retrieve the stop button ref externally and register to an external event loop (belonging to the actor, that created the VI Reference). This did not work and I was wondering why. To investigate this issue I fetched (as depicted) the ref on the VI by the VI server ref (which is also not working). Both strategies work if the VI is not embedded into an subpanel (It seems that have some fundamental missunderstanding, since I do not understand what makes the difference here.)
I am using about twenty different VI types (I started with four very simple VIs), some with stop button and some which will not run at all but show values. The frontpanels are defined in specialized actor classes (which are descendents of the AF actor) . The solution which has been used so far was to register to the stop button directly on the front panel. This works perfectly as well as setting the value (signaling) through the external retrieved reference node.
The stop button is not parametrized by the caller, since the interface type (connector pane) consists (due to requirement) only out of err in, err out and an object that is labelled "Enqueuer". If I did so, the value would be read only once and the event structure would not make sense at all.
Stopping the VI by an button on the GUI is difficult and would increase the complexity. It is simpler to do direct coding in the embedded VIs.
12-08-2017 08:38 AM
Sorry, I wrote sub VI, but meant subpanel. The value is changed by pressing the button on the VI.
12-08-2017 09:02 AM
Can you attach a simple version of what you are trying to do.
It will help a lot on the understanding of your Actor Framework setup.
12-08-2017 09:06 AM
To clarify, the unexpected bahaviour is the following:
When I register a control reference with the register for events node, the behavoiur of event is different if the VI FP is embedded into a sub panel or if it opens its frontpanel itself.
If add the control value change event case directly to the event structure the behavoiur is the same for the VI embedded into a sub panel and for the VI which is running seperately.
This seems weird to me. Im not sure if this behaviour is not a bug.
12-08-2017 09:42 AM
I think this has to do with when the front panel is loaded. When you run a VI off on its own, the front panel is already loaded, so the control reference is valid. No problems. But if you start running the VI and then load it into a subpanel, there is a really good chance that the registration happened before the front panel was loaded.
Are you getting an error? You will need to add an indicator before the Event Structure to check this.
12-08-2017 09:58 AM
I was mentioned my actor framework setup to make clear, that I do not want to pass any reference from one actor to another who can make use of it. My actor framework setup is complicated.
The main advantage for me using the actor framework is that one can work locally and has nothing to know about actors. The complexity of this particular actor is low. It embeds its own FP into an sub panel somewhere else. This is triggered by a message. Everything is straight forward but has nothing to do with the problem.
The attached project illustrates the behaviour which seems weird to me. There is a Main VI, that starts another VI twice asynchronously as shared clones. One of them is embedded into a sub panel and the other one is not.
If you press the stop button on both VIs the one in the subpanel does not stop, but the other one stops. You can see this on the Boolean Indicator labeled "Running"
In my (humble) opinion, the behaviour should not depend where the FP is shown. Therefore it seems to be a bug to me.