System information

Appendix D. JAVA Example Code
D-16
/** <!-- elapsed() -->
* Returns milliseconds elapsed since start or reset.
*
* @return elapsed milliseconds since start or reset
* @see #Counter()
* @see #reset()
*/
public int elapsed() { return diff( counter(), start ); }
/** <!-- setStart(int) -->
* Set the specified value as the start time.
*
* @param msec value to set as new start time
*/
public void setStart( int msec ) { this.start = msec; }
/** <!-- counter() -->
* Returns the value of the one day free running counter in
* milliseconds. The counter is synchronized with the
* system clock so it can be used to get milliseconds into
* the current day.
*
* @return milliseconds into the current day
*/
public static int counter() {
return (int)((new Date()).getTime() % msecPerDay);
}
/** <!-- diff() -->
* Returns the difference between two times allowing for
* one time laps. If the end mark has passed into a new
* day (value of <code>mark</code> is less than <code>start</code>)
* then the result is adjusted by adding one day. A one day counter
* using milliseconds is assumed.
*
* @param mark end time of the interval
* @param start start time of the interval
* @return <code>mark</code> - <code>start</code>; adjusted
* if <code>mark</code> is in second day
*/
private static int diff( int mark, int start ) {
if( mark >= start ) return mark - start;
return mark - start + msecPerDay;
}
} //Counter class
/** class Packet
*
* Encapsulates a PakBus Packet
*/
protected static class Packet {
private byte[] storage;
private int storage_len;
private int read_index;