MCPcopy Create free account
hub / github.com/facebook/time / NewPiServo

Function NewPiServo

phc/pps_source.go:190–217  ·  view source on GitHub ↗

NewPiServo returns a servo.PiServo object configure for synchronizing the given device. maxFreq 0 is equivalent to no maxFreq

(interval time.Duration, firstStepth time.Duration, stepth time.Duration, device FrequencyGetter, maxFreq float64)

Source from the content-addressed store, hash-verified

188
189// NewPiServo returns a servo.PiServo object configure for synchronizing the given device. maxFreq 0 is equivalent to no maxFreq
190func NewPiServo(interval time.Duration, firstStepth time.Duration, stepth time.Duration, device FrequencyGetter, maxFreq float64) (*servo.PiServo, error) {
191 servoCfg := servo.DefaultServoConfig()
192 if firstStepth != 0 {
193 // allow stepping clock on first update
194 servoCfg.FirstUpdate = true
195 servoCfg.FirstStepThreshold = int64(firstStepth)
196 }
197 servoCfg.StepThreshold = int64(stepth)
198 freq, err := device.FreqPPB()
199 if err != nil {
200 return nil, err
201 }
202
203 pi := servo.NewPiServo(servoCfg, servo.DefaultPiServoCfg(), -freq)
204 pi.SyncInterval(interval.Seconds())
205
206 if maxFreq == 0 {
207 maxFreq, err = device.MaxFreqAdjPPB()
208 if err != nil {
209 log.Printf("unable to get max frequency adjustment from device, using default: %f", defaultMaxFreqAdj)
210 maxFreq = defaultMaxFreqAdj
211 }
212 }
213
214 pi.SetMaxFreq(maxFreq)
215
216 return pi, nil
217}
218
219func validatePPSEvent(eventTimestamp time.Time, dstDevice DeviceController) error {
220 dstTs, err := dstDevice.Time()

Callers 7

ts2phcRunFunction · 0.92
TestNewPiServoFunction · 0.70
TestNewPiServoUseMaxFreqFunction · 0.70
TestNewPiServoStepthFunction · 0.70

Calls 9

SyncIntervalMethod · 0.95
SetMaxFreqMethod · 0.95
DefaultServoConfigFunction · 0.92
NewPiServoFunction · 0.92
DefaultPiServoCfgFunction · 0.92
SecondsMethod · 0.80
FreqPPBMethod · 0.65
MaxFreqAdjPPBMethod · 0.65
PrintfMethod · 0.65

Tested by 6

TestNewPiServoFunction · 0.56
TestNewPiServoUseMaxFreqFunction · 0.56
TestNewPiServoStepthFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…