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
.tracecompass
.btf
.core
.trace
;
15 import org
.eclipse
.jdt
.annotation
.NonNull
;
16 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
20 * Timstamp format of BTF timescale as per v2.1 of the spec
22 * @author Matthew Khouzam
25 public enum BtfTimestampFormat
{
29 PS("ps", -12, 0.001), //$NON-NLS-1$
33 NS("ns", -9, 1.0), //$NON-NLS-1$
37 US("us", -6, 1000.0), //$NON-NLS-1$
41 MS("ms", -3, 1000000.0), //$NON-NLS-1$
45 S("s", 0, 1000000000.0); //$NON-NLS-1$
47 private final String fName
;
48 private final int fScale
;
49 private final double fScaleFactor
;
51 private BtfTimestampFormat(String name
, int scale
, double scaleFactor
) {
54 fScaleFactor
= scaleFactor
;
58 * Get the scaling factor
60 * @return the scaling factor
62 public double getScaleFactor() {
67 public String
toString() {
72 * Parse a string to get a scale
75 * the timestamp in text "ns", "ms" ...
76 * @return a BtfTimestampFormat object
78 public static BtfTimestampFormat
parse(String text
) {
79 switch (text
.toLowerCase()) {
80 case "ps": //$NON-NLS-1$
81 throw new IllegalArgumentException("ps not yet supported"); //$NON-NLS-1$
82 case "ns": //$NON-NLS-1$
83 return BtfTimestampFormat
.NS
;
84 case "us": //$NON-NLS-1$
85 return BtfTimestampFormat
.US
;
86 case "ms": //$NON-NLS-1$
87 return BtfTimestampFormat
.MS
;
88 case "s": //$NON-NLS-1$
89 return BtfTimestampFormat
.S
;
91 throw new IllegalArgumentException(text
+ " not a valid argument, use ps, ns, us, ms, s"); //$NON-NLS-1$
96 * Create an ITmfTimestamp with a proper scale
99 * timestamp without scale
100 * @return TmfTimestamp with proper scale
102 public @NonNull ITmfTimestamp
createTimestamp(long timestamp
) {
103 return new TmfTimestamp(timestamp
, fScale
);
This page took 0.038703 seconds and 5 git commands to generate.