예제 #1
0
//current_sockfd == file descriptor of pipe from client
//buffer == input from client
//nread == num chars of input
void server_process(int current_sockfd, char *buffer, int nread){

      printf("message from client: %s\n", buffer);
      //Essentially original mystore3 main function,
      //with return statements eliminated
   
      char inputCopy[strlen(buffer)];
      strcpy(inputCopy, buffer+1);
      char *fields[5];
      //int nfields;

      




	

      if (!Process(inputCopy)) {
	if (errmsg[0] != '\0')
	  printf("%s\n",errmsg);
	else
	  printf("|status: ERROR: No command-line arguments, error in arguments, or error in writing to FIFO\n\nVersion: %s\n%s|\n",
		 version,Requests);
      }

      if (!readData()) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Error reading mystore.dat\n\n%s|\n", Requests);
     }

      strcpy(inputCopy, buffer+1);
      SeparateIntoFields(inputCopy, fields, 5);


      if (command == ADD && !add(fields[2],fields[3])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Failure to add new item|\n");
      }

     		 
      if (command == STAT) {
	status();
      }

      
      if (command == DISPLAY && !display(fields[2])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Cannot display %s|\n",fields[2]);
      }

      
      if (command == DELETE && !delete(fields[2])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: Cannot delete %s|\n", fields[2]);
      }

        
      if (command == EDIT && !edit(fields[2])) {
	if (errmsg[0] != '\0')
	  printf("|status: ERROR: %s|\n", errmsg);
	else
	  printf("|status: ERROR: cannot edit %s|\n",fields[2]);
      }

      if (rewrite)
	if (!writeData()) {
	  if (errmsg[0] != '\0')
	    printf("|status: ERROR: %s|\n", errmsg);
	  else
	    printf("|status: ERROR: Could not write the data, file may be destroyed|\n");
	}


}
예제 #2
0
int _tmain(int argc, char* argv[])
{
// determine my process name
_splitpath(argv[0],NULL,NULL,gszProcName,NULL);
#else
int 
main(int argc, const char** argv)
{
// determine my process name
CUtility::splitpath((char *)argv[0],NULL,gszProcName);
#endif
int iScreenLogLevel;		// level of screen diagnostics
int iFileLogLevel;			// level of file diagnostics
char szLogFile[_MAX_PATH];	// write diagnostics to this file

int Rslt;
etPMode PMode;				// processing mode
int Idx;

int NumInputFiles;							// number of input sequence files
char *pszInFastaFile[cMaxInFileSpecs];		// names of input sequence files (wildcards allowed)

char szRsltsFile[_MAX_PATH];	// output stats to this file


// command line args
struct arg_lit  *help    = arg_lit0("h","help",                 "print this help and exit");
struct arg_lit  *version = arg_lit0("v","version,ver",			"print version information and exit");
struct arg_int *FileLogLevel=arg_int0("f", "FileLogLevel",		"<int>","Level of diagnostics written to screen and logfile 0=fatal,1=errors,2=info,3=diagnostics,4=debug");
struct arg_file *LogFile = arg_file0("F","log","<file>",		"diagnostics log file");

struct arg_int *pmode = arg_int0("m","mode","<int>",		    "Processing mode:  0 - BED output, single exon");
struct arg_file *pinputfiles = arg_filen("i","infasta","<file>",1,cMaxInFileSpecs,"input fasta file(s)");
struct arg_file *RsltsFile = arg_file0("o","output","<file>",	"output BED file");
struct arg_end *end = arg_end(20);

void *argtable[] = {help,version,FileLogLevel,LogFile,
					pmode,pinputfiles,RsltsFile,
					end};
char **pAllArgs;
int argerrors;
argerrors = CUtility::arg_parsefromfile(argc,(char **)argv,&pAllArgs);
if(argerrors >= 0)
	argerrors = arg_parse(argerrors,pAllArgs,argtable);

/* special case: '--help' takes precedence over error reporting */
if (help->count > 0)
        {
		printf("\n%s Generate BED file from multifasta file, Version %s\nOptions ---\n", gszProcName,cpszProgVer);
        arg_print_syntax(stdout,argtable,"\n");
        arg_print_glossary(stdout,argtable,"  %-25s %s\n");
		printf("\nNote: Parameters can be entered into a parameter file, one parameter per line.");
		printf("\n      To invoke this parameter file then precede its name with '@'");
		printf("\n      e.g. %s @myparams.txt\n",gszProcName);
		printf("\nPlease report any issues regarding usage of %s at https://github.com/csiro-crop-informatics/biokanga/issues\n\n",gszProcName);
		exit(1);
        }

    /* special case: '--version' takes precedence error reporting */
if (version->count > 0)
        {
		printf("\n%s Version %s\n",gszProcName,cpszProgVer);
		exit(1);
        }

if (!argerrors)
	{
	if(FileLogLevel->count && !LogFile->count)
		{
		printf("\nError: FileLogLevel '-f%d' specified but no logfile '-F<logfile>\n'",FileLogLevel->ival[0]);
		exit(1);
		}

	iScreenLogLevel = iFileLogLevel = FileLogLevel->count ? FileLogLevel->ival[0] : eDLInfo;
	if(iFileLogLevel < eDLNone || iFileLogLevel > eDLDebug)
		{
		printf("\nError: FileLogLevel '-l%d' specified outside of range %d..%d\n",iFileLogLevel,eDLNone,eDLDebug);
		exit(1);
		}
	
	if(LogFile->count)
		{
		strncpy(szLogFile,LogFile->filename[0],_MAX_PATH);
		szLogFile[_MAX_PATH-1] = '\0';
		}
	else
		{
		iFileLogLevel = eDLNone;
		szLogFile[0] = '\0';
		}

	// now that log parameters have been parsed then initialise diagnostics log system
	if(!gDiagnostics.Open(szLogFile,(etDiagLevel)iScreenLogLevel,(etDiagLevel)iFileLogLevel,true))
		{
		printf("\nError: Unable to start diagnostics subsystem\n");
		if(szLogFile[0] != '\0')
			printf(" Most likely cause is that logfile '%s' can't be opened/created\n",szLogFile);
		exit(1);
		}

	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Version: %s",cpszProgVer);

	PMode = (etPMode)(pmode->count ? pmode->ival[0] : ePMdefault);
	if(PMode < ePMdefault || PMode >= ePMplaceholder)
		{
		gDiagnostics.DiagOut(eDLFatal,gszProcName,"Error: Processing mode '-m%d' specified outside of range %d..%d\n",PMode,ePMdefault,(int)ePMplaceholder-1);
		exit(1);
		}

	NumInputFiles = 0;

	for(NumInputFiles=Idx=0;NumInputFiles < cMaxInFileSpecs && Idx < pinputfiles->count; Idx++)
		{
		pszInFastaFile[Idx] = NULL;
		if(pszInFastaFile[NumInputFiles] == NULL)
			pszInFastaFile[NumInputFiles] = new char [_MAX_PATH];
		strncpy(pszInFastaFile[NumInputFiles],pinputfiles->filename[Idx],_MAX_PATH);
		pszInFastaFile[NumInputFiles][_MAX_PATH-1] = '\0';
		CUtility::TrimQuotedWhitespcExtd(pszInFastaFile[NumInputFiles]);
		if(pszInFastaFile[NumInputFiles][0] != '\0')
			NumInputFiles++;
		}

	if(!NumInputFiles)
		{
		gDiagnostics.DiagOut(eDLFatal,gszProcName,"Error: After removal of whitespace, no input file(s) specified with '-i<filespec>' option)\n");
		exit(1);
		}

	if(!RsltsFile->count)
		{
		gDiagnostics.DiagOut(eDLFatal,gszProcName,"Error: No output BED file specified");
		exit(1);
		}
	strncpy(szRsltsFile,RsltsFile->filename[0],_MAX_PATH);
	szRsltsFile[_MAX_PATH-1] = '\0';

	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Processing parameters:");
	for(Idx=0; Idx < NumInputFiles; Idx++)
		gDiagnostics.DiagOutMsgOnly(eDLInfo,"input fasta sequence files (%d): '%s'",Idx+1,pszInFastaFile[Idx]);

	if(szRsltsFile[0] != '\0')
		gDiagnostics.DiagOutMsgOnly(eDLInfo,"Output to BED file: '%s'",szRsltsFile);

#ifdef _WIN32
	SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
#endif
	// processing here...
	gStopWatch.Start();
	Rslt = Process(PMode,NumInputFiles,pszInFastaFile,szRsltsFile);

	gStopWatch.Stop();
	Rslt = Rslt >=0 ? 0 : 1;
	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Exit code: %d Total processing time: %s",Rslt,gStopWatch.Read());
	exit(Rslt);
	}
else
	{
	printf("\n%s Generate BED file from multifasta file, Version %s\n",gszProcName,cpszProgVer);
	arg_print_errors(stdout,end,gszProcName);
	arg_print_syntax(stdout,argtable,"\nUse '-h' to view option and parameter usage\n");
	exit(1);
	}
return 0;
}
예제 #3
0
    /** Returns a gnnsSatTypeValue object, adding the new data generated
     *  when calling this object.
     *
     * @param gData    Data object holding the data.
     */
 virtual gnssSatTypeValue& Process(gnssSatTypeValue& gData)
    throw(ProcessingException)
 { Process(gData.header.epoch, gData.body); return gData; };
예제 #4
0
void GLFlat::ProcessSector(sector_t * frontsector)
{
	lightlist_t * light;

#ifdef _DEBUG
	if (frontsector->sectornum==gl_breaksec)
	{
		int a = 0;
	}
#endif

	// Get the real sector for this one.
	sector=&sectors[frontsector->sectornum];	
	extsector_t::xfloor &x = sector->e->XFloor;
	this->sub=NULL;
	dynlightindex = -1;

	byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum];

	//
	//
	//
	// do floors
	//
	//
	//
	if (frontsector->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) <= FIXED2FLOAT(viewz))
	{
		// process the original floor first.

		srf |= SSRF_RENDERFLOOR;

		lightlevel = gl_ClampLight(frontsector->GetFloorLight());
		Colormap=frontsector->ColorMap;
		if ((stack = (frontsector->portals[sector_t::floor] != NULL)))
		{
			gl_drawinfo->AddFloorStack(sector);
			alpha = frontsector->GetAlpha(sector_t::floor)/65536.0f;
		}
		else
		{
			alpha = 1.0f-frontsector->GetReflect(sector_t::floor);
		}
		if (frontsector->VBOHeightcheck(sector_t::floor))
		{
			vboindex = frontsector->vboindex[sector_t::floor];
		}
		else
		{
			vboindex = -1;
		}

		ceiling=false;
		renderflags=SSRF_RENDERFLOOR;

		if (x.ffloors.Size())
		{
			light = P_GetPlaneLight(sector, &frontsector->floorplane, false);
			if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || !light->fromsector)	
				&& (light->p_lightlevel != &frontsector->lightlevel))
			{
				lightlevel = *light->p_lightlevel;
			}

			Colormap.CopyLightColor(light->extra_colormap);
		}
		renderstyle = STYLE_Translucent;
		if (alpha!=0.0f) Process(frontsector, false, false);
	}
	
	//
	//
	//
	// do ceilings
	//
	//
	//
	if (frontsector->ceilingplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) >= FIXED2FLOAT(viewz))
	{
		// process the original ceiling first.

		srf |= SSRF_RENDERCEILING;

		lightlevel = gl_ClampLight(frontsector->GetCeilingLight());
		Colormap=frontsector->ColorMap;
		if ((stack = (frontsector->portals[sector_t::ceiling] != NULL))) 
		{
			gl_drawinfo->AddCeilingStack(sector);
			alpha = frontsector->GetAlpha(sector_t::ceiling)/65536.0f;
		}
		else
		{
			alpha = 1.0f-frontsector->GetReflect(sector_t::ceiling);
		}

		if (frontsector->VBOHeightcheck(sector_t::ceiling))
		{
			vboindex = frontsector->vboindex[sector_t::ceiling];
		}
		else
		{
			vboindex = -1;
		}

		ceiling=true;
		renderflags=SSRF_RENDERCEILING;

		if (x.ffloors.Size())
		{
			light = P_GetPlaneLight(sector, &sector->ceilingplane, true);

			if ((!(sector->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING))
				&& (light->p_lightlevel != &frontsector->lightlevel))
			{
				lightlevel = *light->p_lightlevel;
			}
			Colormap.CopyLightColor(light->extra_colormap);
		}
		renderstyle = STYLE_Translucent;
		if (alpha!=0.0f) Process(frontsector, true, false);
	}

	//
	//
	//
	// do 3D floors
	//
	//
	//

	stack=false;
	if (x.ffloors.Size())
	{
		player_t * player=players[consoleplayer].camera->player;

		renderflags=SSRF_RENDER3DPLANES;
		srf |= SSRF_RENDER3DPLANES;
		// 3d-floors must not overlap!
		fixed_t lastceilingheight=sector->CenterCeiling();	// render only in the range of the
		fixed_t lastfloorheight=sector->CenterFloor();		// current sector part (if applicable)
		F3DFloor * rover;	
		int k;
		
		// floors are ordered now top to bottom so scanning the list for the best match
		// is no longer necessary.

		ceiling=true;
		for(k=0;k<(int)x.ffloors.Size();k++)
		{
			rover=x.ffloors[k];
			
			if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES))
			{
				if (rover->flags&FF_FOG && gl_fixedcolormap) continue;
				if (!rover->top.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES))
				{
					fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector));
					if (ff_top<lastceilingheight)
					{
						if (FIXED2FLOAT(viewz) <= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
						{
							SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
							Colormap.FadeColor=frontsector->ColorMap->Fade;
							Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG));
						}
						lastceilingheight=ff_top;
					}
				}
				if (!rover->bottom.copied && !(rover->flags&FF_INVERTPLANES))
				{
					fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector));
					if (ff_bottom<lastceilingheight)
					{
						if (FIXED2FLOAT(viewz)<=rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
						{
							SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
							Colormap.FadeColor=frontsector->ColorMap->Fade;
							Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG));
						}
						lastceilingheight=ff_bottom;
						if (rover->alpha<255) lastceilingheight++;
					}
				}
			}
		}
			  
		ceiling=false;
		for(k=x.ffloors.Size()-1;k>=0;k--)
		{
			rover=x.ffloors[k];
			
			if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES))
			{
				if (rover->flags&FF_FOG && gl_fixedcolormap) continue;
				if (!rover->bottom.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES))
				{
					fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector));
					if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX))
					{
						if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
						{
							SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
							Colormap.FadeColor=frontsector->ColorMap->Fade;

							if (rover->flags&FF_FIX)
							{
								lightlevel = gl_ClampLight(rover->model->lightlevel);
								Colormap = rover->GetColormap();
							}

							Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG));
						}
						lastfloorheight=ff_bottom;
					}
				}
				if (!rover->top.copied && !(rover->flags&FF_INVERTPLANES))
				{
					fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector));
					if (ff_top>lastfloorheight)
					{
						if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
						{
							SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
							Colormap.FadeColor=frontsector->ColorMap->Fade;
							Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG));
						}
						lastfloorheight=ff_top;
						if (rover->alpha<255) lastfloorheight--;
					}
				}
			}
		}
	}
}
예제 #5
0
bool SpawnManager::DoInitialSpawn() {
	//right now, just running through Process will spawn what needs to be spawned.
	Process();
	return true;
}
예제 #6
0
//---------------------------------------------------------------------------
void __fastcall TProgressForm::TimerTimer(TObject *Sender)
{
	Timer->Enabled = false;
	Process();
}
예제 #7
0
/* Function that runs the application */
INT CXBApplicationEx::Run(CFileItemList &playlist)
{
  CLog::Log(LOGNOTICE, "Running the application..." );

  unsigned int lastFrameTime = 0;
  unsigned int frameTime = 0;
  const unsigned int noRenderFrameTime = 15;  // Simulates ~66fps

  if (playlist.Size() > 0)
  {
    g_playlistPlayer.Add(0, playlist);
    g_playlistPlayer.SetCurrentPlaylist(0);
    KODI::MESSAGING::CApplicationMessenger::GetInstance().PostMsg(TMSG_PLAYLISTPLAYER_PLAY, -1);
  }

  // Run xbmc
  while (!m_bStop)
  {
#ifdef HAS_PERFORMANCE_SAMPLE
    CPerformanceSample sampleLoop("XBApplicationEx-loop");
#endif
    //-----------------------------------------
    // Animate and render a frame
    //-----------------------------------------
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      lastFrameTime = XbmcThreads::SystemClockMillis();
      Process();
      //reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS

    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::Process()");
      throw;
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Process()");
      throw;
    }
#endif
    // Frame move the scene
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      if (!m_bStop)
      {
        FrameMove(true, m_renderGUI);
      }

      //reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS
    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::FrameMove()");
      throw;
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::FrameMove()");
      throw;
    }
