SamLogic Internet Components - Home
ActiveX: AtomicClock      (Filename: SLATOMIC.OCX)


AtomicClock is an ActiveX component that allows you to retrieve the current time from time servers on the Internet. These time servers often use an atomic clock to obtain their time so the retrieved time is always very accurate.

You can use the AtomicClock control in any application where you need to have accurate time/date stamps, including financial transactions, medical data, long-term data collection, or anywhere else where a reliable time-stamp is needed. You can also use this control to synchronize a computers system clock with an atomic clock at Internet. The control can handle both NTP and NIST time servers. The time can be obtained both as local time and as Greenwich Mean Time (GMT).
 
 
Properties
 
Name Type Description
Correction Long Specifies how many milliseconds the obtained time should be corrected after arrival. It takes some time to for the data packet to arrive from the time server to your local computer and you can with this property set a value that should be added to the arrived time.
 
DateStr String Returns the date as a string (converted to local date) that the time server has returned.
 
DelayBetweenReads Long Specifies the allowed minimum time (in milliseconds) between two reads of a time server. If you read a time server several times, you should wait a time before you read again otherwise your time requests may be ignored for a time. The default value for this property is 3000 ms.
 
GMTDateStr String Returns the date as a string in Greenwich Mean Time (GMT) that the time server has returned.
 
GMTTimeStr String Returns the time as a string in Greenwich Mean Time (GMT) that the time server has returned.
 
RemotePort Long Specifies which port to read at a time server. For NIST servers it's normally port 13 and for NTP servers it's normally port 37.
 
ServerName String Specifies the domain name of the time server.
 
ServerType Short Specifies the type of server to read. 0 = NIST and 1 = NTP.
 
SyncSystemTime Boolean If this property has the value True the system clock of the local computer will be synchronized with the received atomic clock time. If this property has the False no such adjustment will occur.
 
TimeStr String Returns the time as a string (converted to local time) that the time server has returned.
 
     
 
 
Events
 
Name Description
TimeReceived This event occurs when date and time information has arrived to the local computer. The date and time can be obtained by reading the DateStr, TimeStr, GMTDateStr and GMTTimeStr properties.
 
 
 
Methods
 

CancelRead () As Boolean

Cancel the waiting for a time data packet. If the time do not arrive in a specified amount of time you can call this method to cancel the waiting.

GetLastError () As Long

Returns an error code for the last error that occurred in the control. A list of possible error codes is available here.

GetNumNISTServers () As Short

Returns the number of NIST servers in the ActiveX internal server list.

GetNumNTPServers () As Short

Returns the number of NTP servers in the ActiveX internal server list.

GetNumServers () As Short

Returns the number of time servers for the select time server type.

GetServerResponseTime () As Long

Returns the elapsed time in milliseconds between a time request and the arrival of the time. If the elapsed time is to high you should select another server for your time requests. The response time should never exceed 700 ms.

ReadTime () As Boolean

Requests a time from a time server. When the time arrives to the local computer the event TimeReceived is fired. The arrived time (and date) can be read from the DateStr, TimeStr, GMTDateStr and GMTTimeStr properties.

SelectServer (ServerIndex As Integer)

Selects a time server from the internal server list. The ServerName property will contain the name of the selected time server. The value for the ServerIndex parameter can be between 0 and the value obtained by calling the GetNumServers method and subtracting 1 from the return value (GetNumServers() - 1).
 

 
 
Example
 

Private Sub Command1_Click()
    AtomicClock1.ReadTime          
' Send a read time request
End Sub

Private Sub AtomicClock1_TimeReceived()
    Label1 = AtomicClock1.TimeStr  
' Write the arrived time to a label on the form
End Sub
 
 
 
< Go back
 
 
SamLogic