networktables

package
v0.0.0-...-f8bd198 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Store    Store
	Logger   *logrus.Logger
	Addr     string
	Identity string
	// contains filtered or unexported fields
}

Client is a networktables 3 client. It's zero value is usable for communicating with a local networktables server at port 1735 with an in-memory store and logging disabled.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying connection if one exists.

func (*Client) Create

func (c *Client) Create(entry Entry) error

Create tells the server to issue an entry assignment to all clients (including us) for the given entry. It does not immediately create an entry in the underlying store, and for this reason it's not guaranteed that the value will exist after this function returns, so successive Puts may fail. It is only guaranteed that the create request has been written to the server. This is unfortunately due to how the networktables protocol works, because there is no way for us to know which entry assignment from the server corresponds to our entry assignment.

func (*Client) Delete

func (c *Client) Delete(name string) error

Delete deletes an entry from the underlying store and issues a delete request to the server.

func (*Client) Get

func (c *Client) Get(name string) (Entry, error)

Get returns an entry from the underlying store for the given name.

func (*Client) Ping

func (c *Client) Ping() error

Ping sends a keep alive to the server. If you need to keep the connection alive you should call this function no more than once every 100ms.

func (*Client) UpdateOptions

func (c *Client) UpdateOptions(name string, opt EntryOptions) error

UpdateOptions updates the entry options for an existing entry with the given name, and issues an entry options update to the server.

func (*Client) UpdateValue

func (c *Client) UpdateValue(name string, value EntryValue) error

UpdateValue updates the entry value for an existing entry with the given name, and issues an entry value update to the server.

type Entry

type Entry struct {
	ID             int
	SequenceNumber int
	Name           string
	Options        EntryOptions
	Value          EntryValue
}

Entry is an all-encompassing networktables entry.

type EntryOptions

type EntryOptions struct {
	Persist bool
}

EntryOptions is the options (or flags) that an entry can be annotated with.

type EntryType

type EntryType int

EntryType defines a networktables entry type.

const (
	// Boolean represents a boolean (true or false) entry type.
	Boolean EntryType = iota
	// Double represents a double (float64) entry type.
	Double
	// RawData represents a raw data (byte slice) entry type.
	RawData
	// String represents a string entry type.
	String
	// BooleanArray represents a boolean array (boolean slice) entry type.
	BooleanArray
	// DoubleArray represents a double array (float64 slice) entry type.
	DoubleArray
	// StringArray represents a string array entry type.
	StringArray
)

type EntryValue

type EntryValue struct {
	EntryType EntryType

	Boolean      bool
	Double       float64
	RawData      []byte
	String       string
	BooleanArray []bool
	DoubleArray  []float64
	StringArray  []string
}

EntryValue represents a single networktables entry value. It only ever makes sense for the entry types corresponding type to be set.

type Store

type Store interface {
	GetValue(id int) (e EntryValue, err error)
	GetIDSeq(name string) (id int, seq int, err error)
	GetNames() (names []string, err error)
	GetByName(name string) (e Entry, err error)
	Create(e Entry) error
	UpdateValue(id int, seq int, ev EntryValue) error
	UpdateOptions(id int, opt EntryOptions) error
	Delete(id int) error
	DeleteByName(name string) (id int, err error)
	Clear() error
}

Store defines a minimal interface for a generic networktables store.

func OpenBadgerDB

func OpenBadgerDB(options badger.Options) (Store, error)

OpenBadgerDB opens a badger DB with the given options as a networktables store.

Jump to

Keyboard shortcuts

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