Jump to content

ShaunR

Members
  • Posts

    4,849
  • Joined

  • Days Won

    292

Posts posted by ShaunR

  1. Many moons ago I wrote some code where (I thought) this sort of construct did not reliably work. I had to separate one property node into multiple nodes and access them sequentially to get them to always execute in the right order.

    Was I imagining things? Does LV automatically execute property nodes in the same top-to-bottom order all the time? If so, it would definitely save me some screen space.

    Cat

    Yes.

    The node executes each property in order from top to bottom.

    http://zone.ni.com/reference/en-XX/help/371361E-01/glang/property_node/

  2. The rest: nonsense.

    :P

    A procedural state machine (PSM) doesn't break dataflow (certainly not the way locals, globals, refs and property nodes do). A PSM does allow much more flexibility over how the dataflow occurs, and that admittedly does increase complexity.

    I would disagree. The premis behind dataflow is that the change in value in one variable will cause a cascaded re-calculation in others. In a state machine, the change in value is dependent on "which" states and the "order" of the states that it passes through before another value is re-calculated. Whilst you may argue that "which" states is equivelent to the wired vis, with wired vis, the order is fixed by the wires and a value can only be modified by passing through a vi. The state machine releases you from the ordering restraint enabling branching backwards against dataflow.

    However, saying there are too many states is like saying something is "too pink": purely stylistic. After all, changing the structure of well written code doesn't result in any less code, or necessarily any more readability. Particularly where decision making is involved.

    Well. If you had ever worked for a defence company or a large corperation then there is only 1 "pink" and it has a specific RGB value.:D

    Better criteria for state machines: Are the states well factored? Single responsibility? Grouped by purpose?Well named and well commented? Is the code properly contained in sub-vi's for re-use? Are the states given some forethought, or just thrown out as they occurred to the developer? Can you shoot yourself in the foot by calling them in the wrong order?

    I would proffer that most of that is just good engineering principles. Although I'm not sure how you "group by purpose" a case statement :blink:

    The only time I've had difficulty with errors in PSM's is when they're interacting asynchronously with each other.

    I'm still not particularly convinced that deep hierarchies have anything to offer besides complexity and brittleness. Do you happen to know any good references on the subject (seriously :))?

    Not off-hand. I was brought up in a formal design environment so it became aparent to me very early on that LV was very appropriate for "top down" and "bottom up design". Those methodologies naturally yield "deep" hierarchical structure.

    Coding in C... nah, too harsh. Coding in Python is closer.

    Joe Z.

    I don't know python so can't really comment (9 languages is enough my for tiny brain :P )

    Um, I know plenty of them. That's what a state transistion diagram is for, and we use them.

    Amen! :beer_mug:

    I don't like that you're suggesting that the second implementation isn't dataflow - unless you've got some hidden references, globals, etc then it *is* dataflow - you're using shift registers.

    I *think* what you're argueing is that having your subVIs flat on a diagram is more intuative than a sequence machine (definition already exaplained by others in this thread), which I cautiously agree with. It makes little sense to use a state machine in this case, and I don't think there's much arguement there.

    Indeed.

    It was a rather a feeble example, since each state would only have 1 vi in it (but thats because of the hierarchal design). But it was more to demonstrate readablility.

    I did try (miserably by the sounds of it) to make that clear by saying "The readablilty issue is clear" ;). But the point was that a state machines readability suffers from the same issues as stacked sequences.

    What is your definition of dataflow? I don't think that just because shift registers are used makes it any more "dataflow" than using an "object" makes a program "object orientated".

  3. Hi Shaun,

    I'm not sure if I cought your problem right and I don't know the Passa Mak project.

    But what about some mechanism like this one in the screenshot?

    Implementsome little standard components in all the VIs which should besupported by the Passa Mak thing. Produce events with changing a value(which represents a Q name for sending information back) and receivethe according menu reference from the VIs.

    Any other solution without any extra code in (Main)VIs would be better. But I have no idea for such an improved way.

    Regards,

    Frank

    Its a good idea, but it requires special code in the users vi for everyvi. Passa Mak is a tranlsation tool that can be pointed to your projectand it will create spreadsheet format files for translations. These canbe dynamically loaded at run-time to change languages. Currently (fromthe users point of view) its a single vi that you plonk of the subdiagram and give it a translation name and it will dynamically changethe language of all controls and indicators you wish to translate. Theonly code you need to add is the vi and a text string (translationname) to one vi and it will change all that are loaded. This means itcan easily be retrofitted to existing code as well as new code.

    Idon't have a solution to get you the menu reference, but to get themenu items you could do like this (and I guess you have done somethingsimilar).

    post-5958-125733718385_thumb.png

    GetMenuItems.vi

    /J

    Indeed. The current implementation is very similar. Like I said..."It 'aint pretty" :P One issue you run into is that the vi you load the menu into needs to be visible which isn't very slick. You can get round that by putting it off screen but its all very messy and quite slow. I was kind-a hoping that there was a way to get the menu ref without resorting to file manipulation so everything could be in-place.

  4. A state machine "should" (with a captial SH) be used to allow branching and "break" dataflow, not enforce it (dataflow does that implicitly). And you "SHould" only break dataflowas a last resort (it is after all LV biggest asset). A sequential statemachine is no different from a stacked sequence (in fact it is worse since it is more complicated). A procedural state machine not only flattens the hierarchy reducing abstraction and code re-use. It also hides functionality (making reading more difficult), is more difficult to debug and prone to transitional errors. Used sparingly, it is a powerful tool. Used excessively, well, you might as well write C.

    With the exception of message handlers, I've yet to come accross a state machine that requires more than 10 states. I have however seen many with 30+. (In fact, the last time I saw that many I made him re-write it in 5....lol)

    The readablilty issue is clear (as it applies to stacked sequences).

    Here is a dataflow implementation:

    Same thing written as a state machine:

    • Like 1
  5. I've just added menu support for Passa Mak. It works fine, but it 'aint pretty. The main reason being I can't find a way to get a top level vis menu reference. The menu seems to be the only FP functionality that doesn't have a reference thats exposed. Theres the vi menu ref (that only works within the current vi) and you can get it in an event structure (but can't programtically generate the event to execute the case). Anyone have any ideas?

  6. When I chimed in on the QD-SM, I was referring to the JKI String-Based Queued State Machine. I'm not sure how to avoid having many states if my ATE performs many functions using many devices. One thing I'm avoiding (like the plague H1N1 FUD virus) is making one state perform multiple functions. Each state does one thing and I call it wherever I need that function (using Macros). This results in a long list. What else can I do? However, I must say, that the CaseSelect RCF plugin makes it a piece of cake.

    Jim

    PS - Ben, I've read enough of your posts to put the best possible construction on anything you write. :thumbup1:

    The JKI State Machine Plugin........

    The quickest way to turn a dataflow language into a procedural one :P

  7. Congrats ShaunR! At this rate you'll catch crelf by the spring. :yes:

    Gary

    Ta very muchly :)

    You are averaging 2 per day. Shaun's at 2.4. If I wasn't so lazy, I could write a VI to predict when he'll surpass you. Or I could be like a textbook author and just state that the exercise is left to the reader.

    EDIT: To whomever is currently writing this VI (I'm sure someone must be), we'll all be really impressed if it automatically updates based on current post count and post rate :worshippy:

    I doubt it would be that soon. I'm off on holiday for quite a while soon:) And I've lost my momentum now I know I can't change my title at 500 :P

  8. The subtle one.

    So subtle, I never saw it before :P

    To be fair, the term "pun" isn't really accurate in this case, but I think it should be fairly obvious from the context of my previous post if you look in the right place.

    Indeed. I don't think a speech impedement qualifies as a "pun" :)

  9. Hmmm.

    I've rewritten this post several times now, because there are so many aspects to what you are trying to acheive, I don't know where to start!. :blink:

    The first point that strikes me is that you are a victim of your own success. You have made yourself a "keyman" - an indispensible resource without whom projects cannot succeed. Whilst this is desirable from a job security point of view, when successful, you inevitably run out of resource (you). You obviously realise this and take the next logical decision to obtain more resource. so far so good. :thumbup1:

    So you have identified some more resource.....students :D They will make the bits you need to make the projects. Sounds good, but is it?

    If it were a sub-contract software house or highly skilled, experienced engineering team, then yes, it would work since they know thier onoins and you can decide the granularity of the sub-components dependent on how much you want (or how much time you have) to be involved in the detail. Effectively, you would be recinding your "keyman" status and moving from a sole "deveoper" to a "team leader/manager". You could distribute small functions right up to complete applications dependent on your loading all under the watchful eye of your experience. and guide the project through to completion.

    But you have students (lots of 'ology' students at that, by the sounds of it). Inexperienced, un-trained, possibly un-receptive but none-the less cheap :P In addition to deveoping the projects, you will also have to teach, correct and probably re-write a whole shedload of code adding to your loading rather than alleviating it. Effectively you are still the "keyman". You have relinquished a bit of the boring stuff that would take you 1 day, in exchange for using resource that will use (say) 5 days of training, 2 days of correcting and a further day to write it the way it should have been :D Sure in 3 months time, they might (if thay stick at it) actually be contributing usefully to your project, but you didn't have enough time for one day to begin with.:(

    So is it a hopeless cause? Should we never train anyone because its always easier to do it ourselves? Not even close! We have access to resource :yes: And we can always use resource :P We just have to be intelligent about where we get it and how we use it........even if it means losing our "keyman" status".

    It sounds to me like you are making the transition from deveoper to manager (whether you like it or not), but can't quite let go. I can understand why, because you are the only expertise and a student is never going to be able to do what you do in the limited time available. And although this maybe true, maybe its not necessarily the coding you need to offload first, but the training. A few, cherry picked individuals, the chosen few (we used to call them "Prefects" at school) with an aptitude and eagerness for programming that can impart thier knowledge to lesser mortals and answer the inevitable time wasting questions so you don't have to. It means your time is well spent in training (they want to learn and are pretty good at it) and you can offload more and more of your key skills (well, always keep one or two, eh? :) ) whilst still delivering projects in the interim.

    If I'm barking up the wrong tree, I'm sure you'll let me know. I have a few further ideas if its worth persuing this direction.

  10. Yep - you can customize your text once you get to 1000:

    post-181-125692704619_thumb.png

    I've updated the post to reflect the correct number.

    Yep - we usually change it based on how many posts you've made - when you get to around 98% of the target, we double the target. So, all you need to do is post enough to get through that last 2% *really* quickly and you'll beat us to it :D

    Many thanks. That list might be worth pinning.

    Now, wheres my PHP editor so that I can write a Post Daemon :P One reply to all posts might just do it.

    Ooooh. Did I write that out loud :D:oops:

  11. Without getting into gradients, this is a quick and dirty example of extracting data over a threshold level directly into a 2D array, where each row represents each waveform above the threshold. Because LV uses square arrays, when you process each row, you will have to truncate the data where the zeros start.

  12. Hmmm, I see some advantages to using references, but I'm not sure how you use this to get a multi-column listbox to word wrap. How do you get the reference to a particular cell?

    Bruce

    You would have to coerce the refnum to a more specific class to make the properties for that type available.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.