timer.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
33 #ifndef _TIMER_H_
34 #define _TIMER_H_
35 
40 #define MINIMUM_IPC_SLEEP 0.005
41 
42 //####################################################################
43 // Includes:
44 //####################################################################
45 
46 //System Includes
47 #include <sys/time.h>
48 #include <unistd.h>
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <pthread.h>
52 #include <ros/ros.h>
53 //Include lar wrappers
54 
55 //Include lar individual modules
56 
57 
58 //Include local modules
59 
60 
61 
62 // double lar_get_time();
63 
64 class c_timer{
65  public:
66  c_timer();
67  ~c_timer();
68 
69  void tic(int);
70  void toc(int);
71  void run_sleep(int, double);
72  void set_ipc_sleep(int);
73  char run_ipc_sleep(double, int, char);
74  double get_toc(int);//added by dgameiro on 25-02-2010
75  void verb(int start=0, int end=10){printf("class timer tocs...\n");for (int i=start;i<end;i++) {printf("toc[%d]=%3.4f ms\n",i,lar_toc[i]*1000.0);}};
76 
77  private:
78  //pthread_mutex_t ipc_connected_mutex;
79  char ipc_connected;
80  pthread_mutex_t clock_tic_mutex;
81  double clock_tic[10];
82  pthread_mutex_t clock_set_mutex;
83  char clock_set[10];
84  pthread_mutex_t lar_tic_mutex;
85  double lar_tic[10];
86  pthread_mutex_t lar_toc_mutex;
87  double lar_toc[10];
88 };
89 #endif
90 
pthread_mutex_t clock_set_mutex
Definition: timer.h:82
char run_ipc_sleep(double, int, char)
to use this method is required to run set_ipc_sleep method previously
Definition: timer.cpp:148
void set_ipc_sleep(int)
method with run_ipc_sleep that allows that to set a refresh rate of a specified code.
Definition: timer.cpp:98
double lar_tic[10]
Definition: timer.h:85
double clock_tic[10]
Definition: timer.h:81
void verb(int start=0, int end=10)
Definition: timer.h:75
pthread_mutex_t lar_toc_mutex
Definition: timer.h:86
void toc(int)
method when used with t1c enables you to know how many time have passed since
Definition: timer.cpp:205
pthread_mutex_t clock_tic_mutex
Definition: timer.h:80
double lar_toc[10]
Definition: timer.h:87
c_timer()
runned when created class
Definition: timer.cpp:61
void run_sleep(int, double)
method to use inside thread to avoid collisions between threads
Definition: timer.cpp:115
char clock_set[10]
Definition: timer.h:83
char ipc_connected
Definition: timer.h:75
pthread_mutex_t lar_tic_mutex
Definition: timer.h:84
~c_timer()
method ruuned when class is destroyed
Definition: timer.cpp:89
Definition: timer.h:64
double get_toc(int)
Definition: timer.cpp:217
void tic(int)
method when used with toc enables you to know how many time have passed since
Definition: timer.cpp:190


atlasmv_base
Author(s): David Gameiro, Jorge Almeida
autogenerated on Mon Mar 2 2015 01:31:28