libpandac  0.0.0
A library designed for a comm.ai Panda.
gpsTime.h
1 /*
2  Author: Matt Bunting
3  Copyright (c) 2021 Arizona Board of Regents
4  All rights reserved.
5 
6  Permission is hereby granted, without written agreement and without
7  license or royalty fees, to use, copy, modify, and distribute this
8  software and its documentation for any purpose, provided that the
9  above copyright notice and the following two paragraphs appear in
10  all copies of this software.
11 
12  IN NO EVENT SHALL THE ARIZONA BOARD OF REGENTS BE LIABLE TO ANY PARTY
13  FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14  ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15  IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
16  SUCH DAMAGE.
17 
18  THE ARIZONA BOARD OF REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20  AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER
21  IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION
22  TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 
24  */
25 
26 #ifndef PANDA_GPS_TIME_H
27 #define PANDA_GPS_TIME_H
28 
29 #include "panda/gps.h"
30 
31 namespace Panda {
32 
33 
34 // For debugging time
35 //std::string timevalToPrettyString(struct timeval& time);
36 
38 public:
39 
40  // Example usage:
41  // double epsilon = 0.2; // If system time is off from GPS time by this amount, update time.
42  // SetSystemTimeObserver mSetSystemTimeObserver(epsilon);
43 
44  // // Initialize Usb, this requires a conencted Panda
45  // Panda::Handler pandaHandler;
46  // pandaHandler.addGpsObserver(mSetSystemTimeObserver);
47 
48  // Constructor with time to be set
49  SetSystemTimeObserver(double minimumAcceptableOffsetInSeconds);
50 
51  // Check this before using system time
52  bool hasTimeBeenSet();
53 
54 private:
55  bool timeHasBeenSet;
56  double epsilon;
57 
58  void newDataNotification( Panda::GpsData* gpsData );
59 };
60 
61 }
62 
63 #endif
Handles USB communication and parsing with a comma.ai Panda.
Definition: can.h:38
Definition: gpsdata.h:143
Definition: gpsTime.h:37
An abstract class for new data notifications for new GPS data.
Definition: gps.h:50