PLCnext API Documentation  21.0.0.35466
SystemTick.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include <chrono>
9 namespace Arp { namespace System { namespace Commons { namespace Chrono
10 {
11 
12 using namespace std::chrono;
13 
16 {
17 public: // typedefs
18 
19 public: // construction/destruction
21  SystemTick(void) = delete;
23  SystemTick(const SystemTick& arg) = delete;
25  SystemTick& operator=(const SystemTick& arg) = delete;
27  ~SystemTick(void) = delete;
28 
29 public: // operators
30 
31 public: // static operations
33  static Milliseconds GetMilliTick(void);
34 
36  static Microseconds GetMicroTick(void);
37 
39  static Nanoseconds GetNanoTick(void);
40 
41 public: // setter/getter operations
42 
43 public: // operations
44 
45 protected: // operations
46 
47 private: // static methods
48 
49 private: // methods
50 
51 private: // fields
52 
53 private: // static fields
54 
55 };
56 
58 // inline methods of class SysTick
59 
61 {
62  return duration_cast<Milliseconds>(steady_clock::now().time_since_epoch());
63 }
64 
66 {
67  return duration_cast<Microseconds>(steady_clock::now().time_since_epoch());
68 }
69 
71 {
72  return duration_cast<Nanoseconds>(steady_clock::now().time_since_epoch());
73 }
74 
75 }}}} // end of namespace Arp::System::Commons::Chrono
static Microseconds GetMicroTick(void)
Returns the current system tick in microseconds
Definition: SystemTick.hpp:65
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: TypeSystem.h:36
static Milliseconds GetMilliTick(void)
Returns the current system tick in milliseconds
Definition: SystemTick.hpp:60
static Nanoseconds GetNanoTick(void)
Returns the current system tick in nanoseconds
Definition: SystemTick.hpp:70
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: TypeSystem.h:34
std::chrono::nanoseconds Nanoseconds
The Arp Nanoseconds unit class.
Definition: TypeSystem.h:32
Root namespace for the PLCnext API
Static methods to get a current system tick in different units
Definition: SystemTick.hpp:15
System components used by the System, Device, Plc or Io domains.