*/
public TimeOffset getOffset() throws RemoteOSGiException {
if (timeOffset == null) {
// if unknown, perform a initial offset measurement round of 4
// messages
TimeOffsetMessage timeMsg = new TimeOffsetMessage();
for (int i = 0; i < 4; i++) {
timeMsg.timestamp();
timeMsg = (TimeOffsetMessage) sendAndWait(timeMsg);
}
timeOffset = new TimeOffset(timeMsg.getTimeSeries());
} else if (timeOffset.isExpired()) {
// if offset has expired, start a new measurement round
TimeOffsetMessage timeMsg = new TimeOffsetMessage();
for (int i = 0; i < timeOffset.seriesLength(); i += 2) {
timeMsg.timestamp();
timeMsg = (TimeOffsetMessage) sendAndWait(timeMsg);
}
timeOffset.update(timeMsg.getTimeSeries());
}
return timeOffset;
}