How to do state machine using events .

Hi all.
i like to create a state machine using events methos .
i have 4 functions 1,2,3,4. (event based functios) (seperate sub vis)
1.i will trigger the 1 function.
then end of the first function should trigger the next function.
like state machine .
how to create this method in labview .. i tried value signaling its still not working . what i want.
Solved!
Go to Solution.

JGar wrote:
Wouldn't it make sense to have the entire state machine within one event case?  When you trigger the event case the state machine then executes like a normal state machine.
DO NOT DO THAT!!!!!!  Long parts of code do NOT belong inside of an event case.
The Event Structure should be in its own state and the state machine should to to that state every once in awhile to check for user events.
Alternatively, you could put just the state case structure inside of the Timeout event case.  Something like this: http://www.notatamelion.com/2015/03/02/building-a-proper-labview-state-machine-design-pattern-pt-2/
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • How to implement state machine architecture

    Earlier in this forum, i had taken help in improving the subparts of my main vi, now i had developed a main vi,it is working correctly without any error, but i had used sequence architecture in that and as everyone says we should use state machine instead of sequence architecture, i am posting my vi please help how to implement state machine architecture in this, and actually in my vi, i am having 5 tabs( presently i have developed only 2 tabs) 1. patient info, 2.naadi acquisition, 3.nostril temp., 4.vision acquisition, 5.other info. presently with tab control i am using case structure so that only only particular page runs at particular time, i want to know how can i improve this code to work more efficiently.
    Attachments:
    intelligent diagnostic bench.lvproj ‏68 KB

    i am sorry, i thought that vi's are by default attched with project files,i am attaching the main vi and all other associated subvi's also. 
    Attachments:
    Final Diagnostic Project.vi ‏375 KB
    createfolder(SubVI).vi ‏65 KB
    checkstring(SubVI).vi ‏11 KB

  • How to create State machine workflow?:

    How to create State machine workflow

    Hi,
    According to your post, my understanding is that you want to send email to Assigned to person when item is created in Task List.
    You can set E-Mail Notification to Yes under your Workflow Tasks list > Settings > Advanced Settings. By doing so user specified in AssignedTo will receive e-mail notification when task is created.
    Here is a similar thread for your reference:
    https://social.technet.microsoft.com/Forums/office/en-US/44f63c3c-8dfc-4f02-b627-a92249404ae3/task-list-advance-settings-email-notification-send-email-when-ownership-is-assigned-or?forum=sharepointgeneral
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How can A state machine be used to monitor flow from a micro motion using bridgeview/labview

    I want to be able to use a state machine to monitor if the flow stops during a chemical charge. Currently I am using labview 5.0 and this monitors flow but I need an alarm to let me know if flow stops during a charge. Any suggestions?

    this example might explain what i meant.
    A Rafiq
    Attachments:
    statemon.vi ‏55 KB

  • Finite state machine using jsf ?

    I am building an online payment module and would like to implement it using a finite state machine. I am hoping that someone may give us advice on how to build it with jsf.
    Firstly, I am just beginning with jsf.
    Here is the example: Let's say that in the module there are 7 possible states that the user may be in, each represented by a jsp. I cannot decide where to manage state transitions. One option is to change states in the backer bean of every state, but that is dispersing transition logic across all my backer beans. The other option I can see is to have one single actionListener and have all action events pass through the 'processAction' method, keeping all the state management logic in one place.
    Please comment on either of these two approaches...or any alternatives :)
    Thanks in advance !
    Mark

    Sounds like a state machine in combination with a decorator on the ViewHandler might do the trick.
    Off the top of my head I'd suggest creating a managed bean in session scope that keeps track of the state in the user's session (the state machine). Check the bean from the ViewHandler decorator when a page is requested and direct the user to the correct page if they are trying to navigate to a page that conflicts with what is allowed for their current state.
    Your actionlisteners or action methods could change the user's state in the session as they process their actions.
    http://forum.java.sun.com/thread.jsp?forum=427&thread=502322
    The above thread discusses the use of a decorator to control navigation for authentication purposes, but it should be adaptable to this use.
    Is that plausable or am I smoking crack? :-)
    -jeff howard

  • How open a service order using event handling

    HOw to open a service order using event handling

    Hi,
    Can you explain your requirement elaborately.
    I understand from it as, you want to open Service order creation page, based on some event(may be submit button).
    For that technically you can use navigation->goto_page('Provide the URL').
    or you can use inbound-plug and out-bound plug concept for naviagation.
    Regards,
    Devender V

  • How to run a particular case continuously in event based state machine architecture.

    I am making a program using event based state machine architecture, it is running as expected whenever i am generating an event, case structure corresponding to that event executes.
    we are taking some measurements from oscilloscope e.g. i am having one boolean button for rise time whenever i am pressing that that button it displays the value of rise time, it displays only once( since i have generated an event on that boolean button so it executes only once and displays value for one time and then comeback to timeout state) but in our program what we want, we want it to update value continously once that button is pressed.
    Now for a time being i have placed while loop on the case corresponding to rise time but this is not the right approach.
    since i am using state machine architecture( event based ), i am not getting how to run particular case continuously ,or if there is any other better architecture that i can use to implement the same application.
    Attached below is the program.
    Attachments:
    OScilloscope .zip ‏108 KB

    Say, in the attached program, when the user selects Autoset, it inserts corresponding state (Autoset) and now if you want this state to run again and again, probbbly you can again insert Autoset state while executing Autoset state... ohhh its confusing... check the picture below (A picture is worth a thousand words):
    1. Based on user selection, insert Autoset state.
    2. Re-insert Autoset state again and again while executing Autoset state.
    3. Now to come out of this loop, based on appropriate event generation, insert any other state AT FRONT (equivalent to Enqueue Element At Opposite End).
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • Need help with basic user events in Queued state machine example

    I have written a little queued state machine example to try to teach myself about creating and using user events.  The objective of the machine is to periodically choose a number (I'm doing it now with a control instead of a random number generator for troubleshooting), and compare that number with the number I have set in a control.  When they match, I want to cause an event to fire so I can do something about having found a match.  The examples in the LV Help file references show the events within the event structure, but I want to reach out of a state and cause an event ....
    Can someone point me in the right direction here?
    Thanks
    Hummer1
    Solved!
    Go to Solution.
    Attachments:
    User Event Generator Example01 snip.png ‏102 KB

    Yep....That was it...I had tried to do that but got fouled up with the variant definition...so defined the user event using a boolian and did the same in the case structure where I wanted to create the event and it worked great...
    Thanks.
    Here is the final version...not bulletproof, but does have a queued state machine using a user event to cause an event to fire.
    Hope you find it useful.
    Hummer1
    Attachments:
    User Event Generator Example01.vi ‏45 KB
    Operating States Enum Example01.ctl ‏5 KB

  • Data acquisition in a state machine

    I've recently learned how to implement state machines, but I have a question that I haven't been able to find an aswer to.
    Question:
    How do I record uninterupted data (presently i'm using the DAQ assistant to record a single channel at 10kS/s at 1kS intervals) without interfering with my state machine?  
    Background:
    I have a time sensitive test setup (measuring pressure in a rocket chamber), and I'm using labview to both record a single pressure transducer as well as operate the valves (O2, N2, igniter, etc).  I'm using a state machine Labview architecture (just learned how).  Presently, the DAQ assistant sits in the "Idle" state, and timers (valves need to be turned on at specific times) and manual buttons control when the other states are activated.  I have a 10ms timer controlling how often each state is run, and this is the root of my concern.  
    Main concerns:
    I'm worried that:
    1)  I'm forced to change my data recording to 10ms intervals to match the 10ms timer, and
    2)  The 10ms timer will interrupt my data recording when it's in another state.  
    It's very important that the pressure data is recorded without interruption but that I have high time resolution in controlling my valves as well.
    Thoughts:
    1)  Maybe I put the 10ms timer in the "Idle" state only, and this way the other states won't interrupt the data acqusition
    2)  Maybe there is a way to completely isolate the state machine for controlling the valves and the data acqusition.  I'm not sure how to do this.
    3)  People on the forums have been talking about Queuing their data acqusition, but I'm not sure how this would benefit my situation.  
    Thanks to everyone for their feedback!

    The data acquisition and state machine timer do not have to be equal, you should however have the same data write rate as you have data read rate, otherwise over the course of long running programs you can build up a large buffer of data to be written using a lot of memory, or lose data.
    Your data acquisition should be continuous, the most common way of doing this is every time you receive data write it to a queue, then when you are in other states except your data write stage you simply build up data in the queue that is to be written when you enter the write state again.
    Think of it as traffic reaching a set of lights:
    The traffic represents the data acquisition, there is a constant flow of it always coming through, the state of your state machine is the lights, green is the data write state clearing the queue, red is when in any other state, letting the traffic build up behind the lights.
    It is just important that the light is green long enough to let the traffic not build up too much, otherwise you have a jam.
    EDIT: For the basics of how queues work, look at the Queue basics example from the example finder. 

  • Need help created state machine that is time based

    I need help with my labview program. My goal is to write a program that allows the user to turn a toggle button on/off. When they do this it will start a loop witch turns on a digital switch for 45 minutes then off for 30 seconds and on and on till the user toggles the switch off. The timing does not have to be precise. I am using the NI 9476 digital output card.
    I have written the code to turn the switch on/off. I know need to add the looped fuction for on 45 minutes/off 30 seconds. I assume the most efficient method would be using a state machine, but I was having trouble figuring it out.
    Attached is the program I have written thus far without the loops.
    Thanks,
    Barrett
    Solved!
    Go to Solution.
    Attachments:
    Test Setup X01.vi ‏16 KB

    I cannot see your code since I don't have 2010 installed. A state machine would be good approach but in order to allow the user to cancel and possibly abort the process at any time your state machine should have a state such as "Check for timeout". In teh loop containing the state machine use a shift register to pass the desired delay value and the start time time for that particular delay. Once the user starts the process set the delay time to your desired time (45 minutes expressed as seconds) and have another shift register that contains the next state to go to after the delay completes. Use a small delay (100ms to 500ms depending on how accurate you want your times to be) to prevent your state machine from free running and then check the delay again. Use the current time and compare it to the start time. If the desired time has passed then go to the next state. You can store the next state in a shift register. No do the same thing for your Off Time state.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    Simple Delay in State Machine.vi ‏14 KB

  • Add an item to all state machine constants

    I have a state machine using an enum for the state indicator.  In
    the current state, the next state is indicated by an enum
    constant.  If I want to add a state, how can I update all of the
    constants?  Here is the problem.  If I add (or delete) an
    item in the selector of the case structure, it is red because the enum
    constants do not have that value in them.  Conversely, if I add an
    item to one of the constants I can "Add case for every value" and add
    it to the seletor, but then I have to manually add that item to each of
    the other constants.  Also, the way I usually create the constants
    is to pop-up on the exit tunnel for the enum in the case structure and
    "Create constant".  Unfortunately, that tunnel retains the choices
    of the old enum and the new choice must be manually added.  Is
    there any way around this?  I would like a method that allows me
    to add or delete choices at will and have all of the constants
    automatically update to match.
    Roy

    Well LabVIEW has just what you need in the "type def"! The next time you create a enum, right click on it, select create a control go to the front panel, right click on the control and select "Advanced" and then "Customize" to enter the control editor (if you have selected in your front panel "tools", "options", "front panel", "open the control editor with a double click", you can ust double click on the control to enter the control editor). In the control editor you will see a toolbar pull down with the "Control" option. If you pull it down and change to "Type Def" you can modify the control and all copies of it will now get automatically updated, including constants created from the type definition. The strict type def controls the look of the control as well, so it is most often used to make sure that operator interface instances of a control look the same. When you save this new type def it should ask you whether to update all instances, which will update the original control , you will have to go back and make a constant from the new control type to replace that original one, but now every copy made from that one will update when you update the type definition, and you can do that from the constant on the diagram by right clicking and selecting "open type def".
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • State Machine Programming books

    I just finished the LabVIEW basics I & II.Are there any third party books available that can help explain and expand on building State machines and event driven programming. Or at least cover this material in detail. Thanks in advance.
    SS

    I definitely agree on the Labview Style book. best LV book i read (and reread).
    my experience with the other book was not enlightning, but definitely worth a look.
    allow me to propose :
    "A Software Engineering Approach to Labview", by Jon Conway and Steve Watts.
    the book is really good, and expand on programming techniques and architecture in general. i think it is well written.
    The print version has a quality problem of the figures tough (at least some editions), so i suggest you contact the authors directly or purchase the online version.
    ... And here's where I keep assorted lengths of wires...

  • How to use a event structure with a state machine

    First, I would like to inform you that I only work on LabView part time, and have much to learn.  Anything I do learn, I usually forget until I need it again, because I only work on it part time.
    Using your StopWhileLoopMOD[1].vi, I am trying to put a state machine inside the event structure.  
    Related link: http://forums.ni.com/t5/LabVIEW/How-to-stop-while-loop-in-Event-case/td-p/465564/page/2
    Here is my application:  on the front panel, the user can select any combination of 7 different tests.  I have created cases to perform each step of each test in the correct order, but if the user presses stop, the tests won't stop because some of the cases have a while loop inside the event structure (like you mentioned is a bad idea).  The user should be able to stop the test, reselect tests to perform, and re-start the tests. 
    When the start button is pressed for the event structure, I need all the cases to run in the proper order, unless stop is pressed.
    In the past I have indexed an array and used that to run the state machine, but it won't stop immediately.  
    I have sub VIs that are built in while loops because the outputs of the product needs time to stabilize.  The state machine stops and waits up to a certain number of iterations.  If it passes the test, the while loop stops and the next state starts.  If it takes too long, it exits and reports an error.  Maybe I need to just use the state machine and not an event structure?
    Is there a good example of an event structure?
    metzler CLAD
    Solved!
    Go to Solution.

    I'm not sure exactly what you are asking, but it sounds like you want to script a bunch of tests and if the user says stop, to immediately stop the current test and abandon the others?  I'm going to assume that you know how to clear the array so that it will abandon the others, so I'm guessing that you are having trouble abandoning the current test?  If this is indeed the case, then the problem is that you are not able to propagate the message from the main VI FP which is the GUI to the sub vi which is the test, where the test may or may not have a GUI (FP visible) of it's own.  Threading was the first thing to come to mind, but this may not be necessary using events.
    You can do this by passing a refnum of the stop button to the subVI, where you can then add that wait to the event case structure.
    I've attached 2 VIs, mainvi.vi which is just a loop displays the count*2 (number of seconds passed since running) that will call subvi.vi and then check to see if the stop button is pressed.  mainvi.vi is by no means a state engine, it is just a simple loop for demonstration purposes.  subvi.vi just waits 2 seconds and leaves, it is a better structured state engine with an init state to start a poll case to wait for events and an exit state to clean up.  You can modify this any way you wish to get it to do what you want.  You will note that even if subvi.vi is being executed, it will terminate immediately when the stop button is pressed.
    Hope this helps.
    A
    Attachments:
    mainvi.vi ‏17 KB
    subvi.vi ‏33 KB

  • State machine with using event case

    Hallo everyone,
    i have a question about how to realize the "Timeout". In the flow diagram below we can see 2 different situation:
    1. in the 1st Situation i have used the state machine, it begins at state 1, which contains a event case. In there it will be at first determined, if the input value has changed within 10 second,  if it didn't, the state machine will go to state 2, if it 's  changed, will be furthermore determined, whether the input value equal to 3, if yes, the state mashine will jump to state 3, if no, jump back to state 1. (this VI i have done before, you can take a look at the Attachment).
    2. my question is in the 2nd situation. It begins also at state 1. In there the input value can also be changed (once or many times) or not. If the value has not been changed within 10 s, or even though it's been changed many times within 10s, but  it's never been equal to 3, the state machine will go to state 2; only when the input value within 10s equal to 3, it can jump to state 3.
    This problem i have no idea how to solve, does anybody have  idea or better methods?
    thanks a lot!!
    Solved!
    Go to Solution.
    Attachments:
    situation 1.vi ‏12 KB

    The statement in the OP is not covering all cases.
    mexaviesta wrote:
    2. my question is in the 2nd situation. It begins also at state 1. In there the input value can also be changed (once or many times) or not. If the value has not been changed within 10 s, or even though it's been changed many times within 10s, but  it's never been equal to 3, the state machine will go to state 2; only when the input value within 10s equal to 3, it can jump to state 3.
    This problem i have no idea how to solve, does anybody have  idea or better methods?
    thanks a lot!!
    Just check my implementation for Situation 2 and let us know, if it works for you.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.
    Attachments:
    Situation 2.llb ‏40 KB

  • Use event to jump to a case in a state machine

    How would I use an event to force a jump to a certain case in a state machine? For example, in the attached VI, I have a state machine that will simply blink a green LED indicator on and off for five seconds. I have a case in which the LED turns red for five seconds and a button which I would like to use to jump to this case. In other words, if the state machine is currently halfway (2.5 seconds) through my "Green_Light_ON" case when the button is pressed, I would like the state machine to immediately jump out of the "Green_Light_ON" case and into the "Red_Light_ON" case. This is not my ACTUAL VI, but it's a simplified example that will work for finding my solution. Thank you very much in advance for your help! 
    Attachments:
    DemoStateMachine.zip ‏18 KB

    Sounds like the classic "Producer-Consumer (Events)" design pattern.  File>>New...>>VI from template.  There is a good shipping example as well as the comments on the template vi
    Jeff