#endif

    // Render the scene
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      if (m_renderGUI && !m_bStop)
      {
        Render();
      }
      else if (!m_renderGUI)
      {
        frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime;
        if(frameTime < noRenderFrameTime)
          Sleep(noRenderFrameTime - frameTime);
      }
#ifdef XBMC_TRACK_EXCEPTIONS
    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::Render()");
      throw;
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Render()");
      throw;
    }
#endif
  } // while (!m_bStop)
  Destroy();

  CLog::Log(LOGNOTICE, "application stopped..." );
  return m_ExitCode;
}
예제 #8
0
파일: main.c 프로젝트: Bidski/TAJ3850
int main(void)
{

	byte bCount;
	long lTemp;

	System_Configuration();

	dxl_set_power(OFF);
	//dxl_set_power(ON);
	Zigbee_SetState(ON);
	//gbDxlPwr = ON;

	//LED_SetState(LED_POWER, ON);
	//	LED_RGB_SetState(LED_R|LED_G|LED_B);
	//LED_RGB_SetState(OFF);

	BufferClear(USART_DXL);
	BufferClear(USART_PC);
	BufferClear(USART_ZIGBEE);

	setBuzzerOff();

/*
	for(bCount =0; bCount < 50; bCount++ )
	{
		setBuzzerData(bCount);
		setBuzzerPlayLength(10);
		PlayBuzzer();
		//mDelay(3000);
		while(getBuzzerState());
		mDelay(500);
	}
*/


/*
	//BKP_WriteBackupRegister((P_OPERATING_MODE+1)<<2, 0xffff);

	  if(BKP_ReadBackupRegister((P_OPERATING_MODE+1)<<2) == 0xffff) //Initialize to Factory Default or reset mode restart
	  {
	    for(bCount=0; bCount < ROM_CONTROL_TABLE_LEN; bCount++)
	    {
	        //ROM_CAST(bCount) = gbpControlTable[bCount] = ROM_INITIAL_DATA[bCount];
	    	gbpControlTable[bCount] = ROM_INITIAL_DATA[bCount];
	        BKP_WriteBackupRegister((bCount+1)<<2, WORD_CAST(gbpControlTable[bCount]));
	    }
	    gbLEDBlinkCounter = 32;
	  }
	  else
	  {
	    for(bCount=0; bCount < ROM_CONTROL_TABLE_LEN; bCount++)
	    {
	      //gbpControlTable[bCount] = (byte)(BKP_ReadBackupRegister((bCount+1)<<2)); !!!!!
	      gbpControlTable[bCount] = ROM_INITIAL_DATA[bCount];
	    }
	    gbLEDBlinkCounter = 8;
	  }

	for (bCount = 0; bCount < 3; bCount++) {
		LED_SetState(LED_MANAGE|LED_EDIT|LED_PLAY, ON);
		mDelay(50);
		LED_SetState(LED_MANAGE|LED_EDIT|LED_PLAY, OFF);
		mDelay(50);
	}
*/
	/*
	if( (EEPROM_Read(P_OPERATING_MODE) == 0xffff) || (EEPROM_Read(P_OPERATING_MODE) == 0xff) ) //Initialize to Factory Default or reset mode restart
	{
		EEPROM_Write( P_BAUD_RATE, ROM_INITIAL_DATA[P_BAUD_RATE] );
		EEPROM_Write( P_OPERATING_MODE, 0);
	}
	else if(EEPROM_Read(P_OPERATING_MODE) == 0x11) //Digital Reset
	{
		EEPROM_Write( P_BAUD_RATE, ROM_INITIAL_DATA[P_BAUD_RATE] );
		EEPROM_Write( P_OPERATING_MODE, 0);
	}
	*/


	for(bCount=0; bCount < ROM_CONTROL_TABLE_LEN; bCount++)
	{
		  gbpControlTable[bCount] = ROM_INITIAL_DATA[bCount];
	}
	//GB_BAUD_RATE = EEPROM_Read(P_BAUD_RATE);
/*
	lTemp = 2000000;
	lTemp /= (GB_BAUD_RATE+1);
	USART_Configuration(USART_DXL,lTemp);
	USART_Configuration(USART_PC,lTemp);
*/


    gbLEDBlinkCounter = 8;





	for (bCount = 0; bCount < 3; bCount++) {
		LED_SetState(LED_MANAGE|LED_EDIT|LED_PLAY, ON);
		mDelay(50);
		LED_SetState(LED_MANAGE|LED_EDIT|LED_PLAY, OFF);
		mDelay(50);
	}
/*
	dxl_set_power(1);
	gbDxlPwr = 1;
	mDelay(100);

	GPIO_ResetBits(PORT_ENABLE_RXD, PIN_ENABLE_RXD);	// RX Disable
	GPIO_SetBits(PORT_ENABLE_TXD, PIN_ENABLE_TXD);	// TX Enable
	  while(1)
	  {
		GPIO_ResetBits(PORT_ENABLE_RXD, PIN_ENABLE_RXD);	// RX Disable
		GPIO_SetBits(PORT_ENABLE_TXD, PIN_ENABLE_TXD);	// TX Enable

		  USART_SendData(USART1, 'a');
			while( USART_GetFlagStatus(USART1, USART_FLAG_TC)==RESET );

			GPIO_ResetBits(PORT_ENABLE_TXD, PIN_ENABLE_TXD);	// TX Disable
			GPIO_SetBits(PORT_ENABLE_RXD, PIN_ENABLE_RXD);	// RX Enable
			mDelay(100);

	  }

*/

	Process();

	while(1);

}
예제 #9
0
	void	Process(const btDbvtNode* n)
	{
		Process(n,proxy->leaf);
	}
