/** Application Main <BR> * ====================================================================== */ void main(void) { ///1. Standard Power-on routine (Clocks, Timers, IRQ's, etc) ///2. Standard OpenTag Init (most stuff actually will not be used) otapi_poweron(); otapi_init(); ///3. Palfi Application Initialization /// Palfi app acts as an interupt-driven thread. An interrupt pre-empts /// the kernel and seeds the thread. After this, the kernel takes-over /// the execution of the thread. This function enables these driving /// interrupts. palfi_init(); ///4. Top-level application init /// In this demo, the top-level application does very little. app_init(); OTAPI_LOG_MSG(MSG_utf8, 6, 26, (ot_u8*)"SYS_ON", (ot_u8*)"System on and Mpipe active"); ///5. MAIN RUNTIME (post-init) <BR> ///<LI> a. Pre-empt the kernel (first run) </LI> ///<LI> b. Go to sleep; OpenTag kernel will run automatically in /// the background </LI> ///<LI> c. The kernel has a built-in applet loader. It is the best way /// to use applets that generate requests or manipulate the system. /// The applets only load during full-idle, so time slotting or /// any other type of MAC activity is not affected. </LI> ///<LI> d. 99.99% (or more) of the time, the kernel is not actually /// running. You can run parallel, local tasks alongside OpenTag /// as long as they operate above priority 1. (I/O is usually /// priority 0 and kernel is always priority 1) </LI> otapi_preempt(); while(1) { app_manager(); app_sleep(); } ///6. Note on manually pre-empting the kernel for you own purposes: /// It can be done (many internal tasks do it), but be careful. /// It is recommended that you only do it when sys.mutex <= 1 /// (i.e. no radio data transfer underway). One adaptation of /// this demo is to have the mode-switching applets pre-empt the /// kernel (it works fine, but you need to make your own loader /// instead of using sys.loadapp). }
CORBA::Object_ptr Plan_Launcher_Base_Impl< Manager, AppManager, Application> ::start_launch (CORBA::Object_ptr app_mgr, const ::Deployment::Properties &properties, ::Deployment::Connections_out connections) { DANCE_TRACE ("Plan_Launcher_Base_Impl::start_launch"); AppManager_var app_manager (AppManager::_narrow (app_mgr)); if (CORBA::is_nil (app_manager.in ())) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher_Base_Impl::start_launch - ") ACE_TEXT ("Nil ApplicationManager reference\n"))); return 0; } Deployment::Application_var da; try { DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - ") ACE_TEXT("before startLaunch...\n"))); da = app_manager->startLaunch (properties, connections); DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - ") ACE_TEXT("startLaunch completed...\n"))); } catch (::Deployment::StartError &ex) { ACE_CString error; error += "Caught StartError exception while invoking startLaunch: " ; error += ex.name.in (); error += ", "; error += ex.reason.in (); DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - %C\n"), error.c_str ())); throw Deployment_Failure (error); } catch (::Deployment::InvalidProperty &ex) { ACE_CString error; error += "Caught InvalidProperty exception while invoking startLaunch: "; error += ex.name.in (); error += ", "; error += ex.reason.in (); DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - %C\n"), error.c_str ())); throw Deployment_Failure (error); } catch (::Deployment::InvalidNodeExecParameter &ex) { ACE_CString error; error += "Caught InvalidNodeExecParameter exception while invoking startLaunch: "; error += ex.name.in (); error += ", "; error += ex.reason.in (); DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - %C\n"), error.c_str ())); throw Deployment_Failure (error); } catch (::Deployment::InvalidComponentExecParameter &ex) { ACE_CString error; error += "Caught InvalidComponentExecParameter exception while invoking startLaunch: "; error += ex.name.in (); error += ", "; error += ex.reason.in (); DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - %C\n"), error.c_str ())); throw Deployment_Failure (error); } catch (::Deployment::ResourceNotAvailable &ex) { ACE_CString error; error += "Caught ResourceNotAvailable while invoking startLaunch: "; error += ex.name.in (); error += ", Type: <"; error += ex.resourceType.in (); error += "> Property Name: <"; error += ex.propertyName.in (); error += "> Element: <"; error += ex.elementName.in (); error += "> Resource Name: <"; error += ex.resourceName.in (); error += ">"; DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - %C\n"), error.c_str ())); throw Deployment_Failure (error); } catch (::CORBA::Exception &ex) { ACE_CString error; error += "Caught CORBA exception while invoking startLaunch: "; error += ex._info ().c_str (); DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - %C\n"), error.c_str ())); throw Deployment_Failure (error); } catch(...) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - ") ACE_TEXT("An exception was thrown during DAM->startLaunch.\n"))); throw Deployment_Failure ("Unexpected C++ exception in startLaunch\n"); } if (CORBA::is_nil (da.in())) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - ") ACE_TEXT("CIAO_PlanLauncher:startLaunch call failed: ") ACE_TEXT("nil DomainApplication reference\n"))); return 0; } else { DANCE_DEBUG (DANCE_LOG_MINOR_EVENT, (LM_DEBUG, DLINFO ACE_TEXT("Plan_Launcher_Base_Impl::start_launch - ") ACE_TEXT("DomainApplication was received from startLaunch\n"))); } return da._retn (); }