001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenixpro; 008 009/** 010 * A collection of timestamps for a received signal. 011 * 012 * @deprecated Classes in the phoenixpro package will be removed in 2024. 013 * Users should instead use classes from the phoenix6 package. 014 */ 015@Deprecated(forRemoval = true) 016public class AllTimestamps { 017 private Timestamp systemTimestamp = new Timestamp(); 018 private Timestamp canivoreTimestamp = new Timestamp(); 019 020 void update(Timestamp newSystemTimestamp, Timestamp newCanivoreTimestamp, Timestamp newDeviceTimestamp) { 021 systemTimestamp = newSystemTimestamp; 022 canivoreTimestamp = newCanivoreTimestamp; 023 } 024 void update( 025 double systemTimestampSeconds, Timestamp.TimestampSource systemTimestampSource, boolean systemTimestampValid, 026 double canivoreTimestampSeconds, Timestamp.TimestampSource canivoreTimestampSource, boolean canivoreTimestampValid, 027 double deviceTimestampSeconds, Timestamp.TimestampSource deviceTimestampSource, boolean deviceTimestampValid 028 ) { 029 this.systemTimestamp.update(systemTimestampSeconds, systemTimestampSource, systemTimestampValid); 030 this.canivoreTimestamp.update(canivoreTimestampSeconds, canivoreTimestampSource, canivoreTimestampValid); 031 } 032 033 /** 034 * Get the best timestamp available. 035 * 036 * @return Best available timestamp 037 */ 038 public Timestamp getBestTimestamp() { 039 if (canivoreTimestamp.isValid()) 040 return canivoreTimestamp; 041 /* System timestamp is always available */ 042 return systemTimestamp; 043 } 044 045 /** 046 * Get the timestamp as reported by the system. 047 * 048 * @return {@link Timestamp.TimestampSource#System System} timestamp 049 */ 050 public Timestamp getSystemTimestamp() { 051 return systemTimestamp; 052 } 053 /** 054 * Get the timestamp as reported by the CANivore. 055 * 056 * @return {@link Timestamp.TimestampSource#CANivore CANivore} timestamp 057 */ 058 public Timestamp getCANivoreTimestamp() { 059 return canivoreTimestamp; 060 } 061}