예제 #10
0
/* Function that runs the application */
INT CXBApplicationEx::Run()
{
  CLog::Log(LOGNOTICE, "Running the application..." );

  unsigned int lastFrameTime = 0;
  unsigned int frameTime = 0;
  const unsigned int noRenderFrameTime = 15;  // Simulates ~66fps

  // Run xbmc
  while (!m_bStop)
  {
#ifdef HAS_PERFORMANCE_SAMPLE
    CPerformanceSample sampleLoop("XBApplicationEx-loop");
#endif
    //-----------------------------------------
    // Animate and render a frame
    //-----------------------------------------
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      lastFrameTime = XbmcThreads::SystemClockMillis();
      Process();
      //reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS

    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::Process()");
      throw;
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Process()");
      throw;
    }
#endif
    // Frame move the scene
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      if (!m_bStop) FrameMove(true, m_renderGUI);
      //reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS
    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::FrameMove()");
      throw;
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::FrameMove()");
      throw;
    }
#endif

    // Render the scene
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      if (m_renderGUI && !m_bStop) Render();
      else if (!m_renderGUI)
      {
        frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime;
        if(frameTime < noRenderFrameTime)
          Sleep(noRenderFrameTime - frameTime);
      }
#ifdef XBMC_TRACK_EXCEPTIONS
    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::Render()");
      throw;
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Render()");
      throw;
    }
#endif
  } // while (!m_bStop)
  Destroy();

  CLog::Log(LOGNOTICE, "application stopped..." );
  return m_ExitCode;
}
예제 #11
0
// 线程运行接口对象
void CQueueThread::run( void *param )
{
	while( _inited ) {
		Process() ;
	}
}
예제 #12
0
파일: api.cpp 프로젝트: bgotink/worker
 void Error(const char *format, ...) {
     va_list args;
     va_start(args, format);
     Process(format, args, "ERROR  ");
     va_end(args);
 }
예제 #13
0
파일: api.cpp 프로젝트: bgotink/worker
 void Fatal(const char *format, ...) {
     va_list args;
     va_start(args, format);
     Process(format, args, "FATAL", true);
     va_end(args);
 }
