15.10.2012 - version 0.2.0 - PIIODevice - base of file, ethernet, serial and packets extractor. PIEthernet now support also TCP (client and server). PIConsole now can align labels in each column individually.
This commit is contained in:
32
pitimer.h
32
pitimer.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Timer
|
||||
Copyright (C) 2011 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -32,12 +32,14 @@ struct PITime {
|
||||
int seconds;
|
||||
int minutes;
|
||||
int hours;
|
||||
PIString toString(const PIString & format = "h:mm:ss");
|
||||
};
|
||||
|
||||
struct PIDate {
|
||||
int day;
|
||||
int month;
|
||||
int year; // since 1900
|
||||
PIString toString(const PIString & format = "d.mm.yyyy");
|
||||
};
|
||||
|
||||
class PITimer
|
||||
@@ -50,7 +52,7 @@ class PITimer
|
||||
public:
|
||||
PITimer(TimerEvent slot = 0, void * data = 0);
|
||||
~PITimer();
|
||||
|
||||
|
||||
void setData(void * data_) {data = data_;}
|
||||
void setSlot(TimerEvent slot) {ret_func = slot;}
|
||||
#ifdef WINDOWS
|
||||
@@ -76,15 +78,25 @@ public:
|
||||
double elapsed_u(); // microseconds
|
||||
double elapsed_m(); // miliseconds
|
||||
double elapsed_s(); // seconds
|
||||
|
||||
|
||||
double reset_time_n(); // nanoseconds
|
||||
double reset_time_u(); // microseconds
|
||||
double reset_time_m(); // miliseconds
|
||||
double reset_time_s(); // seconds
|
||||
|
||||
static double elapsed_system_n(); // nanoseconds
|
||||
static double elapsed_system_u(); // microseconds
|
||||
static double elapsed_system_m(); // miliseconds
|
||||
static double elapsed_system_s(); // seconds
|
||||
|
||||
private:
|
||||
#ifdef WINDOWS
|
||||
void run();
|
||||
|
||||
long int t_st, t_cur;
|
||||
|
||||
long t_st, t_cur;
|
||||
#else
|
||||
static void timer_event(sigval e);
|
||||
|
||||
|
||||
bool running;
|
||||
volatile bool lockRun;
|
||||
PIMutex mutex_;
|
||||
@@ -100,16 +112,16 @@ private:
|
||||
int delim;
|
||||
int tick;
|
||||
};
|
||||
|
||||
|
||||
void * data;
|
||||
TimerEvent ret_func;
|
||||
PIVector<TimerSlot> ret_funcs;
|
||||
|
||||
|
||||
};
|
||||
|
||||
PITime currentTime();
|
||||
PIDate currentDate();
|
||||
PIString time2string(const PITime & time, const PIString & format = "h:mm:ss");
|
||||
PIString date2string(const PIDate & date, const PIString & format = "d.mm.yyyy");
|
||||
PIString time2string(const PITime & time, const PIString & format = "h:mm:ss"); // obsolete, use PITime.toString() instead
|
||||
PIString date2string(const PIDate & date, const PIString & format = "d.mm.yyyy"); // obsolete, use PITime.toString() instead
|
||||
|
||||
#endif // PITIMER_H
|
||||
|
||||
Reference in New Issue
Block a user