|
A WRLD.time chronometer.
It does everything I could imagine a chronometer object would want to do.
The ones you'd probably use most are the constuctor, setDate(Date) and getTime()
Alright. So you want to know what these variables really mean in the big scheme of things.
Well, since this is documentation, I'll tell you...
- adjust
-
any other miscellaneous adjustment, but this one is in seconds.
By default, this is 0.
If you know your computer's clock is 5 minutes off, set this to 300 and it'll work fine. or FIX YOUR CLOCK!
You're most likely to set this indirectly via a UTC server.
- divisor
-
how to divide the beats from the measures.
By default, WRLD.time has 100 beats per measure... turns out there's also 100 measures because of the factor.
A 24-hour clock would have a divisor of 60, since there are 60 beats (minutes) for every measure (hour).
- factor
-
the number of seconds in one 'tick'.
A 24-hour clock, whose 'tick' is one minute, would have a factor of 60, since there's that many seconds in a minute.
Keep in mind that this chronometer can only measure 2 chunks of time.
- fromGMT
-
how many minutes from GMT the chronometer is aligned to (ie. a timezone simulator, without DST).
By default, WRLD.time is aligned to GMT+12, which is the International Date Line.
It lies between Kamchatka and Alaska on your standard RISK(tm) board.
- patience
-
indicates how accurate you want to be during patient waiting.
By default, WRLD.time is willing to be patient to an accurace of 1/100 of a tick (.01).
Note that the chronometer can only internally maintain 4 unique digits, two for beat and two for measure.
If you end up with more precision than that, you'll have to mainipulate the raw beats & measures yourself.
This implementation is even capable of displaying that 24-hour clock i've used as example.
Pretty neato, huh?
jonathan recently sent me specs on two Indian standards of time which could be just as easily represented with this chronometer.
- public WRLDcron()
The constuctor... it creates a new, initialized chronometer and calculates WRLD.time for 'now'.
- public synchronized Object clone()
Creates a duplicate of myself, all my conversion values and my current time.
- public long getAdjust()
-
returns the current adjustment for the chronometer
The adjust is any other miscellaneous adjustment, but this one is in seconds (vs. minutes in fromGMT).
By default, this is 0.
If you know your computer's clock is 5 minutes off, set this to 300 and it'll work fine. or FIX YOUR CLOCK!
You're most likely to set this indirectly via a UTC server.
- public int getBeat()
-
returns the beat of the current converted time for the chronometer
By default, the beat of WRLD.time ranges from 0 to 99. the beat of a 24-hour clock would range from 0 to 59
- public Date getDate()
Gets the last date that the chronometer converted
- public int getDigit(int which)
-
which - the digit you want, 0 thru 3.
returns the specific digit of the current converted time for the chronometer.
There are only four digits... 0 and 1 are for the measure, 2 and 3 are for the beat... 0 and 2 are the 'higher' digits of their pair
By default, each of WRLD.time's digits ranges from 0 to 9.
If they didn't, I probably wouldn't have a digit array.
Note that the chronometer can only internally maintain 4 unique digits, two for beat and two for measure.
If you end up with more precision than that, you'll have to mainipulate the raw beats & measures yourself.
- public int getDivisor()
-
returns the current divisor for the chronometer
The divisor indicates how to divide the beats from the measures
By default, WRLD.time has 100 beats per measure... turns out there's also 100 measures because of the factor
A 24-hour clock would have a divisor of 60, since there are 60 beats (minutes) for every measure (hour)
- public double getFactor()
-
returns the current factor for the chronometer
The factor is the number of 'ticks' in one second.
A 24-hour clock would have a factor of 60, since there's that many seconds in a minute.
Keep in mind that this chronometer can only measure 2 chunks of time.
- public long getFromGMT()
-
returns the current GMT offset for the chronometer
FromGMT is how many minutes from GMT the chronometer is aligned to (ie. a timezone simulator, without DST)
By default, WRLD.time is aligned to GMT+12, which is the International Date Line
It lies between Kamchatka and Alaska on your standard RISK(tm) board.
- public int getMeasure()
-
returns the measure of the current converted time for the chronometer
By default, the measure of WRLD.time ranges from 0 to 99. the measure of a 24-hour clock would range from 0 to 23
- public double getPatience()
-
returns the current patience for the chronometer
The patience indicates how accurate you want to be during patient waiting (ie. waitForUpdatePatiently())
By default, WRLD.time is willing to be patient to an accurace of 1/100 of a tick (.01).
- public int getTime()
-
returns the current converted time for the chronometer
By default, WRLD.time ranges from 0 to 9999. a 24-hour clock would range from 0 to 1440
- public boolean isUpdated()
Indicates whether the chronometer has received its 'tick'.
You'd ask this if you were waiting for the update in a loop of your own.
- public synchronized void setAdjust(long adj)
-
adj - the new adjustment (see above)
Sets the current adjustment for the chronometer
- public synchronized void setAdjustByUTC(String utcHost, int utcPort) throws SocketException
-
utcHost - the UTC host
utcPort - the UTC port
Sets the current adjustment for the chronometer using a UTC code provided by a host:port combination
Over here i've put a list of known UTC sites.
The UTC protocol is usually served from port 13
- public synchronized void setAdjustByUTC(URL utcCgi) throws SocketException
-
utcCgi - a reference to the CGI script
Sets the current adjustment for the chronometer using a UTC code provided by a CGI script
A little perl script which opens a socket to a UTC host:port should do the trick.
- public synchronized void setAdjustByUTC(String line) throws NumberFormatException
-
line - a valid UTC code
Sets the current adjustment for the chronometer using a UTC code
The following is the format of a UTC code
JJJJJ YR-MO-DA HH:MM:SS TT L UT1 msADV UTC(NIST) OTM
Since this is a dateless chronometer, ony the HH:MM:SS is important here.
For much more detailed information on the UTC format, please see http://www.bldrdoc.gov/timefreq/.
- public synchronized void setDate()
Converts the current date via the chronometer
- public synchronized void setDate(Date nowDate)
-
nowDate - the date to convert into the chronometer's time
Converts the requested date via the chronometer
- public synchronized void setDivisor(int div)
-
div - the new divisor (see above)
Sets the current divisor for the chronometer
- public synchronized void setFactor(double fct)
-
fct - the new factor (see above)
Sets the current factor for the chronometer
- public synchronized void setFromGMT(long gmt)
-
gmt - the new offset (see above)
Sets the current GMT offset for the chronometer
- public synchronized void setPatience(double pat)
-
pat - the new patience (see above)
Sets the current patience for the chronometer
- public void startPatientUpdate()
Starts the 'tick' update process by creating a patient update thread.
Very similar to startUpdate() (see above), but it allows for more external processing.
- public void startUpdate()
Starts the dedicated 'tick' update process by creating an update thread.
This causes the run() routine to wait for the next tick.
- public void stopUpdate()
Stops the 'tick' update process in its tracks.
- public void waitForUpdate()
Wait with bated breath (ie. yeilding) until the next 'tick'.
This takes control of the active thread and dedicates it to giving as accurate a result as possible
- public void waitForUpdatePatiently()
Wait patiently (ie. sleeping) until the next 'tick'.
This takes control of the active thread but gives others plenty of time to work in exchange for a loss of accuracy
- public void waitPatiently() throws InterruptedException
Wait as patiently as the chronometer should.
You'd ask this if you were patiently waiting for the update in a loop of your own.
|
|