예제 #14
0
void TDBProcess::OnExecSQL(const ServiceIdentifier&sender,UserTransferMessage& utm)
{
	string sql = utm[_TagSql];
	string sourceName=utm[_TagSourceName];
	strarray result ;
	strarray fieldname;

	BaseFieldDescription *pField;
	int rowcount = 0;
	u32 fieldcount = 0;
	bool	tryconnect	= false;

	utm.setRes(utm.getReq());
	utm.setMessageId(_ResExecSQL);
	PrintLog("RECV ReqExecSQL  sql = %s \n",sql.c_str() );

	if(!PreExecSQL(sender,utm, sql ) )
	{
		PrintLog("Check SQL Statement Error\n");
		return;	
	}
	try 
	{
		m_pDbQuery->command(sql);
		for(u32 i= 1 ; i <= m_pDbQuery->outputCount() ; i++)
		{
			m_pDbQuery->registerOutParam(i,FT_STRING);
		}
		PrintLog("Debug DO ExecSQL\n");
		m_pDbQuery->execute();
		PrintLog("Debug Finish ExecSQL\n");
		fieldcount = (u32) m_pDbQuery->fieldCount();
		utm[_TagFieldCount] = fieldcount;
		while ( !m_pDbQuery->eof())
		{
			rowcount++;
			m_pDbQuery->fetchNext();
			for(u32 i= 0 ; i < fieldcount ; i++)
				result.push_back( m_pDbQuery->getFieldByColumn(i)->asString());
		}
		if( 0 == rowcount )
		{
			for(u32 i=1; i <= m_pDbQuery->outputCount() ; i++ )
				result.push_back(m_pDbQuery->getOutParamByIndex(i)->asString());
			utm[_TagFieldCount] = (u32) m_pDbQuery->outputCount();
		}
		utm[_TagResult] = result;
		if( fieldcount )
		{
			for(u32 i = 0; i< fieldcount ; i++)
			{
				pField = m_pDbQuery->getFieldInfoByColumn(i);
				if( pField)
					fieldname.push_back(pField->name());
			}
		}
		utm[_TagFieldName] = fieldname;
	}
#ifdef _DB_ORACLE_ 
		catch( BaseException &err )
	{		
		Service::printConsole(cacti::LogLevel::FATAL, "%s %s\n",err.name.c_str(),err.description.c_str());
		utm.setReturn(ERR_DBS_ERROR);
		PrintLog("SEND ResExecSQL  failed, Exec SQL %s %s\n",
			err.name.c_str(),err.description.c_str());
		errProcess(err,sourceName);
		m_rowCount = 0;
		m_owner->postMessage(sender, utm);
		return ;
	}
#endif
#ifdef _DB_SYBASE_ 
	catch( BaseException &err )
	{
		if ( utm.getReturn() == 0 ){
			//	check the error information.
			//	if the communication is lost, reconnect it.
			if ( err.state == "08S01" || err.state == "HY000"){
				tryconnect	= true;
			};
		};		
		if ( ! tryconnect ){
			Service::printConsole(cacti::LogLevel::FATAL, "%s %s\n",err.name.c_str(),err.description.c_str());
			utm.setReturn(ERR_DBS_ERROR);
			PrintLog("SEND ResExecSQL  failed, Exec SQL %s %s\n",
				err.name.c_str(),err.description.c_str());
			errProcess(err,sourceName);
			m_owner->postMessage(sender, utm);
			return ;
		}
	}
#endif
#ifdef FOR_ODBC 
		catch( BaseException &err )
		{
			if ( utm.getReturn() == 0 ){
				//	check the error information.
				//	if the communication is lost, reconnect it.
				if ( err.state == "08S01" || err.state == "HY000"){
					tryconnect	= true;
				};
			};		
			if ( ! tryconnect ){
				Service::printConsole(cacti::LogLevel::FATAL, "%s %s\n",err.name.c_str(),err.description.c_str());
				utm.setReturn(ERR_DBS_ERROR);
				PrintLog("SEND ResExecSQL  failed, Exec SQL %s %s\n",
					err.name.c_str(),err.description.c_str());
				errProcess(err,sourceName);
				m_owner->postMessage(sender, utm);
				return ;
			}
		}
	if ( tryconnect ){
		ODBCQuery*	oq	= (ODBCQuery*)m_pDbQuery;
		try{
			oq->getParentConnection()->_odbcReconnect( oq->getIndex() );
		}
		catch( BaseException& err ){
			Service::printConsole(cacti::LogLevel::FATAL, "%s %s\n",err.name.c_str(),err.description.c_str());
			utm.setReturn(ERR_DBS_ERROR);
			PrintLog("SEND ResExecSQL  failed, Exec SQL %s %s\n",
				err.name.c_str(),err.description.c_str());
			errProcess(err,sourceName);
			m_owner->postMessage(sender, utm);
			return ;
		};
		utm.setMessageId( _ReqExecSQL );
		utm.setReturn( utm.getReturn() + 1 );
		Process( utm );
		return;
	};
	utm.setReturn( 0 );
#endif

	PrintLog("SEND ResExecSQL  fieldcount =%d, rowcount=%d\n",fieldcount,rowcount);
	m_owner->postMessage(sender, utm);

	return;
}
예제 #15
0
int _tmain(int argc, char* argv[])
{
// determine my process name
_splitpath(argv[0],NULL,NULL,gszProcName,NULL);
#else
int 
main(int argc, const char** argv)
{
// determine my process name
CUtility::splitpath((char *)argv[0],NULL,gszProcName);
#endif

int iScreenLogLevel;		// level of screen diagnostics
int iFileLogLevel;			// level of file diagnostics
char szLogFile[_MAX_PATH];	// write diagnostics to this file
int Rslt = 0;   			// function result code >= 0 represents success, < 0 on failure

int PMode;					// processing mode

char szInPE1File[_MAX_PATH];	// parse PE1 alignments from this file
char szInPE2File[_MAX_PATH];	// parse PE1 alignments from this file

char szOutFile[_MAX_PATH];		// write corelations to this file

char szSQLiteDatabase[_MAX_PATH];	// results summaries to this SQLite file
char szExperimentName[cMaxDatasetSpeciesChrom+1];			// experiment name
char szExperimentDescr[1000];		// describes experiment

// command line args
struct arg_lit  *help    = arg_lit0("h","help",                 "Print this help and exit");
struct arg_lit  *version = arg_lit0("v","version,ver",			"Print version information and exit");
struct arg_int *FileLogLevel=arg_int0("f", "FileLogLevel",		"<int>","Level of diagnostics written to screen and logfile 0=fatal,1=errors,2=info,3=diagnostics,4=debug");
struct arg_file *LogFile = arg_file0("F","log","<file>",		"Diagnostics log file");

struct arg_int *mode = arg_int0("m","mode","<int>",				"Processing mode: 0 default");

struct arg_file *inpe1file = arg_file1("i","in","<file>",		"Input SAM file containing PE1 alignments");
struct arg_file *inpe2file = arg_file1("I","in","<file>",		"Input SAM file containing PE2 alignments");

struct arg_file *outfile = arg_file1("o","out","<file>",		"Output corelations to this file");

struct arg_file *summrslts = arg_file0("q","sumrslts","<file>",		"Output results summary to this SQLite3 database file");
struct arg_str *experimentname = arg_str0("w","experimentname","<str>",		"experiment name SQLite3 database file");
struct arg_str *experimentdescr = arg_str0("W","experimentdescr","<str>",	"experiment description SQLite3 database file");

struct arg_end *end = arg_end(20);

void *argtable[] = {help,version,FileLogLevel,LogFile,
					summrslts,experimentname,experimentdescr,
	                mode,inpe1file,inpe2file, outfile,
					end};

char **pAllArgs;
int argerrors;
argerrors = CUtility::arg_parsefromfile(argc,(char **)argv,&pAllArgs);
if(argerrors >= 0)
	argerrors = arg_parse(argerrors,pAllArgs,argtable);

/* special case: '--help' takes precedence over error reporting */
if (help->count > 0)
        {
		printf("\n%s PE1/PE2 Corelation, Version %s\nOptions ---\n", gszProcName,cpszProgVer);
        arg_print_syntax(stdout,argtable,"\n");
        arg_print_glossary(stdout,argtable,"  %-25s %s\n");
		printf("\nNote: Parameters can be entered into a parameter file, one parameter per line.");
		printf("\n      To invoke this parameter file then precede its name with '@'");
		printf("\n      e.g. %s @myparams.txt\n",gszProcName);
		printf("\nPlease report any issues regarding usage of %s at https://github.com/csiro-crop-informatics/biokanga/issues\n\n",gszProcName);
		return(1);
        }

    /* special case: '--version' takes precedence error reporting */
if (version->count > 0)
        {
		printf("\n%s Version %s\n",gszProcName,cpszProgVer);
		return(1);
        }

if (!argerrors)
	{
	if(FileLogLevel->count && !LogFile->count)
		{
		printf("\nError: FileLogLevel '-f%d' specified but no logfile '-F<logfile>\n'",FileLogLevel->ival[0]);
		return(1);
		}

	iScreenLogLevel = iFileLogLevel = FileLogLevel->count ? FileLogLevel->ival[0] : eDLInfo;
	if(iFileLogLevel < eDLNone || iFileLogLevel > eDLDebug)
		{
		printf("\nError: FileLogLevel '-l%d' specified outside of range %d..%d\n",iFileLogLevel,eDLNone,eDLDebug);
		return(1);
		}

	if(LogFile->count)
		{
		strncpy(szLogFile,LogFile->filename[0],_MAX_PATH);
		szLogFile[_MAX_PATH-1] = '\0';
		}
	else
		{
		iFileLogLevel = eDLNone;
		szLogFile[0] = '\0';
		}

	// now that log parameters have been parsed then initialise diagnostics log system
	if(!gDiagnostics.Open(szLogFile,(etDiagLevel)iScreenLogLevel,(etDiagLevel)iFileLogLevel,true))
		{
		printf("\nError: Unable to start diagnostics subsystem\n");
		if(szLogFile[0] != '\0')
			printf(" Most likely cause is that logfile '%s' can't be opened/created\n",szLogFile);
		return(1);
		}
	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Process %s Version %s starting",gszProcName,cpszProgVer);

	gExperimentID = 0;
	gProcessID = 0;
	gProcessingID = 0;
	szSQLiteDatabase[0] = '\0';
	szExperimentName[0] = '\0';
	szExperimentDescr[0] = '\0';

	if(experimentname->count)
		{
		strncpy(szExperimentName,experimentname->sval[0],sizeof(szExperimentName));
		szExperimentName[sizeof(szExperimentName)-1] = '\0';
		CUtility::TrimQuotedWhitespcExtd(szExperimentName);
		CUtility::ReduceWhitespace(szExperimentName);
		}
	else
		szExperimentName[0] = '\0';

	gExperimentID = 0;
	gProcessID = 0;
	gProcessingID = 0;
	szSQLiteDatabase[0] = '\0';
	szExperimentDescr[0] = '\0';
	if(summrslts->count)
		{
		strncpy(szSQLiteDatabase,summrslts->filename[0],sizeof(szSQLiteDatabase)-1);
		szSQLiteDatabase[sizeof(szSQLiteDatabase)-1] = '\0';
		CUtility::TrimQuotedWhitespcExtd(szSQLiteDatabase);
		if(strlen(szSQLiteDatabase) < 1)
			{
			gDiagnostics.DiagOut(eDLFatal,gszProcName,"Error: After removal of whitespace, no SQLite database specified with '-q<filespec>' option");
			return(1);
			}

		if(strlen(szExperimentName) < 1)
			{
			gDiagnostics.DiagOut(eDLFatal,gszProcName,"Error: After removal of whitespace, no SQLite experiment name specified with '-w<str>' option");
			return(1);
			}
		if(experimentdescr->count)
			{
			strncpy(szExperimentDescr,experimentdescr->sval[0],sizeof(szExperimentDescr)-1);
			szExperimentDescr[sizeof(szExperimentDescr)-1] = '\0';
			CUtility::TrimQuotedWhitespcExtd(szExperimentDescr);
			}
		if(strlen(szExperimentDescr) < 1)
			{
			gDiagnostics.DiagOut(eDLFatal,gszProcName,"Error: After removal of whitespace, no SQLite experiment description specified with '-W<str>' option");
			return(1);
			}

		gExperimentID = gSQLiteSummaries.StartExperiment(szSQLiteDatabase,false,true,szExperimentName,szExperimentName,szExperimentDescr);
		if(gExperimentID < 1)
			return(1);
		gProcessID = gSQLiteSummaries.AddProcess((char *)gszProcName,(char *)gszProcName,(char *)szExperimentDescr);
		if(gProcessID < 1)
			return(1);
		gProcessingID = gSQLiteSummaries.StartProcessing(gExperimentID,gProcessID,(char *)cpszProgVer);
		if(gProcessingID < 1)
			return(1);
		gDiagnostics.DiagOut(eDLInfo,gszProcName,"Initialised SQLite database '%s' for results summary collection",szSQLiteDatabase);
		gDiagnostics.DiagOut(eDLInfo,gszProcName,"SQLite database experiment identifier for '%s' is %d",szExperimentName,gExperimentID);
		gDiagnostics.DiagOut(eDLInfo,gszProcName,"SQLite database process identifier for '%s' is %d",(char *)gszProcName,gProcessID);
		gDiagnostics.DiagOut(eDLInfo,gszProcName,"SQLite database processing instance identifier is %d",gProcessingID);
		}
	else
		{
		szSQLiteDatabase[0] = '\0';
		szExperimentDescr[0] = '\0';
		}

	PMode = mode->count ? mode->ival[0] : 0;
	if(PMode < 0 || PMode > 1)
		{
		gDiagnostics.DiagOut(eDLFatal,gszProcName,"Error: Processing mode '-m%d' must be in range 0..0",PMode);
		return(1);
		}

	strcpy(szInPE1File,inpe1file->filename[0]);
	CUtility::TrimQuotedWhitespcExtd(szInPE1File);

	strcpy(szInPE2File,inpe2file->filename[0]);
	CUtility::TrimQuotedWhitespcExtd(szInPE2File);

	strcpy(szOutFile,outfile->filename[0]);
	CUtility::TrimQuotedWhitespcExtd(szOutFile);

// show user current resource limits
#ifndef _WIN32
	gDiagnostics.DiagOut(eDLInfo, gszProcName, "Resources: %s",CUtility::ReportResourceLimits());
#endif

	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Processing parameters:");
	const char *pszDescr;
	switch(PMode) {
		case 0:
			pszDescr = "Corelate PE1 and PE2 alignments";
			break;
		}

	gDiagnostics.DiagOutMsgOnly(eDLInfo,"Processing mode is : '%s'",pszDescr);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"Experiment name : '%s'",szExperimentName);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"Experiment description : '%s'",szExperimentDescr);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"SQLite database file: '%s'",szOutFile);

	gDiagnostics.DiagOutMsgOnly(eDLInfo,"PE1 SAM file: '%s'",szInPE1File);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"PE2 SAM file: '%s'",szInPE2File);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"Corelations to file: '%s'",szOutFile);

#ifdef _WIN32
	SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
#endif
	gStopWatch.Start();

	Rslt = Process(PMode,szInPE1File,szInPE2File,szOutFile);
	Rslt = Rslt >=0 ? 0 : 1;
	if(gExperimentID > 0)
		{
		if(gProcessingID)
			gSQLiteSummaries.EndProcessing(gProcessingID,Rslt);
		gSQLiteSummaries.EndExperiment(gExperimentID);
		}
	gStopWatch.Stop();
	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Exit code: %d Total processing time: %s",Rslt,gStopWatch.Read());
	exit(Rslt);
	}
else
	{
    printf("\n%s, Version %s\n", gszProcName,cpszProgVer);
	arg_print_errors(stdout,end,gszProcName);
	arg_print_syntax(stdout,argtable,"\nUse '-h' to view option and parameter usage\n");
	exit(1);
	}
