Update to version 2
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* 01.01.2013 Adapted code to CAPS client library requirements (gempa GmbH)
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef CAPS_MSEED_SPCLOCK_H
|
||||
#define CAPS_MSEED_SPCLOCK_H
|
||||
|
||||
@@ -28,51 +29,43 @@ namespace Gempa {
|
||||
namespace CAPS {
|
||||
|
||||
|
||||
class SPClock
|
||||
{
|
||||
public:
|
||||
typedef Gempa::CAPS::Time INT_TIME;
|
||||
class SPClock {
|
||||
public:
|
||||
SPClock(int freqn, int freqd)
|
||||
: freqn(freqn), freqd(freqd) {}
|
||||
|
||||
private:
|
||||
INT_TIME itime;
|
||||
int ticks;
|
||||
int corr;
|
||||
void syncTime(const Time &time) {
|
||||
_itime = time;
|
||||
_ticks = 0;
|
||||
_corr = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
const int freqn;
|
||||
const int freqd;
|
||||
void tick() {
|
||||
++_ticks;
|
||||
}
|
||||
|
||||
SPClock(int freqn_init, int freqd_init): ticks(0), corr(0),
|
||||
freqn(freqn_init), freqd(freqd_init)
|
||||
{}
|
||||
Time getTime(int tickDiff) const {
|
||||
int64_t correctness = (double)freqd / (double)freqn * 1000000 * (_ticks - tickDiff - _corr);
|
||||
return _itime + TimeSpan(long(correctness / 1000000), long(correctness % 1000000));
|
||||
}
|
||||
|
||||
void sync_time(const INT_TIME &time)
|
||||
{
|
||||
itime = time;
|
||||
ticks = 0;
|
||||
corr = 0;
|
||||
}
|
||||
int correction() const {
|
||||
return _corr;
|
||||
}
|
||||
|
||||
void tick()
|
||||
{
|
||||
++ticks;
|
||||
}
|
||||
public:
|
||||
const int freqn;
|
||||
const int freqd;
|
||||
|
||||
INT_TIME get_time(int tick_diff) const
|
||||
{
|
||||
int64_t correctness = (double)freqd / (double)freqn * 1000000 * (ticks - tick_diff - corr);
|
||||
return itime + Gempa::CAPS::TimeSpan(long(correctness/1000000),long(correctness%1000000));
|
||||
}
|
||||
|
||||
int correction() const
|
||||
{
|
||||
return corr;
|
||||
}
|
||||
};
|
||||
private:
|
||||
Time _itime;
|
||||
int _ticks{0};
|
||||
int _corr{0};
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // SPCLOCK_H
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user