EtherCAT Control Framework v0.9
Implementation of EtherCAT protocol using IgH EtherCAT library for robot controller.
timing.hpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * $Id$
4 *
5 * Copyright (C) 2021 Veysi ADIN, UST KIST
6 *
7 * This file is part of the Wrapped IgH EtherCAT master userspace program
8 * for control applications.
9 *
10 * The Wrapped IgH EtherCAT master userspace program for control application
11 * in userspace is free software; you canredistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; version 2 of the License.
14 *
15 * The Wrapped IgH EtherCAT master userspace program for control application
16 * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
17 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 * PURPOSE.
19 * See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with the Wrapped IgH EtherCAT master userspace program for control application.
23 * If not, see <http://www.gnu.org/licenses/>.
24 *
25 * ---
26 *
27 * The license mentioned above concerns the source code only. Using the
28 * EtherCAT technology and brand is only permitted in compliance with the
29 * industrial property and similar rights of Beckhoff Automation GmbH.
30 *
31 * Contact information: veysi.adin@kist.re.kr
32 *****************************************************************************/
33/*******************************************************************************
34 * \file timing.hpp
35 * \brief Contains timing measurement functions for convenience
36 *******************************************************************************/
37#pragma once
38#include <vector>
39#include <chrono>
40#include <memory>
41#include <functional>
42#include <string>
43#include <cstdint>
44#include <ctime>
45#include <ratio>
46#include <fstream>
47#include <string>
48#include <iostream>
49
50#define NUMBER_OF_SAMPLES 1E6
55class Timing{
56 public:
57 std::chrono::high_resolution_clock::time_point timer_start_;
58 std::chrono::high_resolution_clock::time_point last_start_time_;
59 std::chrono::duration<long,std::micro> time_span_;
60 std::vector<long> timing_info_ = std::vector<long>(NUMBER_OF_SAMPLES);
61 uint32_t counter_ = 0;
65 void GetTime();
76 void OutInfoToFile();
77};
Contains Timing measurement related functions.
Definition: timing.hpp:55
void MeasureTimeDifference()
Measures time difference from last call to function GetTime() and writes is to time_span member.
Definition: timing.cpp:7
std::chrono::duration< long, std::micro > time_span_
Definition: timing.hpp:59
std::vector< long > timing_info_
Definition: timing.hpp:60
std::chrono::high_resolution_clock::time_point timer_start_
Definition: timing.hpp:57
void GetTime()
Gets the current time and assings to timer_start_ member.
Definition: timing.cpp:3
uint32_t counter_
Definition: timing.hpp:61
std::chrono::high_resolution_clock::time_point last_start_time_
Definition: timing.hpp:58
void OutInfoToFile()
Outputs timing information to loop_timing_info.txt file.
Definition: timing.cpp:14
#define NUMBER_OF_SAMPLES
Definition: timing.hpp:50