SF2 C++ FRC Class Library
Sensor Fusion Framework (SF2) for FRC
TimestampInfo.h
1 /* ============================================
2  SF2 source code is placed under the MIT license
3  Copyright (c) 2017 Kauai Labs
4 
5  Permission is hereby granted, free of charge, to any person obtaining a copy
6  of this software and associated documentation files (the "Software"), to deal
7  in the Software without restriction, including without limitation the rights
8  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  copies of the Software, and to permit persons to whom the Software is
10  furnished to do so, subject to the following conditions:
11 
12  The above copyright notice and this permission notice shall be included in
13  all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21  THE SOFTWARE.
22  ===============================================
23  */
24 
25 #ifndef SRC_TIME_TIMESTAMPINFO_H_
26 #define SRC_TIME_TIMESTAMPINFO_H_
27 
29 public:
30  enum Scope {
31  Sensor, /* Timestamp is unique to this sensor. */
32  Processor, /* Timestamp is unique to the sensor's Host Processor. */
33  SynchNetwork /* Timestamp is network-synchronized. */
34  };
35 
36  enum Basis {
37  Epoch, /* Timestamp is num of nanoseconds since Jan. 1, 1970 (UTC) */
38  SinceLastReboot /* Timestamp is num of nanoseconds since last sensor/processor reboot. */
39  };
40 
41  Basis basis;
42  Scope scope;
43  double resolution_secs;
44  double accuracy_secs; /* +/- */
45  double drift_secs_per_hour;
46  double average_latency_secs;
47  Timestamp default_timestamp;
48 
49  TimestampInfo(Scope scope, Basis basis, double resolution_secs,
50  double accuracy_secs, double drift_secs_per_hour,
51  double average_latency_secs, Timestamp& default_timestamp) {
52  this->scope = scope;
53  this->basis = basis;
54  this->resolution_secs = resolution_secs;
55  this->accuracy_secs = accuracy_secs;
56  this->drift_secs_per_hour = drift_secs_per_hour;
57  this->default_timestamp = default_timestamp;
58  this->average_latency_secs = average_latency_secs;
59  }
60 
61  Scope getScope() {
62  return scope;
63  }
64  Basis getBasis() {
65  return basis;
66  }
67  double getTimestampResolutionSecs() {
68  return resolution_secs;
69  }
70  double getTimestampAccuracyPlusMinusSecs() {
71  return accuracy_secs;
72  }
73  double getTimestampDriftSecsPerHour() {
74  return drift_secs_per_hour;
75  }
76  double getAverageLatencySecs() {
77  return average_latency_secs;
78  }
79  Timestamp getDefaultTimestamp() {
80  return default_timestamp;
81  }
82 };
83 
84 #endif /* SRC_TIME_TIMESTAMPINFO_H_ */
Definition: TimestampInfo.h:28
Definition: Timestamp.h:30