Ejemplo n.º 1
0
void RhoRubyStart()
{
    const char* szRoot = rho_native_rhopath();
    //VALUE moduleRhom;
#ifdef HAVE_LOCALE_H
    setlocale(LC_CTYPE, "");
#endif
    {
#ifdef ENABLE_RUBY_VM_STAT
    g_collect_stat = 1; 
#endif    
    
    RUBY_INIT_STACK;
    ruby_init();
#if defined(WIN32)
    rb_w32_sysinit(NULL,NULL);
#endif

#if defined(DEBUG)
    //enable_gc_profile();
#endif
    //rb_funcall(rb_mGC, rb_intern("stress="), 1, Qtrue);

    ruby_init_loadpath(szRoot);
#ifdef RHODES_EMULATOR
    {
        VALUE load_path = GET_VM()->load_path;
        char* app_path = malloc(strlen(szRoot)+100);

        rb_ary_clear(load_path);

        strcpy(app_path, szRoot);
        strcat(app_path, "app");

        rb_ary_push(load_path, rb_str_new2(app_path) );

        strcpy(app_path, rho_rhodesapp_getrhodespath());
        strcat(app_path, "\\lib\\framework");
        rb_ary_push(load_path, rb_str_new2(app_path) );
    }

#endif

    Init_strscan();
    Init_sqlite3_api();
    Init_GeoLocation();
    Init_SyncEngine();
    Init_AsyncHttp();
    Init_System();
    Init_Phonebook();
    Init_WebView();
    Init_RhoConf();
    Init_Alert();
    Init_SignatureTool();
    Init_RhoBluetooth();	
	Init_RhodesNativeViewManager();	
    Init_Camera();
    Init_stringio();
    Init_DateTimePicker();
    Init_NativeBar();
    Init_RhoSupport();
    Init_MapView();
    Init_RingtoneManager();
    Init_socket();
    Init_NavBar();
    Init_RhoEvent();
    Init_Calendar();
    Init_Extensions();

#ifdef ENABLE_RUBY_VM_STAT
    struct timeval  start;
    struct timeval  end;

    gettimeofday (&start, NULL);
#endif

#ifdef RHODES_EMULATOR
    rb_const_set(rb_cObject, rb_intern("RHODES_EMULATOR"), Qtrue);
    require_compiled(rb_str_new2("rhoframework"), &framework );
    framework = rb_const_get(rb_cObject,rb_intern("RHO_FRAMEWORK"));
#else
    require_compiled(rb_str_new2("rhoframework"), &framework );
#endif //RHODES_EMULATOR

    if ( framework == 0 || framework == Qnil )
    {
        RAWLOG_FATAL("RHO framework creating failed. Application will exit.");
    }

#ifdef ENABLE_RUBY_VM_STAT
    gettimeofday (&end, NULL);

    if ( end.tv_sec > 0 )
        g_require_compiled_msec += (end.tv_sec  - start.tv_sec) * 1000;
    else
        g_require_compiled_msec += (end.tv_usec - start.tv_usec)/1000; 

#endif

    rb_gc_register_mark_object(framework);

    CONST_ID(framework_mid, "serve");
    CONST_ID(framework_mid2, "serve_index");
    CONST_ID(initApp_mid, "init_app");
    CONST_ID(onConfigConflicts_mid, "on_config_conflicts");
    CONST_ID(activateApp_mid, "activate_app");
    CONST_ID(deactivateApp_mid, "deactivate_app");
    CONST_ID(uiCreated_mid, "ui_created");
    CONST_ID(uiDestroyed_mid, "ui_destroyed");
    CONST_ID(loadServerSources_mid,"load_server_sources");
    CONST_ID(loadAllSyncSources_mid,"load_all_sync_sources");
    CONST_ID(resetDBOnSyncUserChanged_mid, "reset_db_on_sync_user_changed");

    //moduleRhom = rb_const_get(rb_cObject, rb_intern("Rhom"));

#ifdef ENABLE_RUBY_VM_STAT
    g_collect_stat = 0; 
#endif

    }
}
Ejemplo n.º 2
0
void RhoRubyStart()
{
    const char* szRoot = rho_native_rhopath();
    //VALUE moduleRhom;
#ifdef HAVE_LOCALE_H
    setlocale(LC_CTYPE, "");
#endif
    {
#ifdef ENABLE_RUBY_VM_STAT
    g_collect_stat = 1; 
#endif    
    
    RUBY_INIT_STACK;
    ruby_init();
#if defined(WIN32)
    rb_w32_sysinit(NULL,NULL);
#endif

#if defined(DEBUG)
    //enable_gc_profile();
#endif
    //rb_funcall(rb_mGC, rb_intern("stress="), 1, Qtrue);

    ruby_init_loadpath(szRoot);
#if defined(RHODES_EMULATOR) || defined(APP_BUILD_CAPABILITY_MOTOROLA) || defined(OS_WP8)
    {
        VALUE load_path = GET_VM()->load_path;
        char* app_path = malloc(strlen(szRoot)+100);

        rb_ary_clear(load_path);

        strcpy(app_path, szRoot);
#if defined(RHODES_EMULATOR)
        strcat(app_path, "app");
#elif defined(OS_WP8)
		strcat(app_path, "/apps/app");
#else
        strcat(app_path, "apps/app");
#endif
        rb_ary_push(load_path, rb_str_new2(app_path) );

#if defined(APP_BUILD_CAPABILITY_MOTOROLA)
        strcpy(app_path, rho_native_reruntimepath());
        strcat(app_path, "lib");
#elif defined(OS_WP8)
		strcpy(app_path, szRoot);
        strcat(app_path, "/lib");
#else
        strcpy(app_path, rho_simconf_getRhodesPath());
        strcat(app_path, "/lib/framework");
#endif
        rb_ary_push(load_path, rb_str_new2(app_path) );
    }

#endif

#if !defined(OS_WP8)

    Init_strscan();
    Init_sqlite3_api();
    Init_GeoLocation();
    Init_AsyncHttp();
    Init_System();
    Init_Phonebook();
    Init_WebView();
    Init_RhoConf();
    Init_Alert();
#if defined(WINDOWS_PLATFORM)
    init_rhoext_Signature();
#else
    Init_SignatureCapture();
#endif
    
    Init_RhoBluetooth();	
	Init_RhodesNativeViewManager();	
    Init_Camera();
    Init_stringio();
    Init_DateTimePicker();
    Init_NativeBar();
    Init_RhoSupport();
    Init_MapView();
    Init_RingtoneManager();
    Init_socket();
    Init_NavBar();
    Init_RhoEvent();
    Init_Calendar();

//TODO: RhoSimulator  - load extensions dll dynamically
#if !defined(RHO_SYMBIAN)
    Init_Extensions();
#endif //RHO_SYMBIAN

#else // OS_WP8 is set
	Init_sqlite3_api();
	Init_strscan();
	Init_GeoLocation();
	Init_AsyncHttp();
	Init_RhoSupport();	
	Init_RhoConf();
	Init_WebView();
#endif //OS_WP8


    if ( rho_rcclient_have_rhoconnect_client() ) {
        rb_const_set(rb_cObject, rb_intern("RHOCONNECT_CLIENT_PRESENT"), Qtrue);
    }


#if defined(APP_BUILD_CAPABILITY_MOTOROLA)
    rb_require("rhomotoapi");
#endif //APP_BUILD_CAPABILITY_MOTOROLA

#ifdef ENABLE_RUBY_VM_STAT
    struct timeval  start;
    struct timeval  end;

    gettimeofday (&start, NULL);
#endif

#ifdef RHODES_EMULATOR
    rb_const_set(rb_cObject, rb_intern("RHODES_EMULATOR"), Qtrue);
    require_compiled(rb_str_new2("rhoframework"), &framework );
    framework = rb_const_get(rb_cObject,rb_intern("RHO_FRAMEWORK"));
#else
    {
		VALUE res = rho_ruby_disable_gc();

#if defined(OS_WP8) // temporary constant for wp8 development
		rb_const_set(rb_cObject, rb_intern("RHO_WP8"), Qtrue);
#endif // OS_WP8
        require_compiled(rb_str_new2("rhoframework"), &framework );
        rho_ruby_enable_gc(res);
    }
#endif //RHODES_EMULATOR

    if ( framework == 0 || framework == Qnil )
    {
        RAWLOG_FATAL("RHO framework creating failed. Application will exit.");
    }

#ifdef ENABLE_RUBY_VM_STAT
    gettimeofday (&end, NULL);

    if ( end.tv_sec > 0 )
        g_require_compiled_msec += (end.tv_sec  - start.tv_sec) * 1000;
    else
        g_require_compiled_msec += (end.tv_usec - start.tv_usec)/1000; 

#endif

    rb_gc_register_mark_object(framework);

    CONST_ID(framework_mid, "serve");
    CONST_ID(framework_mid2, "serve_index");
    CONST_ID(initApp_mid, "init_app");
    CONST_ID(onConfigConflicts_mid, "on_config_conflicts");
    CONST_ID(activateApp_mid, "activate_app");
    CONST_ID(deactivateApp_mid, "deactivate_app");
    CONST_ID(uiCreated_mid, "ui_created");
    CONST_ID(uiDestroyed_mid, "ui_destroyed");
    CONST_ID(loadServerSources_mid,"load_server_sources");
    CONST_ID(loadAllSyncSources_mid,"load_all_sync_sources");
    CONST_ID(resetDBOnSyncUserChanged_mid, "reset_db_on_sync_user_changed");

    //moduleRhom = rb_const_get(rb_cObject, rb_intern("Rhom"));

#ifdef ENABLE_RUBY_VM_STAT
    g_collect_stat = 0; 
#endif

    }
}
Ejemplo n.º 3
0
void System_Time(void)
{
	// task setup
	INT16U milis = 0;
	INT16U segundos = 0;

	OSResetTime();

	led_onboard_init();
	
	led_onboard_on();
	
	#if RTC_PRESENTE
		while(Init_Calendar() == FALSE)
		{
			DelayTask(10);
			#if (WATCHDOG == 1)
				__RESET_WATCHDOG();
			#endif			
		}
	#endif	
	
	led_onboard_off();

	// task main loop
	for (;;)
	{
		#if (WATCHDOG == 1)
			__RESET_WATCHDOG();
		#endif     

		DelayTask(10);
		milis += 10;
		
		if (milis >= 1000)
		{
			milis = 0;
			
			OSUpdateUptime();
			OSUpdateCalendar();
			
			segundos++;
			if (segundos == 3600)
			{
				segundos = 0;
				
				#if RTC_PRESENTE				
					Resync_calendar();  // resync with RTC every 3600s = 60min = 1h
				#endif				
				
			}
		}

		///////////////////////////////////////////////////
		///   FatFS Timer Handler                       ///
		///////////////////////////////////////////////////
		disk_timerproc();
		///////////////////////////////////////////////////        
	}

}