Пример #1
0
// called in Com_Frame, so don't take up any time! (can also be called during dedicated)
//
void SP_CheckForLanguageUpdates(void)
{
	if (sp_language && sp_language->modified)
	{
		SP_Init();	// force language package to reload
		sp_language->modified = qfalse;
	}
}
int Unscented_Kalman_Filter::_update(const dcovector &Y)
{
      Gaussian_Nonlinear_Model *m=dynamic_cast<Gaussian_Nonlinear_Model *>(model);

      const double _2_PI_= 6.283185307;

      int N,i;
      dgematrix cyy,cxy,k;
      dcovector my,mx;
      dcovector I;

      
      if(SP_Init())
            return 1;

      N=sX.size();

      for(i=0;i<N;i++)
	    {
		  sX[i]=m->State_Function(sX[i],sW[i]);
	    }

      U_Mean(sX,mx);


      U_Cov(sX,mx,sX,mx,Rp);
      Xp=mx;


      for(i=0;i<N;i++)
	    {
		  sY[i]=m->Observation_Function(sX[i]);
	    }

      U_Mean(sY,my);
      U_Cov(sY,my,sY,my,cyy);

      cyy=cyy + m->Qv;

      U_Cov(sX,mx,sY,my,cxy);

      k=cxy*CPPL::i(cyy);

      I = (Y-my);
      M = mx + k * I;

      R = Rp - k * cyy * t(k);


      Likelihood += -0.5* I.l * log(_2_PI_) - 0.5*log(det(cyy)) - 0.5 * CPPL::t(I) * CPPL::i(cyy) * I;

      return 0;
}
SAPIRESULTCODE	CSAPIConfig::SP_New(char* lpConfigName)
{
	SAPIRESULTCODE iRet;
	DeleteAll();
	iRet = SP_Init();
	if(SAPI_OK != iRet)
	{
		return iRet;
	}
	SAPI_ASSERT(strlen(lpConfigName) < MAX_STRING_COUNT_HUGE);
	strncpy(m_szConfigFile,lpConfigName,MAX_STRING_COUNT_HUGE-1);

	return iRet;
}
SAPIRESULTCODE	CSAPIConfig::SP_Open(char* lpConfigName)
{
	SAPIRESULTCODE iRet;
	DeleteAll();

	iRet = SP_Init();
	if(SAPI_OK != iRet)
	{
		return iRet;
	}

	SAPI_ASSERT(strlen(lpConfigName) < MAX_STRING_COUNT_HUGE);
	strncpy(m_szConfigFile,lpConfigName,MAX_STRING_COUNT_HUGE-1);
	
	SAPI_DB_PRINTF("SP_Open---m_szConfigFile = %s\r\n",m_szConfigFile);
	iRet = __SP_Read();
	if(SAPI_OK != iRet)
	{
		return iRet;
	}

	return iRet;
}
Пример #5
0
/*
=================
Com_Init
=================
*/
void Com_Init( char *commandLine ) {
	char	*s;

	Com_Printf( "%s %s %s\n", Q3_VERSION, CPUSTRING, __DATE__ );

	try {
		// prepare enough of the subsystems to handle
		// cvar and command buffer management
		Com_ParseCommandLine( commandLine );
		
		Swap_Init ();
		Cbuf_Init ();
		
		Com_InitZoneMemory();

		Cmd_Init ();
		Cvar_Init ();
		
		// get the commandline cvars set
		Com_StartupVariable( NULL );

		// done early so bind command exists
		CL_InitKeyCommands();
		
		FS_InitFilesystem ();	//uses z_malloc
		
		Com_InitJournaling();
		
		Cbuf_AddText ("exec default.cfg\n");

		// skip the jk2config.cfg if "safe" is on the command line
		if ( !Com_SafeMode() ) {
			Cbuf_AddText ("exec jk2config.cfg\n");
		}

		Cbuf_AddText ("exec autoexec.cfg\n");
		
		Cbuf_Execute ();
		
		// override anything from the config files with command line args
		Com_StartupVariable( NULL );
		
		// allocate the stack based hunk allocator
		Com_InitHunkMemory();

		// if any archived cvars are modified after this, we will trigger a writing
		// of the config file
		cvar_modifiedFlags &= ~CVAR_ARCHIVE;
		
		//
		// init commands and vars
		//
		Cmd_AddCommand ("quit", Com_Quit_f);
		Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );
		
		com_maxfps = Cvar_Get ("com_maxfps", "85", CVAR_ARCHIVE);
		
		com_developer = Cvar_Get ("developer", "0", CVAR_TEMP );
		com_logfile = Cvar_Get ("logfile", "0", CVAR_TEMP );
		com_speedslog = Cvar_Get ("speedslog", "0", CVAR_TEMP );
		
		com_timescale = Cvar_Get ("timescale", "1", CVAR_CHEAT );
		com_fixedtime = Cvar_Get ("fixedtime", "0", CVAR_CHEAT);
		com_showtrace = Cvar_Get ("com_showtrace", "0", CVAR_CHEAT);
		com_viewlog = Cvar_Get( "viewlog", "0", CVAR_TEMP );
		com_speeds = Cvar_Get ("com_speeds", "0", 0);
		
		cl_paused	   = Cvar_Get ("cl_paused", "0", CVAR_ROM);
		sv_paused	   = Cvar_Get ("sv_paused", "0", CVAR_ROM);
		com_sv_running = Cvar_Get ("sv_running", "0", CVAR_ROM);
		com_cl_running = Cvar_Get ("cl_running", "0", CVAR_ROM);
		com_skippingcin = Cvar_Get ("skippingCinematic", "0", CVAR_ROM);
		com_buildScript = Cvar_Get( "com_buildScript", "0", 0 );
		
		com_FirstTime = Cvar_Get( "com_FirstTime", "0", CVAR_ARCHIVE);
		if ( com_developer && com_developer->integer ) {
			Cmd_AddCommand ("error", Com_Error_f);
			Cmd_AddCommand ("crash", Com_Crash_f );
			Cmd_AddCommand ("freeze", Com_Freeze_f);
		}
		
		s = va("%s %s %s", Q3_VERSION, CPUSTRING, __DATE__ );
		com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );

		SP_Init();	// Initialize StripEd
	
		Sys_Init();	// this also detects CPU type, so I can now do this CPU check below...

		if( !com_FirstTime->integer )	// special request to detect and use top-settings for Intel Williamette chip...	
		{
			Cvar_Set( "com_FirstTime", "1" );	// only do this once			
			//
			// ( make a local ptr only for quick test, since this is a common module )
			//
			cvar_t* s_CPUType = Cvar_Get("sys_cpuid","",0);
			if (s_CPUType->value == CPUID_INTEL_WILLIAMETTE)
			{
				Cbuf_AddText ("exec perfect.cfg\n");
//				Cbuf_Execute ();
			}
		}

		Netchan_Init( Com_Milliseconds() & 0xffff );	// pick a port value that should be nice and random
