view include/VirtualClock.h @ 138:53e3c0a3295d ClockSync

Added xenomai version of Clock, now includes header
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 13 Sep 2015 21:33:01 +0100
parents e77e2e712fbc
children 44d07fa9bd03
line wrap: on
line source
#ifndef VIRTUAL_CLOCK_H_INCLUDED
#define VIRTUAL_CLOCK_H_INCLUDED

#include "stats.hpp"
#include "Clock.h"

class VirtualClock{
private:
	myClock_t startTime;
	myClock_t lastSync;
	bool firstRun;
	double period;
	MovingAverage<double> movingAverage;
public:
	void init();
	VirtualClock();
/**
	Call this method at regular intervals to sync che virtual clock
*/
	void sync();
/**
	Call this method asynchronously, passing a number of equally spaced events that have elapsed since the last call.
*/
	void sync(double count);
/**
	Get the current time according to the VirtualClock.
	
	@return Time elapsed since the first call to sync(), in period units. 
*/
	double getNow();
/** 
	Get the length of the period.
	
	Get the length of the period (difference between calls to sync() after various filtering operations)
*/
	double getPeriod();
};

#endif /* VIRTUAL_CLOCK_H_INCLUDED */