MachineIntelligenceCore:Visualization
OpenGLEpisodicApplication.cpp
Go to the documentation of this file.
1 
24 
25 namespace mic {
26 namespace opengl {
27 namespace application {
28 
29 OpenGLEpisodicApplication::OpenGLEpisodicApplication(std::string node_name_) : mic::opengl::application::OpenGLApplication(node_name_),
30  episode(0),
31  number_of_episodes("number_of_episodes", 0)
32 {
33  // Register properties - so their values can be overridden (read from the configuration file).
34  registerProperty(number_of_episodes);
35 
36 }
37 
38 
40 
41  // Start a new episode.
43 
44  // Main application loop.
45  while (!APP_STATE->Quit()) {
46 
47  // If not paused.
48  if (!APP_STATE->isPaused()) {
49  // If single step mode - pause after the step.
50  if (APP_STATE->isSingleStepModeOn())
51  APP_STATE->pressPause();
52 
53  // Enter critical section - with the use of scoped lock from AppState!
54  APP_DATA_SYNCHRONIZATION_SCOPED_LOCK();
55 
56  // Increment iteration number - at START!
57  iteration++;
58  // Perform single step and - if required - break the loop.
59  if (!performSingleStep()) {
60  // Finish the current episode.
61  episode++;
63 
64  // Check terminal condition.
65  if (((long)number_of_episodes > 0) && ( (long)episode >= (long) number_of_episodes)) {
66  APP_STATE->setQuit();
67  LOG(LINFO) << "Reached last episode (" << episode << "). Terminating application...";
68  } else {
69  // Else - start a new episode.
71  iteration=0;
72  }//: else
73  }//: if singleStep
74 
75  } //: if! is paused & end of critical section
76 
77  // Sleep.
78  APP_SLEEP();
79  }//: while
80 }
81 
82 
83 } /* namespace application */
84 } /* namespace opengl */
85 } /* namespace mic */
An abstract class implementing basic functions for two-threaded, OpenGL-based applications. Introduces the execution phases that are typical for all learning/classification applications, imposes fine code granulation.
virtual void processingThread(void)
Function realizing the processing thread. Implements basic quit/pause/single step functionality...