Documentation ¶
Overview ¶
Package model provides entities for safe device configuration.
By using an extra model layer between the device drivers and network interfaces like HTTP we can control what information we want to expose to the outside world. On the one hand side we can catch invalid device configurations at an early stage on the other side we can hide (complicated) implementation details from the API user.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DDSDeviceValidation ¶
func DDSDeviceValidation(sl validator.StructLevel)
DDSDeviceValidation implements struct level validation.
func DDSParamValidation ¶
func DDSParamValidation(sl validator.StructLevel)
DDSParamValidation implements struct level validation.
func ValidateRange ¶
func ValidateRange(f validator.FieldLevel) bool
ValidateRange checks if an array of size two is a valid range.
This means that the last value should be greater than the first value.
Types ¶
type DDSConst ¶
type DDSConst struct {
Value float64 `json:"value" validate:"gte=0"`
}
DDSConst is the DDS mode where a DDS controllable parameter is constant.
type DDSDevice ¶
type DDSDevice struct { ID uint8 `json:"id" validate:"max=31"` Name string `json:"name" validate:"required"` Amplitude DDSParam `json:"amplitude"` Frequency DDSParam `json:"frequency"` PhaseOffset DDSParam `json:"phase"` }
DDSDevice is a public entity to a digital synthesizer device.
Instead of exposing an entity for every support operation mode we will decide what mode to use from the defined properties. For example in singletone mode it only makes sense to provide an amplitude and frequency property wherein in sweep mode we expect to have a frequency range defined over a single frequency.
type DDSDevices ¶
type DDSDevices []DDSDevice
DDSDevices is a collection of DDSDevices.
DDSDevices implements the flag.Value interface so that you can parse a list of device addresses.
func (*DDSDevices) FindByID ¶
func (s *DDSDevices) FindByID(id uint8) int
FindByID returns the first index of the DDSDevice with the given id.
If no device matches -1 is returned.
func (*DDSDevices) FindByIDString ¶
func (s *DDSDevices) FindByIDString(id string) int
FindByIDString returns the first index of the DDSDevice with the given id.
If no device matches -1 is returned.
func (*DDSDevices) FindByName ¶
func (s *DDSDevices) FindByName(name string) int
FindByName returns the first index of the DDSDevice with the given name.
If no device matches -1 is returned.
type DDSParam ¶
type DDSParam struct { Mode Mode `json:"mode"` Const DDSConst `json:"const" validate:"structonly"` Sweep DDSSweep `json:"sweep" validate:"structonly"` Playback DDSPlayback `json:"playback" validate:"structonly"` }
DDSParam is the DDS mode in which a DDS controllable parameter runs.
Note that usually only one of the embedded structs will be not nil as it does not make sense to have a constant frequency which we is also swept.
type DDSPlayback ¶
type DDSPlayback struct { Trigger bool `json:"trigger"` Duplex bool `json:"duplex"` Interval Seconds `json:"interval" validate:"gt=0"` Data []float64 `json:"data" validate:"required"` }
DDSPlayback is the DDS mode where a DDS controllable parameter is playbed back from memory.
type DDSSweep ¶
type DDSSweep struct { Limits [2]float64 `json:"limits" validate:"len=2,range,dive,gte=0"` NoDwells [2]bool `json:"nodwells"` Duration Seconds `json:"duration" validate:"required,gt=0"` }
DDSSweep is the DDS mode where a DDS controllable parameter is swept.
type Mode ¶
type Mode int
Mode is a DDS parameter mode.
func (Mode) MarshalJSON ¶
MarshalJSON implements json.Marshaller interface.
func (*Mode) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaller interface.
type Seconds ¶
type Seconds float64
Seconds represents a time duration in seconds.
Actually we would use time.Duration for this case but unfortunately time.Duration states strange json requirements which we do not support.