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
;
18 * Clock description used in CTF traces
20 public class CTFClock
{
22 private static final String NAME
= "name"; //$NON-NLS-1$
23 private static final String FREQ
= "freq"; //$NON-NLS-1$
24 private static final String OFFSET
= "offset"; //$NON-NLS-1$
26 private long clockOffset
= 0;
27 private double clockScale
= 1.0;
28 private double clockAntiScale
= 1.0;
33 final private HashMap
<String
, Object
> properties
= new HashMap
<String
, Object
>();
38 private boolean isScaled
= false;
47 * Method addAttribute.
54 public void addAttribute(String key
, Object value
) {
55 this.properties
.put(key
, value
);
56 if (key
.equals(NAME
)) {
57 this.name
= (String
) value
;
59 if (key
.equals(FREQ
)) {
61 * Long is converted to a double. the double is then dividing
62 * another double that double is saved. this is precise as long as
63 * the long is under 53 bits long. this is ok as long as we don't
64 * have a system with a frequency of > 1 600 000 000 GHz with
67 isScaled
= !((Long
) getProperty(FREQ
)).equals(1000000000L);
68 clockScale
= 1000000000.0 / ((Long
) getProperty(FREQ
)).doubleValue();
69 clockAntiScale
= 1.0 / clockScale
;
72 if (key
.equals(OFFSET
)) {
73 clockOffset
= (Long
) getProperty(OFFSET
);
82 public String
getName() {
93 public Object
getProperty(String key
) {
94 return properties
.get(key
);
98 * @return the clockOffset
100 public long getClockOffset() {
105 * @return the clockScale
107 public double getClockScale() {
112 * @return the clockAntiScale
114 public double getClockAntiScale() {
115 return clockAntiScale
;
119 * @return is the clock in ns or cycles?
121 public boolean isClockScaled() {
This page took 0.034338 seconds and 6 git commands to generate.