logunit.cpp

来自「robocup3d源化码 Nexus3D.tar.gz」· C++ 代码 · 共 99 行

CPP
99
字号
/*Copyright (C) 2005 Ferdowsi University*/#include <sstream>#include <stdarg.h>#include <string.h> #include "logunit.h"#include "global.h"LogUnit::LogUnit(){ 	for(int i = 0; i < Max_Channels; i++)		LogOn[i] = false;}LogUnit::~LogUnit(){}void LogUnit::SetLogOn(int lognum){	if(IsValidChannel(lognum))		LogOn[lognum] = true;}void LogUnit::SetLogOff(int lognum){	if(IsValidChannel(lognum))		LogOn[lognum] = false;}void LogUnit::SetLabel(int lognum, char* caption){	if (IsValidChannel(lognum))		strcpy(&label[lognum][0], caption);}void LogUnit::LogAction(int lognum,char * format, ...){	if (!IsValidChannel(lognum) || logpause || !LogOn[lognum])		return;	if (label[lognum][0] != 0)		printf("(p%d,t%.2f)[%s]", Unum, CurrentTime, label[lognum]);/*it should write dimulation time istead of 0*/	else		printf("(p%d,t%.2f)[%s]", Unum, CurrentTime, "Undefined");	char * argptr;	va_start(argptr, format);	vsprintf(logstring, format, argptr);	va_end(argptr);	printf(logstring);	printf("\n");	fflush(0);}void LogUnit::Init(int unum){	SetLabel(LOG_NONE,"None");	SetLabel(LOG_POS,"Position");	SetLabel(LOG_GOALIE,"Goalie");	SetLabel(LOG_KICK,"Kick");	SetLabel(LOG_PASS,"Pass");	SetLabel(LOG_ADJUST,"AdjustKick");	SetLabel(LOG_SETPLAY,"SetPlay");	SetLabel(LOG_DRIBBLE,"Dribble");	SetLabel(LOG_SHOOT,"Shoot");	SetLabel(LOG_EVAL,"Evaluate");	SetLabel(LOG_PARSE,"Parser");	SetLabel(LOG_NET,"Network");	SetLabel(LOG_LOG,"LOG");	SetLabel(LOG_UPDATE,"Update");	SetLabel(LOG_GOTO,"Goto");	SetLabel(LOG_INTERCEPT, "Interception");	SetLabel(LOG_HANDLE, "HabdelBall");/* to turn off a channel rem its SetLogOn line */	//SetLogOn(LOG_NONE);	//SetLogOn(LOG_POS);	//SetLogOn(LOG_GOALIE);	//SetLogOn(LOG_KICK);	SetLogOn(LOG_PASS);	SetLogOn(LOG_ADJUST);	//SetLogOn(LOG_SETPLAY);	SetLogOn(LOG_DRIBBLE);	//SetLogOn(LOG_SHOOT);	//SetLogOn(LOG_EVAL);	//SetLogOn(LOG_PARSE);	//SetLogOn(LOG_NET);	//SetLogOn(LOG_LOG);	//SetLogOn(LOG_UPDATE);	//SetLogOn(LOG_GOTO);	SetLogOn(LOG_INTERCEPT);	SetLogOn(LOG_HANDLE);	PauseLog(false);	Unum = unum;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?