return 0;
}
예제 #16
0
int _tmain(int argc, char* argv[])
{
// determine my process name
_splitpath(argv[0],NULL,NULL,gszProcName,NULL);
#else
int 
main(int argc, const char** argv)
{
// determine my process name
CUtility::splitpath((char *)argv[0],NULL,gszProcName);
#endif
int iScreenLogLevel;		// level of screen diagnostics
int iFileLogLevel;			// level of file diagnostics
char szLogFile[_MAX_PATH];	// write diagnostics to this file

int Rslt;

int iMode;
char szOutputFile[_MAX_PATH];
char szInputFile[_MAX_PATH];
char szInSeqFile[_MAX_PATH];
char szInputBiobedFile[_MAX_PATH];
int iRegionsIn;
int iRegionsOut;
char szRegionsIn[128];		// regions to retain
char szRegionsOut[128];		// regions to exclude
int iRegLen;

// command line args
struct arg_lit  *help    = arg_lit0("hH","help",                "print this help and exit");
struct arg_lit  *version = arg_lit0("v","version,ver",			"print version information and exit");
struct arg_int *FileLogLevel=arg_int0("f", "FileLogLevel",		"<int>","Level of diagnostics written to logfile 0=fatal,1=errors,2=info,3=diagnostics,4=debug");
struct arg_int *ScreenLogLevel=arg_int0("S", "ScreenLogLevel",	"<int>","Level of diagnostics written to logfile 0=fatal,1=errors,2=info,3=diagnostics,4=debug");
struct arg_file *LogFile = arg_file0("F","log","<file>",	"diagnostics log file");

struct arg_int  *Mode = arg_int0("m","procmode","<int>",	"processing mode 0:default");
struct arg_int  *RegLen = arg_int0("L","updnstream","<int>",	"length of 5'up or 3'down  stream regulatory region length (default = 2000) 0..1000000");
struct arg_file *InFile = arg_file1("i",NULL,"<file>",			"input from loci csv file");
struct arg_file *OutFile = arg_file1("o",NULL,"<file>",			"output to multifasta file");
struct arg_file *InSeqFile = arg_file1("a","assemb","<file>","get sequences fron this file");
struct arg_file *InBedFile = arg_file1("b","bed","<file>",		"characterise regions from biobed file");
struct arg_str  *RegionsOut = arg_str0("R","regionsout","<string>","Filter out random samples in any of these regions (space or comma delimit), 1: Intergenic, 2: US, 3: 5'UTR, 4: CDS, 5: Intron, 6: 3'UTR, 7: DS");
struct arg_str  *RegionsIn = arg_str0("r","regionsin","<string>","Accept random samples in any of these exclusive regions (space or comma delimit), 1: Intergenic, 2: US, 3: 5'UTR, 4: CDS, 5: Intron, 6: 3'UTR, 7: DS");

struct arg_end *end = arg_end(20);

void *argtable[] = {help,version,FileLogLevel,ScreenLogLevel,LogFile,
					Mode,RegLen,InFile,OutFile,InSeqFile,InBedFile,RegionsIn,RegionsOut,
					end};

char **pAllArgs;
int argerrors;
argerrors = CUtility::arg_parsefromfile(argc,(char **)argv,&pAllArgs);
if(argerrors >= 0)
	argerrors = arg_parse(argerrors,pAllArgs,argtable);

    /* special case: '--help' takes precedence over error reporting */
if (help->count > 0)
        {
		printf("Usage: %s ", gszProcName);
        arg_print_syntax(stdout,argtable,"\n");
        arg_print_glossary(stdout,argtable,"  %-25s %s\n");
		exit(1);
        }

    /* special case: '--version' takes precedence error reporting */
if (version->count > 0)
        {
		printf("\n%s: Version: %d.%2.2d\n",gszProcName,cProgVer/100,cProgVer%100);
		exit(1);
        }

if (!argerrors)
	{
	iScreenLogLevel = ScreenLogLevel->count ? ScreenLogLevel->ival[0] : eDLInfo;
	if(iScreenLogLevel < eDLNone || iScreenLogLevel > eDLDebug)
		{
		printf("\nError: ScreenLogLevel '-S%d' specified outside of range %d..%d",iScreenLogLevel,eDLNone,eDLDebug);
		exit(1);
		}
	if(FileLogLevel->count && !LogFile->count)
		{
		printf("\nError: FileLogLevel '-f%d' specified but no logfile '-F<logfile>'",FileLogLevel->ival[0]);
		exit(1);
		}

	iFileLogLevel = FileLogLevel->count ? FileLogLevel->ival[0] : eDLInfo;
	if(iFileLogLevel < eDLNone || iFileLogLevel > eDLDebug)
		{
		printf("\nError: FileLogLevel '-l%d' specified outside of range %d..%d",iFileLogLevel,eDLNone,eDLDebug);
		exit(1);
		}
	if(LogFile->count)
		{
		strncpy(szLogFile,LogFile->filename[0],_MAX_PATH);
		szLogFile[_MAX_PATH-1] = '\0';
		}
	else
		{
		iFileLogLevel = eDLNone;
		szLogFile[0] = '\0';
		}

	iMode = Mode->count ? Mode->ival[0] : eProcModeStandard;
	if(iMode < eProcModeStandard || iMode > eProcModeStandard)
		{
		printf("\nError: Requested processing mode '-x%d' not supported",iMode);
		exit(1);
		}

	if(RegionsIn->count)
		{
		strcpy(szRegionsIn,RegionsIn->sval[0]);
		TrimQuotes(szRegionsIn);
		if((iRegionsIn = ParseRegions(szRegionsIn)) < 0)
			{
			printf("Error: unable to parse '-r%s' into regions to retain",szRegionsIn);
			exit(1);
			}
		}
	else
		{
		szRegionsIn[0] = '\0';
		iRegionsIn = (cFeatBitIG | cFeatBitUpstream | cFeatBit5UTR | cFeatBitCDS | cFeatBitIntrons | cFeatBit3UTR | cFeatBitDnstream);
		}

	if(RegionsOut->count)
		{
		strcpy(szRegionsOut,RegionsOut->sval[0]);
		TrimQuotes(szRegionsOut);
		if((iRegionsOut = ParseRegions(szRegionsOut)) < 0)
			{
			printf("Error: unable to parse '-R%s' into regions to remove",szRegionsOut);
			exit(1);
			}
		}
	else
		{
		szRegionsOut[0] = '\0';
		iRegionsOut = 0;
		}
	iRegionsIn &= ~iRegionsOut;
	if(!iRegionsIn)
		{
		printf("Error: no regions to retain");
		exit(1);
		}

	iRegLen = RegLen->count ? RegLen->ival[0] : cDfltRegLen;
	if(iRegLen < cMinRegLen)
		{
		printf("\nRegulatory region length '-L%d' less than minimum %d, assuming you meant to use '-L%d'",iRegLen,cMinRegLen,cMinRegLen);
		iRegLen = cMinRegLen;
		}
	else
		{
		if(iRegLen > cMaxRegLen)
			{
			printf("\nRegulatory region length '-L%d' more than maximum %d, assuming you meant to use '-L%d'",iRegLen,cMaxRegLen,cMaxRegLen);
			iRegLen = cMaxRegLen;
			}
		}

	strcpy(szInputFile,InFile->filename[0]);
	strcpy(szOutputFile,OutFile->filename[0]);
	strcpy(szInputBiobedFile,InBedFile->filename[0]);
	strcpy(szInSeqFile,InSeqFile->filename[0]);

		// now that command parameters have been parsed then initialise diagnostics log system
	if(!gDiagnostics.Open(szLogFile,(etDiagLevel)iScreenLogLevel,(etDiagLevel)iFileLogLevel,true))
		{
		printf("\nError: Unable to start diagnostics subsystem.");
		if(szLogFile[0] != '\0')
			printf(" Most likely cause is that logfile '%s' can't be opened/created",szLogFile);
		exit(1);
		}

	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Version: %d.%2.2d Processing parameters:",cProgVer/100,cProgVer%100);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"Loci file (.csv) file to process: '%s'",szInputFile);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"bio assembly (.seq) file to process: '%s'",szInSeqFile);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"where to write out fasta with random sequences: '%s'",szOutputFile);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"biobed file containing regional features: '%s'",szInputBiobedFile);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"Processing mode: %s",iMode == eProcModeStandard ? "standard" : iMode == eProcModeStandard ? "extended" : "summary");
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"Accept random samples in any of these regions: '%s'",Regions2Txt(iRegionsIn));

#ifdef _WIN32
	SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
#endif

	Rslt = Process(iMode,iRegionsIn,iRegLen,szInputFile,szInputBiobedFile,szInSeqFile,szOutputFile);
	gStopWatch.Stop();
	Rslt = Rslt < 0 ? 1 : 0;
	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Exit Code: %d Total processing time: %s",Rslt,gStopWatch.Read());
	exit(Rslt);
	}
else
	{
	arg_print_errors(stdout,end,gszProcName);
	arg_print_syntax(stdout,argtable,"\nend of help\n");
	exit(1);
	}
}
예제 #17
0
 Process ProcessIterator::dereference() const
 {
     SYSTEM_PROCESS_INFORMATION const *casted = reinterpret_cast<SYSTEM_PROCESS_INFORMATION const*>(&*blockPtr);
     return Process(casted->ProcessId);
 }
