コード例 #1
0
int MicroHttpMain(int npar,char **par) {
int i,Limit=1000000;
if (npar==1) {
    printf("microHttp.exe -p[port] -r[rootDir] -d[debugLevel] -m[ext=mime[&..]]) -L[limitPPS:1000000]\n");
    return 0;
    }
for(i=1;i<npar;i++) {
    char *cmd = par[i];
    if (*cmd=='-') cmd++;
    switch(*cmd) {
    case 'p': sscanf(cmd+1,"%d",&port); break;
    //case 'S': sscanf(cmd+1,"%d",&sleepTime); break;
    case 'd': sscanf(cmd+1,"%d",&logLevel); break;
    case 'k': sscanf(cmd+1,"%d",&keepAlive); break;
    case 'T': sscanf(cmd+1,"%d",&runTill); break;
    case 'L': sscanf(cmd+1,"%d",&Limit); break;
    case 'r': rootDir=cmd+1; break;
    case 'm': mimes = cmd+1; break;
    }
    }
net_init();
TimeUpdate();
httpSrv *srv = httpSrvCreate(0); // New Instance, no ini
srv->log =  srv->srv.log = logOpen("microHttp.log"); // Create a logger
srv->logLevel = srv->srv.logLevel = logLevel;
srv->keepAlive=keepAlive;
srv->readLimit.Limit = Limit;
IFLOG(srv,0,"...starting microHttp {port:%d,logLevel:%d,rootDir:'%s',keepAlive:%d,Limit:%d},\n   mimes:'%s'\n",
  port,logLevel,rootDir,keepAlive,Limit,
  mimes);
//printf("...Creating a http server\n");
srv->defmime= vssCreate("text/plain;charset=windows-1251",-1);
httpSrvAddMimes(srv,mimes);
//httpMime *m = httpSrvGetMime(srv,vssCreate("1.HHtm",-1));printf("Mime here %*.*s\n",VSS(m->mime));
//httpSrvAddFS(srv,"/c/","c:/",0); // Adding some FS mappings
httpSrvAddFS(srv,"/",rootDir,0); // Adding some FS mappings
httpSrvAddMap(srv, strNew("/.stat",-1), onHttpStat, 0);
if (httpSrvListen(srv,port)<=0) { // Starts listen port
   Logf("-FAIL start listener on port %d\n",port); return 1;
   }
Logf(".. listener is ready, Ctrl+C to abort\n");
if (runTill) srv->runTill = TimeNow + runTill;
httpSrvProcess(srv); // Run All messages till CtrlC...
TimeUpdate();
IFLOG(srv,0,"...stop microHttp, done:{connects:%d,requests:%d,runtime:%d}\n",
     srv->srv.connects,srv->srv.requests,TimeNow - srv->created);
return 0;
}
コード例 #2
0
ファイル: Dma.cpp プロジェクト: 0xZERO3/PCSX2-rr-lua
void SPU2writeDMA(int core, u16* pMem, u32 size) 
{
	if(hasPtr) TimeUpdate(*cPtr);

	Cores[core].DMAPtr=pMem;

	if(size<2) {
		//if(dma7callback) dma7callback();
		Cores[core].Regs.STATX &= ~0x80;
		//Cores[core].Regs.ATTR |= 0x30;
		Cores[core].DMAICounter=1;

		return;
	}

	if( IsDevBuild )
		DebugCores[core].lastsize = size;

	Cores[core].TSA&=~7;

	bool adma_enable = ((Cores[core].AutoDMACtrl&(core+1))==(core+1));

	if(adma_enable)
	{
		Cores[core].TSA&=0x1fff;
		StartADMAWrite(core,pMem,size);
	}
	else
	{
		DoDMAWrite(core,pMem,size);
	}
	Cores[core].Regs.STATX &= ~0x80;
	//Cores[core].Regs.ATTR |= 0x30;
}
コード例 #3
0
ファイル: PS2E-spu2.cpp プロジェクト: Coderx7/pcsx2
EXPORT_C_(void) CALLBACK SPU2readDMA4Mem(u16 *pMem, u32 size)	// size now in 16bit units
{
	if( cyclePtr != NULL ) TimeUpdate( *cyclePtr );

	FileLog("[%10d] SPU2 readDMA4Mem size %x\n",Cycles, size<<1);
	Cores[0].DoDMAread(pMem, size);
}
コード例 #4
0
ファイル: screen.c プロジェクト: base698/ProQCC
void *
qmalloc(int size)
{
#undef malloc
    int total = size + sizeof(int);
    void *mem = malloc(total);
    long int diff;

    if (mem == NULL)
	Error("Insufficient memory.");

    *((int *)mem) = size + sizeof(int);

    TotalAlloc += total;

    diff = TotalAlloc - LastAlloc;
    if (diff < 0L)
	diff = -diff;
    if (diff > 131072L) {
	LastAlloc = TotalAlloc;
	LastCheck = -1L;
	TimeUpdate();
    }
    return ((char *)mem + sizeof(int));
}
コード例 #5
0
ファイル: screen.c プロジェクト: base698/ProQCC
void 
ShowWarningEntry(char *format,...)
{
    char text[1024];
    va_list v;

    va_start(v, format);
    vsprintf(text, format, v);

    SetBackColor(ANSI_BLUE);

    if (StatusLine > ScrnHeight - 2) {
	SetForeColor(ANSI_WHITE);
	ScrollText();
	StatusLine--;
    }
    SetForeColor(ANSI_RED);

    MoveCurs(2, StatusLine);
    CPrintf("$f1*** %s", text);

    if (logging) {
	LogFile = fopen("error.log", "a+");
	if (LogFile != NULL)
	    CfPrintf(LogFile, "*** %s", text);
	fclose(LogFile);
    }
    StatusLine++;

    TimeUpdate();
}
コード例 #6
0
ファイル: screen.c プロジェクト: base698/ProQCC
void 
ShowTempEntry(char *format,...)
{
    char text[1024];
    va_list v;

    va_start(v, format);
    vsprintf(text, format, v);

    SetBackColor(ANSI_BLUE);

    if (StatusLine > ScrnHeight - 2) {
	SetForeColor(ANSI_WHITE);
	ScrollText();
	StatusLine--;
    }
    SetForeColor(ANSI_YELLOW);

    MoveCurs(4, StatusLine);
    CPrintf("%s", text);

    StatusLine++;

    TimeUpdate();
}
コード例 #7
0
ファイル: PS2E-spu2.cpp プロジェクト: Coderx7/pcsx2
EXPORT_C_(void) CALLBACK SPU2readDMA7Mem(u16* pMem, u32 size)
{
	if( cyclePtr != NULL ) TimeUpdate( *cyclePtr );

	FileLog("[%10d] SPU2 readDMA7Mem size %x\n",Cycles, size<<1);
	Cores[1].DoDMAread(pMem,size);
}
コード例 #8
0
ファイル: DA.c プロジェクト: stefanberger/libtpms
/* This function requires that NV be available and not rate limiting. */
void
DAStartup(
	  STARTUP_TYPE     type           // IN: startup type
	  )
{
    NOT_REFERENCED(type);
#if !ACCUMULATE_SELF_HEAL_TIMER
    _plat__TimerWasReset();
    s_selfHealTimer = 0;
    s_lockoutTimer = 0;
#else
    if(_plat__TimerWasReset())
	{
	    if(!NV_IS_ORDERLY)
		{
		    // If shutdown was not orderly, then don't really know if go.time has
		    // any useful value so reset the timer to 0. This is what the tick
		    // was reset to
		    s_selfHealTimer = 0;
		    s_lockoutTimer = 0;
		}
	    else
		{
		    // If we know how much time was accumulated at the last orderly shutdown
		    // subtract that from the saved timer values so that they effectively
		    // have the accumulated values
		    s_selfHealTimer -= go.time;
		    s_lockoutTimer -= go.time;
		}
	}
#endif
    // For any Startup(), if lockoutRecovery is 0, enable use of lockoutAuth.
    if(gp.lockoutRecovery == 0)
	{
	    gp.lockOutAuthEnabled = TRUE;
	    // Record the changes to NV
	    NV_SYNC_PERSISTENT(lockOutAuthEnabled);
	}
    // If DA has not been disabled and the previous shutdown is not orderly
    // failedTries is not already at its maximum then increment 'failedTries'
    if(gp.recoveryTime != 0
       && gp.failedTries < gp.maxTries
       && !IS_ORDERLY(g_prevOrderlyState))
	{
#if USE_DA_USED
	    gp.failedTries += g_daUsed;
	    g_daUsed = FALSE;
#else
	    gp.failedTries++;
#endif
	    // Record the change to NV
	    NV_SYNC_PERSISTENT(failedTries);
	}
    // Before Startup, the TPM will not do clock updates. At startup, need to
    // do a time update which will do the DA update.
    TimeUpdate();
    return;
}
コード例 #9
0
ファイル: Stage.cpp プロジェクト: chocomellon/Defoliation
// 準備後の処理
void CStage::UpdateOfAfterReady(){
	if (isReady || isFinish)return;
	Control();
	TimeUpdate();

	for (auto &Obj : m_obj_list){
		Obj->Update();
	}
	std::dynamic_pointer_cast<CPlayer>(m_obj_list[0])->UpdateOfObject(m_obj_list);

}
コード例 #10
0
ファイル: PS2E-spu2.cpp プロジェクト: Coderx7/pcsx2
EXPORT_C_(void) CALLBACK SPU2writeDMA7Mem(u16* pMem, u32 size)
{
	if( cyclePtr != NULL ) TimeUpdate( *cyclePtr );

	FileLog("[%10d] SPU2 writeDMA7Mem size %x at address %x\n",Cycles, size<<1, Cores[1].TSA);
#ifdef S2R_ENABLE
	if(!replay_mode)
		s2r_writedma7(Cycles,pMem,size);
#endif
	Cores[1].DoDMAwrite(pMem,size);
}
コード例 #11
0
ファイル: PS2E-spu2.cpp プロジェクト: AdmiralCurtiss/pcsx2
CALLBACK SPU2writeDMA4Mem(u16 *pMem, u32 size) // size now in 16bit units
{
    if (cyclePtr != NULL)
        TimeUpdate(*cyclePtr);

    FileLog("[%10d] SPU2 writeDMA4Mem size %x at address %x\n", Cycles, size << 1, Cores[0].TSA);
#ifdef S2R_ENABLE
    if (!replay_mode)
        s2r_writedma4(Cycles, pMem, size);
#endif
    Cores[0].DoDMAwrite(pMem, size);
}
コード例 #12
0
ファイル: Scheduler.cpp プロジェクト: BuckRogers1965/Examples
 void
 DoTasks(){
     // Do all this stuff in Exec Tasks to make the main loop easier to maintain. 
   // Call timer loop.
   unsigned long offset;
   int CountOfScheduledTasks = 0;
   offset = (unsigned long) TimeUpdate();
   //if ( offset > 0 )
   //  AdjustDelayedTasks (Tasks, offset);
 
   CountOfScheduledTasks = ExecTasks(Tasks);
 }
