#include <Kernel.h>
Collaboration diagram for vrj::Kernel:

Public Methods | |
| int | start () |
| Starts the Kernel running by spawning the kernel thread. More... | |
| void | stop () |
| Stops the kernel control loop. More... | |
| bool | isRunning () const |
| Returns the status of kernel. More... | |
| void | waitForKernelStop () |
| Blocks until the kernel exits. More... | |
| void | initConfig () |
| Loads initial configuration data for the managers. More... | |
| void | controlLoop (void *nullParam) |
| The Kernel loop. More... | |
| void | setApplication (vrj::App *newApp) |
| Sets the application object for the Kernel to deal with. More... | |
| void | loadConfigFile (const char *filename) |
| Loads configuration data for Kernel. More... | |
| void | loadConfigFile (std::string filename) |
| Loads configuration data for Kernel. More... | |
| void | scanForConfigDefinitions (const std::string &path) |
| Scans the given directory (or directories) for .jdef files and loads all discovered files into the JCCL Element Factory. More... | |
| gadget::InputManager * | getInputManager () |
| Gets the Input Manager. More... | |
| vrj::User * | getUser (const std::string &userName) |
| Gets the user associated with given name. More... | |
| std::vector< vrj::User * > | getUsers () |
| Returns a list of the users. More... | |
| const vpr::BaseThread * | getThread () |
Protected Methods | |
| virtual bool | configCanHandle (jccl::ConfigElementPtr element) |
| Can the handler handle the given element? More... | |
| virtual bool | configAdd (jccl::ConfigElementPtr element) |
| Adds the element to the configuration. More... | |
| virtual bool | configRemove (jccl::ConfigElementPtr element) |
| Removes the element from the current configuration. More... | |
| bool | addUser (jccl::ConfigElementPtr element) |
| Adds a User to the system. More... | |
| bool | removeUser (jccl::ConfigElementPtr element) |
| Removes a User from the system. More... | |
| void | updateFrameData () |
| Updates any data that needs updated once a frame (Trackers, etc.). More... | |
| void | checkForReconfig () |
| Checks to see if there is reconfiguration to be done. More... | |
| void | changeApplication (vrj::App *newApp) |
| Changes the application in use. More... | |
| void | initSignalButtons () |
| Initializes the signal buttons for the kernel. More... | |
| void | checkSignalButtons () |
| Checks the signal buttons to see if anything has been triggered. More... | |
| void | startDrawManager (bool newMgr) |
| Starts the Draw Manager running. More... | |
| void | stopDrawManager () |
| Stops the Draw Manager, closes its resources, and deletes it. More... | |
| Kernel () | |
| Constructor: Hidden, so no instantiation is allowed. More... | |
| Kernel (const vrj::Kernel &k) | |
| void | operator= (const vrj::Kernel &k) |
| virtual | ~Kernel () |
| vprSingletonHeader (Kernel) | |
Protected Attributes | |
| vrj::App * | mApp |
| The current active app object. More... | |
| vrj::App * | mNewApp |
| New application to set. More... | |
| bool | mNewAppSet |
| Flag to notify that a new application should be set. More... | |
| bool | mIsRunning |
| Flag for wether the kernel is currently running. More... | |
| bool | mExitFlag |
| Set true when the kernel should exit. More... | |
| vpr::BaseThread * | mControlThread |
| The thread in control of me. More... | |
| vpr::CondVar | mExitWaitCondVar |
| Cond var for waiting for exit. More... | |
| gadget::DigitalInterface | mStopKernelSignalButton |
| Control "signals" from input interfaces. More... | |
Factories and Managers | |
| gadget::InputManager * | mInputManager |
| The input manager for the system. More... | |
| DrawManager * | mDrawManager |
| The Draw Manager we are currently using. More... | |
| SoundManager * | mSoundManager |
| The Audio Manager we are currently using. More... | |
| DisplayManager * | mDisplayManager |
| The Display Manager we are currently using. More... | |
| cluster::ClusterManager * | mClusterManager |
| The Cluster Manager for the system. More... | |
Multi-user information | |
| std::vector< vrj::User * > | mUsers |
| A list of user objects in system. More... | |
Takes care of all initialization and object creation for the system. This class is the only class that MUST be instantiated for all application objects.
Definition at line 77 of file Kernel.h.
|
|
Constructor: Hidden, so no instantiation is allowed.
Definition at line 561 of file Kernel.cpp.
00562 : mApp(NULL) 00563 , mNewApp(NULL) 00564 , mNewAppSet(false) 00565 , mIsRunning(false) 00566 , mExitFlag(false) 00567 , mControlThread(NULL) 00568 , mInputManager(NULL) 00569 , mDrawManager(NULL) 00570 , mSoundManager(NULL) 00571 , mDisplayManager(NULL) 00572 , mClusterManager(NULL) 00573 { 00574 // Print out the Juggler version number when the kernel is created. 00575 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) 00576 << std::string(strlen(VJ_VERSION) + 12, '=') 00577 << std::endl << vprDEBUG_FLUSH; 00578 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) 00579 << clrOutNORM(clrGREEN, "VR Juggler: ") 00580 << clrOutNORM(clrGREEN, VJ_VERSION) << clrRESET 00581 << std::endl << vprDEBUG_FLUSH; 00582 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) 00583 << clrOutNORM(clrGREEN, "VPR: ") 00584 << clrOutNORM(clrGREEN, vpr::getVersionString()) 00585 << clrRESET << std::endl << vprDEBUG_FLUSH; 00586 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) 00587 << clrOutNORM(clrGREEN, "Gadgeteer: ") 00588 << clrOutNORM(clrGREEN, gadget::getVersionString()) 00589 << clrRESET << std::endl << vprDEBUG_FLUSH; 00590 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) 00591 << std::string(strlen(VJ_VERSION) + 12, '=') 00592 << std::endl << vprDEBUG_FLUSH; 00593 00594 // Load in the configuration definitions 00595 std::string def_path; 00596 if ( ! vpr::System::getenv("JCCL_DEFINITION_PATH", def_path).success() ) 00597 { 00598 def_path = "${VJ_BASE_DIR}/" VJ_SHARE_DIR "/data/definitions"; 00599 vprDEBUG(vprDBG_ALL, vprDBG_WARNING_LVL) 00600 << "JCCL_DEFINITION_PATH environment variable not set.\n" 00601 << vprDEBUG_FLUSH; 00602 vprDEBUG_NEXT(vprDBG_ALL, vprDBG_WARNING_LVL) 00603 << "Defaulting to " << def_path << std::endl << vprDEBUG_FLUSH; 00604 } 00605 jccl::ElementFactory::instance()->loadDefs(def_path); 00606 00607 // Set up a default configuration path if the user does not already have 00608 // one defined in the environment variable $JCCL_CFG_PATH. If that 00609 // environment variable is not defined, check to see if $VJ_CFG_PATH is 00610 // defined. If it is, use it. Otherwise, use 00611 // $VJ_BASE_DIR/share/data/configFiles as a last-ditch fallback. 00612 // XXX: Should $VJ_CFG_PATH supercede $JCCL_CFG_PATH instead of doing it 00613 // this way? 00614 std::string cfg_path; 00615 if ( ! vpr::System::getenv("JCCL_CFG_PATH", cfg_path).success() ) 00616 { 00617 if ( vpr::System::getenv("VJ_CFG_PATH", cfg_path).success() ) 00618 { 00619 vprDEBUG(vprDBG_ALL, vprDBG_WARNING_LVL) 00620 << "JCCL_CFG_PATH environment variable not set.\n" 00621 << vprDEBUG_FLUSH; 00622 vprDEBUG_NEXT(vprDBG_ALL, vprDBG_WARNING_LVL) 00623 << "Using VJ_CFG_PATH instead.\n" << vprDEBUG_FLUSH; 00624 } 00625 // Neither $JCCL_CFG_PATH nor $VJ_CFG_PATH is set, so use what basically 00626 // amounts to a hard-coded default. 00627 else 00628 { 00629 cfg_path = "${VJ_BASE_DIR}/" VJ_SHARE_DIR "/data/configFiles"; 00630 vprDEBUG(vprDBG_ALL, vprDBG_WARNING_LVL) 00631 << "Neither JCCL_CFG_PATH nor VJ_CFG_PATH is set.\n" 00632 << vprDEBUG_FLUSH; 00633 vprDEBUG_NEXT(vprDBG_ALL, vprDBG_WARNING_LVL) 00634 << "Defaulting to " << cfg_path << std::endl << vprDEBUG_FLUSH; 00635 cfg_path = vpr::replaceEnvVars(cfg_path); 00636 } 00637 00638 jccl::ParseUtil::setCfgSearchPath(cfg_path); 00639 } 00640 } |
|
|
Definition at line 287 of file Kernel.h.
00287 : jccl::ConfigElementHandler() {;}
|
|
|
Definition at line 290 of file Kernel.h.
00291 {;}
|
|
|
Starts the Kernel running by spawning the kernel thread.
Definition at line 69 of file Kernel.cpp. References initSignalButtons, mControlThread, mIsRunning, and vrjDBG_KERNEL.
00070 {
00071 if(mControlThread != NULL) // Have already started
00072 {
00073 vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
00074 << clrOutNORM(clrRED,"ERROR:")
00075 << " vrj::Kernel::start() called when kernel already running!\n"
00076 << vprDEBUG_FLUSH;
00077 vprASSERT(false);
00078 exit(0);
00079 }
00080
00081 mIsRunning = true;
00082 initSignalButtons(); // Initialize the signal buttons that may be pressed
00083
00084 // Create a new thread to handle the control
00085 vpr::ThreadMemberFunctor<Kernel>* memberFunctor =
00086 new vpr::ThreadMemberFunctor<Kernel>(this, &Kernel::controlLoop, NULL);
00087
00088 // mControlThread is set in controlLoop().
00089 new vpr::Thread(memberFunctor);
00090
00091 vprDEBUG(vrjDBG_KERNEL,vprDBG_STATE_LVL)
00092 << "vrj::Kernel::start(): Just started control loop." << std::endl
00093 << vprDEBUG_FLUSH;
00094
00095 return 1;
00096 }
|
|
|
Stops the kernel control loop. If there is an application set, then it will be closed first.
Definition at line 101 of file Kernel.cpp. References mExitFlag, mExitWaitCondVar, and setApplication. Referenced by checkSignalButtons.
00102 {
00103 mExitWaitCondVar.acquire();
00104 {
00105 mExitFlag = true;
00106 mExitWaitCondVar.signal();
00107 }
00108 mExitWaitCondVar.release();
00109
00110 setApplication(NULL); // Set NULL application so that the app gets closed
00111 }
|
|
|
Returns the status of kernel.
Definition at line 92 of file Kernel.h.
00093 {
00094 return mIsRunning;
00095 }
|
|
|
Blocks until the kernel exits. This method waits for the condition !mIsRunning && mExitFlag. We need both of those because even though exit flag may be triggered we can not exit until the kernel control loop stops. This is signaled by setting mIsRunning to false. Definition at line 121 of file Kernel.cpp. References mExitFlag, mExitWaitCondVar, and mIsRunning.
00122 {
00123 mExitWaitCondVar.acquire();
00124 {
00125 while (! (!mIsRunning && mExitFlag) ) // Wait until !mIsRunning && mExitFlag
00126 {
00127 mExitWaitCondVar.wait();
00128 }
00129 }
00130 mExitWaitCondVar.release();
00131 }
|
|
|
Loads initial configuration data for the managers.
Definition at line 360 of file Kernel.cpp. References mClusterManager, mDisplayManager, mInputManager, and vrjDBG_KERNEL. Referenced by controlLoop.
00361 {
00362 vprDEBUG_BEGIN(vrjDBG_KERNEL, vprDBG_CONFIG_LVL)
00363 << "vrj::Kernel::initConfig(): Setting initial config.\n"
00364 << vprDEBUG_FLUSH;
00365
00366 // ---- ALLOCATE MANAGERS --- //
00367 //initialSetupInputManager();
00368 mInputManager = gadget::InputManager::instance();
00369
00370 //initialSetupDisplayManager();
00371 mDisplayManager = DisplayManager::instance(); // Get display manager
00372 vprASSERT(mDisplayManager != NULL); // Did we get an object
00373
00374 mClusterManager = cluster::ClusterManager::instance();
00375
00376 //??// processPending() // Should I do this here
00377
00378 // hook dynamically-reconfigurable managers up to config manager
00379 // XXX: Should replace with dynamic support in future
00380 jccl::ConfigManager::instance()->addConfigElementHandler(this);
00381 jccl::ConfigManager::instance()->addConfigElementHandler(mInputManager);
00382 jccl::ConfigManager::instance()->addConfigElementHandler(mClusterManager);
00383 jccl::ConfigManager::instance()->addConfigElementHandler(mDisplayManager);
00384 vprDEBUG_END(vrjDBG_KERNEL, vprDBG_CONFIG_LVL)
00385 << "vrj::Kernel::initConfig(): Done.\n" << vprDEBUG_FLUSH;
00386 }
|
|
|
The Kernel loop.
Definition at line 135 of file Kernel.cpp. References checkForReconfig, checkSignalButtons, getInputManager, initConfig, vrj::App::intraFrame, vrj::App::latePreFrame, mApp, mClusterManager, mControlThread, mDrawManager, mExitFlag, mExitWaitCondVar, mIsRunning, mSoundManager, vrj::App::postFrame, vrj::App::preFrame, updateFrameData, and vrjDBG_KERNEL.
00136 {
00137 boost::ignore_unused_variable_warning(nullParam);
00138 vprDEBUG(vrjDBG_KERNEL, vprDBG_CONFIG_LVL)
00139 << "vrj::Kernel::controlLoop: Started.\n" << vprDEBUG_FLUSH;
00140 vprASSERT (NULL != vpr::Thread::self());
00141
00142 mControlThread = vpr::Thread::self();
00143
00144 // Do any initial configuration
00145 initConfig();
00146
00147 // --- MAIN CONTROL LOOP -- //
00148 while(! (mExitFlag && (mApp == NULL))) // While not exit flag set and don't have app. (can't exit until app is closed)
00149 {
00150 // Might not want the Kernel to know about the ClusterNetwork
00151 // It is currently being registered as a jccl::ConfigElementHandler in
00152 // the ClusterManager constructor
00153 cluster::ClusterNetwork::instance()->updateNewConnections();
00154 cluster::ClusterManager::instance()->sendRequests();
00155
00156 bool cluster = !(cluster::ClusterManager::instance()->isClusterActive() &&
00157 !cluster::ClusterManager::instance()->isClusterReady());
00158
00159 // Iff we have an app and a draw manager
00160 if((mApp != NULL) && (mDrawManager != NULL) && cluster)
00161 {
00162 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00163 << "vrj::Kernel::controlLoop: mApp->preFrame()\n"
00164 << vprDEBUG_FLUSH;
00165 mApp->preFrame(); // PREFRAME: Do Any application pre-draw stuff
00166 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00167 << "vrj::Kernel::controlLoop: Update ClusterManager preDraw()\n"
00168 << vprDEBUG_FLUSH;
00169 }
00170 else
00171 {
00172 // ??? Should we do this, or just grind up the CPU as fast as possible
00173 vprASSERT(NULL != mControlThread); // If control thread is not set correctly, it will seg fault here
00174 vpr::Thread::yield(); // Give up CPU
00175 }
00176
00177 mClusterManager->preDraw();
00178
00179 if((mApp != NULL) && (mDrawManager != NULL) && cluster)
00180 {
00181 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00182 << "vrj::Kernel::controlLoop: mApp->latePreFrame()\n"
00183 << vprDEBUG_FLUSH;
00184 mApp->latePreFrame();
00185 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00186 << "vrj::Kernel::controlLoop: drawManager->draw()\n"
00187 << vprDEBUG_FLUSH;
00188 mDrawManager->draw(); // DRAW: Trigger the beginning of frame drawing
00189 mSoundManager->update();
00190 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00191 << "vrj::Kernel::controlLoop: mApp->intraFrame()\n"
00192 << vprDEBUG_FLUSH;
00193 mApp->intraFrame(); // INTRA FRAME: Do computations that can be done while drawing. This should be for next frame.
00194 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00195 << "vrj::Kernel::controlLoop: drawManager->sync()\n"
00196 << vprDEBUG_FLUSH;
00197 mSoundManager->sync();
00198 mDrawManager->sync(); // SYNC: Block until drawing is done
00199 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00200 << "vrj::Kernel::controlLoop: mApp->postFrame()\n"
00201 << vprDEBUG_FLUSH;
00202 mApp->postFrame(); // POST FRAME: Do processing after drawing is complete
00203 }
00204 else
00205 {
00206 // ??? Should we do this, or just grind up the CPU as fast as possible
00207 vprASSERT(NULL != mControlThread); // If control thread is not set correctly, it will seg fault here
00208 vpr::Thread::yield(); // Give up CPU
00209 }
00210
00211 // --- Stop for reconfiguration -- //
00212 checkForReconfig(); // Check for any reconfiguration that needs done (system or application)
00213 checkSignalButtons(); // Check for any pending control requests
00214 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00215 << "vrj::Kernel::controlLoop: Update Trackers\n" << vprDEBUG_FLUSH;
00216 getInputManager()->updateAllData(); // Update the input manager
00217 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00218 << "vrj::Kernel::controlLoop: Update ClusterManager\n"
00219 << vprDEBUG_FLUSH;
00220 mClusterManager->postPostFrame(); // Can I move to before pre-frame to allow future config barrier
00221 vprDEBUG(vrjDBG_KERNEL, vprDBG_HVERB_LVL)
00222 << "vrj::Kernel::controlLoop: Update Projections\n"
00223 << vprDEBUG_FLUSH;
00224 updateFrameData(); // Any frame-based manager data
00225 }
00226
00227 vprDEBUG(vrjDBG_KERNEL, vprDBG_WARNING_LVL)
00228 << "vrj::Kernel::controlLoop: Exiting. \n" << vprDEBUG_FLUSH;
00229
00230 // Set the running status to false
00231 mExitWaitCondVar.acquire();
00232 {
00233 mIsRunning = false;
00234 mExitWaitCondVar.signal();
00235 }
00236 mExitWaitCondVar.release();
00237 }
|
|
|
Sets the application object for the Kernel to deal with. If there is another app active, it has to stop that application first then restart all API-specific Managers.
Definition at line 241 of file Kernel.cpp. References mNewApp, mNewAppSet, and vrjDBG_KERNEL. Referenced by stop.
00242 {
00243 vprDEBUG(vrjDBG_KERNEL,vprDBG_CONFIG_LVL)
00244 << "vrj::Kernel::setApplication: New application set\n" << vprDEBUG_FLUSH;
00245 mNewApp = newApp;
00246 mNewAppSet = true;
00247 }
|
|
|
Loads configuration data for Kernel.
Definition at line 123 of file Kernel.h.
00124 {
00125 std::string filename_str = std::string(filename);
00126 loadConfigFile(filename_str);
00127 }
|
|
|
Loads configuration data for Kernel.
Definition at line 466 of file Kernel.cpp. References vrjDBG_KERNEL.
00467 {
00468 vprDEBUG(vrjDBG_KERNEL,vprDBG_CONFIG_LVL)
00469 << "Loading config file: " << filename << std::endl << vprDEBUG_FLUSH;
00470
00471 // We can allocate this on thte stack because the config elements get
00472 // copied into a new PendingConfigElement from the configuration.
00473 jccl::Configuration cfg;
00474
00475 // ------- OPEN Program specified Config file ------ //
00476 if(filename.empty()) // We have a filename
00477 {
00478 return;
00479 }
00480
00481 bool cfg_load_success = cfg.load(filename);
00482 if (!cfg_load_success)
00483 {
00484 vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED,"ERROR:")
00485 << "vrj::Kernel::loadConfigFile: Failed to load file: "
00486 << filename << std::endl << vprDEBUG_FLUSH;
00487 exit(1);
00488 }
00489
00490 // Put all the newly loaded config elments into the Config Manager's
00491 // incoming element list.
00492 jccl::ConfigManager::instance()->addConfigurationAdditions(&cfg);
00493 }
|
|
|
Scans the given directory (or directories) for .jdef files and loads all discovered files into the JCCL Element Factory.
Definition at line 497 of file Kernel.cpp.
00498 {
00499 jccl::ElementFactory::instance()->loadDefs(path);
00500 }
|
|
|
Can the handler handle the given element?
Definition at line 395 of file Kernel.cpp. Referenced by configAdd, and configRemove.
00396 {
00397 return std::string("user") == element->getID();
00398 }
|
|
|
Adds the element to the configuration.
Definition at line 400 of file Kernel.cpp. References addUser, and configCanHandle.
00401 {
00402 const std::string element_type(element->getID());
00403
00404 vprASSERT(configCanHandle(element));
00405
00406 if(std::string("user") == element_type)
00407 {
00408 return addUser(element);
00409 }
00410 else
00411 {
00412 return false;
00413 }
00414 }
|
|
|
Removes the element from the current configuration.
Definition at line 416 of file Kernel.cpp. References configCanHandle, and removeUser.
00417 {
00418 const std::string element_type(element->getID());
00419
00420 vprASSERT(configCanHandle(element));
00421
00422 if(std::string("user") == element_type)
00423 {
00424 return removeUser(element);
00425 }
00426 else
00427 {
00428 return false;
00429 }
00430 }
|
|
|
Adds a User to the system.
Definition at line 433 of file Kernel.cpp. References mUsers, and vrjDBG_KERNEL. Referenced by configAdd.
00434 {
00435 vprASSERT(element->getID() == "user");
00436
00437 User* new_user = new User;
00438 bool success = new_user->config(element);
00439
00440 if(!success)
00441 {
00442 vprDEBUG(vrjDBG_KERNEL, vprDBG_CRITICAL_LVL)
00443 << clrOutNORM(clrRED,"ERROR:") << " Failed to add new User: "
00444 << element->getName() << std::endl << vprDEBUG_FLUSH;
00445 delete new_user;
00446 }
00447 else
00448 {
00449 vprDEBUG(vrjDBG_KERNEL, vprDBG_STATE_LVL)
00450 << "vrj::Kernel: Added new User: " << new_user->getName() << std::endl
00451 << vprDEBUG_FLUSH;
00452 mUsers.push_back(new_user);
00453 }
00454
00455 return success;
00456 }
|
|
|
Removes a User from the system.
Definition at line 459 of file Kernel.cpp. Referenced by configRemove.
00460 {
00461 boost::ignore_unused_variable_warning(element);
00462 return false;
00463 }
|
|
|
Updates any data that needs updated once a frame (Trackers, etc.).
Definition at line 388 of file Kernel.cpp. Referenced by controlLoop.
00389 {
00390 // When we have a draw manager, tell it to update its projections
00391 // XXX: Moved to be updated on demand
00392 // mDisplayManager->updateProjections();
00393 }
|
|
|
Checks to see if there is reconfiguration to be done.
Definition at line 250 of file Kernel.cpp. References changeApplication, vrj::App::depSatisfied, mControlThread, mNewApp, mNewAppSet, and vrjDBG_KERNEL. Referenced by controlLoop.
00251 {
00252 vprASSERT(vpr::Thread::self() == mControlThread); // ASSERT: We are being called from kernel thread
00253 // ---- RECONFIGURATION --- //
00254 jccl::ConfigManager* cfg_mgr = jccl::ConfigManager::instance();
00255 unsigned num_processed(0);
00256
00257 do
00258 {
00259 num_processed = cfg_mgr->attemptReconfiguration();
00260 }
00261 while (num_processed > 0);
00262 // ---- APP SWITCH ---- //
00263 // check for a new applications
00264 if(mNewAppSet)
00265 {
00266 if((mNewApp == NULL) || (mNewApp->depSatisfied()) ) // If app is NULL or dependencies satisfied
00267 {
00268 vprDEBUG(vrjDBG_KERNEL,vprDBG_CONFIG_STATUS_LVL)
00269 << "vrj::Kernel: New application set, dependencies: Satisfied.\n"
00270 << vprDEBUG_FLUSH;
00271 mNewAppSet = false;
00272 changeApplication(mNewApp);
00273 }
00274 else
00275 {
00276 vprDEBUG(vrjDBG_KERNEL,vprDBG_WARNING_LVL)
00277 << "vrj::Kernel: New application set, dependencies: Not satisfied yet.\n"
00278 << vprDEBUG_FLUSH;
00279 }
00280 }
00281 }
|
|
|
Changes the application in use. If there is another application object active, it has to stop that application first then restart all API-specific Managers.
Definition at line 289 of file Kernel.cpp. References vrj::App::exit, vrj::App::getDrawManager, vrj::App::getSoundManager, mApp, mControlThread, mDrawManager, mSoundManager, startDrawManager, stopDrawManager, and vrjDBG_KERNEL. Referenced by checkForReconfig.
00290 {
00291 vprDEBUG(vrjDBG_KERNEL, vprDBG_CONFIG_LVL)
00292 << "vrj::Kernel::changeApplication: Changing to:" << newApp << std::endl
00293 << vprDEBUG_FLUSH;
00294
00295 vprASSERT(vpr::Thread::self() == mControlThread); // ASSERT: We are being called from kernel thread
00296 jccl::ConfigManager* cfg_mgr = jccl::ConfigManager::instance();
00297 // EXIT Previous application
00298 if(mApp != NULL)
00299 {
00300 cfg_mgr->removeConfigElementHandler(mApp);
00301 mApp->exit();
00302 mApp = NULL; // ASSERT: We have no handles to the application any more (ie. the app could be deleted)
00303 } // Done with old app
00304
00305 // SET NEW APPLICATION
00306 if(newApp != NULL) // We were given an app
00307 {
00308 mApp = newApp;
00309 DrawManager* new_draw_mgr = mApp->getDrawManager();
00310 vprASSERT(NULL != new_draw_mgr);
00311
00312 if (new_draw_mgr != mDrawManager) // Have NEW draw manager
00313 {
00314 stopDrawManager(); // Stop old one
00315 cfg_mgr->removeConfigElementHandler(mDrawManager);
00316
00317 mDrawManager = mApp->getDrawManager(); // Get the new draw manager
00318 mSoundManager = mApp->getSoundManager(); // Get the new sound manager
00319 cfg_mgr->addConfigElementHandler(mDrawManager); // Tell config manager about them
00320 cfg_mgr->addConfigElementHandler(mSoundManager); // Tell config manager about them
00321 startDrawManager(true); // Start the new one
00322 }
00323 else // SAME draw manager
00324 {
00325 startDrawManager(false); // Start new app
00326 }
00327 // Now handle configuration
00328 cfg_mgr->addConfigElementHandler(mApp);
00329 cfg_mgr->refreshPendingList(); // New managers, so we may be able to handle config requests now
00330 }
00331 else // No app, clear to NULL
00332 {
00333 stopDrawManager();
00334 mApp = NULL;
00335 }
00336 }
|
|
|
Initializes the signal buttons for the kernel.
Definition at line 339 of file Kernel.cpp. References mStopKernelSignalButton. Referenced by start.
00340 {
00341 mStopKernelSignalButton.init("VJSystemStopKernel");
00342 }
|
|
|
Checks the signal buttons to see if anything has been triggered.
Definition at line 345 of file Kernel.cpp. References mStopKernelSignalButton, and stop. Referenced by controlLoop.
00346 {
00347 if(mStopKernelSignalButton->getData() == gadget::Digital::ON)
00348 {
00349 vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00350 << "Stop kernel signal button pressed: Kernel will exit.\n"
00351 << vprDEBUG_FLUSH;
00352 this->stop(); // Signal kernel to stop
00353 }
00354 }
|
|
|
Starts the Draw Manager running. Calls the app callbacks for the Draw Manager.
Definition at line 503 of file Kernel.cpp. References vrj::App::apiInit, vrj::App::init, mApp, mDisplayManager, and mDrawManager. Referenced by changeApplication.
00504 {
00505 vprASSERT((mApp != NULL) && (mDrawManager != NULL) && (mDisplayManager != NULL));
00506
00507 if(newMgr)
00508 {
00509 mDrawManager->setDisplayManager(mDisplayManager);
00510 jccl::ConfigManager::instance()->lockPending();
00511 {
00512 mDrawManager->configProcessPending(); // Handle any pending configuration requests BEFORE we init and start it going
00513 }
00514 jccl::ConfigManager::instance()->unlockPending();
00515 }
00516 mDrawManager->setApp(mApp);
00517
00518 mApp->init(); // Init the app
00519 if(newMgr)
00520 mDrawManager->initAPI(); // Just sets up API type stuff, possibly starts new processes
00521 mApp->apiInit(); // Have app do any app-init stuff
00522 if(newMgr)
00523 {
00524 mDisplayManager->setDrawManager(mDrawManager); // This can trigger the update of windows to the draw manager
00525 }
00526 }
|
|
|
Stops the Draw Manager, closes its resources, and deletes it.
Definition at line 531 of file Kernel.cpp. References mDisplayManager, and mDrawManager. Referenced by changeApplication.
00532 {
00533 if(mDrawManager != NULL)
00534 {
00535 mDrawManager->closeAPI();
00536 delete mDrawManager;
00537 mDrawManager = NULL;
00538 mDisplayManager->setDrawManager(NULL);
00539 }
00540 }
|
|
|
Gets the Input Manager.
Definition at line 543 of file Kernel.cpp. References mInputManager. Referenced by controlLoop.
00544 {
00545 return mInputManager;
00546 }
|
|
|
Gets the user associated with given name.
Definition at line 548 of file Kernel.cpp. References mUsers.
|
|
|
Returns a list of the users.
Definition at line 243 of file Kernel.h.
00244 {
00245 return mUsers;
00246 }
|
|
|
Definition at line 248 of file Kernel.h.
00249 {
00250 return mControlThread;
00251 }
|
|
|
Definition at line 288 of file Kernel.h.
00288 {;}
|
|
|
|
|
|
The current active app object.
Definition at line 254 of file Kernel.h. Referenced by changeApplication, controlLoop, and startDrawManager. |
|
|
New application to set.
Definition at line 255 of file Kernel.h. Referenced by checkForReconfig, and setApplication. |
|
|
Flag to notify that a new application should be set.
Definition at line 256 of file Kernel.h. Referenced by checkForReconfig, and setApplication. |
|
|
Flag for wether the kernel is currently running.
Definition at line 258 of file Kernel.h. Referenced by controlLoop, start, and waitForKernelStop. |
|
|
Set true when the kernel should exit.
Definition at line 259 of file Kernel.h. Referenced by controlLoop, stop, and waitForKernelStop. |
|
|
The thread in control of me.
Definition at line 260 of file Kernel.h. Referenced by changeApplication, checkForReconfig, controlLoop, and start. |
|
|
Cond var for waiting for exit.
Definition at line 261 of file Kernel.h. Referenced by controlLoop, stop, and waitForKernelStop. |
|
|
The input manager for the system.
Definition at line 265 of file Kernel.h. Referenced by getInputManager, and initConfig. |
|
|
The Draw Manager we are currently using.
Definition at line 266 of file Kernel.h. Referenced by changeApplication, controlLoop, startDrawManager, and stopDrawManager. |
|
|
The Audio Manager we are currently using.
Definition at line 267 of file Kernel.h. Referenced by changeApplication, and controlLoop. |
|
|
The Display Manager we are currently using.
Definition at line 268 of file Kernel.h. Referenced by initConfig, startDrawManager, and stopDrawManager. |
|
|
The Cluster Manager for the system.
Definition at line 269 of file Kernel.h. Referenced by controlLoop, and initConfig. |
|
|
A list of user objects in system.
|
|
|
Control "signals" from input interfaces.
Definition at line 278 of file Kernel.h. Referenced by checkSignalButtons, and initSignalButtons. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002