예제 #18
0
void MultiTasking::start() {
	Process proc = Process();
	processList.add(proc);
	initTimer(10);
}
예제 #19
0
double MultiLayerNN::LearnCrossValidation(int maxIteration, int k, double& ErrorAverage, double& ErrorStandarDesviation, bool doFeedBack, std::ostream& feedbackStream) throw(std::exception)
{
	if( k >= mLearnBook.size() )
		throw (new std::exception("No se puede hacer leave-k-out con k mas grande o igual a la particion universal"));

	std::stringstream firstNetwork;//Save the first Network
	Serialize(firstNetwork);

	 //Create necesary variables
	double** Y  = NULL;
	double** ro = NULL;
	double*  e  = NULL;
	std::vector< std::vector< std::vector<double> > > deltaWeights(mLayerCount);
	std::vector< std::vector< std::vector<double> > > deltaWeightsPrevious(mLayerCount);
	_LearnInicialization(Y,ro,e,deltaWeights,deltaWeightsPrevious);//reserve initialize variables

	
	int PartitionsNumber = ceil(mLearnBook.size()/(double)k);

	double* aux = new double[mOutputsNumber];//to calculate output error with learning data

	int* errors  = new int[PartitionsNumber];
	std::fill(errors,errors+PartitionsNumber, 0);
	double errorsThreshold = 0;

	Partition validationPartition(mLearnBook);

	validationPartition.InitLeaveKOut(k);

	for(int curPart=0;;++curPart)//until no more leave-k-out partitions
	{
		std::vector<int> shuffle(validationPartition.mLearnPartition.size());//creates shuffe here could be optimized
		validationPartition.GetShuffle(shuffle);
		std::vector<LearnInfo*>& LearnData = validationPartition.mLearnPartition;

		Load(firstNetwork);//each partition start again

		if( doFeedBack )
			feedbackStream<<"Particion Numero: "<<curPart<<std::endl;

		for(int k=0; k < maxIteration; ++k)//iterates the learning of the patrons
		{

			//Learn each patron
			for(int sample=0; sample < LearnData.size(); ++sample)
			{
				LearnInfo& info = *LearnData[shuffle[sample]];
				std::copy(info.mInputs.begin(), info.mInputs.end(), mInputs);
				_ProcessAll(Y);

				std::fill(aux,aux+mOutputsNumber, -1.0);
				aux[(int)info.mOutput] = 1.0;

				for(int j=0; j < mOutputsNumber; ++j)
					e[j] = mErrorFunction(Y[mLayerCount-1][j], aux[j]);

				_Retropropagate(Y,ro,e,deltaWeights,deltaWeightsPrevious);
			}

		}

		std::vector<double> Outputs(mOutputsNumber);
		std::vector<LearnInfo*>& TestData = validationPartition.mTestPartition;

		//Test each patron
		for(int sample=0; sample < TestData.size(); ++sample)
		{
			LearnInfo& info = *TestData[sample];
			std::copy(info.mInputs.begin(), info.mInputs.end(), mInputs);
			
			Outputs = Process();

			std::fill(aux,aux+mOutputsNumber, -1.0);
			aux[(int)info.mOutput] = 1.0;

			for(int j=0; j < mOutputsNumber; ++j)
			{
				e[j] = mErrorFunction(mSignFunction(Outputs[j]), aux[j]);
				if( e[j] != 0 )
					e[j] = e[j]/e[j];
			}

			//Errors to check with tolerance
			double newErrors = 0.0;
			for(int j=0; j < mOutputsNumber; ++j)
				aux[j] = abs(e[j]);
			Math::Sum(aux,mOutputsNumber,newErrors);
			errorsThreshold += newErrors;

			if(std::find(e,e+mOutputsNumber,1) != e+mOutputsNumber)
				++errors[curPart];
		}

		//Next Partitions
		if( !validationPartition.NextLeaveKOut() )
			break;
	}

	//errors / (double)PartitionsNumber;
	//errorsThreshold / (double)PartitionsNumber;
	ErrorAverage = 0.0;
	Math::Sum(errors, PartitionsNumber,ErrorAverage);
	ErrorAverage /= (double)PartitionsNumber;

	ErrorStandarDesviation = 0;
	for(int i=0; i < PartitionsNumber; ++i)
		ErrorStandarDesviation += errors[i]*errors[i];
	ErrorStandarDesviation = sqrt(ErrorStandarDesviation)/(double)PartitionsNumber;

	_LearnFinish(Y,ro,e,deltaWeights,deltaWeightsPrevious);

	Load(firstNetwork);//Keep the first Network

	firstNetwork.clear();

	delete[] aux;
	delete[] errors;
	return 1.0;
	//return ( errors/(double)mLearnBook.size() );
}
예제 #20
0
파일: XYZ2NEU.hpp 프로젝트: ianmartin/GPSTk
    /** Returns a reference to a gnnsRinex object after converting
     *  from a geocentric reference system to a topocentric reference
     *  system.
     *
     * @param gData    Data object holding the data.
     */
 virtual gnssRinex& Process(gnssRinex& gData)
    throw(ProcessingException)
 { Process(gData.body); return gData; };
예제 #21
0
int _tmain(int argc, char* argv[])
{
// determine my process name
_splitpath(argv[0],NULL,NULL,gszProcName,NULL);
#else
int 
main(int argc, const char** argv)
{
// determine my process name
CUtility::splitpath((char *)argv[0],NULL,gszProcName);
#endif
int iScreenLogLevel;		// level of screen diagnostics
int iFileLogLevel;			// level of file diagnostics
char szLogFile[_MAX_PATH];	// write diagnostics to this file

int Rslt;

int iProcMode;			// processing mode
char szRefFile[_MAX_PATH];	// nput from reference csv file
char szFilterRefIDFile[_MAX_PATH];  // exclude any RefIDs in this filter file
char szRelFile[_MAX_PATH];	// input from relative csv file(s)
char szRsltfile[_MAX_PATH];	// output to results CSV file
int iMinLen;			// minimum accepted length
int iMaxLen;			// maximum accepted length


// command line args
struct arg_lit  *help    = arg_lit0("hH","help",                "print this help and exit");
struct arg_lit  *version = arg_lit0("v","version,ver",			"print version information and exit");
struct arg_int *FileLogLevel=arg_int0("f", "FileLogLevel",		"<int>","Level of diagnostics written to logfile 0=fatal,1=errors,2=info,3=diagnostics,4=debug");
struct arg_int *ScreenLogLevel=arg_int0("S", "ScreenLogLevel",	"<int>","Level of diagnostics written to logfile 0=fatal,1=errors,2=info,3=diagnostics,4=debug");
struct arg_file *LogFile = arg_file0("F","log","<file>",		"diagnostics log file");
struct arg_int *ProcMode = arg_int0("m", "mode","<int>",		"processing mode (default 0) 0: Identities (Match/Match+Mismatches), 1: Identities (Match/CoreLength), 2: Aligned Length 3: Score");

struct arg_file *RefFile = arg_file1("i","in","<file>",			"input from reference csv file");
struct arg_file *FilterRefIDFile = arg_file0("X",NULL,"<file>",	"filter out any ref or rel loci with RefIDs in this filter file");
struct arg_file *RelFile = arg_file1("I","in","<file>",			"input from relative csv file(s) - can use wildcards");
struct arg_file *Rsltfile= arg_file1("o","out","<file>",		"output to results CSV file");
struct arg_int *MinLen=arg_int0("l", "MinLen",	"<int>","minimum accepted length");
struct arg_int *MaxLen=arg_int0("L", "MaxLen",	"<int>","maximum accepted length");

struct arg_end *end = arg_end(20);
void *argtable[] = {help,version,FileLogLevel,ScreenLogLevel,LogFile,
			ProcMode,RefFile,FilterRefIDFile,RelFile,Rsltfile,
			MinLen,MaxLen,
			end};

char **pAllArgs;
int argerrors;
argerrors = CUtility::arg_parsefromfile(argc,(char **)argv,&pAllArgs);
if(argerrors >= 0)
	argerrors = arg_parse(argerrors,pAllArgs,argtable);

/* special case: '--help' takes precedence over error reporting */
if (help->count > 0)
        {
		printf("\n%s ", gszProcName);
        arg_print_syntax(stdout,argtable,"\n");
        arg_print_glossary(stdout,argtable,"  %-25s %s\n");
		printf("\nNote: Parameters can be entered into a parameter file, one parameter per line.");
		printf("\n      To invoke this parameter file then precede its name with '@'");
		printf("\n      e.g. %s @myparams.txt\n\n",gszProcName);
		exit(1);
        }

    /* special case: '--version' takes precedence error reporting */
if (version->count > 0)
        {
		printf("\n%s Version %d.%2.2d",gszProcName,cProgVer/100,cProgVer%100);
		exit(1);
        }

if (!argerrors)
	{
	iScreenLogLevel = ScreenLogLevel->count ? ScreenLogLevel->ival[0] : eDLInfo;
	if(iScreenLogLevel < eDLNone || iScreenLogLevel > eDLDebug)
		{
		printf("\nError: ScreenLogLevel '-S%d' specified outside of range %d..%d",iScreenLogLevel,eDLNone,eDLDebug);
		exit(1);
		}
	if(FileLogLevel->count && !LogFile->count)
		{
		printf("\nError: FileLogLevel '-f%d' specified but no logfile '-F<logfile>'",FileLogLevel->ival[0]);
		exit(1);
		}

	iFileLogLevel = FileLogLevel->count ? FileLogLevel->ival[0] : eDLInfo;
	if(iFileLogLevel < eDLNone || iFileLogLevel > eDLDebug)
		{
		printf("\nError: FileLogLevel '-l%d' specified outside of range %d..%d",iFileLogLevel,eDLNone,eDLDebug);
		exit(1);
		}
	if(LogFile->count)
		{
		strncpy(szLogFile,LogFile->filename[0],_MAX_PATH);
		szLogFile[_MAX_PATH-1] = '\0';
		}
	else
		{
		iFileLogLevel = eDLNone;
		szLogFile[0] = '\0';
		}

	iProcMode = ProcMode->count ? ProcMode->ival[0] : eProcModeStandard;
	if(iProcMode < eProcModeStandard || iProcMode > eProcModeScore)
		{
		printf("\nError: Requested processing mode '-x%d' not supported",iProcMode);
		exit(1);
		}

	iMinLen = MinLen->count ? MinLen->ival[0] : 0;
	if(iMinLen < 0)
		{
		printf("\nError: Requested minimum length '-l%d' is negative",iMinLen);
		exit(1);
		}

	iMaxLen = MaxLen->count ? MaxLen->ival[0] : 1000000000;
	if(iMaxLen < iMinLen)
		{
		printf("\nError: Requested maximum ength '-l%d' must be >= minimum %d",iMaxLen,iMinLen);
		exit(1);
		}



	strcpy(szRefFile,RefFile->filename[0]);
	strcpy(szRelFile,RelFile->filename[0]);
	strcpy(szRsltfile,Rsltfile->filename[0]);

	if(FilterRefIDFile->count)
		{
		strncpy(szFilterRefIDFile,FilterRefIDFile->filename[0],sizeof(szFilterRefIDFile));
		szFilterRefIDFile[sizeof(szFilterRefIDFile)-1] = '\0';
		}
	else
		szFilterRefIDFile[0] = '\0';


			// now that command parameters have been parsed then initialise diagnostics log system
	if(!gDiagnostics.Open(szLogFile,(etDiagLevel)iScreenLogLevel,(etDiagLevel)iFileLogLevel,true))
		{
		printf("\nError: Unable to start diagnostics subsystem.");
		if(szLogFile[0] != '\0')
			printf(" Most likely cause is that logfile '%s' can't be opened/created",szLogFile);
		exit(1);
		}

	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Version: %d.%2.2d Processing parameters:",cProgVer/100,cProgVer%100);
	switch(iProcMode) {
		case eProcModeStandard:
			gDiagnostics.DiagOutMsgOnly(eDLInfo,"Processing mode:  Identity = Match/(Match+Mismatch)");
			break;
		case eProcModeIdentity:
			gDiagnostics.DiagOutMsgOnly(eDLInfo,"Processing mode:  Identity = Match/(CoreLength)");
			break;
		case eProcModeAligned:
			gDiagnostics.DiagOutMsgOnly(eDLInfo,"Processing mode:  Aligned = (Match+Mismatch)/CoreLength");
			break;
		case eProcModeScore:
			gDiagnostics.DiagOutMsgOnly(eDLInfo,"Processing mode: score");
			break;
		}

	gDiagnostics.DiagOutMsgOnly(eDLInfo,"reference csv file to process: '%s'",szRefFile);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"relative csv file(s) to processs: '%s'",szRelFile);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"results file to generate: '%s'",szRsltfile);
	if(szFilterRefIDFile[0])
		gDiagnostics.DiagOutMsgOnly(eDLInfo,"Exclude any RefIDs in this filter file: '%s'",szFilterRefIDFile);

	gDiagnostics.DiagOutMsgOnly(eDLInfo,"minimum length: %d",iMinLen);
	gDiagnostics.DiagOutMsgOnly(eDLInfo,"maximum length: %d",iMaxLen);

	gStopWatch.Start();
#ifdef _WIN32
	SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
#endif
	Rslt = Process((etProcMode)iProcMode,		// processing mode 0: default
					szRefFile,		// reference csv file to process
					szFilterRefIDFile, // exclude any RefIDs in this filter file
					szRelFile,		// relative csv file(s) to processs
					szRsltfile,  	// results file to generate
					iMinLen,		// minimum accepted ref length
					iMaxLen);		// maximum accepted ref length

	gStopWatch.Stop();
	Rslt = Rslt < 0 ? 1 : 0;
	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Exit Code: %d Total processing time: %s",Rslt,gStopWatch.Read());
	exit(Rslt);
	}
