PLCnext API Documentation  22.9.0.33
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 
14 {
15 public: // typedefs
16 
17 public: // construction/destruction
19  SystemTick(void) = delete;
21  SystemTick(const SystemTick& arg) = delete;
23  SystemTick& operator=(const SystemTick& arg) = delete;
25  ~SystemTick(void) = delete;
26 
27 public: // operators
28 
29 public: // static operations
31  static Milliseconds GetMilliTick(void);
32 
34  static Microseconds GetMicroTick(void);
35 
37  static Nanoseconds GetNanoTick(void);
38 
39 public: // setter/getter operations
40 
41 public: // operations
42 
43 protected: // operations
44 
45 private: // static methods
46 
47 private: // methods
48 
49 private: // fields
50 
51 private: // static fields
52 
53 };
54 
56 // inline methods of class SysTick
57 
59 {
60  return std::chrono::duration_cast<Milliseconds>(std::chrono::steady_clock::now().time_since_epoch());
61 }
62 
64 {
65  return std::chrono::duration_cast<Microseconds>(std::chrono::steady_clock::now().time_since_epoch());
66 }
67 
69 {
70  return std::chrono::duration_cast<Nanoseconds>(std::chrono::steady_clock::now().time_since_epoch());
71 }
72 
73 }}}} // end of namespace Arp::System::Commons::Chrono
Static methods to get a current system tick in different units
Definition: SystemTick.hpp:14
~SystemTick(void)=delete
Destructs this instance and frees all resouces.
SystemTick(const SystemTick &arg)=delete
Copy contructor.
static Microseconds GetMicroTick(void)
Returns the current system tick in microseconds
Definition: SystemTick.hpp:63
static Milliseconds GetMilliTick(void)
Returns the current system tick in milliseconds
Definition: SystemTick.hpp:58
SystemTick(void)=delete
Constructs an SysTick instance.
static Nanoseconds GetNanoTick(void)
Returns the current system tick in nanoseconds
Definition: SystemTick.hpp:68
SystemTick & operator=(const SystemTick &arg)=delete
Assignment operator.
std::chrono::nanoseconds Nanoseconds
The Arp Nanoseconds unit class.
Definition: TypeSystem.h:32
std::chrono::milliseconds Milliseconds
The Arp Milliseconds unit class.
Definition: TypeSystem.h:36
std::chrono::microseconds Microseconds
The Arp Microseconds unit class.
Definition: TypeSystem.h:34
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API