functionblock

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

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 added in v0.2.0

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

HaveResponseStatus checks if err corresponds to functionblock status error code

Types

type Client added in v0.2.0

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

Client represents a client for a generic functionblock

func NewClientFromUniversalAddress added in v0.2.0

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 added in v1.0.0

func (c *Client) Close()

Close terminates the underlying connection to the functionblock

func (*Client) Describe added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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

ReadStream reads the next stream data object from the buffer

func (*Client) StartStream added in v0.2.0

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 added in v0.2.0

func (c *Client) StopStream() error

StopStream stops the stream

func (*Client) UploadConfiguration added in v0.2.0

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 added in v0.2.0

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

ResponseError holds the details of functionblock errors

func (*ResponseError) Error added in v0.2.0

func (e *ResponseError) Error() string

func (*ResponseError) StatusCode added in v0.2.0

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

StatusCode returns the numeric error status code from the functionblock

type StreamConfigOption added in v1.0.0

type StreamConfigOption func(*StreamConfiguration)

StreamConfigOption is a type to pass options to StartStream()

func WithBucketSamples added in v1.0.0

func WithBucketSamples(numSamples uint32) StreamConfigOption

WithBucketSamples may be passed to StartStream.

numSamples define the max number of samples per message in StreamData

func WithBufferedSamples added in v1.0.0

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 added in v1.0.0

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 added in v1.5.0

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 added in v0.2.0

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

StreamConfiguration defines the configuration of a stream

type StreamData added in v0.2.0

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 added in v0.2.0

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