Jump to content


Photo
- - - - -

state machines with very many states


  • Please log in to reply
65 replies to this topic

#1 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 16 July 2009 - 04:39 PM

*
POPULAR

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.

Attached Files


Edited by jcarmody, 22 July 2009 - 12:30 PM.

Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#2 Jim Kring

Jim Kring

    packages everywhere!

  • JKI
  • 1,901 posts
  • Location:Lafayette, CA
  • Version:LabVIEW 2011
  • Since:1995

Posted 16 July 2009 - 09:30 PM

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:

1.png

Cheers,

-Jim

#3 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 17 July 2009 - 10:28 AM

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.)

Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#4 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 17 July 2009 - 12:29 PM

*
POPULAR

I've updated this with Jim's input, changed the way it closes and set the array indicator to resize with the panel.

Attached Files


Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#5 Jim Kring

Jim Kring

    packages everywhere!

  • JKI
  • 1,901 posts
  • Location:Lafayette, CA
  • Version:LabVIEW 2011
  • Since:1995

Posted 18 July 2009 - 04:09 AM

Thank you. My next step is to make this into a RCF plug-in.


Cool! Let me know if you need any help.

#6 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 20 July 2009 - 08:05 PM

*
POPULAR

[...] My next step is to make this into a RCF plug-in.


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

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?

Attached Files


Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#7 François Normandin

François Normandin

    Son of Scotland

  • Premium Member
  • 1,081 posts
  • Location:Montréal, QC
  • Version:LabVIEW 2012
  • Since:1999

Posted 20 July 2009 - 08:41 PM

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?

François [frɑ̃swa], CLA


#8 Jim Kring

Jim Kring

    packages everywhere!

  • JKI
  • 1,901 posts
  • Location:Lafayette, CA
  • Version:LabVIEW 2011
  • Since:1995

Posted 20 July 2009 - 09:31 PM

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.

#9 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 20 July 2009 - 10:01 PM

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.

Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#10 François Normandin

François Normandin

    Son of Scotland

  • Premium Member
  • 1,081 posts
  • Location:Montréal, QC
  • Version:LabVIEW 2012
  • Since:1999

Posted 20 July 2009 - 10:21 PM

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


Looking forward to it.

François [frɑ̃swa], CLA


#11 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 20 July 2009 - 10:23 PM

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...)

Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#12 François Normandin

François Normandin

    Son of Scotland

  • Premium Member
  • 1,081 posts
  • Location:Montréal, QC
  • Version:LabVIEW 2012
  • Since:1999

Posted 20 July 2009 - 10:39 PM

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...)


That would be called a "cedilla". It softens the "c" into an "s".
No offense taken if you don't put it... ;)

François [frɑ̃swa], CLA


#13 Jim Kring

Jim Kring

    packages everywhere!

  • JKI
  • 1,901 posts
  • Location:Lafayette, CA
  • Version:LabVIEW 2011
  • Since:1995

Posted 20 July 2009 - 10:41 PM

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.

#14 Michael Aivaliotis

Michael Aivaliotis

    MindFreak

  • JKI
  • 2,662 posts
  • Version:LabVIEW 2012
  • Since:1994

Posted 21 July 2009 - 09:02 AM

You can also submit it to the VI Scripting code repository.
Thank You
Michael Aivaliotis

VI Shots

#15 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 21 July 2009 - 10:50 AM

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...

Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#16 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 21 July 2009 - 03:28 PM

*
POPULAR

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.

Attached Files


Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#17 François Normandin

François Normandin

    Son of Scotland

  • Premium Member
  • 1,081 posts
  • Location:Montréal, QC
  • Version:LabVIEW 2012
  • Since:1999

Posted 21 July 2009 - 03:38 PM

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!

François [frɑ̃swa], CLA


#18 Jim Kring

Jim Kring

    packages everywhere!

  • JKI
  • 1,901 posts
  • Location:Lafayette, CA
  • Version:LabVIEW 2011
  • Since:1995

Posted 21 July 2009 - 04:36 PM

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,

#19 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 787 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 22 July 2009 - 12:19 PM

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!

Attached Files


Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#20 Antoine Châlons

Antoine Châlons

    The 500 club

  • Members
  • PipPipPipPipPip
  • 589 posts
  • Location:France
  • Version:LabVIEW 2012
  • Since:1999

Posted 22 July 2009 - 12:50 PM

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.


Hey, that's really cool, I love this tool! :thumbup1:

____________________________
most boring end of the world ever!