1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.ctf
.core
.event
;
15 import java
.util
.HashMap
;
19 * Clock description used in CTF traces
21 public class CTFClock
{
23 private static final long ONE_BILLION_L
= 1000000000L;
24 private static final double ONE_BILLION_D
= 1000000000.0;
26 private static final String NAME
= "name"; //$NON-NLS-1$
27 private static final String FREQ
= "freq"; //$NON-NLS-1$
28 private static final String OFFSET
= "offset"; //$NON-NLS-1$
30 private long fClockOffset
= 0;
31 private double fClockScale
= 1.0;
32 private double fClockAntiScale
= 1.0;
37 private final Map
<String
, Object
> fProperties
= new HashMap
<>();
42 private boolean fIsScaled
= false;
51 * Method addAttribute.
58 public void addAttribute(String key
, Object value
) {
59 fProperties
.put(key
, value
);
60 if (key
.equals(NAME
)) {
61 fName
= (String
) value
;
63 if (key
.equals(FREQ
)) {
65 * Long is converted to a double. the double is then dividing
66 * another double that double is saved. this is precise as long as
67 * the long is under 53 bits long. this is ok as long as we don't
68 * have a system with a frequency of > 1 600 000 000 GHz with
71 fIsScaled
= !((Long
) getProperty(FREQ
)).equals(ONE_BILLION_L
);
72 fClockScale
= ONE_BILLION_D
/ ((Long
) getProperty(FREQ
)).doubleValue();
73 fClockAntiScale
= 1.0 / fClockScale
;
76 if (key
.equals(OFFSET
)) {
77 fClockOffset
= (Long
) getProperty(OFFSET
);
86 public String
getName() {
97 public Object
getProperty(String key
) {
98 return fProperties
.get(key
);
102 * @return the clockOffset
105 public long getClockOffset() {
110 * @return the clockScale
113 public double getClockScale() {
118 * @return the clockAntiScale
121 public double getClockAntiScale() {
122 return fClockAntiScale
;
126 * @return is the clock in ns or cycles?
129 public boolean isClockScaled() {
This page took 0.0333830000000001 seconds and 5 git commands to generate.