コード例 #1
0
bool SystemClass::initialize()
{
	int Width, Height;

	initializeWindow(Width, Height);

	EventDispatcher.reset(new Dispatcher);
	assert(EventDispatcher);
	EventDispatcher->initialize();

	InputManager.reset(new Input::Manager);
	assert(InputManager);
	if (!InputManager->initialize(ApplicationInstance, Window, EventDispatcher))
	{
		MessageBox(Window, L"Failed to initialize DirectInput8 interface", L"Error", MB_OK);
		return false;
	}

	// Sets the initial timer to zero
	calculateFrameTime();

	SceneManager.reset(new Scenes::SceneManager);
	assert(SceneManager);

	PhysicsWorld.reset(new Physics::Environment);
	assert(PhysicsWorld);

	if (!SceneManager->initialize(Width, Height, Window, InputManager, PhysicsWorld, EventDispatcher))
		return false;

	PhysicsWorld->initialize();

	return true;
}
コード例 #2
0
bool SystemClass::doFrame()
{
	float FrameTime = calculateFrameTime();

	if (!InputManager->doFrame())
		return false;

	PhysicsWorld->doFrame(FrameTime);

	if (!SceneManager->runFrame(FrameTime))
		return false;

	return true;
}
コード例 #3
0
void CalculateAirtimeUtilization(long slotTime, int lastSlot)
{
int eFrame;	
long nextFrame;
char *success;
int rtsctsFrames=0;
int dataFrames=0;
int ackFrames=0;
char address[18];

double currentTS, nextTS, finalTS;
long nextSlot;
double slot;
long simulationTime = 1800;

dataFrames=0;
rtsctsFrames=0;
ackFrames=0;
eFrame=0;
slot=(float)slotTime;

nextSlot = (lastSlot>0)? lastSlot:1;
currentTS = PCAP_DATA_VAL[eFrame].frame_time_epoch;
nextTS = PCAP_DATA_VAL[eFrame+1].frame_time_epoch;
finalTS = currentTS + slot;


float frameTime = 0.0;
float probeTrafficFrameTime = 0.0;
float dataTrafficFrameTime = 0.0;
float otherTrafficFrameTime = 0.0;
int dispSlot;
	while (eFrame<framesCount-1) 
	{
		
		 if ((nextTS - currentTS) <= slot)
		 {
			float currentFrameTime = 0.0;

			if (eFrame >= 1)
 			currentFrameTime = calculateFrameTime(PCAP_DATA_VAL[eFrame], PCAP_DATA_VAL[eFrame-1], PCAP_DATA_VAL[eFrame+1]); 
			
			
			frameTime = frameTime + currentFrameTime;
			//else
			//frameTime = frameTime + calculateFrameTime(PCAP_DATA_VAL[eFrame], PCAP_DATA_VAL[eFrame], PCAP_DATA_VAL[eFrame+1]); 

			if (strcmp(PCAP_DATA_VAL[eFrame].wlan_fc_type_subtype, "0x04")==0||strcmp(PCAP_DATA_VAL[eFrame].wlan_fc_type_subtype, "0x05")==0)//Probe Traffic
			probeTrafficFrameTime+=currentFrameTime;

			else if ((PCAP_DATA_VAL[eFrame].wlan_fc_type==0) || (PCAP_DATA_VAL[eFrame].wlan_fc_type==1))//Control Traffic or Management Traffic
			otherTrafficFrameTime+=currentFrameTime;

			else if (PCAP_DATA_VAL[eFrame].wlan_fc_type==2)//Data Traffic
			dataTrafficFrameTime+=currentFrameTime;

		 }else{
			//Calculate %
			dispSlot = (slot + nextSlot*slot)/slot;
			
			double percentage = 100 * ((float)frameTime/1000000); //Airtime Utilization %
			double datapercentage = 100 * ((float)dataTrafficFrameTime/1000000); //Airtime Utilization %
			double probepercentage = 100 * ((float)probeTrafficFrameTime/1000000); //Airtime Utilization %
			double otherpercentage = 100 * ((float)otherTrafficFrameTime/1000000); //Airtime Utilization %

			printf("%d,%f,%f,%f,%f\n",dispSlot, percentage, datapercentage, probepercentage, otherpercentage); 

			nextSlot = nextSlot + 1; 
			frameTime = 0;
			dataTrafficFrameTime=0;
			probeTrafficFrameTime=0;
			otherTrafficFrameTime=0;
			currentTS = PCAP_DATA_VAL[eFrame].frame_time_epoch;
		 }
	eFrame++;	
	nextTS = PCAP_DATA_VAL[eFrame].frame_time_epoch;
	}
}