From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine with event structures that share a control

Solved!
Go to solution

@jgvarner57 wrote:

and there should be only one event structure in the VI.

 

This is absolutely untrue. I have thousands of application with many states with their own event structures that work fine. This was the first time I found a way to have multiple event structures share controls within a single state machine.


I'd like to see those thousands of applications. One application at least every 3 days (>2000 / 20 = 100 a year) sounds very productive, or very repetitive.

 

I'm ignoring the fact that the event structure was introduced much later (6 or 7?), and multiple event structures where not officially allowed (nor working) even later (12 or 13?).

 

I do agree that there are situations where maybe more then one event structure can be useful, but I personally don't think I used two event structures in one VI in any of my dozens of applications. 

 

I have been using events coming from one VI, but usually though either dynamically registered events or callback events.

0 Kudos
Message 21 of 48
(981 Views)

I wasn't aware that I was on Twitter hurting people's little feelings. A typical project of mine can have hundreds of sub VIs, almost all of them with event structures, sometimes many. I have been a coding professional for over 20 years while you must be some hobbyist who calls himself a coder because he built a drone with an Arduino or something. I'll tell you what, Sparky, why don't you look at my very simple model and tell me why it couldn't possibly do precisely what it is actually doing. Why would you have a 'state machine' that does not have interactive states? I'll wait ...

0 Kudos
Message 22 of 48
(973 Views)

@jgvarner57 wrote:

I have been a coding professional for over 20 years while you must be some hobbyist who calls himself a coder because he built a drone with an Arduino or something. I'll tell you what, Sparky, 


 

I don't know who Sparky is here, but as somebody who has been programming since 1973 (And LabVIEW since 1995) I will not participate in a pissing contest where you are trying to prove "something" by posturing with unproven credentials. I am sorry that your feelings are getting hurt more but I firmly side with the other experts here that your architecture is highly flawed, inefficient, and does not scale well.

 

One of the great things with LabVIEW is that even poor code tends to run just fine, giving the illusion that it is perfect. I know that it is hard to teach an old dog new tricks, but my advice is to listen carefully to the comments here. Maybe something will stick, sending your programming skills to new heights. 😄 Good luck!

Message 23 of 48
(962 Views)

@jgvarner57 wrote:

I wasn't aware that I was on Twitter hurting people's little feelings. A typical project of mine can have hundreds of sub VIs, almost all of them with event structures, sometimes many. I have been a coding professional for over 20 years while you must be some hobbyist who calls himself a coder because he built a drone with an Arduino or something. I'll tell you what, Sparky, why don't you look at my very simple model and tell me why it couldn't possibly do precisely what it is actually doing. Why would you have a 'state machine' that does not have interactive states? I'll wait ...


Perhaps things have worked for you. Either way, I wouldn't recommend the way you are currently doing things. If you want to start discussing experience and credentials fine, I have been programming professionally for well over 30 years, I'm a CLA, LabVIEW Champion and presenter at NI Week multiple times. In addition, most of my applications contain 100s of classes and 1000s of VIs. Not to mention I was the author of the vending machine CLD exam. I have seen things get squirrelly when multiple event structures are contained within a single VI, hence why it is not recommended. I have not dug into the internals of LabVIEW to determine why that is the case but nonetheless it happens.  What I have observed and it appears it is what you are seeing as well is that the event does not get queued for all the event structures when there are multiple event structures in the same VI. Your pattern more closely represents the State actor pattern. The reason that works more reliably is that the individual states are separate actors and therefore the VIs only contain a single event structure.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 24 of 48
(953 Views)

Along to what Mark stated, study this. I've simplified your VI A LOT. You don't need 3/4 of the things you have there.

 

There are mistakes here as I tried to get a quick-n-dirty example fast.

0 Kudos
Message 25 of 48
(950 Views)

I clearly wasn't responding to you, the thread progression makes this obvious. I tried to keep the conversation civil but I still get a lot of vitriol from people who didn't even have enough intellectual curiosity to understand my original question, the requirements for my application, or even basic fundamental concepts. I reacted to the room, which is apparently the bottom of the barrel as far as "peers", filled with people who confuse vitriol for wit. I'm done here. This is clearly a waste of my time.

0 Kudos
Message 26 of 48
(960 Views)

Then continue to do it the wrong way & don't come to us for help when you're stuck. Your method may work this time, but the way you are doing it for a state machine are clearly and fundamentally wrong.

 

We all tried to help but you are not taking any advice from us.

0 Kudos
Message 27 of 48
(952 Views)

Responding to Mark:

You just reiterated my point exactly. Thank you for your insight. Can you explain why I was getting so much flack for simply pointing out what you so eloquently stated? I only brought up credentials when people just assumed I was a "novice" (direct quote from someone who clearly didn't understand my original quote) and just disregarded everything I was saying. Adults ask for clarification, while I was engaged with a couple people who are perfect examples of "what assuming makes".

0 Kudos
Message 28 of 48
(950 Views)

@jgvarner57 wrote:

I wasn't aware that I was on Twitter hurting people's little feelings. A typical project of mine can have hundreds of sub VIs, almost all of them with event structures, sometimes many. I have been a coding professional for over 20 years while you must be some hobbyist who calls himself a coder because he built a drone with an Arduino or something.


Ok, everybody, we can do without the flame war.

 


@jgvarner57 wrote:
I'll tell you what, Sparky, why don't you look at my very simple model and tell me why it couldn't possibly do precisely what it is actually doing.

You forked the registration (used by more than 1 Event Structure).  I have seen some extremely bizarre things when the registration is forked, including a structure not seeing the event to a structure processing an old event.

 


@jgvarner57 wrote:

Why would you have a 'state machine' that does not have interactive states? I'll wait ...


A UI generally does not need a State Machine.  Hardware interfaces generally do in some shape, form, or fashion.  I generally keep my hardware interfaces running in a form of a Queued Message Handler (some may even call it an Actor), which maintains the state for that interface.  It could signal the UI that something changed and even receive commands from the UI to change its state.  What this does is decouple the hardware from the UI, allowing for easier testing (we can test just the interface without everything else in the system), easier debugging, and more reuse.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 29 of 48
(949 Views)

@jgvarner57 wrote:

Responding to Mark:

You just reiterated my point exactly. Thank you for your insight. Can you explain why I was getting so much flack for simply pointing out what you so eloquently stated? I only brought up credentials when people just assumed I was a "novice" (direct quote from someone who clearly didn't understand my original quote) and just disregarded everything I was saying. Adults ask for clarification, while I was engaged with a couple people who are perfect examples of "what assuming makes".


With respect to the "flack" you are/were getting I would say that it is most likely because you seemed very hesitant to listen to the advice which was being given. You are new hear on the forums and no one knows you are your experience level. Avoiding using multiple event structures in a single VI has been the advice for quite some time. Since you are new here you also don't know the people who were responding to you. Many of the people responding are quite experienced and well respected members of the forum. It does rankle some feathers when people ask for advice and then debate or argue against the advice given. There are quite a few very experienced active members on the forums and it can be a wealth of good information. We all need help at some time.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 30 of 48
(930 Views)