Editing GreenHouse Monitor Program

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 100: Line 100:
 
Now a complexity of the application is that it is running in 2 different threads.  When the application starts up it has a single thread that after a bit of time creates the gui and runs its main method.  I call that the GUI thread.  The GUI thread starts another thread, ( the class SmartTerminalHelper ) which has its own methods and attributes.  In a multi threaded application you have to be careful what calls what.  Calls between the threads are particularly tricky once both are running.  For the more difficult issues of this type communication between the threads is managed by pushing data into queues which are thread safe and allow the threads to communicate safely with each other.  All this is in the code.  The GHCSVProcessing class is a bit complicated since parts of it run in one thread, parts in the other.  How do you tell what is what.  There are two ways one is to reason it out, one is to read the comments, this discussion should help. Init is called from the GUI thread which is the one that is "in charge" of the application.  It also calls __add_gui__ which since it adds to the GUI will create objects that are also executed in the GUI thread.  All the functions in the class are commented so you know what class they should be called from ( run in )
 
Now a complexity of the application is that it is running in 2 different threads.  When the application starts up it has a single thread that after a bit of time creates the gui and runs its main method.  I call that the GUI thread.  The GUI thread starts another thread, ( the class SmartTerminalHelper ) which has its own methods and attributes.  In a multi threaded application you have to be careful what calls what.  Calls between the threads are particularly tricky once both are running.  For the more difficult issues of this type communication between the threads is managed by pushing data into queues which are thread safe and allow the threads to communicate safely with each other.  All this is in the code.  The GHCSVProcessing class is a bit complicated since parts of it run in one thread, parts in the other.  How do you tell what is what.  There are two ways one is to reason it out, one is to read the comments, this discussion should help. Init is called from the GUI thread which is the one that is "in charge" of the application.  It also calls __add_gui__ which since it adds to the GUI will create objects that are also executed in the GUI thread.  All the functions in the class are commented so you know what class they should be called from ( run in )
  
==== Additional Functions that Run in the GIU ====
+
==== Additional Functions Run in the GIU ====
 
Both of these are call back function called from the GUI we have created in add_gui, so they run in the GUI thread.  However both want to call functions in the helper thread.  There code is very simple, each one pushes its request into a queue which is processed by the helper thread when it get to it.
 
Both of these are call back function called from the GUI we have created in add_gui, so they run in the GUI thread.  However both want to call functions in the helper thread.  There code is very simple, each one pushes its request into a queue which is processed by the helper thread when it get to it.
  
 
*cb_find_and_monitor_arduino()
 
*cb_find_and_monitor_arduino()
 
*cb_end_helper( )
 
*cb_end_helper( )
 
+
 
 
==== Rest of Functions Run in Helper ====
 
==== Rest of Functions Run in Helper ====
  

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)