CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

GUI event handling architecture

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hellopic



Joined: 21 Feb 2013
Posts: 8

View user's profile Send private message

GUI event handling architecture
PostPosted: Sat Mar 02, 2013 10:18 am     Reply with quote

I am trying to change the structure of the code that someone else has written. It is basically a home automation system with a monochrome graphical GUI. There are over 50+ different screens that the user can cycle through to set and monitor various things. There is also the application logic that does all the behind the scene stuff.

The current architecture is that each gui screen is a case-statement of large switch-block. Within each screen, there is some code that just displays stuff on the LCD and event handling (button presses, request from application logic to change screen etc). The event handling is implemented as a if-statement for each event.

Now, the problem is that some of these events trigger actions that need time to complete and the screen should not be exited before that, which would could leave the system in an indeterminate state. There are a whole bunch of flag-bits that are set and checked in the even handling code and sometimes it does lock-up (race conditions or something like that).

I am thinking, a better way to do it would be a state-machine (switch-block) for handling events in each screen. So case 0 would be the event handler dispatcher(so to speak) and depending on the event, it moves to another state where the event is handled to completion and goes back to handle more events.

The up-side is clean code, correct implementation. The down-side would be that no concurrent handling of slow and fast events. For example, an event may be to just turn on the LED, while the another event may be to analyze log data or something - then the LED event would have to wait which may be perceived as a sluggish gui response.

How are such architectures usually implemented?

Sorry for the long post but thought it could be useful to others as well.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group