toggleswitch

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: AGPL-3.0 Imports: 10 Imported by: 2

Documentation

Overview

Package toggleswitch contains a gRPC based switch client.

Package toggleswitch contains a gRPC based switch service server.

Package toggleswitch defines a multi-position switch.

Index

Constants

View Source
const SubtypeName = "switch"

SubtypeName is a constant that identifies the component resource API string.

Variables

View Source
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)

API is a variable that identifies the component resource API.

View Source
var ErrInvalidPosition = func(switchName string, position, maxPosition int) error {
	return fmt.Errorf("switch component %v position %d is invalid (max: %d)", switchName, position, maxPosition)
}

ErrInvalidPosition is the returned error if switch position is invalid.

Functions

func Named

func Named(name string) resource.Name

Named is a helper for getting the named switch's typed resource name.

func NamesFromRobot

func NamesFromRobot(r robot.Robot) []string

NamesFromRobot is a helper for getting all switch names from the given Robot.

func NewRPCServiceServer

func NewRPCServiceServer(coll resource.APIResourceCollection[Switch]) interface{}

NewRPCServiceServer constructs a switch gRPC service server. It is intentionally untyped to prevent use outside of tests.

Types

type Switch

type Switch interface {
	resource.Resource

	// SetPosition sets the switch to the specified position.
	// Position must be within the valid range for the switch type.
	// This will block until done or a new operation cancels this one.
	SetPosition(ctx context.Context, position uint32, extra map[string]interface{}) error

	// GetPosition returns the current position of the switch.
	GetPosition(ctx context.Context, extra map[string]interface{}) (uint32, error)

	// GetNumberOfPositions returns the total number of valid positions for this switch.
	GetNumberOfPositions(ctx context.Context, extra map[string]interface{}) (uint32, error)
}

A Switch represents a physical multi-position switch.

func FromDependencies

func FromDependencies(deps resource.Dependencies, name string) (Switch, error)

FromDependencies is a helper for getting the named button component from a collection of dependencies.

func FromRobot

func FromRobot(r robot.Robot, name string) (Switch, error)

FromRobot is a helper for getting the named Switch from the given Robot.

func NewClientFromConn

func NewClientFromConn(
	ctx context.Context,
	conn rpc.ClientConn,
	remoteName string,
	name resource.Name,
	logger logging.Logger,
) (Switch, error)

NewClientFromConn constructs a new Client from connection passed in.

Directories

Path Synopsis
Package fake implements fake switches with different position counts.
Package fake implements fake switches with different position counts.
Package register registers all relevant switches and also API specific functions
Package register registers all relevant switches and also API specific functions

Jump to

Keyboard shortcuts

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