//	VM_Init();
		SV_Init();
		
		CL_Init();
		Sys_ShowConsole( com_viewlog->integer, qfalse );
		
		// set com_frameTime so that if a map is started on the
		// command line it will still be able to count on com_frameTime
		// being random enough for a serverid
		com_frameTime = Com_Milliseconds();

		// add + commands from command line
		if ( !Com_AddStartupCommands() ) {
#ifdef NDEBUG
			// if the user didn't give any commands, run default action
//			if ( !com_dedicated->integer ) 
			{
				Cbuf_AddText ("cinematic openinglogos\n");				
//				if( !com_introPlayed->integer ) {
//					Cvar_Set( com_introPlayed->name, "1" );
//					Cvar_Set( "nextmap", "cinematic intro" );
//				}
			}
#endif	
		}
		com_fullyInitialized = qtrue;
		Com_Printf ("--- Common Initialization Complete ---\n");
	}

	catch (const char* reason) {
		Sys_Error ("Error during initialization %s", reason);
	}

}
Пример #6
0
// *****************************************************************************
// InitialiseHW
// Setup the processor
// *****************************************************************************
void InitialiseHW ( void )
{
	// If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
	// a workaround to allow the PLL to operate reliably.
	//
	if(REVISION_IS_A2)
	{
		SysCtlLDOSet(SYSCTL_LDO_2_75V);
	}

	// 50 MHz
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	// Enable Peripherals
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

	// Set interrupt priority levels
	IntPrioritySet(INT_ETH, 0x20);
	IntPrioritySet(FAULT_SYSTICK, 0x40);

	//
	// Enable the peripherals that should continue to run when the processor
	// is sleeping.
	//
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOC);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOD);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOG);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOH);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART1);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ETH);

	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER0);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER1);
	SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_TIMER2);

    //
    // Enable peripheral clock gating.  Note that this is required in order to
    // measure the the processor usage.
    //
    SysCtlPeripheralClockGating(true);

	// Grab the Config from Flash
	SysConfigInit();

	AdcInit();
	pwmInit();
	RelayInit();

	//usrand(0x23482937);

	// Note (From the DriverLib) :
	// It takes five clock cycles after the write to enable a peripheral
	// before the the peripheral is actually enabled.  During this time, attempts
	// to access the peripheral result in a bus fault.  Care should be taken
	// to ensure that the peripheral is not accessed during this brief time
	// period.

	#ifdef SERIAL_ENABLED
		Serial_Init();
	#endif

	#ifdef UPNP_ENABLED
		UPnPInit();
	#endif

	Ethernet_Init();

	#ifdef LOGIC_ENABLED
		LogicStartStop(true);
	#endif

	#ifdef SOLDERBRIDGES_ENABLED
		SB_Init();
		ExtGpio_Init();

		SolderBridge_StartScan();
		ExtGpio_Scan();
	#endif

	#ifdef SPLASHPIXEL_ENABLED
		SP_Init();
	#endif

	// Set up the GPIO as specified by the user
	UserGpioInit();

	// Most, if not all M3's have a SysTick which you can use for scheduling your code
	SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
	SysTickEnable();
	SysTickIntEnable();
}