Saving string array in Standard State Machine.

I use a Standard State Machine to control a laser unit with multiple lasers. When I give the unit a command, it gives me much information back. When LabVIEW is reading this information, it is putting it in a string array.
But the program shows only the information in the array when I enable 'Highlight Execution'.  What do I have to do to solve this problem?
Thanks for all commands,
Bjorn
Attachments:
StandardStateMachine 1.vi ‏26 KB
statemachine.ctl ‏5 KB

Does your device use a termination charcter at the end of each transmission?  You are already set up to use 0xA as a termination character (default on the Configure Serial Port).  If so, do not do the big mess with the checking of bytes at port and what not.  Just use a VISA Read with a very large number for the bytes to read.  The read will complete when that termination character is reached.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • 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

  • Saving String-Array in mySQL DB

    Hello.
    How can I save an dynamic array in a DB, without looping over
    the content.
    I think serialization is the key word. Can anybody give me
    further information, pls?
    Thx an lot.
    Regards, Philipp

    I am working with 3-dimensional string arrays, which have
    differet sizes.
    I think enum-Cols can't solve my problem.

  • 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

  • Producer consumer vs state machine

    Hi there,
    I have been on and around for quite a while to understand how can I re-design an application, which was originally built using a mix of sequence structure, while loops and event structures. And now I am making a newer version of the same application, for research purposes, while learning the LabVIEW techniques. Earlier I used LabVIEW versions 5 and 6 to make simple programs for fuzzy logic and neural networks. And that's not a good reference.
    Ok, after learning that Producer Consumer (PC) and Standard State Machines (SSM or SM) are two new approaches for a better (scalable, flexible and efficient) coding as suggest by veterans, in one thread where I asked about another issue, I have started digging into this topic and now I am on a point where I have to implement it finally (spent pretty much time in the learning phase).
    I have several questions.
    To start the discussion, I would give a brief description of my application.
    It's a networked application, where the network communication happens using DataSocket (one reason to use LabVIEW as the environment).
    We are talking about the client application, which communicates with other applications on remote computer, via Internet.
    User interface involves a tab control, with several pages-
    On startup, the controls/indicators (now onwards referred as controls only), are initialized, datasocket connection is checked (rather internet is checked, and a connection established with the remote datasocket server) (page 1)
    If connected to the datasocket server, the user selects Login/Registration (page 2)
    Login and/or Registration happen on page 3/4
    Then the user sees a table of remote users to connect to (page 5)
    Upon selection of a remote user, and after clicking on "connect", the user will see a video indicator, with a lot of other controls. (page 6)
    On this page with video indicator and controls, the user has a lot of activities, in which many messages are sent and received to/from the remote machine.
    the user may disconnect and go back to page 5, and log out and go back to page 2 and so on.
    I hope this is clear.
    I have thought about two different ways to do this application. Using PS or by SSM.
    In the attachments, I have given a diagram (with errors, of course, because of unlinked controls), for each of the approach, plus the original application's diagram.
    I hope this is sufficient for anybody to understand my case and give suggestions.
    I am looking for suggestions about which is a better model for my type of case. I have been to discussions like this one and saw that there are many issues regarding dequeue in PC model. So I am curious to know if SSM is a better and latest model or it's more primitive? Which looks better for my application's performance?
    Thanks ahead!
    Vaibhav
    Attachments:
    OldDesign.vi ‏41 KB
    PCDesign.vi ‏42 KB
    SSMDesign.vi ‏46 KB

    Vaibhav wrote:
    @ Harold
    Thanks. Any suggestion how can I start and stop that loop in parallel with other loops? Like, if some event occurs, the loop should start execution, and keep on moving, while other events are being traced and executed.
    In those examples where you had a while loop inside a case structure, that bit of code will only execute one time.  It will immediately read the boolean at the start of the program, if the value was true before the porgram started, then the while loop will run.  Once that while loop stops, the case structure will end.  It will never execute again unless you completely stop and restart your program.  If the boolean is false before the program starts, the false case will execute immediately.  Nothing happens since it is empty and it is done, never to run again (unless you stop and restart your VI)  You should turn the structure around.  Put the case structure in the while loop.  Make sure you put a small wait statement in the loop so that it doesn't run full speed eating up CPU cycles just polling the status of the boolean.
    @ Ravens
    Thanks for the detailed comment.
    One thing I would clarify. The user will not be able to switch between the pages using the tab control. The program will direct appropriate page to the user. I kept the tabs visible just for your idea of the pages. Sorry, I didn't mention that.
    Do you think it's still a bad design?
    If the tabs will be hidden or disabled, you will probably be okay.  I wouldn't call it a bad design.  I wouldn't do it that way.  But as long as you understand the possibility of problems and prevent that.  Especially some time down the road when you modify the program in some other way that could lead to a problem because you forgot about the dependencies of the event structures on the state of the state machine. 
    Yes, I agree about only one event structure to handle all the events. But since the user will not be able to click somewhere else, other than those possible controls, I thought to keep it like this.
    I thought the events are captured only if we are in that case. I think I am wrong, right? Events are captured at any time, even if the case has never executed before, or will never execute.  Ok, The events will be captured, but will not be executed until in that case.
    And that's the reason why I have two separate event structures, in two separate phases of the program.
    Because, prior to page 6, the events will occur sequencially. The user will click somewhere, then some message will be transmitted over DataSocket, then some message may come , then again some user action and so on. But, when the user starts using page 6, there will be parallel process of user controls events and actions, and incoming messages and corresponding actions. For this, in the page 6, I need a different kind of execution. So I separated the two event structures.
    At first I thought to have SSM, and then I thought to PC, just because I can have two separate parallel processes - one for user events, and another for messages (because that way I can take maximum advantage of message tracking). But looking at other complexities, I find SSM more appropriate. Can you please tell me how can I have my message loop and events loop parallel to each other and just one event structure?
    You can have a dequeue function in your state machine loop and have it be a consumer loop.  Use a timeout on the Dequeue.  If there is a timeout, have the statemachine execute normally after that perhaps just passing the enum wire straight into the case structure of the state machine.  If it doesn't timeout meaning you got a message, then look at the message that is dequeued and act on it.  Perhaps it means ignoring the enum coming in from the shift register and changing the enum to something else to feed into the case structure of the state machine.  Attached is an example
    Attachments:
    PCDesign[1]_BD.png ‏6 KB

  • Need help created state machine with timed digital output

    Hello everyone I'm new in LabView especially about how to make a state machine. I want to make simulation about state machine with digital output. In Front Panel there are volt_in as an input slider (0-10 V), two numeric control (upper limit and bottom limit), a waveform chart to plot those 3 value, and three boolean (P0.0, P0.1, P0.2) as an indicator. Boolean indicator will on if input from slider exceed the limit in certain situation. This simulation will work as follow:
    1. Define the upper & bottom limit (ex. 8 & 4V)
    2. Make an input from slider (0-10V)
    3. If input (2) exceed the upper limit but less than 10 second (ex. you have 9V input for 8 second, but after 8 second you change the slider back to normal between 4-8V) then the boolean indicator P0.0 & P0.2 will stay off
    4. If input (2) exceed the upper limit more than 10 second (ex. you have 9V input for 4 second, change to 8.5 V for 3 second, and then change to 10V for 3 second) then the boolean indicator P0.0 will turn on for 5 second, turn off, then follow by indicator P0.2 for 5 second, and turn off
    5. Wait 15 second, then repeat process from (2)
    Same process for input that exceed the bottom limit (P0.1 and P0.2 as indicator).
    Can you help me make the block diagram of this process? I will appreciate any of your help.
    Best Regards
    juventom 
    Attachments:
    State Machine Digital Output.vi ‏28 KB

    I would highly recommend you to open the template in LabVIEW to design state machines. You can the Standard State Machine template if you go to File -> New.. and Browse to VI -> From Template -> Frameworks -> Design Patterns.
    Also, here is a good explanation of one:
    https://decibel.ni.com/content/groups/northeast-oh-labview-users/blog/2009/09/08/state-machines
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • 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

  • 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

  • An example of a state machine with transition array?

    I am looking at state machine design patterns and am interested particularly in a state machine with boolean trasition array which defines the next state to be executed using an array. Here, the index of the first “True” boolean in the boolean array corresponds to the index of the new state in the array of enums. Has anyone got an example of this design pattern as it would greatly help in my understanding of it. Refer to figure 3c in http://zone.ni.com/devzone/cda/tut/p/id/3024#toc2 for clarity on what i am asking for.
    Thanks in advance.

    That seems like a lot of extra work. Why not just use a queue, and queue up the enum you want to go to next? Look up examples on queued state machine. No need for an array and then a boolean to index that array. here is an example
    CLA, LabVIEW Versions 2010-2013

  • Producer Consumer with a state machine within the consumer

        Hi All,
    I have been trying to develop a data acquisition system with the producer consumer architecture.  To the left of the two main loops I initialize the serial port and any constants and variables im using.  I also have an obtain queue VI needed for enqueue and dequeue. Then in the producer loop i have a state machine.  The first state is where I wait for a button press on the front panel to write a GO signal on the serial line which will tell the device connected to the serial port to begin sampling data.  After this button press I go into the next state which is called my read state.
    In the read state I use a property node to read all of the available bytes at the serial port and then enqueue this collected data into a queue.  The state machine then is directed to continously go to the read state again and collect more data.
    Now this is where my dilemma is......  The consumer loop has the dequeue VI inside it and after this VI i have a state machine (while loop and case structure) which contains the following states
    1.  Build Array - build an array from the dequeue element and if there is any left over data from the parsing states it will build an array with the left over data and the dequeued data
    2.  Determine packet type - this state looks for the packet type byte(not necessarily the first byte in the message) and also check the next byte (packet length) to ensure that I am at the begininng of this chunk of data.  This state may be a little slow because there can be three different packet types and based on this byte and the packet length it may have to search the array several time to find the valid starting point.  This state also determine the next state to go to based on the packet type.
    3 packet type 1 parsing - parse data and store the remaining data it leftOver array.  Go to exit state.
    4 packet type 2 parsing - "" ""
    5 packet type 3 parsing - "" ""
    6 exit - leave this state machine and fall back to the consumer while loop.
    After it exit I think it should fall back to the consumer while loop and dequeue more data and enter the state machine again to build a new array with the dequeued data and leftover data.  It seems to work when I trace the execution using the Highlight execution feature, however when I run this all at full speed, it seems to go into the consumers 1st and 2nd states back and forth and not completely go through the state machine.
    I tried adding in a delay in the producer loop to give the consumer loop time, but I didnt notice any difference.  Is it possible that my dequeue element is retreiving more data while im still in the state machine, causing the execution to leave the state machine before it finished all states?
    Is there a better approach to take to solve this problem. Basically I need to read data at a 1,000,000 baudrate and parse it as quickly as possible so that I can break it up into 3 different packet types, write the data to a file, and graph the actual data (header info removed) in realtime.  I need to also ensure that I am not losing any of the collected data.  Data loss cannnot occur.

    A couple of things more to go along with Ben's pointers:
    You convert your data from a string, to a U8 array, to a Hex string array in the producer loop, then convert back to a integer to determine what to do with it.  In the process, you create two or three copies of your data, slowing yourself down quite a bit.  The code would be quite a bit more efficient if you left the data as a U8 array.  You can change the format of the controls and indicators to show hex values instead of integer by right clicking on them and selecting Format and Precision...
    Your search code is fairly inefficient.  I made a whack at making it a bit better.  See attachment below.
    If you continue to run into race conditions, you can debug them using a calls to the Windows debug write sprinkled liberally about your code.  Check out the post here for more information.
    Don't let your lack of format LabVIEW training stop you.  The biggest thing to get is the data flow paradigm (aka data is wires, not registers).  Once you get past that and learn how to pass data around using shift registers, queues, events, etc, you are most of the way to mastering LabVIEW.  The rest is just learning the plethora of functionality LabVIEW gives you (yes, I have reimplemented LabVIEW native code more than once in the process of learning).
    Let us know if you need more help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    serialUtil_V3_DFG.zip ‏137 KB

  • Best method for state machine design for multi-dimensional clustered data

    I have an application that is collecting analog tag data(1000 points) and displaying on a graph. In each vi, I may collect data for as many as 32 channels, but only one channel at a time. Usually this is collected in numeric order, but maybe not all the time. I am also saving an "expected profile" to a file for each channel. I display both expected and actual data on the graph and select which channel to view with a ring control. My question is about how to design the state machine for best memory usage/execution speed/... If I use a shift register with a cluster datatype, that holds both 1000 point arrays, some statistical data like max/min/pass/fail/test limits for 32 channels, won't all of the u
    nbundle/bundle functions use a ton of memory??? Right now I am writing the cluster data to memory tags for each channel. I use the ring control to determine which tag to read. I have the tags grouped by channel into several groups for actual data, expected data, results data,... What design methods would provide the best function using a shift register/queues and notifiers/memory tags in the tag engine?? I also use CITADEL to read the max and average as a trend display on each channel and to select a specific 1000 point dataset to view if the max and average are out of limits. Does anyone have similar applications??

    It sounds as if you will be working with alot of data here so I can understand your concerns for memory management. If you were to unbundle and bundle data in your application, you are correct in saying that it will require more memory. It is somewhat difficult to get the overall picture of what you are needing to set up, but from what I can gather, it sounds as if you could have an array of 32 elements; each element a cluster of your data as well as the statistical data, and then you could index through that array to determine what to display on the graph. The shift registers will be reusing the same memory over and over so there should not be a problem there. Queues wouldn't necessarily help you in any way in this situation. Depending on how many memory tag
    s you are using, you could increase the amount of memory usage required by Citadel and the tag engine, but if you are needing to write your cluster data to the database, then there is not much you can do about it. Ultimately it sounds like a pretty involved application and will require a fair amount of memory regardless to ensure smooth functionality.
    In general, questions about the LabVIEW architecture and memory management are typically better answered if they are posted to the general LabVIEW discussion forum area. But I hope that this has addressed some of your concerns. Have a good day.
    Patrick R.

  • Flexible state machine "configuration" (script interpreter?)

    Hi all,
    I am currently re-thinking the implementation of a larger labview project which controls
    an instrument via RT on a CRIO system.
    Since the instrument is constantly improved and new features added to make it more and more
    automated I come to the limits of the current design.
    A quick description:
    The instrument should be capable of taking different kinds of measurements either at
    constant conditions or at conditions that continuously change.
    Before an measurement, the instruments needs to be conditioned, which is a rather complicated
    sequence of valves opened/closed, pumps started/stopped, temperature settings and so on.
    I currently use commands stored in a text file and read into an array of command clusters (enum'ed command + string for parameters)
    to be processed during conditioning.
    Then the user can run another sequence to make a certain kind of measurement.
    This works nicely but is not flexible enough. The conditioning and measurement sequences should be easily 
    editable without making changes to LV code.
    This is one reason I did not yet code this as a state machine, but it is a logical next step to do so.
    States would be idle, conditioning, measurement, re-conditioning ....
    But how do I do this in a most flexible way?
    In the sequences, I sometimes need to check for instrument parameters, and it would be elegant to
    call sub-sequences. I already implemented a looping feature to repeat some commands
    between two positions in the command array several times. But without the possibility to jump
    out of the loop.
    In short, if I continue this way I am about to write an interpreter for a simple scripting language .....
    I know that possibly VeriStand has a lot of this functionality but I am bit hesitant to make
    a big change like this and I am not sure if I can re-use the existing LV code to access and control
    hardware using VeriStand.
    Is there a good/elegant solution to what I intend to do with just LV and without re-inventing the wheel (script interpreter)?
    Olaf

    The most flexible way to implement this would be to use a command pattern and LabVIEW classes.  Using this approach, you core state machine would probably never change and you dynamically add or remove steps as needed.  Take some time to learn how this works by writing a couple of simple examples, then dive in.  It will be easier than you may think.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • State machines caveat

    I have been using the state machine design pattern in programs for a
    while. In this technique, it is a common practice to define boolean
    switches to trigger actions in the next iteration of the machine (eg.
    "TurnLaserON", "Quit", "Compute", "SetAlarm1"...). Thus, the boundary
    between data and processing is easily trespassed.
    This sounds to me like a possible source of errors, that should be
    limited by some design rule of thumb. I tend to believe that boolean
    triggers in state machines should be looked at with the same precautions
    as a "GOTO" control structure.
    Do you have any experience or theoretical frame to enlighten these
    considerations ?
    oz

    Hi,
    I always prefer a state machine with a state buffer. This means, every state
    can, potentially, call several other states. In practice, there is a shift
    register with an array of strings in it. The first string is called, and
    removed. Every state can modify the buffer, so:
    + states can be put before, after or between the buffer
    + states can be removed
    + states can be filtered, sorted etc.
    + buffered states can be copied
    This makes programming with state machines a lot easier. You can simply make
    a state TurnLaserON, and in the calling state(s) diside what the state after
    TurnLaserON has to be. This makes the program a lot clearer.
    Some design rules I use (mainlly because if I don't use them, there is no
    way of documenting the program):
    + states may only put states before the buffer (I call them sub states)
    + buffered states cannot be removed in a state
    Using these rules, I can put the entire program on paper, without any
    problem.
    Still, I have to transfere information between states. This 'information'
    can be a shift register with a bundle, indicators on the front panel (not
    visible to the end user), a GLI, buffers, ini file reference, or whatever. I
    have never found any big advantage or disadvantage for eny of them, but I
    prefer indicators (mixed with buffers when convenient), because they are the
    fastest to use (for me), and easiest to debug (IMO).
    Regards,
    Wiebe.
    "O. Zimmermann" wrote in message
    news:[email protected]...
    >
    > I have been using the state machine design pattern in programs for a
    > while. In this technique, it is a common practice to define boolean
    > switches to trigger actions in the next iteration of the machine (eg.
    > "TurnLaserON", "Quit", "Compute", "SetAlarm1"...). Thus, the boundary
    > between data and processing is easily trespassed.
    >
    > This sounds to me like a possible source of errors, that should be
    > limited by some design rule of thumb. I tend to believe that boolean
    > triggers in state machines should be looked at with the same precautions
    > as a "GOTO" control structure.
    >
    > Do you have any experience or theoretical frame to enlighten these
    > considerations ?
    >
    >
    > oz
    >

  • Any penalty to using one big cluster in a state machine?

    I've been working on a lot of small/medium sized state machines lately, and I've gotten into a habit of putting most of my data (single values, arrays, strings, even LVOOP objects) in one cluster that I pass from state to state with a shift register.  I just unbundle the data I need in each state, work on it, and bundle it back in for the next state.  Part of me says that this is a bad idea - that I should separate the big cluster into a set of smaller clusters that group the data by logical categories.  Another part of me says that if I do it that way, I'm just creating needless clutter on my diagram.
    So my question is simply this - is there any significant performance penalty for using a single cluster rather than multiple clusters in this fashion?  I never run the whole cluster into subVIs, and I never split the main cluster wire, so it doesn't seem like there should be... but I've been wrong before!
    Thanks,
    Jason

    As Norbert mentioned, the answer to your Q is dependant on your data structure. Provided you can do all of your data manipulation "in-place" there should not be any issues. The more complex structures can still be handled "in-place" but you may have to use the in-place operations to achieve this effect. Depending how comfortable you are with those operators, they can complicate the appearence of our code.
    If you can'y do everything "in-plcae" and you have a Super-Cluster, then its time for me to Quote Rolf again when he wrote "Once all of you physical memory is filled up with a single cluster, your application is probably going to suck."
    So lest say you have cleared all of the above hurdles and still want to use a single SR that has all data for all states. I ask you to carefull examine where the app may go in the future and what type of animal it could turn into. if there is even a small chance that app may turn into something that non-computer users will use (requires robust app to prtect itself from dumb users) the single cluster approach is going to get in your way when the app gets big.
    1) If you have to add another field to the cluster, every function that uses that cluster should be re-tested. WE have an app in-house that was developed by our customer and we support. There is an 800+ step proceedure required to re-verify the app!
    2) AS more functionality is added you will add more states to your state machine. Personally, I cringe when I see the support developer have to choose from a list of 300 states when working with the Stae machine.
    3) You will have a hard time re-using code aside from cutting-n-pasting
    4) When you unbundle manipulate and replace, you are in danger of creating duplicate data which will impact performance.
    I never went through the formal IS training but my wife did and she has given me the short version to learn how to normalize a DB. There is actually a science to the process that results in only related items being grouped together and if you take to the full exdtreme of "fully Normalized DB", there absolutely no duplicates of data. For LV apps a Fully Normalized DB adds some overhead so I don't go that far.
    THe following will ignore using an Object Oriented approach and stick with old-school ideas.
    So after I analyze my data structures and group related items together and review who touches what when, THEN I try to wrap-up the data in Action Engines. More often than not, the action will replace some or most of the work done in some states. From your Q it sounds like your "read-mod-replace" constructs can be moved into AEs with little effort.
    Now for OOP
    I'm still learning OO system design but I have found myself "turning my apps inside out" with LVOOP. By this I mean rather than think that the data AND the function are inside the AE, the data is outside and acted on by what is inside the LVOOP methods. I have been amazed at the degree to which LVOOP can operate in-place, but I digress. There is some arguement/design pattern that says that if you have a function like a test that uses other classes, then you can create a class for the test and slam all of the required object into you need.
    Done rambling for now. As usual, if there is anyone out there that want to correct me any of the above, please do so!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • State Machine Demo

    Hi Folks,
    I am a newbiew LabVIEW developer studying & working towards my CLAD certification.
    I already took LabVIEW Basics I & II and I decided to make a simple state machine (please see attached VI).
    I was hopping if there is anyone out there who find a way for the VI be optimized so I can see my weakness.
    ThanX in ADVANCE!!!!!
    Attachments:
    StateSimulatorfromEE428.vi ‏71 KB

    Overly complicated and convoluted is the word.
    I haven't even tried to undestand what you are juggling with all these string operations, but there's gotta be a better way!
    Case 4 and 5 are identical except for a diagram constant. They can be comined into one case.
    "state operation" is a control, but you are constantly writing to it via local variables. This mean it cannot be reliably operated, because the set value could be reset before it is used due to race conditions.
    It is confusing that you replace the "state" of a typical state machine with a "state operation", while the "state" is actually in a string that does not really influnece operation. Whatever you have is not a state machine.
    In state operation=2 you delete from the 2D string array, but later you always seem to iterate over 9 elements (one too many to begin with) in the inner while loop.
    Since the 2D string array can shrink but never grow, you might stop the program once its size reaches zero.
    You write to a local variable in virtually each state, it would be more reasonable to pull this local variable write before the case structure.
    The attached quick modification illustrates some of the above points. This is not a finished or even reasonable program. It would need a complete rewrite.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    StateSimulatorfromEE428MOD.vi ‏64 KB

Maybe you are looking for

  • The year 1942 is MISSING!

    This is an odd bug. With the calendar in view year mode if I scroll back to the 1940s I find that the year 1942 is missing entirely! 1941 is there, 1943 is there but no 1942! Also, years prior to 1941 have no December and the year header is missing.

  • I cant update my display adapters

    hey guys. was on here earlier and someone mentioned to me that i need drivers if i go into device manage, open display adapters, and it says "standard VGA graphics adapter". well it does and that gentalmen seems to have logged and consummed his day w

  • Connecting my iPod to my Car's 30-pin Dock but Being Able to Control It from Within the iPod?

    I have a 5th Generation iPod nano. I own a 2008 VW Eos which has a 30-pin dock. It functions but, my car's UI for iPod is nefastous. I wanted to know if there was a way to control the music within the iPod.

  • IBook G4 into Windows machine

    Hi all, I would like to turn my 2004 iBook G4 (1.33 GHz Power PC G4) into a Windows machine.  It hasn't been my main computer for more than two years, so I'd like to have some other functionality out of it. I know very little about Windows and and Bo

  • How to use a object for both key figure and as a charcteristc

    Dear all, we have a requirement where in we have to use Version Field as a key figure and as well as a charecteristc. Regards venu