09-05-2016 04:21 AM
Is there a programmatic way to extract the Number of the Event Structure case shown in [] to the left of the name? This can be useful when debugging which case has has fired Actions for a Queued State Machine.
Carsten Thomsen
Solved! Go to Solution.
09-05-2016 04:49 AM
Hi Carsten,
in a queued state machine you know which state is requested by the queue. And you should know where that command is getting from or: in which event case that command was issued).
When there are several event cases firing the same queue command you could add a comment (or similar) to your command…
09-05-2016 06:23 AM
Thank you for the quick comment.
I already feed a comment to the Queue from each event, but since I have over 100 events, it is faster to find the actual case by prepending the comment with the case number. The reason I want to to it programmatically, is that I then have the freedom to rearrange, and add events as I please.
09-05-2016 06:35 AM
Hi Carsten,
The reason I want to to it programmatically
You may look into VI scripting: here you can determine the event case number and create/edit a string constant using this number…
(I don't use VI scripting so far, so I only give an (educated) guess about its capabilities.)
09-05-2016 08:53 AM
@CarstenPXI wrote:Thank you for the quick comment.
I already feed a comment to the Queue from each event, but since I have over 100 events, it is faster to find the actual case by prepending the comment with the case number. The reason I want to to it programmatically, is that I then have the freedom to rearrange, and add events as I please.
I'm curious what you mean by "freedom to rearrange, and add events as I please". Do you mean that you'd like a list of the order in which the cases are being executed so you can note where they went wrong, or where they could be more efficient, so you can rearrange them?
Sorry, this isn't an inquiry to help you out, but I am always in learning mode, so if I can understand the problem I can also understand the solution. Then I file it away for future use. There are countless times this strategy has helped me overcome difficulties of my own. I hope you don't consider this a hijacking of your topic.
09-05-2016 09:24 AM
As a program evolves, the order that the events sit in the event structure can get messy, not that it affects performance, but it is always nice togroup them in logical families, such as Input, analysis, display, etc.
09-05-2016 09:27 AM
I try to stay away from scripting and use mainstream functions if they exist, but I have tried it a number of years ago. But may I'll have a look.
Also on another point it would be nice if you could put labels in event struictures, write now i use dummy events to label my groups of events.
09-05-2016 09:58 AM
@CarstenPXI wrote:As a program evolves, the order that the events sit in the event structure can get messy, not that it affects performance, but it is always nice togroup them in logical families, such as Input, analysis, display, etc.
Good, this is exactly what I thought you meant. I always try to arrange my events with human beings in mind, also. For instance, I try to arrange then in the same order they are normally executed - or at least something close. That way, a human being can easily see how the different cases relate to each other. You click the arrows and it flows much like how it would when it is executing.
It's nice to see fellow developers programming with humans in mind, too. You can take your mind off of trying to envision what the previous developer meant and just concentrate on what you need to do. And many times that "previous" developer is you!!!
09-05-2016 02:19 PM - edited 09-05-2016 02:28 PM
Here is the scripting to get the Event Case Names. They would be in the array in the order they are in the structure.
Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner
09-06-2016 04:34 AM
Thanks so much. Dragged it to the diagram, and it worked like a charm. And since I have two event cases, I could just index the array to get the one I wanted.
The LabVIEW Community and folks like you are of great value!!!
Carsten