ca

package module
v0.0.0-...-09d361c Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StringSize = 40
	IntSize    = 2
	EnumSize   = 2
	FloatSize  = 4
	CharSize   = 1
	LongSize   = 4
	DoubleSize = 8
)

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(l *slog.Logger)

Types

type AccessRights

type AccessRights uint32
const (
	AccessNone  AccessRights = 0
	AccessRead  AccessRights = 1 << 0
	AccessWrite AccessRights = 1 << 1
)

type ArrayValue

type ArrayValue[T Numeric] struct {
	// contains filtered or unexported fields
}

func (*ArrayValue[T]) AsBytes

func (a *ArrayValue[T]) AsBytes() []byte

func (*ArrayValue[T]) AsFloat

func (a *ArrayValue[T]) AsFloat() float64

func (*ArrayValue[T]) AsInt

func (a *ArrayValue[T]) AsInt() int64

func (*ArrayValue[T]) AsString

func (a *ArrayValue[T]) AsString() string

func (*ArrayValue[T]) Count

func (a *ArrayValue[T]) Count() int

func (*ArrayValue[T]) HasControl

func (a *ArrayValue[T]) HasControl() bool

func (*ArrayValue[T]) HasGraphics

func (a *ArrayValue[T]) HasGraphics() bool

func (*ArrayValue[T]) HasStatus

func (a *ArrayValue[T]) HasStatus() bool

func (*ArrayValue[T]) HasTime

func (a *ArrayValue[T]) HasTime() bool

func (*ArrayValue[T]) Index

func (a *ArrayValue[T]) Index(i int) Value

func (*ArrayValue[T]) IsArray

func (a *ArrayValue[T]) IsArray() bool

func (*ArrayValue[T]) Metadata

func (a *ArrayValue[T]) Metadata() ValueMetadata

func (*ArrayValue[T]) Slice

func (a *ArrayValue[T]) Slice() interface{}

func (*ArrayValue[T]) Type

func (a *ArrayValue[T]) Type() DataType

type BeaconEvent

type BeaconEvent struct {
	Addr       string
	ServerPort int
	Timestamp  time.Time
}

type ChannelInfo

type ChannelInfo struct {
	Name         string
	State        ConnectionState
	Host         string
	Access       AccessRights
	NativeType   DataType
	ElementCount uint32
}

type Client

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

func NewClient

func NewClient(opts Options) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) CloseChannel

func (c *Client) CloseChannel(ctx context.Context, name string) error

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, names ...string) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, name string, opts ...Option) (Value, error)

func (*Client) Info

func (c *Client) Info(ctx context.Context, name string) (*ChannelInfo, error)

func (*Client) Put

func (c *Client) Put(ctx context.Context, name string, v Value) error

func (*Client) PutNotify

func (c *Client) PutNotify(ctx context.Context, name string, v Value) error

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, name string, opts ...Option) (<-chan Event, Subscription, error)

type ClientMetrics

type ClientMetrics struct {
	SearchResults  atomic.Uint64
	AttachQueued   atomic.Uint64
	AttachInFlight atomic.Uint64
	AttachFailures atomic.Uint64
	Connections    atomic.Uint64
}

ClientMetrics holds optional counters tracking high-level client activity. Attach this to Options.Metrics before creating a client to enable updates.

type Conn

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

func (*Conn) Addr

func (c *Conn) Addr() string

func (*Conn) Attach

func (c *Conn) Attach(ctx context.Context, pv string) (uint32, error)

func (*Conn) ChannelInfo

func (c *Conn) ChannelInfo(cid uint32) (DataType, uint32, AccessRights, bool)

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Detach

func (c *Conn) Detach(ctx context.Context, pv string) error

func (*Conn) Events

func (c *Conn) Events() <-chan ConnEvent

func (*Conn) Get

func (c *Conn) Get(ctx context.Context, pv string, cid uint32, dt DataType) (Value, error)

func (*Conn) Options

func (c *Conn) Options() Options

func (*Conn) Put

func (c *Conn) Put(ctx context.Context, pv string, cid uint32, v Value) error

func (*Conn) PutNotify

func (c *Conn) PutNotify(ctx context.Context, pv string, cid uint32, v Value) error