コード例 #13
0
void CountFPS ()
{
	frames++;

	// is this correct?
	if (TimePassed() >= 1000)
	{
		fps = (fps + frames) / 2; 
		TimeUpdate();
		frames = 0;
	}
}
コード例 #14
0
ファイル: main.c プロジェクト: BuckRogers1965/DataObj
void
MainLoop(NodeObj Main){

	long offset;

	int CountOfScheduledTasks = 0;

	offset = TimeUpdate();

	if ( offset )
		AdjustDelayedTasks (Tasks, offset);

	CountOfScheduledTasks = ExecTasks(Tasks);

	/* if we have no scheduled tasks, then begin stopping */
	if (CountOfScheduledTasks == 0)
		SetPropInt(Main, "State", Stopping);
		
}
コード例 #15
0
void SandClock::run()
{  
  if(!initFlag)
  {
    initFlag = true;
    init();
  }
  
  if(tilt_value != digitalRead(TILT_PIN))
  {
    tilt_value = digitalRead(TILT_PIN);
    T25Minutes = 25*60;
    displayflag = 1;
  }
  
  TimeUpdate();
  if(tilt_value == 0) tm1637.display(TimeDisp,DISPLAY_FLAG_F);
  if(tilt_value == 1) tm1637.display(TimeDisp,DISPLAY_FLAG_B);
}
コード例 #16
0
ファイル: screen.c プロジェクト: base698/ProQCC
void 
qfree(void *mem)
{
#undef free
    long int diff;
    char *tmp = mem;

    mem = tmp - sizeof(int);

    TotalAlloc -= *((int *)mem);

    diff = TotalAlloc - LastAlloc;
    if (diff < 0L)
	diff = -diff;
    if (diff > 131072L) {
	LastAlloc = TotalAlloc;
	LastCheck = -1L;
	TimeUpdate();
    }
    free(mem);
}
コード例 #17
0
ファイル: main.c プロジェクト: BuckRogers1965/DataObj
int 
main ( int argc, char* argv[] ){

	NodeObj Main = NewNode();

	SetPropInt(Main, "State", Starting);

	TimeUpdate();

	DebugPrint ( "Entering Main", __FILE__, __LINE__, PROG_FLOW);

	ProcessCmdLine(Main, argc, argv);

	Init(Main);

	InstallObjects();

	LoadDefaultApp(Main);

	DebugPrint ( "Entering Main Loop.", __FILE__, __LINE__, PROG_FLOW);

	while(IsRunning(Main)){
		MainLoop(Main);
		// improvement: get delay from next scheduled item, min of 10 usecs
		usleep(10);
	}

	DebugPrint ( "No more tasks scheduled, cleaning up and exiting", __FILE__, __LINE__, PROG_FLOW);

	if (GetValueInt(GetPropNode(Main, "PrintNodes"))) {
		DebugPrint ( "Dumping Main Node on exit because -p was passed on command line.\n", __FILE__, __LINE__, PROG_FLOW);
		PrintNode(Main);
	}

	return 0;
}
コード例 #18
0
ファイル: httpTest.c プロジェクト: vSlipenchuk/vos
int MicroHttpMain(int npar,char **par) {
int i,Limit=1000000;
if (npar==1) {
    printf("microHttp.exe -p[port] -r[rootDir] -d[debugLevel] -m[ext=mime[&..]]) -L[limitPPS:1000000] -S[cert.pem]\n");
    return 0;
    }
for(i=1;i<npar;i++) {
    char *cmd = par[i];
    if (*cmd=='-') cmd++;
    switch(*cmd) {
    case 'p': sscanf(cmd+1,"%d",&port); break;
    //case 'S': sscanf(cmd+1,"%d",&sleepTime); break;
    case 'd': sscanf(cmd+1,"%d",&logLevel); break;
    case 'k': sscanf(cmd+1,"%d",&keepAlive); break;
    case 'T': sscanf(cmd+1,"%d",&runTill); break;
    case 'L': sscanf(cmd+1,"%d",&Limit); break;
    case 'r': rootDir=cmd+1; break;
    case 'm': mimes = cmd+1; break;
    case 'S': pem = cmd+1; break;
    }
    }
net_init();
TimeUpdate();
httpSrv *srv = httpSrvCreate(0); // New Instance, no ini
srv->log =  srv->srv.log = logOpen("microHttp.log"); // Create a logger
srv->logLevel = srv->srv.logLevel = logLevel;
srv->keepAlive=keepAlive;
srv->readLimit.Limit = Limit;

#ifdef VOS_SSL
if (pem) {
srv->srv.pem_file=pem; // if have SSL
printf("SSL will use pem_file: %s\n",pem);
} else printf("==NO SSL==, use plain tcp_sockets\n");
#endif

ws = wsSrvCreate();
ws->onMessage = onWebMessage;

IFLOG(srv,0,"...starting microHttp {port:%d,logLevel:%d,rootDir:'%s',keepAlive:%d,Limit:%d},\n   mimes:'%s'\n",
  port,logLevel,rootDir,keepAlive,Limit,
  mimes);
//printf("...Creating a http server\n");
srv->defmime= vssCreate("text/plain;charset=utf-8",-1);
httpSrvAddMimes(srv,mimes);
//httpMime *m = httpSrvGetMime(srv,vssCreate("1.HHtm",-1));printf("Mime here %*.*s\n",VSS(m->mime));
//httpSrvAddFS(srv,"/c/","c:/",0); // Adding some FS mappings
httpSrvAddFS(srv,"/",rootDir,0); // Adding some FS mappings
httpSrvAddMap(srv, strNew("/.stat",-1), onHttpStat, 0);
httpSrvAddMap(srv, strNew("/.chat",-1), onWebSock, 0);

if (httpSrvListen(srv,port)<=0) { // Starts listen port
   Logf("-FAIL start listener on port %d\n",port); return 1;
   }
Logf(".. listener is ready, Ctrl+C to abort\n");
if (runTill) srv->runTill = TimeNow + runTill;

//httpSrvProcess(srv); // Run All messages till CtrlC...

while(!aborted) {
  TimeUpdate(); // TimeNow & szTimeNow
  int cnt = SocketPoolRun(&srv->srv);
      cnt+=wsSrvStep(ws);
  //printf("SockPoolRun=%d time:%s\n",cnt,szTimeNow); msleep(1000);
  RunSleep(cnt); // Empty socket circle -)))
  if (srv->runTill && TimeNow>=srv->runTill) break; // Done???
  }


TimeUpdate();
IFLOG(srv,0,"...stop microHttp, done:{connects:%d,requests:%d,runtime:%d}\n",
     srv->srv.connects,srv->srv.requests,TimeNow - srv->created);
return 0;
}
コード例 #19
0
//------------------------------------------------------------------------------
void ExtendedKalmanInv::Estimate()
{
   #ifdef DEBUG_ESTIMATION
      MessageInterface::ShowMessage("\n\n---------------------\n");
      MessageInterface::ShowMessage("Current covariance:\n");
      for (UnsignedInt i = 0; i < stateSize; ++i)
      {
         for (UnsignedInt j = 0; j < stateSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", (*covariance)(i,j));
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");

      MessageInterface::ShowMessage("Current stm:\n");
      for (UnsignedInt i = 0; i < stateSize; ++i)
      {
         for (UnsignedInt j = 0; j < stateSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", (*stm)(i,j));
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");

      MessageInterface::ShowMessage("Current State: [ ");
      for (UnsignedInt i = 0; i < stateSize; ++i)
         MessageInterface::ShowMessage(" %.12lf ", (*estimationState)[i]);
      MessageInterface::ShowMessage("\n");
   #endif

   // Perform the time update of the covariances, phi P phi^T, and the state
   TimeUpdate();

   #ifdef DEBUG_ESTIMATION
      MessageInterface::ShowMessage("Time updated matrix \\bar P:\n");
      for (UnsignedInt i = 0; i < stateSize; ++i)
      {
         for (UnsignedInt j = 0; j < stateSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", pBar(i,j));
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");
   #endif

   // Construct the O-C data and H tilde
   ComputeObs();

   #ifdef DEBUG_ESTIMATION
      MessageInterface::ShowMessage("hTilde:\n");
      for (UnsignedInt i = 0; i < measSize; ++i)
      {
         for (UnsignedInt j = 0; j < stateSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", hTilde[i][j]);
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");
   #endif

   // Then the Kalman gain
   ComputeGain();

   #ifdef DEBUG_ESTIMATION
      MessageInterface::ShowMessage("The Kalman gain is: \n");
      for (UnsignedInt i = 0; i < stateSize; ++i)
      {
         for (UnsignedInt j = 0; j < measSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", kalman(i,j));
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");
   #endif

   // Finally, update everything
   UpdateElements();

   // Plot residuals if set
   if (showAllResiduals)
      PlotResiduals();


   #ifdef DEBUG_ESTIMATION
      MessageInterface::ShowMessage("Updated covariance:\n");
      for (UnsignedInt i = 0; i < stateSize; ++i)
      {
         for (UnsignedInt j = 0; j < stateSize; ++j)
            MessageInterface::ShowMessage("   %.12lf", (*covariance)(i,j));
         MessageInterface::ShowMessage("\n");
      }
      MessageInterface::ShowMessage("\n");

      MessageInterface::ShowMessage("Updated State: [ ");
      for (UnsignedInt i = 0; i < stateSize; ++i)
         MessageInterface::ShowMessage(" %.12lf ", (*estimationState)[i]);
      MessageInterface::ShowMessage("\n\n---------------------\n");
   #endif

   // ReportProgress();

   // Advance MeasMan to the next measurement and get its epoch
   measManager.AdvanceObservation();
   nextMeasurementEpoch = measManager.GetEpoch();
   FindTimeStep();

   #ifdef DEBUG_ESTIMATION
      MessageInterface::ShowMessage("CurrentEpoch = %.12lf, next "
            "epoch = %.12lf, timeStep = %.12lf\n", currentEpoch,
            nextMeasurementEpoch, timeStep);
   #endif

   if (currentEpoch < nextMeasurementEpoch)
   {
      // Reset the STM
      for (UnsignedInt i = 0; i < stateSize; ++i)
         for (UnsignedInt j = 0; j < stateSize; ++j)
            if (i == j)
               (*stm)(i,j) = 1.0;
            else
               (*stm)(i,j) = 0.0;
      esm.MapSTMToObjects();
      esm.MapVectorToObjects();
      PropagationStateManager *psm = propagator->GetPropStateManager();
      psm->MapObjectsToVector();

      // Flag that a new current state has been loaded in the objects
      resetState = true;

      currentState = PROPAGATING;
   }
   else
      currentState = CHECKINGRUN;  // Should this just go to FINISHED?
}
コード例 #20
0
ファイル: Dma.cpp プロジェクト: 0xZERO3/PCSX2-rr-lua
void SPU2readDMA(int core, u16* pMem, u32 size) 
{
	if(hasPtr) TimeUpdate(*cPtr);

	Cores[core].TSA &= 0xffff8;

	u32 buff1end = Cores[core].TSA + size;
	u32 buff2end = 0;
	if( buff1end > 0x100000 )
	{
		buff2end = buff1end - 0x100000;
		buff1end = 0x100000;
	}

	const u32 buff1size = (buff1end-Cores[core].TSA);
	memcpy( pMem, GetMemPtr( Cores[core].TSA ), buff1size*2 );

	if( buff2end > 0 )
	{
		// second branch needs cleared:
		// It starts at the beginning of memory and moves forward to buff2end

		memcpy( &pMem[buff1size], GetMemPtr( 0 ), buff2end*2 );

		Cores[core].TDA = (buff2end+0x20) & 0xfffff;

		for( int i=0; i<2; i++ )
		{
			if(Cores[i].IRQEnable)
			{
				// Flag interrupt?
				// If IRQA occurs between start and dest, flag it.
				// Since the buffer wraps, the conditional might seem odd, but it works.

				if( ( Cores[i].IRQA >= Cores[core].TSA ) ||
					( Cores[i].IRQA <= Cores[core].TDA ) )
				{
					Spdif.Info=4<<i;
					SetIrqCall();
				}
			}
		}
	}
	else
	{
		// Buffer doesn't wrap/overflow!
		// Just set the TDA and check for an IRQ...

		Cores[core].TDA = buff1end;

		for( int i=0; i<2; i++ )
		{
			if(Cores[i].IRQEnable)
			{
				// Flag interrupt?
				// If IRQA occurs between start and dest, flag it:

				if( ( Cores[i].IRQA >= Cores[i].TSA ) &&
					( Cores[i].IRQA <= Cores[i].TDA+0x1f ) )
				{
					Spdif.Info=4<<i;
					SetIrqCall();
				}
			}
		}
	}


	Cores[core].TSA=Cores[core].TDA & 0xFFFFF;

	Cores[core].DMAICounter=size;
	Cores[core].Regs.STATX &= ~0x80;
	//Cores[core].Regs.ATTR |= 0x30;
	Cores[core].TADR=Cores[core].MADR+(size<<1);

}
コード例 #21
0
int httpTestMain(int npar,char **par) {
int i,sock=1,pack=1,logLevel=1;
int MaxPacket = 1000000;
char *url,*Proxy="";
net_init();
signal(SIGINT,sig_done);
if (npar<2) {
    httpTestHelp();
    return 1; // Error
    }
char *cmd=par[1];
if (strncmp(cmd,"-p",2)==0) return MicroHttpMain(npar,par);
if (strncmp(cmd,"http://",7)==0) cmd+=7; // RemoveHTTP
url=cmd;
static Counter read={100000}; // ReadLimit
for(i=2;i<npar;i++) { // Decode Optional
    char *cmd=par[i]; int ok=1;
    if (*cmd=='-') {
    cmd++; ok=1;
    if (*cmd=='s') sscanf(cmd+1,"%d",&sock);
    //else if (*cmd=='S') sscanf(cmd+1,"%d",&sleepTime);
    else if (*cmd=='p') sscanf(cmd+1,"%d",&pack);
    else if (*cmd=='d') sscanf(cmd+1,"%d",&logLevel);
    else if (*cmd=='M') sscanf(cmd+1,"%d",&MaxPacket);
    else if (*cmd=='P') Proxy=cmd+1;
    else if (*cmd=='R') sscanf(cmd+1,"%d",&ReplayCode);
    else if (*cmd=='r') sscanf(cmd+1,"%d",&read.Limit);
    else ok=0;
    }
    if (!ok) {
        printf("httpTest - unknownParameter: '%s'\n",cmd);
        httpTestHelp();
        return 2;
        }
    }
//thread_create(httpClientTest1);

httpClient *Cli[sock];
logger *log;
log = logOpen("httpTest.log");
Logf("httpStressTest: {logLevel:%d,Sockets:%d,Commands:%d,MaxPacket:%d,URL:'%s',Proxy='%s'\n",
   logLevel,sock,pack,MaxPacket,url,Proxy);
for(i=0;i<sock;i++) {
     httpClient *c;
     Cli[i]= c = httpClientNew();
     c->log = log;
     c->logLevel = logLevel;
     snprintf(c->name,sizeof(c->name),"[%d]%s",i,url);
     if (!httpClientInit(c,url,Proxy)) return 0;
     c->onDisconnect = onTestDisconnect;
     c->sock.readPacket = &read;

     //c->sock->readPacket.Limit = readPackLimit;
     //printf("Begin?\n");
     int j; for(j=0;j<pack;j++) SendTestPack(c); // SendTestPacks
     //printf("Done?\n");
     }
TimeUpdate(); time_t Started=TimeNow;
printf("StressStarted: %s, mem=%d\n",szTimeNow,os_mem_used());
while(!aborted) {
  int c=0;
  TimeUpdate();
  for(i=0;i<sock;i++) if (httpClientRun(Cli[i])) c++;
  if (read.Total>=MaxPacket) {
      Logf("MaxPacket %d received\n", MaxPacket);
      break;
      }
  //printf("Run=%d\n",c);
  RunSleep(c);
  if (NeedReport()) Reportf("Time:'%s',Packet_Per_Second:%5d,Total:%5d,os_mem:%d",szTimeNow,
     (read.pValue+read.ppValue)/2,read.Total,os_mem_used());
  //if (!c) msleep(1);
  }
TimeUpdate(); int Dur=TimeNow-Started,PPS=0; if (Dur) PPS=read.Total/Dur;
printf("StressStopped:'%s',Dur:%d,PPS:%d,Total:%5d,os_mem:%d",szTimeNow,Dur,PPS,read.Total,os_mem_used());
return 0;
//return httpClientTest1(logLevel,sock,pack,url); // Слушай - а у меня в микрохттп нету ли такого - что я останавливаюсь???
}
コード例 #22
0
ファイル: Kalman.cpp プロジェクト: BabyFlower/Tracking
	void Kalman::predict(Frame & frame)
	{

		for(std::vector<Object>::iterator i = frame.objects.begin(); i != frame.objects.end(); i++)
		{
			float yData[] = {(float)i->x, (float)i->y};
			y = Mat(2, 1, CV_32FC1, yData);

			// If object is not found in current frame perform only Time Update
			if (i->isChild != true && i->isLost != true)
			{
				MeasurementUpdate(i);
			}
			TimeUpdate(i);

			// Add uncertainty to object
			i->addPositionUncertainty(i->model.P.at<float>(0,0), i->model.P.at<float>(1,1));
			i->positionUncertantyX = std::min(i->positionUncertantyX, 1000000.0f);
			i->positionUncertantyY = std::min(i->positionUncertantyY, 1000000.0f);

			xHat = i->model.xHat.ptr<float>();
			i->xHat = xHat[0];
			i->yHat	= xHat[1];




			// Smooth velocity with 5 latest measurements
			i->model.dxHist.push_front(xHat[2]);
			i->model.dyHist.push_front(xHat[3]);

			if (i->model.dxHist.size() > i->model.smoothingHistoryAmount)
			{
				i->model.dxHist.pop_back();
				i->model.dyHist.pop_back();
			}

			float dxMean = 0;
			float dyMean = 0;
			int sampleAmount = i->model.smoothingHistoryAmount;
			
			for (list<float>::iterator j = i->model.dxHist.begin(); j != i->model.dxHist.end(); j++)
			{
				dxMean += *j;
			}
			for (list<float>::iterator j = i->model.dyHist.begin(); j != i->model.dyHist.end(); j++)
			{
				dyMean += *j;
			}
			/*
			if(!i->model.hasConverged)
			{
				if(i->model.preConvergenceIteration < i->model.smoothingHistoryAmount)
				{
					sampleAmount = i->model.preConvergenceIteration;
					i->model.preConvergenceIteration++;
				}
				else
					i->model.hasConverged = true;

				dxMean = xHat[2];
				dyMean = xHat[3];
				std::cout << "hasNotConverged!!!\n";
			}
			else
			{
			}*/
				dxMean = dxMean/sampleAmount;
				dyMean = dyMean/sampleAmount;

			if (i->model.dxHist.size() == i->model.smoothingHistoryAmount)
			{
				i->dx = dxMean;
				i->dy = dyMean;
			}

			if (i->isChild == true || i->isLost == true)
			{
				i->x = (int)floor(i->xHat + 0.5);
				i->y = (int)floor(i->yHat + 0.5);
			}
			//cout << i->model.P << endl;
			//waitKey(0);
		}
	}