1 /*******************************************************************************
2 * Copyright (c) 2011-2012 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 clockOffset
= 0;
31 private double clockScale
= 1.0;
32 private double clockAntiScale
= 1.0;
37 private final Map
<String
, Object
> properties
= new HashMap
<String
, Object
>();
42 private boolean isScaled
= false;
51 * Method addAttribute.
58 public void addAttribute(String key
, Object value
) {
59 this.properties
.put(key
, value
);
60 if (key
.equals(NAME
)) {
61 this.name
= (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 isScaled
= !((Long
) getProperty(FREQ
)).equals(ONE_BILLION_L
);
72 clockScale
= ONE_BILLION_D
/ ((Long
) getProperty(FREQ
)).doubleValue();
73 clockAntiScale
= 1.0 / clockScale
;
76 if (key
.equals(OFFSET
)) {
77 clockOffset
= (Long
) getProperty(OFFSET
);
86 public String
getName() {
97 public Object
getProperty(String key
) {
98 return properties
.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 clockAntiScale
;
126 * @return is the clock in ns or cycles?
129 public boolean isClockScaled() {
This page took 0.034036 seconds and 5 git commands to generate.