Using "Enum constant" in state machine.

hallo all.
i bild state machine, with 10 states. i move beetwen the states with Enum constant.
my qustion is: if i want to add/delete some  states, why i need to update the Enum constant at every state ?
there is  way to update "Enum constant" at one state, and  all other "Enum constant"(in other states) will update automatically
thanks

If you save you enum as a type def and replace all of the current occurences of the enum wi the type def, you shoud there after only have to update teh typedef.
1) Find an oocurance of the enum
2) Right-click and change to control.
3) Find control and select Advanced customize
3) Pull down on selector and change from "control" to "type def"
4) Save control.
5) close editor and when prompeted say yes to replace control.
6) Change control back to constant
7) replcae all previous occurances by choosing replace >>> the typedef'd control.
8) Case structure will folow typed def from that point forward.
Ben
Message Edited by Ben on 12-24-2006 03:31 PM
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

  • How to use settings with a state machine?

    I have a "classic" data acquisition program that acquires voltages from different sensors. Each DAQ read subvi has some settings for the scale, range of voltage etc.; additionally I have set a certain buffer size, sampling rate etc.
    I would like to show on the front panel only the start, stop type of buttons, file name and charts, and 'hide' the settings in a subvi. I already built the subvi but now the problem is how to hide it and how to call it through a "settings" button whenever I want to change something. I tried this using New events handler (using events in a while loop); the problem is when I start the program, the settings in the application do not take the settings in the subvi, they all go to 0 (I used shift registers). I started to wonder if this is a good approach or what could I do to make the settings available right from the start.
    Did anybody have the same problems and could give me some suggestions and an example?
    Thank you. 

    Hello,
    Attached is an example to help you get started.  The popup VI in the event structure is called and shows it's front panel when called because of the subVI node setup (right click to check this) - the instance of the subVI outside the loop, which initializes the shift register, does not pop up because it's subVI node setup is not set that way. 
    If you run the example and study the code, you'll find comments in the code to help you understand the behavior.
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear
    Attachments:
    Change Settings Example.llb ‏46 KB

  • How to add a state to an existing state machine?

    Hello,
    I have a state machine with 5 states. See attached vi (LabVIEW 7.1).
    Now I want to add another state ("wait") between state Druck Aufbau and Druck Abbau. How can I do that?
    I tried to add a state to the enum on the left and then I noticed that I would have to modify every enum in the vi and the case structure as well.
    Is there an easier way?
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Attachments:
    Hysterese_Disc.vi ‏75 KB

    You should replace all enums of the state machine with your type def'ed one. Thus, every change you make will be propagated throughout your state machine. When you need to add or delete states, change the typ def (so the Enum.ctl), and then all the enums will change. Thats the very reason of type definitions. In future, always use type defed enums.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • How to update task status from custom task in state machine workflow

    i m using custom task for state machine workflow
    i am using
    if(this.onTaskChangedSupervisorAction_AfterProperties.ExtendedProperties["Workflowstatus"].ToString().Contains("Approved"))
    if above is true moving forward its working fine but i want to update the status field of task as i can update the title and due date for the task but how can i change the status once approved it
    should show the status as approved it's only showing in progress
    this.CreateTaskSupervisorAction_TaskProperties.Title="supervisor task"
    MCTS,ITIL

    If your task shows In Progress state then I think you need to look at your workflow and make sure you are using Complete Task activity and if you are already using Complete Task Activity then verify the Correlation ID. Ideally you are not required to set
    this value in workflow. You simply use the Complete Task Activity.
    If you are running into issue where your workflow is staying in In Progress state even after the task is complete then you can look at the following blog post.
    How to programmatically complete Approval workflow task
    Amit

  • Help me with a state machine design

    I have a little bit of a problem.  I have a system with several modes, each selected by the user and called with a case structure.  Each case in the case structure is its own state machine with a few states (like 4-6).  Now here's the catch.  I need one of the states within one of the modes to call and execute an entirely different mode (and all of its states) without actually changing the mode command, and to do so every iteration until I jump out of that state into another state within the first mode.
    Is there a simple way to do that that I'm just not thinking of?
    Lee Jay

    Lee, my first thought would be to use just a big state machine.  For example if each mode needs 4 states, mode 1 gets states 0-3, mode 2 get states 4-7, and so on.  This way, if you need to change modes in the middle of another mode, you just direct the state selector to the state that starts the mode.  (If that makes sense).  It's not real elegant, but it works fairly well as you still maintain the flexibilty of the state machine design, including the ability to add and rearrange cases. 
    Don't forget you can use any method to select the cases, including strings, so you have full flexibility with how you setup case select.
    Troy

  • Wiring constants into the queue in a queued, event driven state machine

    I'm creating a queued state machine. Every time I change the queue control options to create a new event I have to recreate a constant in each queued event. Is there a way around this? I'm up to 27 events and changing them all is cumbersome. And I'm sure there are more to folow.

    Are you using enums for your constants? If so, make a control from one, right click on it and under "advanced" select "customize" and when in the control editor change the pulldown from "Control" to "Type def." Save it with a useful name, and then in the vi in which you originally created it, use it to create a new constant. You will be able to select the different constant values were you need them and now when you want to add or subtract a "named" value you just click on the closest copy of the type def, either control or diagram constant, and choose customize (or double click into the tool editor if you made that choice in the options in the Tool pulldown at the top of the screen). Any changes you make will automatically be replicated everywhere you have used the typedef, whether a control, indicator or constant. Using enums also allows having case statements that have cases with the same names at the "named" value.
    Hope this helps and is what you were refering too.
    Putnam Monroe
    Certified LabVIEW Developer
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • 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

  • How to use elapsed time function with state machine in Lab VIEW

    Hello
    I've been trying to use state machine with elapsed time function in order to sequentially start and stop my code. The arrangement is to start the code for 1 minute then stop for 5 minutes. I've attached the code, the problem is when I place the elapsed time function out of the while loop it doesn't work, on the other hand when I place it inside the loop it does work but it doesn't give the true  signal to move to the next state. 
    Could you please have a look to my code and help me to solve this issue.
    Regards 
    Rajab
    Solved!
    Go to Solution.
    Attachments:
    daq assistance thermocouple(sate machine raj).vi ‏436 KB

    Rajab84 wrote:
    Thanks apok for your help
    even with pressing start it keeps running on wait case 
    could you please explain the code for me, the use of Boolean crossing, increment , and equal functions 
    Best Regards 
    Rajab 
    OK..I modded the example to stop after 2 cycles. Also recommend taking the free online LabVIEW tutorials.
    run vi. case statement goes to "initialize", shift registers are initialized to their constants. goto "wait"
    "start"= false, stay in current state. If true, transition to "1 min" case
    reset elapsed timer with True from shift register(counter starts at zero)."time has elapsed"=false, stay in current state(1 min). If true, goto "5min" case
    reset elapsed timer with True from shift register of previous case(counter starts at zero)."time has elapsed"=false, stay in current state(5 min). If true, goto "1min" case. Also, bool crossing is looking for "true-false" from "5 min" compare function to add cycle count.
    Once cycle count reaches 2, stop while loop.... 
    Attachments:
    Untitled%202[1].vi ‏42 KB

  • Performance of state machine with enum vs string?

    I am laying out the groundwork for a very large state machine. It will have about 60 to 100 states. I kind of want to use an enum for selecting the states for convenience. But then if I use a string I can use Jim Carmody's case select tool so that wins out in convenience in one respect.
    One concern about using a string is performance. Since an enum is just an integer wouldn't the selections perform better? I need to squeeze out every ounce of performance and in fact this state machine will be set for subroutine priority. Another concern that I have about a typedef enum is that I have heard something about the possibility of them getting "out of sync" between VIs when you edit them. Is there some way to avoid that, such as making sure all VIs that use this typedef are in memory when editing it?
    =====================
    LabVIEW 2012

    Steve Chandler wrote:
    As for the number of states, I am pretty sure that it has to be one state machine. I'm afraid I cannot give a lot of details.
    I am having trouble figuring out the "has to" part.
    See this thread for designs I have posted previously.
    In this SM
    please look the section that is entered from "Change Request 8 " can take multiple paths but all ends at "Stop Monitoring? 15". I could have implemented that as a sub-SM and it would have reduced the number of state required for that part of the work from five to one.
    Any time I see "single entry, fan out, merge" I think sub-SM.
    This could also help with your shift register as well because (again seea bove) the bulk of the ose states deal with Logging so rather than use a SR, put what would have been in the SR (file path or ref) to be used there OR possibly an AE that can be used in each of those states.
    So I still don't understand why sub-SM aren't a possiblity.
    Trying to help,
    Ben 
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Using a Ring in a State Machine - Can I Show the Item Name in Each Case?

    In the past, I've always used strings to pass states from one loop iteration to the next.  I'd like to try doing that numerically, with a Ring or similar to avoid problems with typos in my strings.  However, when I set it up with a ring, each case only shows the Ring number, not the text description.  Is there a way to set up a numerically-based case structure that shows a text description for each case?  Thanks!
    Solved!
    Go to Solution.

    diarmaede wrote:
    Ahah!  Replaced the ring constant with an Enum constant, and everything works beautifully now.  Never mind.
    I'll still mind to help you with the question you will have soon.
    Save the enum as a type def then replace all of the constants of that enum with the type-def'd version. By using a type def, you can edit the type def to add new values and all instanses will automatically adapt. WIth a plain enum, if you edit one instance and not the others, you will be back in number land again.
    Ben
    TO save as type def...
    click-click create control
    Goto FP and right-click new enum control and chose advanced customize.
    In Control editor change drop down from "Control" to "type def".
    Save
    Replace
    Find terminal id diagram and choose convert to constant
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Recipe Management Using State Machines and DAQ Assistants

    I am writing LabVIEW code to control a conversion process for up to 4 devices on one apparatus.
    The operator will select from these 4 devices which ones will go through a conversion process. Therefore - they can select some or all of the devices to go through the process.  The process is the same for all 4 devices. The difference between the 4 are the digital outputs used for the conversion process.
    Clearly a state machine is applicable. However, I would like to "reuse" the process conversion code of the state machine by creating a separate recipe for each device and merely change the digital outputs (their physical location) for the device under conversion. Presently I have DAQ Assistants controlling digital ouputs for the conversion of one device. Is it possible to "reuse" the code by creating a recipe or a lookup table to reassign the DAQ Assistants to their proper physical location (the digital output lines) for the device under conversion?
    I could - copy and paste the code, go into the process and reassign every DAQ Assistant to the correct physical channel of each digital output for the other 3 devices. I was curious if there was a more efficient way.
    I see documentation online for recipes; however they are dated 2006. I thought there may be some updated examples.
    Using:
    LabVIEW 2011
    cDAQ-9188 chassis

    Hi MgDAQ,
    DAQ Assistant is a quick way to start acquiring data, however it's not the most efficient.
    Everything that DAQ Assistant does can be acompished with basic DAQ functions on the
    Measurement I/O -> NI-DAQmx pallete. For example, you can use DAQmx-Create Channel.vi and
    a Channel Constant to select the channel from which you want to acquire data.
    To get started with using the DAQmx functions you can browse through Hardware I/O examples in the Example Finder.
    Open up a new LabVIEW VI and then go to Help -> Find Examples -> Hardware Input and Output [folder] -> DAQmx -> Digital Measurements
    Now, as you probably know, copying and pasting code is inefficient and it's not a good programming practice. So what I would do is create the code for your conversion process and then simply change the channel constant to read the digital output you need.
    Mikhail
    RF Toolkits, Product Support Engineer
    National Instruments

  • How can I keep a state machine readable when using large amounts of in/outputs

    Hello, I am new to Labview,
    Read trough the fundamentals and the
    getting started and a lot of examples.
    What I want to do is use a standard
    state machine from the template, and add some stages, for example
    orange, apple, banana. At this point I can use numeric controls to
    put in the amount of oranges, apples, bananas there are. I can even
    use a led to tell the user which state of the state-machine is
    active.
    The thing is there will be more numeric
    controls and more leds and it would be nice if the code would still
    be readable when there are 20 inputs and 20 outputs.
    Questions
    (1) It would be nice if I could use the
    typedef to select the right state AND the corresponding numeric
    controls and leds out of a cluster or an array kind of structure to
    keep the number of wires low. Is this possible, how can I do this?
    (2) I tried to put the numeric controls
    into a cluster but that way I can't put the numeric control for the
    apples in the upper right corner and the numeric control for the
    oranges in the lower left down corner of the front panel.
    (3) An example would be really nice, I
    know that I saw some examples describing this problem but there are
    so many examples that after a few hours of searching I haven't found
    the right one yet.
    Thanks in advance for the effort.
    p.s. I will not use Labview to do
    calculations on fruit, I am only using this to make the question
    easier to understand.

    I can only start a proper answer but I might as well start with that.
    When I am developing State Machines I have to think about what data is used and manipulated in each state. I then have to think about where am i going to keep and manage the data. I list all of the fields that are "touched" in each state and what values are used together and which are independent form the others. After this phase of the analysis, I usually have some data structure defined (cluser array etc).
    Then I flipp from thinking about the state to thinking about the data (after all this is LabVIEW and the data-flow paradigm is critical). If I see data that is only used by the State machine and is used in many of the states, then the data structure get put in a shift-register for easy access in each state. This maybe enough of an answer for your fruity question.
    When i see data that is shared or only used in a handful of states then I concider putting the data in an Action Engine. Depending on how you design your AE, you can access each of the fruit totoal by name or increment etc as required.
    If your app demands many fileds that are all related (can't be broken into distinct data structures) then create a cluster that has all of your values that are used by the AE. Then create an Wrapper VI for each call of the AE but only put the associated fields on the FP of the wrapper and then bundle that value into the cluster and invoke the AE.
    Ben
    PS: Sorry about reverting to neBulus mode but this topic could take days to cover in detail.
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • 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

  • How do you create array of enums for transitions in a state machine?

    Hello,
    I am trying to build a state machine, but, I am struggling with understanding the methods for determining which state to transition to next.  In other words, I have several states, but, I don't want to go in any particular sequence.  If I have states numbered 1 through 10, I want to be able to go 1-4-2-5-6-2-6-1-10 etc. in no particular order. I want the transition to the next state  (and actions) to be determined by the streaming data, which can be random and require access to any of my 10 states at any time and in any sequence.
    I saw this picture on the "Application Design Patterns: State Machines" white paper, but, it leaves out some important details.  How does one create the structure in BLUE shown in 3C?  When I try to create this array of enums, all of them are the same. I am not able to make a list of different enum values.  In other words, when I type in "2", then, all the values in the array display as "2."
    There is a nice, simple video example of a state machine for dispensing soda for $0.15, however, this state machine moves in a single sequence, from 5 cents, to 10 cents to dispense; it does NOT illustrate how to select a state "out of order."  I need to understand how a state machine can move from "5 cents" state to dispense directly, with the addition of 10 cents to the "5 cents" state.
    Can anyone suggest a really good tutorial on how to make the selector work in a state machine?  I have been reading some of the available material on ni.com, but, I can't find a good detailed explanation of how to do it.  I remain confused. 
    Or, can you just explain how they created the BLUE array in the attached picture?  Maybe I can figure it out from there.
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    next state.jpg ‏75 KB

    Hi Kathryn,
    Yes, this is EXACTLY what I want to accomplish...
    So it would basically run:
    State 1
    Read input
    Determine next state (say 3)
    State 3
    Read input
    Determine next state
    State
    Read input
    Determine next state
    And so on...
    But, I am quite new to programming Labview state machines, and can't figure out how to even start when the sequence of states is random instead of fixed!!! I can do 1,2,3,4, like the vending machine VI example, but,  not 1,3,2,2,2,5,2,1 etc. based on external input.  Is there some simple example case I can study?  I can't believe I am inventing this for the first time.
    "select the state to run" 
    But, HOW do I do this???????   This is exactly the question I am asking...how is this done?  Please see the attached 3-state system....how do I hook this up????  I am totally lost here...can you help me understand how to wire this thing??  In this simpe RED/GREEN/BLUE case, my input is just the number a user would input on the front panel....  Apparently, there are two files necessary... a vi and .ctl???  What  is .ctl?
    Thanks,
    Dave
    Attachments:
    forum nov 12 red green blue.vi ‏7 KB
    forum nov 12 red green blue.ctl ‏5 KB

  • Advantages of Using Queued Message Handler vs. Standard State Machine

    Hello,
    What are the advantages of using a Queued Message Handler?  Also, why are they more powerful than using Standard State Machines?
    Thanks!

    They are really just sort of an extension of a state machine.  The general idea is that you have one loop doing a specific job.  You then use a queue to tell it how/when to do this job.  For instance, I might have a log file loop.  I will send it commands to open a file, write some data, write some more data, and finally close the file.  Each of those commands are coming from the queue.  The beauty with this setup is that anybody that can get a reference to that queue can send the command to that loop.
    So the QMH is "better" than a state machine mostly because of the decoupling of functions.  In a given application, I will have a loop for log file writing, GUI updates, reading of a DAQ, instrumenet communications, server communications, etc.  Trying to do all of that in a single loop state machine is a major pain in the rear end.  Seperating them out makes life so much easier.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for

  • 2009 macbook running very slow with Yosemite?

    After installing Yosemite there was a big change in performance for all actions on my computer. Start up, basic actions around the desktop and all applications are going considerably slower - slower than they ever have with my computer. I've changed

  • Drop shadow issue in Distiller 9.0

    InDesign CS4 has 2-color title, which has Pantone Orange (spot color) and Black (Process Color). The design has two objects, first object has set as Pantone and second object has set as Black on top of the Pantone object and it has Drop shadow too. T

  • Certain ondemand channels via Vision box using up ...

    His anyone else experienced this possible flaw with the ondemand service on the BT Vision system. I have found that programs watched via iplayer and any channel4 related content seem to deduct usage from my monthly broadband allowance. I have only re

  • Orange UK website

    Has anyone had any luck accessing their current usage on the Orange website. I have one of their plans and would like to monitor my usage to avoid paying excess charges. The website has links to current usage which do not show any data having been us

  • How to install Sony audio player to play video on Sony tv over thunderbolt connection?

    When I play movies via thunderbolt connection to my Sony tv the audio won't play over the tv speakers.