Jump to content

state machines with very many states


Recommended Posts

I've developed software for two ATEs with the JKI State Machine and have found myself with very many states to cover all of my requirements. I wasn't comfortable with this at first so I posted a question on the JKI forum. Anyway, I wrote a tool that builds an array of the states (in the last Case Structure selected - it polls and acts if the only selection is a CS). There's a vertical scroll bar to speed up the process of scrolling through the list and double-clicking on any item will bring the corresponding state to the front.

I'm almost satisfied, but there are two things I don't like about it. First, it uses ObjHighlite to bring the case to the front and I don't like having it flash. How else can I do this? Second, the case structure is selected at the end of the process. How can I deselect it?

Thanks,

Jim

Note: don't download/use this file - better stuff is further along this thread.

CaseSelector.vi

Edited by jcarmody
  • Like 2
Link to comment

I've developed software for two ATEs with the JKI State Machine and have found myself with very many states to cover all of my requirements. I wasn't comfortable with this at first so I posted a question on the JKI forum. Anyway, I wrote a tool that builds an array of the states (in the last Case Structure selected - it polls and acts if the only selection is a CS). There's a vertical scroll bar to speed up the process of scrolling through the list and double-clicking on any item will bring the corresponding state to the front.

I'm almost satisfied, but there are two things I don't like about it. First, it uses ObjHighlite to bring the case to the front and I don't like having it flash. How else can I do this? Second, the case structure is selected at the end of the process. How can I deselect it?

Thanks,

Jim

Hi Jim,

You can use the Visible Frame property, as shown below:

post-17-124777975308_thumb.png

Cheers,

-Jim

  • Like 1
Link to comment

