Documentation ¶
Overview ¶
stream device package provides a way to create and manage virtual lab devices that generate and consume data streams
Index ¶
- Constants
- Variables
- type StreamDevice
- func (s *StreamDevice) GetCommandDelay(name string) (time.Duration, error)
- func (s *StreamDevice) GetMismatch() []byte
- func (s *StreamDevice) GetParameter(name string) (any, error)
- func (s *StreamDevice) Handle(cmd []byte) []byte
- func (s *StreamDevice) Mismatch() (res []byte)
- func (s *StreamDevice) SetCommandDelay(name, val string) error
- func (s *StreamDevice) SetMismatch(value string) error
- func (s *StreamDevice) SetParameter(name string, value any) error
- func (s *StreamDevice) Trigger(cmdName string) error
- func (s *StreamDevice) Triggered() chan []byte
Constants ¶
const MISMATCH_LIMIT = 255
Max length of mismatch message
Variables ¶
var ( // Error returned by Trigger when there is no client to send parameter value ErrNoClient = errors.New("no client available") // Error returned by SetMimsatch if new message is too long ErrMismatchTooLong = errors.New("new mismatch message exceeded 255 characters limit") )
Functions ¶
This section is empty.
Types ¶
type StreamDevice ¶
Stream device store the information of a set of parameters
func NewDevice ¶
func NewDevice(vdfile *vdfile.VDFile) (*StreamDevice, error)
Create a new stream device given the virtual device configuration file
func (*StreamDevice) GetCommandDelay ¶
func (s *StreamDevice) GetCommandDelay(name string) (time.Duration, error)
Get delay of the specified command, return error when command not found
func (*StreamDevice) GetMismatch ¶
func (s *StreamDevice) GetMismatch() []byte
Return mismatch message
func (*StreamDevice) GetParameter ¶
func (s *StreamDevice) GetParameter(name string) (any, error)
Method to read value of the specified parameter, returns error when parameter not found
func (*StreamDevice) Handle ¶
func (s *StreamDevice) Handle(cmd []byte) []byte
Method that fulfills Handler interface that is used by TCP server. It divides bytes into understandable pieces of data and parses it.
func (*StreamDevice) Mismatch ¶
func (s *StreamDevice) Mismatch() (res []byte)
Return mismatch message together with terminators
func (*StreamDevice) SetCommandDelay ¶
func (s *StreamDevice) SetCommandDelay(name, val string) error
Set delay of the specified command, return error when command not found or when value cannot be converted to time.Duration
func (*StreamDevice) SetMismatch ¶
func (s *StreamDevice) SetMismatch(value string) error
Method to set mismatch message, returns error when string it too long
func (*StreamDevice) SetParameter ¶
func (s *StreamDevice) SetParameter(name string, value any) error
Method to access value of the specified parameter and change it, return error when parameter not found
func (*StreamDevice) Trigger ¶
func (s *StreamDevice) Trigger(cmdName string) error
Method that cause that value of the parameter associated with the specified command is sent directly via TCP server to connected client. It returns an error when there is no client connected to TCP server or when parameter was not found.
func (*StreamDevice) Triggered ¶
func (s *StreamDevice) Triggered() chan []byte
Method that returns channel with value of the parameter