binaryiotypec

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package binaryiotypec provides the API for the io4edge binaryIoTypeC functionblock

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a client for the binaryIoTypeC Module

func NewClientFromUniversalAddress

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

NewClientFromUniversalAddress creates a new binaryIoTypeC 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 a mdns service (without _io4edge_binaryIoTypeC._tcp). 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) AllInputs

func (c *Client) AllInputs() (states uint32, diag []uint32, err error)

AllInputs reads the state of all channel pins defined by mask.

Each bit in the returned state corresponds to one channel, bit0 being channel 0. The bit is false if the pin level is low, true otherwise.

diag is a slice with bitfields containing diagnostic bits for each channel, see ChannelDiag_* fields here: https://github.com/ci4rail/io4edge_api/blob/main/binaryIoTypeC/go/binaryIoTypeC/v1alpha1/binaryIoTypeC.pb.go#L92 first diag corresponds to channel 0, second to channel 1, etc.

func (*Client) Close

func (c *Client) Close()

Close terminates the underlying connection to the functionblock

func (*Client) Describe

func (c *Client) Describe() (*Description, error)

Describe reads the binaryIoTypeC function block description

func (*Client) DownloadConfiguration

func (c *Client) DownloadConfiguration() (*Configuration, error)

DownloadConfiguration reads the binaryIoTypeC function block configuration

func (*Client) Input

func (c *Client) Input(channel int) (state bool, diag uint32, err error)

Input reads the state of the channel's (regardless whether its configured as input or output) and the diagnostic info of a single channel.

The returned state is false if the pin's level is low, or true if it is high.

The returned diagnostic info is a bitfield containing diagnostic bits, see ChannelDiag_* fields here: https://github.com/ci4rail/io4edge_api/blob/main/binaryIoTypeC/go/binaryIoTypeC/v1alpha1/binaryIoTypeC.pb.go#L92

func (*Client) ReadStream

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

ReadStream reads the next stream data object from the buffer.

Returns the meta data and the unmarshalled function specific stream data

func (*Client) SetAllOutputs

func (c *Client) SetAllOutputs(states uint32, mask uint32) error

SetAllOutputs sets all or a group of output channels

states: binary coded map of outputs. 0 means switch low, 1 means switch high, LSB is Channel0

mask: defines which channels are affected by the set all command.

func (*Client) SetOutput

func (c *Client) SetOutput(channel int, state bool) error

SetOutput sets a single output channel a "true" state sets the output to high, a "false" state sets the output to low

func (*Client) StartStream

func (c *Client) StartStream(opts ...StreamConfigOption) error

StartStream starts the stream on this connection. Arguments may be one or more of the following functions:

  • WithChannelFilterMask
  • WithFBStreamOption(functionblock.WithXXXX(...))

Options that are not specified take default values.

func (*Client) StopStream

func (c *Client) StopStream() error

StopStream stops the stream on this connection

func (*Client) UploadConfiguration

func (c *Client) UploadConfiguration(opts ...ConfigOption) error

UploadConfiguration configures the binaryIoTypeC function block. Arguments may be one or more of the following functions:

  • WithChannelConfig
  • WithOutputWatchdog

Options that are not specified remain unchanged.

type ConfigOption

type ConfigOption func(*fspb.ConfigurationSet)

ConfigOption is a type to pass options to UploadConfiguration()

func WithChannelConfig

func WithChannelConfig(ch []*fspb.ChannelConfig) ConfigOption

WithChannelConfig may be passed to UploadConfiguration. each entry describes the configuration of one channel. Undescribed channels remain unchanged.

func WithOutputWatchdog

func WithOutputWatchdog(mask uint32, timoutMs uint32) ConfigOption

WithOutputWatchdog may be passed to UploadConfiguration. mask defines to which outputs the watchdog shall apply (bit0=first IO). timeoutMs defines the watchdog timeout in ms, it's the same for all selected outputs

type Configuration

type Configuration struct {
	// ChannelConfig describes the configuration of each channel
	ChannelConfig []*fspb.ChannelConfig
	// OutputWatchdogMask reflects on which outputs the watchdog is enabled
	OutputWatchdogMask uint8
	// OutputWatchdogTimeoutMs reflects the watchdog timeout in ms
	OutputWatchdogTimeoutMs uint32
}

Configuration describes the current configuration of the binaryIoTypeC function. Returned by DownloadConfiguration()

type Description

type Description struct {
	NumberOfChannels int
}

Description represents the describe response of the binaryIoTypeC function

type StreamConfigOption

type StreamConfigOption func(*StreamConfiguration)

StreamConfigOption is a type to pass options to StartStream()

func WithChannelFilterMask

func WithChannelFilterMask(channelFilterMask uint32) StreamConfigOption

WithChannelFilterMask may be passed to StartStream.

channelFilterMask defines the watched channels. Only changes on those channels generate samples in the stream

func WithFBStreamOption

func WithFBStreamOption(opt functionblock.StreamConfigOption) StreamConfigOption

WithFBStreamOption may be passed to StartStream.

opt is one of the functions that may be passed to functionblock.StartStream, e.g. WithBucketSamples()

type StreamConfiguration

type StreamConfiguration struct {
	ChannelFilterMask uint32
	FBOptions         []functionblock.StreamConfigOption
}

StreamConfiguration defines the configuration of a stream

type StreamData

type StreamData struct {
	functionblock.StreamDataMeta
	FSData *fspb.StreamData
}

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

Jump to

Keyboard shortcuts

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