Thank you. My next step is to make this into a RCF plug-in. I'd like to take it on this weekend, but I'm getting a PHD today and might not have free time. (In my case, a PHD is a Post Hole Digger - I'm building a fence to keep my chickens from wandering the neighborhood.)

  • Like 1
Link to comment

Here it is. Unzip the contents into [LabVIEW]resourceJKIRCFPluginsCaseSelector

Use: select a Case Structure, apply the RCF Menu Activation Keys, right-click and select CaseSelector. A resizable list will be presented with the selected structure's cases. Select one of the cases, the list will disappear and the selected case will be brought to the front.

I'll certainly use this functionality, but I may prefer to put a VI in the LabVIEW project folder (so I can have the list persist as a floating dialog).

So. Is this anything that you'd use or do I have a unique situation?

Hey Jim,

Great! Thanks for posting this.

This is totally useful. I can think of a couple additional features and usability improvements. For example:

  • How about using a listbox (or tree) instead of a 1D array of strings?
  • The window should be resizable and the list should auto-grow with the window (this might not be possible with 1D array)

PS - JKI has considered creating some "helper tools" for the JKI State Machine. You might even see some demos at/around NIWeek that will BLOW YOUR MIND (I just had my mind blown this morning by some prototype stuff I saw).

Here it is. Unzip the contents into [LabVIEW]\resource\JKI\RCF\Plugins\CaseSelector

Also, I've added this to the List of Community RCF Plugins.

Link to comment

I installed it and got problems. The RCF couldn't be used anymore without restarting it once I used your plugin. I think it doesn't like the continuous monitoring.

How do you use it? Do you have the same problem I've seen?

I had this problem, too, but THOUGHT I had it licked. There's a sub VI that presents the list and waits for a user input it never gets because the Front Panel never shows. I resolved the issue by setting the VI Properties to open & close the front panel as appropriate. It may be that an old copy made it into the zip file; I'll know more tomorrow when I get to the office in the morning (I'm currently restoring my laptop from a series of unfortunate events).

I changed my approach and am not polling as I mentioned in the other thread. This one pulls the first element from the array of selected objects and tests to see if it's a Case Structure. If it is, it sends an array of frame names to the sub VI mentioned above. This has an event structure that waits until you select a state then returns the index to the RCF VI (which sets the VisibleFrame property).

Thanks for trying this. I'll fix it tomorrow, but I think all it needs is the VI Property change.

Link to comment

I can think of a couple additional features and usability improvements. For example:

  • How about using a listbox (or tree) instead of a 1D array of strings?
  • The window should be resizable and the list should auto-grow with the window (this might not be possible with 1D array)
  • I used a Table with only one column visible (because it scrolls with the mouse wheel and the Array indicator didn't). A colleague suggested using a Tree but I didn't know how it would apply to a non-JKI State Machine Case Structure. I'll probably add the functionality to handle both, at least until the rest of the world is converted. This was my first plug-in and I wanted to understand the process before trying to get fancy.
  • The window is resizable w/auto-grow (unless I botched that part of the llb, too).

PS - JKI has considered creating some "helper tools" for the JKI State Machine. You might even see some demos at/around NIWeek that will BLOW YOUR MIND (I just had my mind blown this morning by some prototype stuff I saw).

Alas, but I won't be at NIWeek. Is one of the helper tools, perhaps, the ability to right-click on the queue wire and insert an Add States To Queue? I'm going to do that if nobody else beats me to it. It'd probably be a good exercise for me.

Also, I've added this to the List of Community RCF Plugins.

Cool, thanks. Will I be able to update that when I fix the problem François had? (I had to copy/paste from his signature to get that "c" with the "5" underneath...)

  • Like 1
Link to comment
Is one of the helper tools, perhaps, the ability to right-click on the queue wire and insert an Add States To Queue? I'm going to do that if nobody else beats me to it. It'd probably be a good exercise for me.

Oooh, that's a good one! I don't think that was on our list -- I'll add it, but don't let that stop you from the exercise.

Cool, thanks. Will I be able to update that when I fix the problem François had? (I had to copy/paste from his signature to get that "c" with the "5" underneath...)

Yes, the List of Community RCF Plugins page is configured to allow anyone to edit it. I would also recommend creating a new page in the RCF group, similar to the Build Array of References and Explore plugins pages. There, you can post documentation, a download of the latest version, revision history info, a link to a discussion topic, etc.

Link to comment

I had this problem, too, but THOUGHT I had it licked.

I checked the llb and it looks Ok. There's obviously something wrong, but I haven't figured it out yet. I found another problem to fix - it won't select the first item in the list. I'll keep trying...

Link to comment

Hey Jim,

[...]

  • How about using a listbox (or tree) instead of a 1D array of strings?

I've updated it to use a tree control. It indents states based on the presence of "-------" in the state name (ala JKI State Machine) assuming that these are section headers. Everything between them will be indented from the previous header and structures without this format will be presented without indenting anything. I also made it require a double-click to select a state so it would still be possible to expand/contract sections. The position of the scroll bar is persistent between calls (for the same Case Structure), but all sections are always presented expanded.

CaseSelector.zip

  • Like 2
Link to comment

I've updated it to use a tree control. It indents states based on the presence of "-------" in the state name (ala JKI State Machine) assuming that these are section headers. Everything between them will be indented from the previous header and structures without this format will be presented without indenting anything. I also made it require a double-click to select a state so it would still be possible to expand/contract sections. The position of the scroll bar is persistent between calls (for the same Case Structure), but all sections are always presented expanded.

It works great on my system now. :thumbup1: Nice one!

Link to comment

I've updated it to use a tree control. It indents states based on the presence of "-------" in the state name (ala JKI State Machine) assuming that these are section headers. Everything between them will be indented from the previous header and structures without this format will be presented without indenting anything. I also made it require a double-click to select a state so it would still be possible to expand/contract sections. The position of the scroll bar is persistent between calls (for the same Case Structure), but all sections are always presented expanded.

A very nice improvement! Here are more suggestions:

  • Its window should be set to "floating"
  • It should run as an asynchronous process -- it should not close its front panel after the user double-clicks on a value (you should probably invoke it with the VI.Run method so that it doesn't block the Right-Click Framework)
  • It should allow multiple instances -- make it reentrant so that I can use to work on two Case Structures at the same time.
  • It should make sure that the user actually clicked on a named cell (using the PointToRowColumn method) -- it is currently treating a double-click on the tree node expander ([+]/[-]) as a frame selection.

Cheers,

Link to comment

A very nice improvement! Here are more suggestions:

  • Its window should be set to "floating"
  • It should run as an asynchronous process -- it should not close its front panel after the user double-clicks on a value (you should probably invoke it with the VI.Run method so that it doesn't block the Right-Click Framework)
  • It should allow multiple instances -- make it reentrant so that I can use to work on two Case Structures at the same time.
  • It should make sure that the user actually clicked on a named cell (using the PointToRowColumn method) -- it is currently treating a double-click on the tree node expander ([+]/[-]) as a frame selection.

Cheers,

Done. I've changed from double to single-clicking and I couldn't see how to make the PointToRowColumn do what you suggested, but I've implemented the same effect.

Now, how about some constructive criticism on my coding/style? Please? Thanks!

CaseSelector.zip

  • Like 1
Link to comment

Fixed issue where letting go of the scroll bar inside the tree acts the same as a selection. I didn't like that behavior.

I have a couple of comments:

  • I think that using system controls would look a lot better than 3D control

post-121-124827872653_thumb.png --> post-121-124827889163_thumb.png
  • When you create your custom menu you have:

> CaseSelector : My_Menu_Tag<

  • Instead use this (because the ">" and "<" are only needed if you have SubMenu(s))
CaseSelector : My_Menu_Tag


  • Additionally, it is recommend that you use some meaningful tag, so replace "My_Menu_Tag" by "Case_Selector_Tag" for example.

Otherwise this look pretty good!

PJM

  • Like 2
Link to comment

Fixed issue where letting go of the scroll bar inside the tree acts the same as a selection. I didn't like that behavior.

Hi Jim. Thanks for keeping the new versions coming! I'm sorry for not commenting more on the code. The UI is so much easier and more fun to critique. Along those lines:

* I'd get rid of the big "OK" button -- move it off screen and just let the user press the Close Window button to close the window. This will really stream-line the usability, IMO.

* It would be nice if the vertical scroll bar would auto-hide itself if it is not needed -- there is a VI that can do this automatically for you, but I can't recall off-hand where it is located (somewhere in vi.lib perhaps)

  • Like 1
Link to comment

I have a couple of comments:

  • I think that using system controls would look a lot better than 3D control
  • Instead use this (because the ">" and "<" are only needed if you have SubMenu(s))

CaseSelector : My_Menu_Tag

  • Additionally, it is recommend that you use some meaningful tag, so replace "My_Menu_Tag" by "Case_Selector_Tag" for example.

Done, thanks for the feedback.

* I'd get rid of the big "OK" button

* It would be nice if the vertical scroll bar would auto-hide itself if it is not needed

Done. I had added the OK button because I had always considered it bad practice to stop your program that way; it wasn't in the early versions. I agree though, it is nicer without it.

CaseSelector.zip

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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