4 * Class NtpTime substitutes the struct NtpTime from
5 * C-source code defines in: 'typedefs_defines_rtps.h'
8 * int32_t seconds; // time in seconds
9 * uint32_t fraction; // time in seconds / 2^32
13 * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
14 * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
15 * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
16 * @author dedication to Kj
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
32 package org.ocera.orte.types;
34 /* TODO @fraction: v C pretypovat z long na uint32_t */
36 public class NtpTime {
38 private int seconds; /* time in seconds */
39 private long fraction; /* time in seconds / 2^32 */
43 * Default constructor.
46 //System.out.println(":j: instance of NtpTime created..");
50 * User constructor of NtpTime with zero fraction part.
52 public NtpTime(int sec) {
55 //System.out.println(":j: instance of NtpTime created..");
59 * User constructor full defined.
61 public NtpTime(int sec, long fract) {
64 //System.out.println(":j: instance of NtpTime created..");
68 * @return String with actual state of NtpTime instance.
70 public String toString()
72 return("sec = " + seconds + " fraction = " + fraction);
77 * @return actual state of NtpTime instance
85 * Get NtpTime in its decimal form.
86 * @return actual NtpTime's value
88 public double getDecimal()
90 return this.seconds + (double)this.fraction / ((long)1 << 32);
93 /* ****************************************************************** *
97 * ****************************************************************** */
101 * NtpTimeToStringMs - converts NtpTime from number notation into its
102 * string notation in miliseconds
104 * @param time time given in JNtpTime object
105 * @return NtpTime in string notation in miliseconds
108 String NtpTimeToStringMs(NtpTime time);
111 * NtpTimeToStringUs - converts NtpTime from number notation into its
112 * string notation in microseconds
114 * @param time time given in JNtpTime object
115 * @return NtpTime in string notation in microseconds
118 String NtpTimeToStringUs(NtpTime time);