func (*Conn) Subscribe

func (c *Conn) Subscribe(ctx context.Context, cid uint32, dt DataType, cb func(Value)) (uint32, error)

func (*Conn) Unsubscribe

func (c *Conn) Unsubscribe(ctx context.Context, cid, subID uint32, dt DataType) error

type ConnEvent

type ConnEvent struct {
	Type ConnEventType
	Addr string
	PVs  []string
	Err  error
}

type ConnEventType

type ConnEventType int
const (
	ConnReady ConnEventType = iota
	ConnLost
)

type ConnectionState

type ConnectionState int
const (
	ConnConnected ConnectionState = iota
	ConnDisconnected
	ConnReconnecting
)

type DataType

type DataType uint16
const (
	TypeString DataType = iota
	TypeInt
	TypeFloat
	TypeEnum
	TypeChar
	TypeLong
	TypeDouble
	TypeStsString
	TypeStsInt
	TypeStsFloat
	TypeStsEnum
	TypeStsChar
	TypeStsLong
	TypeStsDouble
	TypeTimeString
	TypeTimeInt
	TypeTimeFloat
	TypeTimeEnum
	TypeTimeChar
	TypeTimeLong
	TypeTimeDouble
	TypeGrString
	TypeGrInt
	TypeGrFloat
	TypeGrEnum
	TypeGrChar
	TypeGrLong
	TypeGrDouble
	TypeCtrlString
	TypeCtrlInt
	TypeCtrlFloat
	TypeCtrlEnum
	TypeCtrlChar
	TypeCtrlLong
	TypeCtrlDouble

	TypeAuto DataType = 0xFFFF
)

func (DataType) Base

func (d DataType) Base() DataType

func (DataType) ElementSize

func (d DataType) ElementSize() int

func (DataType) String

func (d DataType) String() string

type EnumValue

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

func (*EnumValue) AsBytes

func (v *EnumValue) AsBytes() []byte

func (*EnumValue) AsFloat

func (v *EnumValue) AsFloat() float64

func (*EnumValue) AsInt

func (v *EnumValue) AsInt() int64

func (*EnumValue) AsString

func (v *EnumValue) AsString() string

func (*EnumValue) Count

func (v *EnumValue) Count() int

func (*EnumValue) HasControl

func (v *EnumValue) HasControl() bool

func (*EnumValue) HasGraphics

func (v *EnumValue) HasGraphics() bool

func (*EnumValue) HasStatus

func (v *EnumValue) HasStatus() bool

func (*EnumValue) HasTime

func (v *EnumValue) HasTime() bool

func (*EnumValue) Index

func (v *EnumValue) Index(i int) Value

func (*EnumValue) IsArray

func (v *EnumValue) IsArray() bool

func (*EnumValue) Metadata

func (v *EnumValue) Metadata() ValueMetadata

func (*EnumValue) Slice

func (v *EnumValue) Slice() interface{}

func (*EnumValue) Type

func (v *EnumValue) Type() DataType

func (*EnumValue) Values

func (v *EnumValue) Values() []int64

type Event

type Event struct {
	PV              string
	Value           Value
	ConnectionState ConnectionState
	Timestamp       time.Time
	Error           error
}

Event ties a value to connection state changes.

type FloatValue

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

func (*FloatValue) AsBytes

func (v *FloatValue) AsBytes() []byte

func (*FloatValue) AsFloat

func (v *FloatValue) AsFloat() float64

func (*FloatValue) AsInt

func (v *FloatValue) AsInt() int64

func (*FloatValue) AsString

func (v *FloatValue) AsString() string

func (*FloatValue) Count

func (v *FloatValue) Count() int

func (*FloatValue) HasControl

func (v *FloatValue) HasControl() bool

func (*FloatValue) HasGraphics

func (v *FloatValue) HasGraphics() bool

func (*FloatValue) HasStatus

func (v *FloatValue) HasStatus() bool

func (*FloatValue) HasTime

func (v *FloatValue) HasTime() bool

func (*FloatValue) Index

func (v *FloatValue) Index(i int) Value

func (*FloatValue) IsArray

func (v *FloatValue) IsArray() bool

func (*FloatValue) Metadata

func (v *FloatValue) Metadata() ValueMetadata