Maybe you are looking for

  • Hp p1006 laserjet printer is not working. All drivers have been updated. Using windows 7 64-bit

    I have had this printer for about two years now.  All of a sudden it has decided to stop working, and I cannot get it to work now.  All connections have been connected and all software drivers updated.  What can I do to resolve this issue?  Thanks.

  • URGENT: iframe in a dynamic page. Strange Problem.

    Hi all, I have a typical problem. I created a Dynamic Page which brings out the information of a Purchase Order (PO). (PO_REPORT) Now the numer of items in a PO can vary from 1 to anything.... so I made a seperated report based on sql query (ITEM_DET

  • CONNECT HP LAPTOP TO IMAC SHARED INTERNET

    hi can somebody please help me with connecting my new HP Laptop G60 to wirelessly connect to my iMac shared internet? I see my iMac on the HP connect list but when i select it ... it doesnt even give me an option to type my secure password. I get an

  • Cant connect 2 nas to each other via my personal cloud

    hi , i try to connect 2 nas to each other via my personal cloud. 1 of them is under my personal cloud ,, i send an invatation to the other. but when i put user name and password.. it says that the device is already familer and i get an error i cant a

  • Business Object (BAPI/IDOC) for production Order

    Hi All I have requirement where data is coming from legacy system to R/3 via XI to generate a production order. I am not able to get right BAPI/ IDOC for inbound Production Order. Can anyone has done similar scenario. Can u suggest me BAPI or IDOC fo