⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stopwatch.cpp

📁 RoboCup仿真组世界冠军源代码
💻 CPP
字号:
/*
    Copyright (C) 2001  Tsinghuaeolus

    Authors : ChenJiang, YaoJinyi, CaiYunpeng, Lishi

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

	If you make any changes or have any comments we would appreciate a 
	message to yjy01@mails.tsinghua.edu.cn.
*/

#include "stopwatch.h"
#include "global.h"
/*******Stopwatch*****************/
Stopwatch::Stopwatch(){
	LARGE_INTEGER frq;
	QueryPerformanceFrequency(&frq);
	frequency = frq.QuadPart;
	current_cycle = 0;
}

void Stopwatch::QueryTime(TimedDataArray<LARGE_INTEGER, NUMSTOPWATCHS>& t, int cycle){
	LARGE_INTEGER tmp;
	QueryPerformanceCounter(&tmp);
	t.Setdata(tmp, cycle);
}

float Stopwatch::TimeElapsedThisCycle(){
	LARGE_INTEGER tmp;
	QueryPerformanceCounter(&tmp);
	return MsBetween(Cycle_s.Data(current_cycle), tmp);
}

float Stopwatch::TimeElapsedAfterAIStart(){
	LARGE_INTEGER tmp;
	QueryPerformanceCounter(&tmp);
	return MsBetween(AI_s.Data(current_cycle), tmp);
}

float Stopwatch::SightIntervalBetween(int prevcycle, int nextcycle){
	return MsBetween(See_t.Data(prevcycle), See_t.Data(nextcycle));
}

float Stopwatch::TimeElapsedSight(){
	LARGE_INTEGER tmp;
	QueryPerformanceCounter(&tmp);
	return Min(MsBetween(See_t.Data(sensory.LastSightTime), tmp), MsBetween(Changeview_t, tmp));
}

float Stopwatch::PredictNextSight(){
	float timelapsed = Min(MsBetween(See_t.Data(sensory.LastSightTime), Cycle_s.Data(current_cycle)), MsBetween(Changeview_t, Cycle_s.Data(current_cycle)));
	float sightgap = (float)sensory.MySightInterval(); 
	return sightgap - timelapsed;
} 

⌨️ 快捷键说明

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