LAVA Forums Buy cool LAVA gear Forums RSS Feed

Welcome Guest ( Log In | Register )

> Related links

Visit the LabVIEW Wiki Application Design & Architecture Portal


Tags
(This content has not been tagged yet)
 
Reply to this topic Start new topic
> Simon Says Game written in State Machine Architecture
JackHamilton
post Aug 22 2003, 01:25 AM
Post #1


Very Active
***

Member
Posts: 124
Joined: 17-January 03
From: Southern California
Member No.: 37
Using LabVIEW Since:1988
LV:8.0.1 ,. ,.
United States United Kingdom Nothing Selected


Don,

Attached is the Simple Simon game I showed at the LAVA User Group at NI Week. It employs 'Large Code Architecture' features to demonstrate how even a small application can be written with this structure.

I use what I call a "Mono-Cluster State Machine" where there is only one data shift register which passes a Type Def 'Mono-Cluster'. This allows all cases on the State Machine to have access to all the parameters. It also allows you to write very 'pretty' code in that you can resolve each case into one VI - passing the cluster in & out.

The code is pretty efficient:
1. The sound is generated in only state and is triggered via Queue communication between Simon and the User Console.
2. There is very little usage of local and NO Global variable usage.


Another great strenght of this architecture is you break funtions into logical blocks - making it easier to code (smaller tasks to work on).
>Easier to test - you can pass parameters into it's input cluster.
>Less likely to break other parts of the code when implementing changes- because you be working on a single peice of code not a VI buried in a huge loop.

I simply love the Queue-Driven State Machine. I had a 1 year software development project that near the end the client wanted to control in Visual Basic. We decided to link the code using TCP/IP. It took me about 2+ hours to modify the code to accepts commands and allow full control of the software via TCP/IP - because my architecture was already built on a String based command;argument structure. I dropped an addtional TCP/IP link & poll state in the code and handed him my command manual and voila!

PS: the Simple Simon game was written at the request of a potential client who wanted to see a sample of coding style. It took me about 3+ hours to write and I think it is a marvelous way to assess coding style.
Attached File(s)
Attached File  Simon_Says_Game_N1.zip ( 341.71K ) Number of downloads: 519
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Ad
post Aug 22 2003, 01:25 AM
Post #















Tags
(This content has not been tagged yet)
Go to the top of the page
Quote Post
donroth
post Aug 23 2003, 08:15 PM
Post #2


More Active
**

Member
Posts: 30
Joined: 12-June 03
Member No.: 115
Using LabVIEW Since:1993
LV:8.20 ,8.0 ,8.20
Nothing Selected Nothing Selected Nothing Selected


Hi Jack:

The architecture looks very elegant and by virtue of the fact that you require action every 50 msec, you have shown a nice way to use the event structure while still polling as well as using the event structure just to handle user interface events.

With the event structure in LV7 and user events, a number of other possibilties for architectures become available. I was able to add my NI_week slides by zipping up the file rather than sending as .llb in case anyone wants to see how I used the event structure with user events to create a nested tab control example using only the event structure and with no polling.

Also, FYI, your .llb did not contain the .wav files so actually playing the game was a little difficult (kept asking to find the sounds directory).

Sincerely,

Don


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
JackHamilton
post Aug 23 2003, 11:29 PM
Post #3


Very Active
***

Member
Posts: 124
Joined: 17-January 03
From: Southern California
Member No.: 37
Using LabVIEW Since:1988
LV:8.0.1 ,. ,.
United States United Kingdom Nothing Selected


Don

:huh: Oops! Attached is the llb with the sound files.
Attached File(s)
Attached File  Simon_Says_Game_HD.zip ( 439.58K ) Number of downloads: 311
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
JackHamilton
post Dec 9 2003, 04:18 PM
Post #4


Very Active
***

Member
Posts: 124
Joined: 17-January 03
From: Southern California
Member No.: 37
Using LabVIEW Since:1988
LV:8.0.1 ,. ,.
United States United Kingdom Nothing Selected


oops.gif Oops! The Simple Simon State Machine game requires this sound file directory. This file is attached. Jack Hamilton
Attached File(s)
Attached File  sounds.zip ( 103.35K ) Number of downloads: 263
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
Michael_Aivaliot...
post Jan 3 2004, 05:40 AM
Post #5


Confucius say: Crowded elevator always smell different to midget
Group Icon
*****

Admin
Posts: 2363
Joined: 13-October 02
From: Planet Earth
Member No.: 2
Using LabVIEW Since:1994
LV:8.5 ,8.2.1 ,7.1.1
Greece Canada United States My Blog My Gallery


QUOTE (donroth @ Aug 23 2003, 03:15 PM)
With the event structure in LV7 and user events, a number of other possibilties for architectures become available.  I was able to add my NI_week slides by zipping up the file rather than sending as .llb in case anyone wants to see how I used the event structure with user events to create a nested tab control example using only the event structure and with no polling.

Don,

Could you re-post the attachment called "NI week interface slides lv7.zip"?
While upgrading the forums I discovered that this file was not uploaded properly and was in fact blank! sad.gif

--------------------


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
donroth
post Jan 5 2004, 02:44 PM
Post #6


More Active
**

Member
Posts: 30
Joined: 12-June 03
Member No.: 115
Using LabVIEW Since:1993
LV:8.20 ,8.0 ,8.20
Nothing Selected Nothing Selected Nothing Selected


Will do but I am out on leave and will get to this at the end of the week....

I remember having problems posting it and had to do it several times; I thought the last time it showed up properly. If I can't get it to post properly, I will just email it to you and let you do it.

Sincerely,

Don


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post
donroth
post Jan 8 2004, 07:53 PM
Post #7


More Active
**

Member
Posts: 30
Joined: 12-June 03
Member No.: 115
Using LabVIEW Since:1993
LV:8.20 ,8.0 ,8.20
Nothing Selected Nothing Selected Nothing Selected


I am reposting the attachment showing how to use event structure to create nested tab control architecture.

Don
Attached File(s)
Attached File  NI_week_interface_slides_LV7.zip ( 955.43K ) Number of downloads: 333
 


Tags
(This content has not been tagged yet)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

 




Time is now: 22nd November 2008 - 05:22 AM