functionblock

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package functionblock provides the API for the io4edge function blocks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HaveResponseStatus

func HaveResponseStatus(err error, status fbv1.Status) bool

HaveResponseStatus checks if err corresponds to functionblock status error code

Types

type Client

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

Client represents a client for a generic functionblock

func NewClientFromUniversalAddress

func NewClientFromUniversalAddress(addrOrService string, service string, timeout time.Duration) (*Client, error)

NewClientFromUniversalAddress creates a new functionblock client from addrOrService. If addrOrService is of the form "host:port", it creates the client from that host/port, otherwise it assumes addrOrService is the instance name of an mdns service.

If service is non-empty and addrOrService is a mdns instance name, it is appended to the addrOrService. .e.g. if addrOrService is "iou01-sn01-binio" and service is "_io4edge_binaryIoTypeA._tcp", the mdns instance name "iou01-sn01-binio._io4edge_binaryIoTypeA._tcp" is used.

The timeout specifies the maximal time waiting for a service to show up. If 0, use default timeout. Not used for "host:port"

func (*Client) Close

func (c *Client) Close()

Close terminates the underlying connection to the functionblock

func (*Client) Describe

func (c *Client) Describe(fsCmd proto.Message) (*anypb.Any, error)

Describe executes the configuration describe command on the device.

fsCmd is the function specific configuration describe object

returns the function specific response as a protobuf any object

func (*Client) DownloadConfiguration

func (c *Client) DownloadConfiguration(fsCmd proto.Message) (*anypb.Any, error)

DownloadConfiguration executes the configuration get command on the device.

fsCmd is the function specific configuration get object

returns the function specific response as a protobuf any object

func (*Client) FunctionControlGet

func (c *Client) FunctionControlGet(fsCmd proto.Message) (*anypb.Any, error)

FunctionControlGet executes the function control get command on the device.

fsCmd is the function specific command object

returns the function specific response as a protobuf any object

func (*Client) FunctionControlSet

func (c *Client) FunctionControlSet(fsCmd proto.Message) (*anypb.Any, error)

FunctionControlSet executes the function control set command on the device.

fsCmd is the function specific command object

returns the function specific response as a protobuf any object

func (*Client) ReadStream

func (c *Client) ReadStream(timeout time.Duration) (*StreamData, error)

ReadStream reads the next stream data object from the buffer

func (*Client) StartStream

func (c *Client) StartStream(opts []StreamConfigOption, fsCmd proto.Message) error

StartStream starts the stream with configuration config, passing the function specific configuration from fscmd

func (*Client) StopStream

func (c *Client) StopStream() error

StopStream stops the stream

func (*Client) UploadConfiguration

func (c *Client) UploadConfiguration(fsCmd proto.Message) (*anypb.Any, error)

UploadConfiguration executes the configuration set command on the device.

fsCmd is the function specific configuration set object

returns the function specific response as a protobuf any object

type ResponseError

type ResponseError struct {
	Action        string
	Status        fbv1.Status
	FwErrorString string
}

ResponseError holds the details of functionblock errors

func (*ResponseError) Error

func (e *ResponseError) Error() string

func (*ResponseError) StatusCode

func (e *ResponseError) StatusCode() fbv1.Status

StatusCode returns the numeric error status code from the functionblock

type StreamConfigOption

type StreamConfigOption func(*StreamConfiguration)

StreamConfigOption is a type to pass options to StartStream()

func WithBucketSamples

func WithBucketSamples(numSamples uint32) StreamConfigOption

WithBucketSamples may be passed to StartStream.

numSamples define the max number of samples per message in StreamData

func WithBufferedSamples

func WithBufferedSamples(numSamples uint32) StreamConfigOption

WithBufferedSamples may be passed to StartStream.

numSamples define the number of samples buffered in the device for that stream

func WithKeepaliveInterval

func WithKeepaliveInterval(timeMS uint32) StreamConfigOption

WithKeepaliveInterval may be passed to StartStream.

timeMS defines the time in ms after which the devices buffer is flushed and sent to the client, even if the number of buffered samples is less than BucketSamples

func WithLowLatencyMode

func WithLowLatencyMode(lowLatencyMode bool) StreamConfigOption

WithLowLatencyMode may be passed to StartStream.

if true, the stream is started in low latency mode. In low latency mode, samples are sent as soon as possible, if currently no more buffered samples are ready.

type StreamConfiguration

type StreamConfiguration struct {
	BucketSamples     uint32
	KeepaliveInterval uint32
	BufferedSamples   uint32
	LowLatencyMode    bool
}

StreamConfiguration defines the configuration of a stream

type StreamData

type StreamData struct {
	StreamDataMeta
	FSData *anypb.Any // function specific data
}

StreamData contains the meta data of the stream and the function specific message

type StreamDataMeta

type StreamDataMeta struct {
	DeliveryTimestamp uint64
	Sequence          uint32
}

StreamDataMeta contains meta information about a Stream Data message

Jump to

Keyboard shortcuts

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