else
	{
	arg_print_errors(stdout,end,gszProcName);
	arg_print_syntax(stdout,argtable,"\nend of help\n");
	exit(1);
	}
return 0;
}
예제 #22
0
bool CModeratePostsBuilder::Build(CWholePage* pWholePage)
{
	InitPage(pWholePage, "POST-MODERATION", true);
	bool bSuccess = true;

	// do an error page if not an editor or moderator.
	CUser* pViewer = m_InputContext.GetCurrentUser();
	if (pViewer == NULL || !(pViewer->GetIsEditor() || pViewer->GetIsModerator()) )
	{
		bSuccess = bSuccess && pWholePage->SetPageType("ERROR");
		bSuccess = bSuccess && pWholePage->AddInside("H2G2", "<ERROR TYPE='NOT-EDITOR'>You cannot perform moderation unless you are logged in as an Editor or Moderator.</ERROR>");
		return true;
	}

	//Process Actions.
	if ( ! Process(pWholePage,pViewer) )
	{
		SetDNALastError("CModeratePostsBuilder::Build","Build","Unable to process");
		pWholePage->AddInside("H2G2",GetLastErrorAsXMLString());
	}

	//Handle s_returnto.
	if ( bSuccess && CheckAndUseRedirectIfGiven(pWholePage) )
		return bSuccess;

	//Handle 'Oldstyle' redirect - necessary to handle multiple submit buttons for the same form.  
	if ( m_InputContext.ParamExists("Done") )
	{
		CTDVString sRedirect = "Moderate?newstyle=1";
		if ( m_InputContext.GetParamInt("fastmod") == 1 )
			sRedirect += "&fastmod=1";
		return pWholePage->Redirect(sRedirect);
	}

	//Produce XML for page.

	// find out if we are processing referrals or not
	bool bReferrals = m_InputContext.GetParamInt("Referrals") == 1;
	bool bAlerts = m_InputContext.GetParamInt("Alerts") == 1;
	bool bLockedItems = m_InputContext.GetParamInt("Locked") == 1; //Viewing users locked items only.
	bool bHeldItems = m_InputContext.GetParamInt("Held") == 1;
	int iShow = 10;
	if ( m_InputContext.ParamExists("show") )
		iShow = m_InputContext.GetParamInt("show");
	
	bool bFastMod = m_InputContext.GetParamInt("fastmod") != 0;

	int iModClassId = 0;
	if ( m_InputContext.ParamExists("ModClassId") )
		iModClassId = m_InputContext.GetParamInt("ModClassId");

	//Filter on moderation items for a specific post.
	int iPostId = 0;
	if ( m_InputContext.ParamExists("PostFilterId") )
		iPostId = m_InputContext.GetParamInt("PostFilterId");

	//Add Moderation Classes
	CModerationClasses modclasses(m_InputContext);
	if ( modclasses.GetModerationClasses() )
		bSuccess = bSuccess && pWholePage->AddInside("H2G2",&modclasses);
	else if ( modclasses.ErrorReported() )
		bSuccess && bSuccess && pWholePage->AddInside("H2G2",modclasses.GetLastErrorAsXMLString() );

	//Add Moderation Failure - Reasons
	CModReasons reasons(m_InputContext);
	if ( reasons.GetModReasons(iModClassId) )
		bSuccess = bSuccess && pWholePage->AddInside("H2G2",&reasons);

	//Add Refereee List
	CRefereeList referees(m_InputContext);
	if ( referees.FetchTheList() )
		bSuccess = bSuccess && pWholePage->AddInside("H2G2",&referees);

	//Add Site List
	//CTDVString sSiteXML;
	//bSuccess = bSuccess && m_InputContext.GetSiteListAsXML(&sSiteXML, 2);
	//bSuccess = bSuccess && pWholePage->AddInside("H2G2", sSiteXML);
	CBasicSiteList sitelist(m_InputContext);
	if ( !sitelist.PopulateList() )
		pWholePage->AddInside("H2G2",sitelist.GetLastErrorAsXMLString());
	else
		bSuccess = bSuccess && pWholePage->AddInside("H2G2",sitelist.GetAsXML2());

	//Add User Moderation Statuses
	CUserStatuses modstatuses(m_InputContext);
	if ( modstatuses.GetUserStatuses() )
		pWholePage->AddInside("H2G2",&modstatuses);
	else if ( modstatuses.ErrorReported() )
		pWholePage->AddInside("H2G2",modstatuses.GetLastErrorAsXMLString());

	//Add Distress Messages
	CModerationDistressMessages distressmsgs(m_InputContext);
	if ( distressmsgs.GetDistressMessages(iModClassId) )
		pWholePage->AddInside("H2G2",&distressmsgs);
	else
		pWholePage->AddInside("H2G2",distressmsgs.GetLastErrorAsXMLString() );


	CModeratePosts moderate(m_InputContext);
	if ( !moderate.GetPosts( pViewer->GetUserID(), bAlerts, bReferrals, bLockedItems, bHeldItems, iModClassId, iPostId,  iShow, bFastMod ) )
		pWholePage->AddInside("H2G2",moderate.GetLastErrorAsXMLString() );
	else
		pWholePage->AddInside("H2G2",&moderate);
	

	TDVASSERT(bSuccess, "CModeratePostsBuilder::Build() failed");
	return bSuccess;
}
예제 #23
0
파일: KeyStates.cpp 프로젝트: lcs2/carpg
void KeyStates::ProcessDoubleClick(byte key)
{
	assert(key >= VK_LBUTTON && key <= VK_XBUTTON2);
	Process(key, true);
	doubleclk[key] = true;
}
예제 #24
0
파일: lirc.c 프로젝트: shanewfx/vlc-arib
/*****************************************************************************
 * Run: main loop
 *****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
    intf_sys_t *p_sys = p_intf->p_sys;

    for( ;; )
    {
        /* Wait for data */
        struct pollfd ufd = { .fd = p_sys->i_fd, .events = POLLIN, .revents = 0 };
        if( poll( &ufd, 1, -1 ) == -1 )
            break;

        /* Process */
        int canc = vlc_savecancel();
        Process( p_intf );
        vlc_restorecancel(canc);
    }
}

static int Process( intf_thread_t *p_intf )
{
    for( ;; )
    {
        char *code, *c;
        int i_ret = lirc_nextcode( &code );

        if( i_ret )
            return i_ret;

        if( code == NULL )
            return 0;

        while( vlc_object_alive( p_intf )
                && (lirc_code2char( p_intf->p_sys->config, code, &c ) == 0)
                && (c != NULL) )
        {
            vlc_value_t keyval;

            if( !strncmp( "key-", c, 4 ) )
            {
                keyval.i_int = config_GetInt( p_intf, c );
                var_Set( p_intf->p_libvlc, "key-pressed", keyval );
            }
            else if( !strncmp( "menu ", c, 5)  )
            {
                if( !strncmp( c, "menu on", 7 ) ||
                    !strncmp( c, "menu show", 9 ))
                    osd_MenuShow( VLC_OBJECT(p_intf) );
                else if( !strncmp( c, "menu off", 8 ) ||
                         !strncmp( c, "menu hide", 9 ) )
                    osd_MenuHide( VLC_OBJECT(p_intf) );
                else if( !strncmp( c, "menu up", 7 ) )
                    osd_MenuUp( VLC_OBJECT(p_intf) );
                else if( !strncmp( c, "menu down", 9 ) )
                    osd_MenuDown( VLC_OBJECT(p_intf) );
                else if( !strncmp( c, "menu left", 9 ) )
                    osd_MenuPrev( VLC_OBJECT(p_intf) );
                else if( !strncmp( c, "menu right", 10 ) )
                    osd_MenuNext( VLC_OBJECT(p_intf) );
                else if( !strncmp( c, "menu select", 11 ) )
                    osd_MenuActivate( VLC_OBJECT(p_intf) );
                else
                {
                    msg_Err( p_intf, "Please provide one of the following parameters:" );
                    msg_Err( p_intf, "[on|off|up|down|left|right|select]" );
                    break;
                }
            }
            else
            {
                msg_Err( p_intf, "this doesn't appear to be a valid keycombo lirc sent us. Please look at the doc/lirc/example.lirc file in VLC" );
                break;
            }
        }
        free( code );
    }
}
예제 #25
0
void PSMoveManager::Loop ()
{
  for (;;) {
    Process ();
  }
}
예제 #26
0
	void Operation::StartOperation(Session *session)
	{
		_operationContext.AddOperation();
		Process(session);
	}
