mon

package
v0.0.0-...-eb3c2ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ClockLogExtension = ".log"

Variables

This section is empty.

Functions

func PTP4LWorker

func PTP4LWorker(client *pmc.Client, reqCh <-chan GrandmasterUpdateRequest, lg *slog.Logger)

PTP4LWorker processes GrandmasterUpdateRequests and sends them to ptp4l. It should be run in a goroutine. It returns when reqCh is closed. The updating goroutine must wait for a response to each request before sending another request.

func RefClockWorker

func RefClockWorker(rc RefClock, sampCh <-chan RefClockSample, lg *slog.Logger)

Types

type Grandmaster

type Grandmaster struct {
	// contains filtered or unexported fields
}

func NewGrandmaster

func NewGrandmaster() (*Grandmaster, <-chan GrandmasterUpdateRequest)

func (*Grandmaster) Close

func (gm *Grandmaster) Close()

func (*Grandmaster) SetClockAccuracy

func (gm *Grandmaster) SetClockAccuracy(acc time.Duration) error

func (*Grandmaster) SetClockSync

func (gm *Grandmaster) SetClockSync(syncState SyncState)

func (*Grandmaster) Update

func (gm *Grandmaster) Update(state SyncState, leap ptime.LeapSecondState)

type GrandmasterProps

type GrandmasterProps struct {
	ptime.LeapSecondState
	ClockClass    uint8
	ClockAccuracy pmc.ClockAccuracy
}

func (*GrandmasterProps) SetClock

func (props *GrandmasterProps) SetClock(acc pmc.ClockAccuracy)

func (*GrandmasterProps) Settings

func (props *GrandmasterProps) Settings() pmc.GrandmasterSettings

type GrandmasterUpdateRequest

type GrandmasterUpdateRequest struct {
	// contains filtered or unexported fields
}

type LoggingSockRefClock

type LoggingSockRefClock struct {
	// contains filtered or unexported fields
}

LoggingSockRefClock does error handling for a refclock that sends to a socket that may not exist. The error handling consists of logging changes in when the socket exists.

func NewLoggingSockRefClock

func NewLoggingSockRefClock(lg *slog.Logger, sock SockRefClock) *LoggingSockRefClock

func (*LoggingSockRefClock) Close

func (rc *LoggingSockRefClock) Close() error

func (*LoggingSockRefClock) Sample

func (rc *LoggingSockRefClock) Sample(sys time.Time, ref ptime.Time, ls ptime.LeapSecond) error

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

func NewMonitor

func NewMonitor(servo Servo, lg *slog.Logger, cfg MonitorConfig) (*Monitor, error)

func (*Monitor) Close

func (mon *Monitor) Close()

func (*Monitor) Pause

func (mon *Monitor) Pause()

func (*Monitor) ReopenLog

func (mon *Monitor) ReopenLog()

func (*Monitor) Sample

func (mon *Monitor) Sample(ref ptime.Time, local ptime.ClockTime, delayed bool)

func (*Monitor) SetLeapSecond

func (mon *Monitor) SetLeapSecond(leapSecond ptime.LeapSecond)

func (*Monitor) SysSample

func (mon *Monitor) SysSample(ref ptime.Time, sys time.Time)

func (*Monitor) Tick

func (mon *Monitor) Tick(now time.Time)

This is called 4 times per second.

type MonitorConfig

type MonitorConfig struct {
	LeapSecond    ptime.LeapSecond
	LogInterval   int
	ClockLogPath  string
	ClockAccuracy time.Duration
	RefClock      *ProxyRefClock
	Grandmaster   *Grandmaster
	Sampler       Sampler // never nil, uses DefaultObserver when no observability needed
}

type MultiSampler

type MultiSampler struct {
	// contains filtered or unexported fields
}

MultiSampler fans out Sample calls to multiple samplers

func NewMultiSampler

func NewMultiSampler(samplers ...Sampler) *MultiSampler

NewMultiSampler creates a new MultiSampler that fans out to multiple samplers

func (*MultiSampler) Sample

func (m *MultiSampler) Sample(data SampleData)

Sample implements Sampler by calling Sample on all samplers

func (*MultiSampler) Samplers

func (m *MultiSampler) Samplers() iter.Seq[Sampler]

Samplers returns an iterator over the samplers

type ProxyRefClock

type ProxyRefClock struct {
	// contains filtered or unexported fields
}

func NewProxyRefClock

func NewProxyRefClock() (*ProxyRefClock, <-chan RefClockSample)

func (*ProxyRefClock) Close

func (rc *ProxyRefClock) Close()

func (*ProxyRefClock) Sample

func (rc *ProxyRefClock) Sample(sys time.Time, ref ptime.Time, ls ptime.LeapSecond) error

type RefClock

type RefClock interface {
	io.Closer
	Sample(sys time.Time, ref ptime.Time, ls ptime.LeapSecond) error
}

type RefClockSample

type RefClockSample struct {
	Sys time.Time
	Ref ptime.Time
	Ls  ptime.LeapSecond
}

type SampleData

type SampleData struct {
	Kind      SampleKind    // Determines validity of other fields
	Ref       ptime.Time    // GPS reference time (different from system time)
	Offset    time.Duration // PHC/GPS offset (valid for SampleOK and SampleOutlier, 0 for SampleMissing)
	Freq      float64       // Current frequency adjustment in PPB (always valid)
	FreqDelta float64       // Change in frequency adjustment in PPB (valid for SampleOK, 0 for SampleOutlier)
	SyncState SyncState     // Current synchronization state (always valid)
	Era       ptime.Era     // For clock step tracking and logging (always valid)
}

SampleData contains all information about a synchronization sample

type SampleKind

type SampleKind int

SampleKind determines the validity and type of a synchronization sample

const (
	SampleMissing SampleKind = iota // Missing sample (PPS signal not received)
	SampleOK                        // Valid sample within acceptable limits
	SampleOutlier                   // Sample that is an outlier but still measured
)

type Sampler

type Sampler interface {
	// Sample reports a clock synchronization sample of any kind
	Sample(data SampleData)
}

Sampler handles clock synchronization samples of all types

type Servo

type Servo interface {
	Sample(ref ptime.Time, local ptime.ClockTime, delayed bool)
	FreqOffset() float64
	Locked(era ptime.Era) bool // this says whether it is currently using the PI controller
	Reset()
}

type SockRefClock

type SockRefClock interface {
	RefClock
	RemotePath() string
}

type SyncState

type SyncState int

SyncState represents the current synchronization status

const (
	NoSync SyncState = iota // Clock is not synchronized
	InSync                  // Clock is synchronized
)

func (SyncState) String

func (s SyncState) String() string

String returns a human-readable representation of the sync state

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL