ui

package
v0.0.0-...-ab51448 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Theme = huh.ThemeCharm()

Functions

func PromptConfig

func PromptConfig(cfg *ModbusConfiguration) error

PromptConfig prompts to the user to configurate the modbus connection.

Types

type DataType

type DataType byte

DataType represents a data type.

const (
	DataTypeUint16 DataType = iota
	DataTypeUint32
	DataTypeUint64
	DataTypeFloat32
	DataTypeFloat64
	DataTypeBool
	DataTypeCoil
)

type Datapoint

type Datapoint struct {
	SlaveId     uint8    `json:"slaveId"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Addr        uint16   `json:"addr"`
	DataType    DataType `json:"data-type"`
	Flag        Flag     `json:"flag"`
	Unit        string   `json:"unit"`

	// Scaling specifies a scaling of the datapoint value.
	// For example if value can be negative, we have to scale
	// the unsigned value to be negative.
	Scaling *Scaling `json:"scaling"`

	// Value is the last read value.
	Value any `json:"-"`

	// Err is not-nil if the last read failed.
	Err error `json:"-"`
}

Datapoint represents a value from a modbus server. It specifies the datatype, flags and unit.

func PromptTable

func PromptTable(client *modbus.ModbusClient, datapoints []*Datapoint) ([]*Datapoint, error)

func (Datapoint) RegType

func (dp Datapoint) RegType() modbus.RegType

func (Datapoint) TableRow

func (dp Datapoint) TableRow() table.Row

type Flag

type Flag byte

Flag represents a flag.

const (
	FlagRead Flag = iota
	FlagReadWrite
)

type KeyMap

type KeyMap struct {
	Table           table.KeyMap
	Add             key.Binding
	Remove          key.Binding
	Edit            key.Binding
	Refresh         key.Binding
	RefreshEverySec key.Binding
	StopRefresh     key.Binding
	Write           key.Binding

	Duplicate    key.Binding
	MoveLineUp   key.Binding
	MoveLineDown key.Binding

	AutoReload bool
}

func DefaultKeyMap

func DefaultKeyMap(km table.KeyMap) KeyMap

func (KeyMap) FullHelp

func (km KeyMap) FullHelp() [][]key.Binding

FullHelp implements the KeyMap interface.

func (KeyMap) ShortHelp

func (km KeyMap) ShortHelp() []key.Binding

ShortHelp implements the KeyMap interface.

type ModbusConfiguration

type ModbusConfiguration struct {
	Transport string `json:"transport,omitempty"`
	Addr      string `json:"address,omitempty"`
	BaudRate  uint   `json:"baudrate,omitempty"`
	DataBits  uint   `json:"databits,omitempty"`
	Parity    uint   `json:"parity,omitempty"`
	StopBits  uint   `json:"stopbits,omitempty"`
}

ModbusConfiguration represents a modbus client configuration

func (*ModbusConfiguration) ClientConfiguration

func (c *ModbusConfiguration) ClientConfiguration() *modbus.ClientConfiguration

type Model

type Model struct {
	*table.Model

	KeyMap         KeyMap
	Help           help.Model
	Status         *Status
	MaxColumnWidth int

	Datapoints []*Datapoint
	LastEdited *Datapoint
	// contains filtered or unexported fields
}

func NewTable

func NewTable(theme *huh.Theme, client *modbus.ModbusClient) *Model

func (Model) HelpView

func (m Model) HelpView() string

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) SelectedDatapoint

func (m Model) SelectedDatapoint() *Datapoint

func (*Model) SetDatapoints

func (m *Model) SetDatapoints(datapoints []*Datapoint)

SetDatapoints sets the datapoints which are shown

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type NumberAccessor

type NumberAccessor[T Number] struct {
	// contains filtered or unexported fields
}

func NewNumberAccessor

func NewNumberAccessor[T Number](val *T) *NumberAccessor[T]

func (*NumberAccessor[T]) Get

func (a *NumberAccessor[T]) Get() string

func (*NumberAccessor[T]) Set

func (a *NumberAccessor[T]) Set(value string)

type RefreshTickMsg

type RefreshTickMsg struct {
}

type Scaling

type Scaling struct {
	MinIn  string `json:"minIn"`
	MaxIn  string `json:"maxIn"`
	MinOut string `json:"minOut"`
	MaxOut string `json:"maxOut"`
}

func (Scaling) Ranges

func (dp Scaling) Ranges() (minIn float64, maxIn float64, minOut float64, maxOut float64)

func (Scaling) Valid

func (s Scaling) Valid() bool

type Status

type Status struct {
	Text       string
	Err        error
	AutoReload bool
	// contains filtered or unexported fields
}

func NewStatus

func NewStatus(theme *huh.Theme) *Status

func (Status) View

func (s Status) View(width int) string

Jump to

Keyboard shortcuts

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