func (*FloatValue) Slice

func (v *FloatValue) Slice() interface{}

func (*FloatValue) Type

func (v *FloatValue) Type() DataType

func (*FloatValue) Values

func (v *FloatValue) Values() []float64

type Future

type Future[T any] struct {
	// contains filtered or unexported fields
}

func (*Future[T]) Get

func (f *Future[T]) Get(ctx context.Context) (T, error)

type FutureStore

type FutureStore[K comparable, T any] struct {
	// contains filtered or unexported fields
}

type IntValue

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

func (*IntValue) AsBytes

func (v *IntValue) AsBytes() []byte

func (*IntValue) AsFloat

func (v *IntValue) AsFloat() float64

func (*IntValue) AsInt

func (v *IntValue) AsInt() int64

func (*IntValue) AsString

func (v *IntValue) AsString() string

func (*IntValue) Count

func (v *IntValue) Count() int

func (*IntValue) HasControl

func (v *IntValue) HasControl() bool

func (*IntValue) HasGraphics

func (v *IntValue) HasGraphics() bool

func (*IntValue) HasStatus

func (v *IntValue) HasStatus() bool

func (*IntValue) HasTime

func (v *IntValue) HasTime() bool

func (*IntValue) Index

func (v *IntValue) Index(i int) Value

func (*IntValue) IsArray

func (v *IntValue) IsArray() bool

func (*IntValue) Metadata

func (v *IntValue) Metadata() ValueMetadata

func (*IntValue) Slice

func (v *IntValue) Slice() interface{}

func (*IntValue) String

func (v *IntValue) String() string

func (*IntValue) Type

func (v *IntValue) Type() DataType

func (*IntValue) Values

func (v *IntValue) Values() []int64

type MetadataLevel

type MetadataLevel int
const (
	MetadataNone MetadataLevel = iota
	MetadataStatus
	MetadataTime
	MetadataGraphics
	MetadataControl
)

type Numeric

type Numeric interface {
	~int8 | ~int16 | ~int32 | ~int64 | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64
}

type Option

type Option interface {
	// contains filtered or unexported methods
}
var (
	WithStatus Option = optionFunc(func(cfg *requestConfig) {
		cfg.metadata = MetadataStatus
	})
	WithTime Option = optionFunc(func(cfg *requestConfig) {
		cfg.metadata = MetadataTime
	})
	WithGraphics Option = optionFunc(func(cfg *requestConfig) {
		cfg.metadata = MetadataGraphics
	})
	WithControl Option = optionFunc(func(cfg *requestConfig) {
		cfg.metadata = MetadataControl
	})
)
var (
	AsDouble Option = As(TypeDouble)
	AsFloat  Option = As(TypeFloat)
	AsLong   Option = As(TypeLong)
	AsInt    Option = As(TypeInt)
	AsString Option = As(TypeString)
)

func As

func As(dt DataType) Option

func Type

func Type(dt DataType) Option

func WithBufferSize

func WithBufferSize(size int) Option

func WithDataType

func WithDataType(dt DataType) Option

func WithEventHandler

func WithEventHandler(handler func(Event)) Option

type Options

type Options struct {
	SearchAddresses  []string
	ServerPort       int
	RepeaterPort     int
	ContextTimeout   time.Duration
	BeaconPeriod     time.Duration
	MaxArrayBytes    int
	ClientName       string
	HostName         string
	SearchMTU        int
	EventBufferSize  int
	EventQueueSize   int
	EventWorkers     int
	ResultQueueSize  int
	ResultWorkers    int
	AttachQueueSize  int
	MaxAttachPerConn int
	Metrics          *ClientMetrics
}

type RawValue

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

func NewRawValue

func NewRawValue(dataType DataType, count uint32, data []byte) *RawValue

func (*RawValue) Count

func (v *RawValue) Count() int

func (*RawValue) Data

func (v *RawValue) Data() []byte

func (*RawValue) Encode

func (v *RawValue) Encode() ([]byte, error)

func (*RawValue) IsArray

func (v *RawValue) IsArray() bool

func (*RawValue) PayloadSize

func (v *RawValue) PayloadSize() uint32

func (*RawValue) Type

