I am currently building a framework with a simple producer/consumer structure for future applications. The producer loop has an event structure and only reacts to user events.
Now my question:
If an error occurres in the consumer loop, the consumer exits normaly but the producer keeps running.
How do I give the producer the signal to exit when a consumer error occurres?
I forgot to mention, that I already tried to create an error event, by creating a property node that writes the error state to the property "Value Signaling", the problem with this is, that this always occurres in an event.
If the LED is false and the value signaling writes false to the LED the event structure also reacts.
Is there a way to avoid this? (I know I can place a simple case structure but I am searching for a more sleek way)
We typically don't debug images, so please attach your VI (and needed subVIs) Thanks!
A glaring problem is your use of the signaling property, which will fire the event irrespective of the boolean value, meaning that the top loop will end right there, error or not. What is in the other cases/events?
There's multiple ways of achieving what you're trying to do.
I would recommend dedicating a state for error handling in your consumer. If there's an error, have your first VI that dequeues messages or data, handle that error by placing the state machine in an error state.
Sort of like a guard clause for the process.
To actually send an "error" event to stop the loop with the event structure, I would use user events. Just create a stop event and wire that event refnum in the event structure. This would be your software defined stop.
(Don't forget to destroy/release resources)
If you attempt to use the signaling property you would need to handle the special cases like altenbach said. So not "sleek" if that's what you're looking for.
Of course, signaling with a case might be faster. But I wouldn't put that in something I mean for to be a framework. Or if your consumer is super time sensitive or something.