예제 #27
0
// OnReceive
//------------------------------------------------------------------------------
/*virtual*/ void Client::OnReceive( const ConnectionInfo * connection, void * data, uint32_t size, bool & keepMemory )
{
	keepMemory = true; // we'll take care of freeing the memory

	MutexHolder mh( m_ServerListMutex );

	ServerState * ss = (ServerState *)connection->GetUserData();
	ASSERT( ss );

	// are we expecting a msg, or the payload for a msg?
	void * payload = nullptr;
	size_t payloadSize = 0;
	if ( ss->m_CurrentMessage == nullptr )
	{
		// message
		ss->m_CurrentMessage = reinterpret_cast< const Protocol::IMessage * >( data );
		if ( ss->m_CurrentMessage->HasPayload() )
		{
			return;
		}
	}
	else
	{
		// payload
		ASSERT( ss->m_CurrentMessage->HasPayload() );
		payload = data;
		payloadSize = size;
	}

	// determine message type
	const Protocol::IMessage * imsg = ss->m_CurrentMessage;
	Protocol::MessageType messageType = imsg->GetType();

	PROTOCOL_DEBUG( "Server -> Client : %u (%s)\n", messageType, GetProtocolMessageDebugName( messageType ) );

	switch ( messageType )
	{
		case Protocol::MSG_REQUEST_JOB:
		{
			const Protocol::MsgRequestJob * msg = static_cast< const Protocol::MsgRequestJob * >( imsg );
			Process( connection, msg ); 
			break;
		}
		case Protocol::MSG_JOB_RESULT:
		{
			const Protocol::MsgJobResult * msg = static_cast< const Protocol::MsgJobResult * >( imsg );
			Process( connection, msg, payload, payloadSize ); 
			break;
		}
		case Protocol::MSG_REQUEST_MANIFEST:
		{
			const Protocol::MsgRequestManifest * msg = static_cast< const Protocol::MsgRequestManifest * >( imsg );
			Process( connection, msg ); 
			break;
		}
		case Protocol::MSG_REQUEST_FILE:
		{
			const Protocol::MsgRequestFile * msg = static_cast< const Protocol::MsgRequestFile * >( imsg );
			Process( connection, msg ); 
			break;
		}
		case Protocol::MSG_SERVER_STATUS:
		{
			const Protocol::MsgServerStatus * msg = static_cast< const Protocol::MsgServerStatus * >( imsg );
			Process( connection, msg ); 
			break;
		}
		default:
		{
			// unknown message type
			ASSERT( false ); // this indicates a protocol bug
			Disconnect( connection );
			break;
		}
	}

	// free everything
	FREE( (void *)( ss->m_CurrentMessage ) );
	FREE( payload );
	ss->m_CurrentMessage = nullptr;
}
예제 #28
0
//-----------------------------------------------------------------------------
// Name: Run()
// Desc:
//-----------------------------------------------------------------------------
INT CXBApplicationEx::Run()
{
  CLog::Log(LOGNOTICE, "Running the application..." );

  // Get the frequency of the timer
  LARGE_INTEGER qwTicksPerSec;
  QueryPerformanceFrequency( &qwTicksPerSec );
  FLOAT fSecsPerTick = 1.0f / (FLOAT)qwTicksPerSec.QuadPart;

  // Save the start time
  LARGE_INTEGER qwTime, qwLastTime, qwElapsedTime;
  QueryPerformanceCounter( &qwTime );
  qwLastTime.QuadPart = qwTime.QuadPart;

  LARGE_INTEGER qwAppTime, qwElapsedAppTime;
  qwAppTime.QuadPart = 0;
  qwElapsedTime.QuadPart = 0;
  qwElapsedAppTime.QuadPart = 0;

  BYTE processExceptionCount = 0;
  BYTE frameMoveExceptionCount = 0;
  BYTE renderExceptionCount = 0;

#ifndef _DEBUG
  const BYTE MAX_EXCEPTION_COUNT = 10;
#endif

  // Run the game loop, animating and rendering frames
  while (!m_bStop)
  {
#ifdef HAS_PERFORMANCE_SAMPLE
    CPerformanceSample sampleLoop("XBApplicationEx-loop");  
#endif

    //-----------------------------------------
    // Perform app timing
    //-----------------------------------------

    // Check Start button
#ifdef HAS_GAMEPAD
    if ( m_DefaultGamepad.wPressedButtons & XINPUT_GAMEPAD_START )
#endif
      m_bPaused = !m_bPaused;

    // Get the current time (keep in LARGE_INTEGER format for precision)
    QueryPerformanceCounter( &qwTime );
    qwElapsedTime.QuadPart = qwTime.QuadPart - qwLastTime.QuadPart;
    qwLastTime.QuadPart = qwTime.QuadPart;
    if ( m_bPaused )
      qwElapsedAppTime.QuadPart = 0;
    else
      qwElapsedAppTime.QuadPart = qwElapsedTime.QuadPart;
    qwAppTime.QuadPart += qwElapsedAppTime.QuadPart;

    // Store the current time values as floating point
    m_fTime = fSecsPerTick * ((FLOAT)(qwTime.QuadPart));
    m_fElapsedTime = fSecsPerTick * ((FLOAT)(qwElapsedTime.QuadPart));
    m_fAppTime = fSecsPerTick * ((FLOAT)(qwAppTime.QuadPart));
    m_fElapsedAppTime = fSecsPerTick * ((FLOAT)(qwElapsedAppTime.QuadPart));

    //-----------------------------------------
    // Animate and render a frame
    //-----------------------------------------
#ifndef _DEBUG
    try
    {
#endif
      Process();
      //reset exception count
      processExceptionCount = 0;

#ifndef _DEBUG

    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Process()");
      processExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (processExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions");
        throw;
      }
    }
#endif
    // Frame move the scene
#ifndef _DEBUG
    try
    {
#endif
      if (!m_bStop) FrameMove();
      //reset exception count
      frameMoveExceptionCount = 0;

#ifndef _DEBUG

    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::FrameMove()");
      frameMoveExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions");
        throw;
      }
    }
#endif

    // Render the scene
#ifndef _DEBUG
    try
    {
#endif
      if (!m_bStop) Render();
      //reset exception count
      renderExceptionCount = 0;

#ifndef _DEBUG

    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Render()");
      renderExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (renderExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::Render(), too many exceptions");
        throw;
      }
    }
#endif

  }
  Destroy();

  CLog::Log(LOGNOTICE, "application stopped..." );
  return 0;
}
예제 #29
0
    /** Returns a gnnsSatTypeValue object, adding the new data
     *  generated when calling this object.
     *
     * @param gData    Data object holding the data.
     */
 virtual gnssSatTypeValue& Process(gnssSatTypeValue& gData)
    throw(DecimateEpoch)
 { Process(gData.header.epoch, gData.body); return gData; };
예제 #30
0
INT32 ProcessPathDistance::GetCoordAndTangentWithCache(DocCoord* pCoord, 
													  double* pTangent, BOOL* pFound,
											          double Dist, Path* pPath, UINT32* pPressure)
{
	ERROR2IF(pCoord==NULL && pTangent==NULL,FALSE,"ProcessPathDistance::GetCoordAndTangent() - no output pointers specified!");
	ERROR2IF(pFound==NULL,FALSE,"ProcessPathDistance::GetCoordAndTangent() - pFound==NULL");
	ERROR2IF( pPath==NULL,FALSE,"ProcessPathDistance::GetCoordAndTangent() - pPath==NULL");
 
	// we wish to continue processing from the last point that we found
	INT32 PrevCoordIndex = m_LastFoundIndex;
	INT32 NumProcessed = m_LastFoundIndex;

	DesiredDist   = Dist;
	CurrentDist   = m_LastFoundDistance;
	Found         = FALSE;
	CoordAtDist   = DocCoord(0,0);
	TangentAtDist = 0;
	PressureAtDist = 0;
	m_bDrawingBrush = TRUE;
	// set up the processpath process.
	ProcessFlags PFlags;
	
	BOOL bPressure = (pPressure != NULL && pPath->HasWidth());
	// if we are already partway along the path then we need to get the
	// previous point as it is needed in NewPoint
	if (NumProcessed > 0)
	{
		DocCoord* pCoords = pPath->GetCoordArray();
		PrevCoord = pCoords[PrevCoordIndex];
		if (bPressure)
		{
			UINT32* pPressureArray = pPath->GetWidthArray();
			if (pPressureArray != NULL)
				m_PrevPressure = pPressureArray[PrevCoordIndex];
			else
			{
				ERROR3("Wheres the pressure array?");
				m_PrevPressure = (UINT32)(MAXPRESSURE / 2);
			}
		}
	}
	
	BOOL ok=ProcessPath::Init(pPath);
	//TRACEUSER( "Diccon", _T("Desired    = %f\n"), Dist);
	//TRACEUSER( "Diccon", _T("Starting   = %f\n"), CurrentDist);

	if (ok)	NumProcessed = Process(PFlags, NumProcessed);

	if (NumProcessed != -1)
	{
		if (Found==FALSE) // this can happen if we are on the first couple of points
		{
			// get last 2 points on line
			DocCoord* pPathCoords=pPath->GetCoordArray();
			ERROR2IF(pPathCoords==NULL,FALSE,"ProcessPathDistance::GetCoordAndTangent() - pPathCoords==NULL");
			INT32 NumPathCoords=pPath->GetNumCoords();
			//ERROR2IF(NumPathCoords<2,FALSE,"ProcessPathDistance::GetCoordAndTangent() - NumPathCoords < 2");
			if (NumPathCoords >= 2)
			{
				DocCoord LastCoord=pPathCoords[NumPathCoords-1];
				DocCoord PrevCoord=pPathCoords[NumPathCoords-2];

				double dx=LastCoord.x-PrevCoord.x;
				double dy=LastCoord.y-PrevCoord.y;
				double LineLength=sqrt(dx*dx+dy*dy);

				if (LineLength>0)
				{
					double FractOfLine = (DesiredDist-CurrentDist)/LineLength;
					double x = LastCoord.x+dx*FractOfLine;
					double y = LastCoord.y+dy*FractOfLine;

					CoordAtDist   = DocCoord((MILLIPOINT)x,(MILLIPOINT)y);
					TangentAtDist = atan2(dy,dx);
					Found = TRUE;
				}
				else
				{
					CoordAtDist	  =	LastCoord;
					TangentAtDist = 0;
					Found = TRUE;
				}
			}
			else //if we only have one coordinate so far
			{
				CoordAtDist=pPathCoords[0];
				TangentAtDist = 0;
				Found = TRUE;
			}
		}
		else
		{
			if (Dist<0) Found=FALSE;	// if not actually on path, flag not found on path
			
		}
		*pFound = Found;
		if (pCoord)   *pCoord   = CoordAtDist;
		if (pTangent) *pTangent = TangentAtDist;
		if (pPressure != NULL)
			*pPressure = PressureAtDist;
	}
	//m_LastFoundDistance = CurrentDist;
	//TRACEUSER( "Diccon", _T("Last Index = %d\n"), m_LastFoundIndex);
	//TRACEUSER( "Diccon", _T("Last Dist  = %f\n"), m_LastFoundDistance);

	//TRACEUSER( "Diccon", _T("FOUND      = %d\n"), Found);

	return NumProcessed;
}