model

package
v0.0.0-...-87726f4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Table_ColorProfile = "color_profile"
	Table_LedStrip     = "ledstrip"
)

Variables

This section is empty.

Functions

func EventTypeStrings

func EventTypeStrings() []string

EventTypeStrings returns a slice of all String values of the enum

Types

type AppError

type AppError struct {
	Err  error
	Code int
}

func NewAppErr

func NewAppErr(code int, err error) *AppError

func (*AppError) Error

func (e *AppError) Error() string

type BaseModel

type BaseModel struct {
	ID int64 `json:"id,omitempty" gorm:"primary_key" csv:"id"`
}

func (*BaseModel) GenerateID

func (b *BaseModel) GenerateID()

GenerateID generates an ID between 0 and 500

func (*BaseModel) GetID

func (b *BaseModel) GetID() int64

func (*BaseModel) GetNullID

func (b *BaseModel) GetNullID() null.Int

func (*BaseModel) GetStringID

func (b *BaseModel) GetStringID() string

type ColorProfile

type ColorProfile struct {
	BaseModel
	Blue       null.Int `json:"blue,omitempty" csv:"blue"`
	Brightness null.Int `json:"brightness,omitempty" csv:"brightness"`
	Green      null.Int `json:"green,omitempty" csv:"green"`
	Red        null.Int `json:"red,omitempty" csv:"red"`
}

ColorProfile The ColorProfile which reflects color and brightness

func (ColorProfile) TableName

func (ColorProfile) TableName() string

TableName sets the table name for the color profile

type EventType

type EventType int
const (
	Unknown EventType = iota
	Save
	Delete
)

func EventTypeString

func EventTypeString(s string) (EventType, error)

EventTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func EventTypeValues

func EventTypeValues() []EventType

EventTypeValues returns all values of the enum

func (EventType) IsAEventType

func (i EventType) IsAEventType() bool

IsAEventType returns "true" if the value is listed in the enum definition. "false" otherwise

func (EventType) MarshalJSON

func (i EventType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for EventType

func (EventType) MarshalText

func (i EventType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for EventType

func (EventType) String

func (i EventType) String() string

func (*EventType) UnmarshalJSON

func (i *EventType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for EventType

func (*EventType) UnmarshalText

func (i *EventType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for EventType

type IDer

type IDer interface {
	GetID() int64
	TableName() string
}

type LedStrip

type LedStrip struct {
	BaseModel
	Name        string   `json:"name,omitempty" csv:"name"`
	Description string   `json:"description,omitempty" csv:"description"`
	Enabled     bool     `json:"enabled,omitempty" csv:"enabled"`
	MisoPin     null.Int `json:"misoPin,omitempty" gorm:"column:miso_pin" csv:"miso_pin"`
	NumLeds     null.Int `json:"numLeds,omitempty" gorm:"column:num_leds" csv:"num_leds"`
	SclkPin     null.Int `json:"sclkPin,omitempty" gorm:"column:sclk_pin" csv:"sclk_pin"`
	SpeedHz     null.Int `json:"speedHz,omitempty" gorm:"column:speed_hz" csv:"speed_hz"`
	ProfileID   null.Int `json:"profileId,omitempty" gorm:"column:profile_id" csv:"profile_id"`
}

LedStrip definition of a LED strip and its configuration

func (LedStrip) TableName

func (LedStrip) TableName() string

TableName sets the table name for the led strip

type OptProfile

type OptProfile struct {
	Profile ColorProfile
	Valid   bool
}

OptProfile Optional Profile

func (OptProfile) MarshalJSON

func (profile OptProfile) MarshalJSON() (data []byte, err error)

MarshalJSON marshals json for OptProfile

type OptStrip

type OptStrip struct {
	Valid bool
	Strip struct {
		ID      int64      `json:"id,omitempty"`
		Name    string     `json:"name,omitempty"`
		Enabled bool       `json:"enabled,omitempty"`
		MisoPin int64      `json:"misoPin,omitempty"`
		SclkPin int64      `json:"sclkPin,omitempty"`
		NumLeds int64      `json:"numLeds,omitempty"`
		SpeedHz int64      `json:"speedHz,omitempty"`
		Profile OptProfile `json:"profile,omitempty"`
	}
}

OptStrip Optional Strip

func (OptStrip) MarshalJSON

func (strip OptStrip) MarshalJSON() (data []byte, err error)

MarshalJSON marshals json for OptProfile

func (*OptStrip) With

func (pe *OptStrip) With(profile ColorProfile) *OptStrip

type ProfileEvent

type ProfileEvent struct {
	Type  EventType  `json:"type,omitempty"`
	ID    null.Int   `json:"id,omitempty"`
	State OptProfile `json:"state,omitempty"`
}

ProfileEvent a StripEvent

func NewProfileEvent

func NewProfileEvent(id null.Int, typ EventType) *ProfileEvent

func (*ProfileEvent) With

func (pe *ProfileEvent) With(profile ColorProfile) *ProfileEvent

type StripEvent

type StripEvent struct {
	Type  EventType `json:"type,omitempty"`
	ID    null.Int  `json:"id,omitempty"`
	Strip OptStrip  `json:"state,omitempty"`
}

StripEvent a StripEvent

func NewStripEvent

func NewStripEvent(id null.Int, typ EventType) *StripEvent

func (*StripEvent) With

func (pe *StripEvent) With(strip *LedStrip) *StripEvent

Jump to

Keyboard shortcuts

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