File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
core/pv/src/main/java/org/phoebus/pv Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 11/*******************************************************************************
2- * Copyright (c) 2017-2018 Oak Ridge National Laboratory.
2+ * Copyright (c) 2017-2022 Oak Ridge National Laboratory.
33 * All rights reserved. This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License v1.0
55 * which accompanies this distribution, and is available at
6969@ SuppressWarnings ("nls" )
7070public class DBRHelper
7171{
72+ /** 1990/01/01 00:00:00 epoch used by Channel Access and records on IOC */
73+ public static final long EPICS_EPOCH = 631152000L ;
74+
7275 /** @param plain Get plain type of CTRL_... type?
7376 * @param type Example data
7477 * @return CTRL_... type for this channel.
@@ -155,7 +158,7 @@ private static Time convertTime(final DBR dbr)
155158 if (epics_time == null )
156159 return Time .nowInvalid ();
157160
158- final Instant instant = Instant .ofEpochSecond (epics_time .secPastEpoch () + 631152000L , (int ) epics_time .nsec ());
161+ final Instant instant = Instant .ofEpochSecond (epics_time .secPastEpoch () + EPICS_EPOCH , (int ) epics_time .nsec ());
159162 if (epics_time .secPastEpoch () <= 0 )
160163 return Time .of (instant , 0 , false );
161164
Original file line number Diff line number Diff line change 7676import org .epics .vtype .VULongArray ;
7777import org .epics .vtype .VUShort ;
7878import org .epics .vtype .VUShortArray ;
79+ import org .phoebus .pv .ca .DBRHelper ;
7980
8081/** Decodes {@link Time}, {@link Alarm}, {@link Display}, ...
8182 * @author Kay Kasemir
@@ -162,7 +163,14 @@ static Time decodeTime(final PVAStructure struct)
162163 timestamp = NO_TIME ;
163164 usertag = NO_USERTAG ;
164165 }
165- return Time .of (timestamp , usertag , timestamp .getEpochSecond () > 0 );
166+
167+ // A time stamp of all zeroes is not valid.
168+ // In addition, a time stamp of 1990/01/02 00:00:00
169+ // as used for the Channel Access and IOC time stamp epoch
170+ // is considered invalid because IOCs send it for never processed records
171+ final boolean valid = timestamp .getNano () != 0 &&
172+ (timestamp .getEpochSecond () > 0 && timestamp .getEpochSecond () != DBRHelper .EPICS_EPOCH );
173+ return Time .of (timestamp , usertag , valid );
166174 }
167175
168176 /** @param printfFormat Format from NTScalar display.format
You can’t perform that action at this time.
0 commit comments