Documentation
¶
Overview ¶
Package functionblock provides the API for the io4edge function blocks
Index ¶
- func HaveResponseStatus(err error, status fbv1.Status) bool
- type Client
- func (c *Client) Close()
- func (c *Client) Describe(fsCmd proto.Message) (*anypb.Any, error)
- func (c *Client) DownloadConfiguration(fsCmd proto.Message) (*anypb.Any, error)
- func (c *Client) FunctionControlGet(fsCmd proto.Message) (*anypb.Any, error)
- func (c *Client) FunctionControlSet(fsCmd proto.Message) (*anypb.Any, error)
- func (c *Client) ReadStream(timeout time.Duration) (*StreamData, error)
- func (c *Client) StartStream(opts []StreamConfigOption, fsCmd proto.Message) error
- func (c *Client) StopStream() error
- func (c *Client) UploadConfiguration(fsCmd proto.Message) (*anypb.Any, error)
- type ResponseError
- type StreamConfigOption
- type StreamConfiguration
- type StreamData
- type StreamDataMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) UploadConfiguration ¶
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 ¶
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 ¶
StreamDataMeta contains meta information about a Stream Data message