Skip to content

Commit fc155c8

Browse files
committed
Extract EPICS epoch
1 parent 6df939f commit fc155c8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

core/pv/src/main/java/org/phoebus/pv/ca/DBRHelper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
@@ -69,6 +69,9 @@
6969
@SuppressWarnings("nls")
7070
public 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

core/pv/src/main/java/org/phoebus/pv/pva/Decoders.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import org.epics.vtype.VULongArray;
7575
import org.epics.vtype.VUShort;
7676
import org.epics.vtype.VUShortArray;
77+
import org.phoebus.pv.ca.DBRHelper;
7778

7879
/** Decodes {@link Time}, {@link Alarm}, {@link Display}, ...
7980
* @author Kay Kasemir
@@ -166,7 +167,7 @@ static Time decodeTime(final PVAStructure struct)
166167
// as used for the Channel Access and IOC time stamp epoch
167168
// is considered invalid because IOCs send it for never processed records
168169
final boolean valid = timestamp.getNano() != 0 &&
169-
(timestamp.getEpochSecond() > 0 && timestamp.getEpochSecond() != 631152000L);
170+
(timestamp.getEpochSecond() > 0 && timestamp.getEpochSecond() != DBRHelper.EPICS_EPOCH);
170171
return Time.of(timestamp, usertag, valid);
171172
}
172173

0 commit comments

Comments
 (0)