1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made 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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.btf
.core
.trace
;
15 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
19 * Timstamp format of BTF timescale as per v2.1 of the spec
21 * @author Matthew Khouzam
23 public enum BtfTimstampFormat
{
27 PS("ps", -12, 0.001), //$NON-NLS-1$
31 NS("ns", -9, 1.0), //$NON-NLS-1$
35 US("us", -6, 1000.0), //$NON-NLS-1$
39 MS("ms", -3, 1000000.0), //$NON-NLS-1$
43 S("s", 0, 1000000000.0); //$NON-NLS-1$
45 private final String fName
;
46 private final int fScale
;
47 private final double fScaleFactor
;
49 private BtfTimstampFormat(String name
, int scale
, double scaleFactor
) {
52 fScaleFactor
= scaleFactor
;
56 * Get the scaling factor
58 * @return the scaling factor
60 public double getScaleFactor() {
65 public String
toString() {
70 * Parse a string to get a scale
73 * the timestamp in text "ns", "ms" ...
74 * @return a BtfTimestampFormat object
76 public static BtfTimstampFormat
parse(String text
) {
77 switch (text
.toLowerCase()) {
78 case "ps": //$NON-NLS-1$
79 throw new IllegalArgumentException("ps not yet supported"); //$NON-NLS-1$
80 case "ns": //$NON-NLS-1$
81 return BtfTimstampFormat
.NS
;
82 case "us": //$NON-NLS-1$
83 return BtfTimstampFormat
.US
;
84 case "ms": //$NON-NLS-1$
85 return BtfTimstampFormat
.MS
;
86 case "s": //$NON-NLS-1$
87 return BtfTimstampFormat
.S
;
89 throw new IllegalArgumentException(text
+ " not a valid argument, use ps, ns, us, ms, s"); //$NON-NLS-1$
94 * Create an ITmfTimestamp with a proper scale
97 * timestamp without scale
98 * @return TmfTimestamp with proper scale
100 public ITmfTimestamp
createTimestamp(long timestamp
) {
101 return new TmfTimestamp(timestamp
, fScale
);
This page took 0.033272 seconds and 5 git commands to generate.