dsnserver
Class DSNtimetoTime

java.lang.Object
  extended by java.lang.Thread
      extended by dsnserver.DSNtimetoTime
All Implemented Interfaces:
CmdParser, java.lang.Runnable

public class DSNtimetoTime
extends java.lang.Thread
implements CmdParser

This class is for parsing the strings i ncluding the time and for the calculation from DSNtime to Real time.

Author:
kaltt

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  java.text.SimpleDateFormat df
           
(package private)  Communication myComm
           
(package private)  java.util.Date now
           
static long RealTime
           
(package private)  long timeNowDSN
           
(package private)  long timeNowReal
           
(package private)  long timeOldDSN
           
(package private)  long timeOldReal
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DSNtimetoTime(Communication comm)
           
 
Method Summary
 java.lang.String getRealTime(java.lang.String DSNtimeStr)
          Is used to calculate a real time out of a DSNtime.
 void parseLine(java.lang.String line)
          If appears a line which is starting with ":DT" this function is responsible for parsing it.
 void run()
          Requests all x milliseconds a new DSNtime from the DSNnode.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

now

java.util.Date now

df

java.text.SimpleDateFormat df

timeNowReal

long timeNowReal

timeOldReal

long timeOldReal

timeNowDSN

long timeNowDSN

timeOldDSN

long timeOldDSN

RealTime

public static long RealTime

myComm

Communication myComm
Constructor Detail

DSNtimetoTime

public DSNtimetoTime(Communication comm)
Method Detail

parseLine

public void parseLine(java.lang.String line)
If appears a line which is starting with ":DT" this function is responsible for parsing it. It stores the actual time of the arriving time of the line and the DSNtime which was send. This new stored times and the times which were stored last time will be used for the time calculation.

Specified by:
parseLine in interface CmdParser

getRealTime

public java.lang.String getRealTime(java.lang.String DSNtimeStr)
Is used to calculate a real time out of a DSNtime. It can just be done properly if there will be regularly new DSNtime request. After a reboot of the guinode the function gives back "0000-00-00 00:00:00" till the server has two new times for the calculation.

Parameters:
String - DSNtimeStr (the time to convert)
Returns:
String time (real time YYYY-MM-dd hh:mm:ss)

run

public void run()
Requests all x milliseconds a new DSNtime from the DSNnode.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread