Event structure/state machine

Here's the scenario.

I use the buttons controlled by the user in an event structure to control a state machine. Currently, I have a different State for each button. However, 4 or 5 of these buttons could ideally correspond to the State, which is what I would like to get... Each of these 4 or 5 buttons causes flow data and the results are stored in a table, but listened data are different for each button! Therefore, if each of those 4 or 5 buttons caused the same condition occur how I could decipher what button was pushed? Ideally, I would have 4 or 5 different paintings once all the buttons are out of the same State.

Is there anyway that I can achieve this?

Hi the shots.

you have access to the refnum of the element inside the event. With the Ref, you can simply get the name or any other property of the control to distinguish them.

Mike

Tags: NI Software

Similar Questions

  • event and state machine

    Hello

    I have a problem when I want to set up an event in my state machine.

    The state machine is reading communication series through different States 10 +.

    The problem came when I tried to add an event inside the State number 10. In the number of State 9 code seems to work only partially (an option button is not possible to change the value on).

    It seems almost that it is frozen but when I select the code I can see it works well (option button isn't).

    It is strange that when I remove the event in condition 10 all is well again? The event code is not yet performed yet because it is in the frame after!

    Any thoughts?

    I'm under LabView 2013 on a Windows 7 PC.

    I'm trying to figure out which of the two cases is the one who seems to hang if the name would be better than a number.

    When using am event structure you don't we want to use a local variable.  In fact, you should only use local variables on rare occasions that they break the flow of data.  The event structure is fine for the entry.  The problem is the way you treat things after that the button is pressed.  Again, I think you have to look at a design model of producer/consumer with a machine of the State in queue.

    The best way to have a writing occur only after a button must have the code for writing in a case that is active when the button is true and is simply empty, when it has the value false.

  • creation of structures: state machine with controls

    Hello, I wonder if someone can help me with something. I have a sequence, followed by the event structure / while loop.

    someone can help me. I want to create a STATE MACHINE.

    Here's a basic outline of the current structure, I. and this is what I want it to be. I wonder if its possible and how.

    I'm using labview 7.0.

    Thank you

    This is what I want?

    I looked at your Executive VI.  I don't have an easy way to save in LV 7 now so I'll try to describe in words how I would approach this mess.

    I think it can be done with two loops, a structure of the event, a case structure and not global or local variables.  In fact, there is probably some small business structures and lines inside some of the case, but nothing like as layers of ~ 12 nesting, you're struggling now.

    Look at the design model of producer/consumer (events) as a starting point.

    The loop of producer (event loop) will have the structure of the event.  It will be a case for each control that requires immediate action.  Those that I could identify: get telemetry, side, open Journal printing, abandon, press tank Mode (?) Temp tank (?), Scan, Stop, wait, Step (?) unique, continue and Execute. Most of the buttons must be set on the mechanical action of locking and placed terminals in the case of the event appropriate. So no local population is necessary to reset them.  Those with (?) have no event.  You can have a case of timeout to display Date and time, eliminating which (painful to my eyes) loop.  I don't know about the other stuff in the case of a timeout, but most likely, it is up to the other loop.  If the room 1, 2,... buttons change during trips, they may also need event.  Inside of each event is exactly one element: the Enqueue function.  Create an enum command and make it a typedef. Enqueue this enum value. The queue will be read in the loop of consumer where all the action happens.

    The consumer is your state machine. It has a Dequeue function to get a new order for the structure of the event.  It has several shift registers to transfer data from one case to the other.  These removes your global and local variables.  I'd shift for each of the following registers: the State (typedef enum), cluster of error, temperature (table), pressure (table), results (table), Stat results (table grapes) and a big cluster Indicators_Flags (typedef).  The cluster Indicators_Flags everything that is in the cluster you initialize in the black image sequence (and then never reuse) would have more all indicators except the berries in Maj separate records as well as all your globals and no status indicator, you might need.

    The structure of matter is the heart of the state machine.  All shift registers through it.  It will be the case for what the program does.  Everything in this black initialization setting in about 15 cases of Init.  The while loop to the right of the boot image goes away, but the case inside to become some of the cases of the state machine.  Chassis temperature cycling code goes into 1-3 cases. Mode code pump and read the pressure of your case of timeout event are 1-3 cases.  Code of telemetry: 2 cases.  Print the Page before: 1 case.  Excel code.  Abandonment of code.  Temperature and pressure cycling code of main program: 5-20 cases.  Graphics, record in file: more cases.  Break: 1-2 cases.

    I would like to make a list on paper anyway, you think that you may need and allows to create a typedef enum to control cases.  By making a typedef, it is easy to change without running all over the code looking for the constant in all cases of change.  Enum names will appear on the structure of matter as strings.  Create the loop, shift registers and the structure of the case.  Moving is part of both the original thread can duplicate the case until you have a case for each value in the enumeration of the State.  (Do not use the case of the mark for each value option because it will empty cases that you will then need to wire through.)

    Then copy code from various places in your existing code in the case in the new VI.  Try to avoid copying inhabitants that it will create new controls.  Name bundle to get data in and out of the big bend cluster registry and use ungroup by name.  This provides a free documentation of the data used.

    Check in a month when you have other problems. This will not be a quick fix.  But it will be useful to have a program that works and is easy to manage.

    Lynn

  • Closure of a state machine in queue event with several parallel loops

    I am trying to find the best way to stop a program that consists of an architecture of State machine in line waiting for event with several parallel loops. Can anyone recommend the best way to achieve this in my attached VI? (To browse the forum, this seems to be a frequently asked question, but I have not found a solution that works for me.)

    I look forward to any comments on my as well code, if someone is willing to offer it.

    My program needs:

    If the user press the 'Stop' button, the program should prompt the user with "are you sure you want to stop the program?" and then return to a State of rest or move forward to stop the program. In addition if there is an error, the program should prompt the user to ' clear the error and continue, or stop the program. Then back to the idle state or move forward to stop the program.

    Architectural details:

    The program consists of 3 parallel loops: (1) a loop of event management that places different States of a queue of the State, (2) a State Machine that enters the State that is removed from the queue of the State and (3) a loop error/Shutdown, which deals with errors in the error queue management.

    During normal shutdown, where running handling loop in the case of event 'Program.Shutdown' and 'Shutdown' and the 'Idle' States are added to the queue of the State. In the state machine, the State of 'Stop' is invoked. Special "5000" error code is added to the queue of the error. In the loop of error handling and stopping, "5000" error triggered a prompt that asks the user if they want to stop the program. If the user chooses not to stop, a notifier StopNotif is sent to the State of 'Stop' and 'Program.Shutdown' event case with notification 'Go '. If the user decides to stop, the Notifier sends the notification "Stop". Loop and event management State Machine ends when they receive the notification "Stop".

    In case of error, the program behaves in the same way: If the user chooses to clear the error and continue, the program returns to the status "pending".

    HOWEVER - if the user chooses to stop the program, the program crashes. The author of the notification that is sent to stop the loop of events and State Machine management cannot be read because event Program.Shutdown and the stop State (which contain the function "Waiting to notify") are not active.

    I was able to activate the stop State by Queuing in the loop of error/Shutdown management. But I don't know how to activate the "Program.Shutdown" event by program and thus access the function "Waiting to notify" inside.

    I tried to put the function "Waiting to notify" outside the structure of the event, so the event-handling loop never ends. Placing timeouts on the "wait for declaring" and the structure of the event makes the programme of work, but I want to avoid using timeouts because I don't want to turn my event program into a program of polling stations. I would also avoid using variables or nodes property to stop loops, because that requires the creation of a control/indicator for something that the user does not need to interact with.

    Thank you!

    First of all, close the notifier outside loops with your queues.  Second, you must use a user event to send the message to the event structure loop so that it stop in the case of the stop on an error.

  • Structure of the event in a state machine

    Hi all

    I have a state machine with a sort of stand-by, where a user can select the next button state. I tried using a structure of the event with changing the values to select the next case, but when the state machine is in a specific case and the button of another State on the blocks of all things. I've attached an example, the lights simply stating that you are in the State.

    Thx for your time,

    Bert

    Edit: actually, I miss-clicked

    1. you have not need a while loop around the structure of your event.  With no wired time-out, you will never get a timeout event.

    2. your button events are set to 'Lock Front Panel until end of the event'.  Uncheck the box which.

  • Using the Structure of the event in a Machine of State Enum

    Hello!

    I'm new to labview(~10 months). I tried my best to search on the forum/net but didn't have an explanation.
    I simplified the code to show the problem. I'm using Labview 2013 worm 13.0f2 (32 bit).

    The "EventStructure_Trigger_in_EnumStateMachine.vi" is a State Enum machine.
    The "resting" State contains a structure of event that detect evnet of changing value of 3 buttons:

    Do something touches: simply show something of the display flag
    Start Run button: bring the program into "run" State
    End key: put the program in the 'final' State and then close it

    The State of 'run' is a time loop that will be stopped only by clicking the 4th button - button stop running and bring back the program in case of 'lazy '.

    The problem is to "run" State, any click on irrelevent buttons 3 (buttons only detected by the structure of the event in case of 'lazy') will make the program crash.
    By comparison, I create an another vi attached as 'WhileLoop_in_EnumStateMachine.vi', which is almost the same except that the event structure is replaced by a while loop (and do something key has no function). In this vi, everything works well - by clicking the irrelevent buttons will not crash.

    I can't understand why.

    P.S. I failed to attach .vi onto this post... a zip compressed instead.

    A problem that resembles yours: http://forums.ni.com/t5/LabVIEW/why-does-simple-case-structure-code-hang/td-p/3176592

    I think that the response of Stuart will help you understand how your code handles this situation.

    You must manage your events outside your main loop to your structure to operate on any captured event.

  • Master/slave event Structure vs. State Machine

    Hello

    First some background to the question (skip this paragraph if you are simply interested in the question). I'm relatively new to Labview, after only a few months of coding with Labview and LabVIEW Core 1. Being one of the only people in the company who now knows Labview I have been challenged with the creation of a relatively complex application that will perform a selected ten or to view different tests with customizable options, display, analyze and deliver and automate reports.

    For the application I am writing I need a GUI with several screens (I achieve with tabs), initially I tried this code with the structures of the event within a machine to States (but as you probably know this was fundamentally flawed, that you can't put structures of the event within the structures of the case) (, or structures of the event), but from here, I spent several hours of searching the best alternatives.

    So my Question is: would recommend to use a master-slave (with the structure of the event and the State of computer, respectively), or simply use to continually voting machine status?

    (Keep in mind I'm going to use this as part of a larger facility of producer/consumer.)

    Thanks in advance,

    Joshua Walker.

    I use a case in my state machine specifically for checking to GUI events.  It is usually a "Idle" State or a specific State to 'check events.  I can also set the time-out programmatically by using a register shift, just in case I need to do a quick check (some small timeout) or wait for a user to press a button (timeout is - 1).

  • Need help with the events of user base in state machine example in queue

    I wrote a small example queue state machine to try to teach myself about the creation and use of the user events.  The purpose of the machine is periodically pick a number (I do now with a control instead of a generator of random numbers for troubleshooting), and compare this figure with the number I put in a control.  When they match, I want to raise an event to fire so I can do something about having found a match.  The examples in the file LV references help show events within the structure of the event, but I want to reach out of a State and trigger an event...

    Can someone point me in the right direction here?

    Thank you

    Hummer1

    I think the service you're looking for is generating the user event.  What to put in your consumer loop, inside the case structure when identical numbers.

  • problem of data flow in the case structures (using a state machine)

    Good day everyone.

    I'm having a problem with the flow of data between the structures of the case.

    I try to use an example of a state machine for this simple problem. but when I try to send data of a box structure to change the State of the code. It will change not in the desirable output, instead, it offers the possibility that the exit options emul.

    could someone please point what I'm doing wrong here. Any kind of help would be very appreciated.

    With a quick glance at your photos a question you have is that you use not data flow. You write your status updated in local variables value. Your State should pass through the case structures are a single wire. Playback of your order "Enum", happened in the register shift on the right side of your loop probably get running and reading before any processing occurs within the structure of your business. That's why you're reading the old value of the State and not the update. or have a classic case of a race condition in your code.

  • State machine with the help of event

    Hello everyone,

    I have a question on how to achieve the "Timeout". In the diagram below, you can see 2 different situation:

    1. in the 1st case, I used the state machine, it starts in State 1, that contains a case of event. From there, it will first be determined, if the input value has changed in 10 seconds, if it didn't, the state machine will go to State 2, if it is changed, will also be determined, if the value equal to 3, if so, input the distributor of State will in State 3, if not, go back to the State 1. (this VI I've done it before, you can take a look at the attachment).

    2. my question is in the 2nd case. He also started the State 1. Here, the input value can also be changed (once or several times) or not. If the value has not changed within 10 s, or even if it's been changed many times within 10 seconds, but it was never equal to 3, the state machine will go to State 2. only when the value of the entry within 10 seconds equal to 3, he can jump to State 3.

    This problem, I do not know how to solve, everyone has no idea or improve methods?

    Thank you very much!!

    My bad, dint tested before posting (in addition to kills confidence)...!

    Let me know, if it works this time...!

  • Help with State Machine user Sequentail events

    I'm trying to create a program using the state machine which include events genreated user to jump between States. Also, I want the program to require a sequence of events to be genreted before entering in some States.

    For example:

    States: Init, idle, a-1, A-2, A-3, B - 1 and stop

    If a-1 State is selected, the user must enter the setting and select the condition A-2.
    The user cannot directly jump without having to access the mode a-1 to A - 2
    If the user selects the a-1 State, he should have the possibility of not input parameter and jump to another State as B-1 or Stop

    State A-3 can be entered automatically by State A-2.

    How to program the machine in order to do what I want? I've updated a sampling program. I'm not sure if I impleted the program properly. The user Panel hangs if I enter State a-1, and then press the Stop button. It does not allow me to leave the a-1 State and forces me to go to State A-2.

    A few other questions:

    -How to initialize all values of boleean to 0 during my Init State?

    -Why is a timeout value?

    Hey there, I developed example of Jacobson on a bit here to illustrate the case "Idle, how far to walk, ' your state machine diagram.

    Some keys on the front panel when you are in the bad condition will do nothing, as you can see, because I only check for buttons, I would like to respond to each State. For example, by pressing "Start on" the State of market won't do anything because this isn't a valid button, but pressing "Quit" will bring you to Idle. To implement the rest of the state machine, it is up to you!

  • Structure of the event in the event structure

    Is it possible that I can have a structure of the event, which is in another structure of the event? When I run the code, I can't use other buttons. (See chart for details)

    Do not put the event structures in the structures of the event! There is never any reason to do so.

    Redefine architecture your code in a correct state machine.

    (By default, events lock the façade until the event ends and if you raise the event internal or external, first of all, the other event can never fire because the current event can never accomplish or is inaccessible by data stream.)

  • State machine

    Hello

    I get a code for a test setup using the model of State machine project.

    "Standby mode", I would like to show some sort of device face: I want to continually read data and update several indicators, until any key is pressed (triggering of the structure of the event in mode ' sleep').

    However, as I want to "lock when you press on" for fixing buttons (Boolean controls), I can not all their share values. I don't want to "switch when you press on, as is a two UI bad (in my opinion) and caused some disorder (once back to the idle state, cannot press any other button)."

    I would greatly appreciate guidance on how this can be done. A picture of what I want to do, to better illustrate my intention is attached.

    Thank you!

    cl0ck wrote:

    However I'm initializing in the first loop, I need to start with data acquisition off and be able to activate any (in the second loop) from the first.

    I tried 'Wait on Notification' wiring to a case structure, and put the data acquisition in the case of 'true', but for continuous playback, I always send notifications, which I am not in my real program.

    Have your notification send a REAL for the start, data acquisition and a FALSE for when to stop.  When you get the value TRUE, you can set the timeout of your wait on Notification to how fast you want to make your purchase and assign - 1 (wait forever) when you are ordered to stop.  You can simply store this time-out in a shift register.  So then you get data if you got a notification TRUE OR if you have a timeout.

  • State machine in queue

    Hello

    I use a State Machine in queue which is controlled by a Structure of the event. In this example, the State Machine has 3 cases: inactive, State 1 and State 2.

    I need to trigger execution of State 2, in the Interior of the State 1.

    Thank you

    Dan07


  • STOP button for program waiting in a state machine

    Hello

    I am trying to create a state machine in order to control a conveyor, mixer pump and linear actuator. Each component runs in sequential order all the time, so I thought that using a state machine would probably be the best architecture program.

    The problem that I am facing, it's that there are States that require more time before the start of the next State. For example, I need to be able to run the pump or mixer for an another period of time. I understand that simply using the VI of waiting is not a good idea because it removes the option to stop the program on the chance that something goes wrong (at least until the end waiting for execution function). I tried to use clock calendar in order to force the program to wait for a term between States, but I found myself with all nested in loops for each State that require stop buttons separate who ends up doing the complicated program (this is what we see in the attached VI).

    I looked at other threads mentioned using notifiers or the structures of the event, but since I use a state machine, I don't know how to use them with several States.

    If there is a way to force synchronization between States while maintaining control of stop button and, eventually, the ability to run any code while you wait, please let me know. I have attached the VI I train, and the emphasis is on the 'wait to hatch open' State.

    Thank you.

    That your state machine shift register is a cluster.  First point is an enum for say the next State to go to.  Second element is a digital that defines how long to wait if the next State is a wait.  Third point is an another enum as first to tell what State to go after the wait ends.

    Start of the loop of State machine, ungroup the first point to know what State to go to.  In your state of waiting, when you have determined the wait is made, ungroup the 3rd point.  Set the first element of the cluster machine of the State to be this enum even if he goes on the next State.  Basically leave wire to move the machine of State wear with it another State of the State, not only the next State, but also what would be the next state when the next State is completed (in case there are several choice.)

Maybe you are looking for