func (v *RawValue) Type() DataType

type Repeater

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

func NewRepeater

func NewRepeater(conn *net.UDPConn) *Repeater

func (*Repeater) Run

func (r *Repeater) Run()

func (*Repeater) Stop

func (r *Repeater) Stop()

type SearchResult

type SearchResult struct {
	PV   string
	Addr string
}

type Searcher

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

func NewSearcher

func NewSearcher(searchConn, repeaterConn udpConn, addresses []string, mtu int, repeaterPort int) *Searcher

func (*Searcher) Beacons

func (s *Searcher) Beacons() <-chan BeaconEvent

func (*Searcher) Cancel

func (s *Searcher) Cancel(pv string)

func (*Searcher) Force

func (s *Searcher) Force(pv string)

func (*Searcher) Request

func (s *Searcher) Request(pv string)

func (*Searcher) Results

func (s *Searcher) Results() <-chan SearchResult

func (*Searcher) Stop

func (s *Searcher) Stop()

type StringValue

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

func (*StringValue) AsBytes

func (v *StringValue) AsBytes() []byte

func (*StringValue) AsFloat

func (v *StringValue) AsFloat() float64

func (*StringValue) AsInt

func (v *StringValue) AsInt() int64

func (*StringValue) AsString

func (v *StringValue) AsString() string

func (*StringValue) Count

func (v *StringValue) Count() int

func (*StringValue) HasControl

func (v *StringValue) HasControl() bool

func (*StringValue) HasGraphics

func (v *StringValue) HasGraphics() bool

func (*StringValue) HasStatus

func (v *StringValue) HasStatus() bool

func (*StringValue) HasTime

func (v *StringValue) HasTime() bool

func (*StringValue) Index

func (v *StringValue) Index(i int) Value

func (*StringValue) IsArray

func (v *StringValue) IsArray() bool

func (*StringValue) Metadata

func (v *StringValue) Metadata() ValueMetadata

func (*StringValue) Slice

func (v *StringValue) Slice() interface{}

func (*StringValue) Type

func (v *StringValue) Type() DataType

func (*StringValue) Values

func (v *StringValue) Values() []string

type Subscription

type Subscription interface {
	Cancel() error
}

Subscription represents an active monitor subscription.

type Value

type Value interface {
	Type() DataType
	Count() int
	AsInt() int64
	AsFloat() float64
	AsString() string
	AsBytes() []byte

	IsArray() bool
	HasStatus() bool
	HasTime() bool
	HasGraphics() bool
	HasControl() bool
	Metadata() ValueMetadata

	Index(i int) Value
	Slice() interface{}
}

func NewArray

func NewArray[T Numeric](dataType DataType, vals []T) Value

func NewFloatArray

func NewFloatArray(vals []float64) Value

func NewFloatValue

func NewFloatValue(val float64) Value

func NewIntArray

func NewIntArray(vals []int64) Value

func NewIntValue

func NewIntValue(val int64) Value

func NewStringArray

func NewStringArray(vals []string) Value

func NewStringValue

func NewStringValue(val string) Value

func NewValueWithMetadata

func NewValueWithMetadata[T comparable](val T, metadata ValueMetadata) Value

func ParseValue

func ParseValue(dataType DataType, dataCount uint32, data []byte) (Value, error)

type ValueMetadata

type ValueMetadata struct {
	Status    uint16
	Severity  uint16
	Timestamp time.Time

	Units       string
	DisplayLow  float64
	DisplayHigh float64
	AlarmLow    float64
	AlarmHigh   float64
	WarningLow  float64
	WarningHigh float64
	ControlLow  float64
	ControlHigh float64
	Precision   int16
	// contains filtered or unexported fields
}

func ExtractControl

func ExtractControl(v *RawValue) (ValueMetadata, []byte, error)

func ExtractGraphics

func ExtractGraphics(v *RawValue) (ValueMetadata, []byte, error)

func ExtractStatus

func ExtractStatus(v *RawValue) (ValueMetadata, []byte, error)

func ExtractTime

func ExtractTime(v *RawValue) (ValueMetadata, []byte, error)

Directories

Path Synopsis
cmd
monitor command
recorder command
simple-monitor command

Jump to

Keyboard shortcuts

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