entities

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NormallyOpen   = uint8(1)
	NormallyClosed = uint8(2)
	Controlled     = uint8(3)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	CardNumber uint32         `json:"number"`
	From       *types.Date    `json:"from,omitempty"`
	To         *types.Date    `json:"to,omitempty"`
	Doors      map[uint8]bool `json:"doors,omitempty"`
}

type CardList

type CardList [64]*Card

func (*CardList) Delete

func (l *CardList) Delete(cardNumber uint32) bool

func (*CardList) DeleteAll

func (l *CardList) DeleteAll() bool

func (*CardList) Put

func (l *CardList) Put(card *Card) error

func (*CardList) Size

func (l *CardList) Size() uint32

type Delay

type Delay time.Duration

func DelayFromSeconds

func DelayFromSeconds(t uint8) Delay

func (Delay) MarshalJSON

func (delay Delay) MarshalJSON() ([]byte, error)

func (Delay) Seconds

func (delay Delay) Seconds() uint8

func (*Delay) UnmarshalJSON

func (delay *Delay) UnmarshalJSON(bytes []byte) error

type Door

type Door struct {
	ControlState uint8 `json:"control"`
	Delay        Delay `json:"delay"`
	// contains filtered or unexported fields
}

func NewDoor

func NewDoor(id uint8) *Door

func (*Door) Close added in v0.6.7

func (d *Door) Close(closed func()) bool

func (*Door) IsButtonPressed

func (d *Door) IsButtonPressed() bool

func (*Door) IsOpen

func (d *Door) IsOpen() bool

func (*Door) IsUnlocked added in v0.6.7

func (d *Door) IsUnlocked() bool

func (*Door) Open

func (d *Door) Open(duration *time.Duration, opened func(uint8), closed func()) bool

func (*Door) PressButton added in v0.6.7

func (d *Door) PressButton(duration time.Duration) (pressed bool, unlocked bool)

func (*Door) Unlock added in v0.6.7

func (d *Door) Unlock(duration time.Duration) bool

type Event

type Event struct {
	RecordNumber uint32         `json:"record-number"`
	Type         uint8          `json:"type"`
	Granted      bool           `json:"granted"`
	Door         uint8          `json:"door"`
	Direction    uint8          `json:"direction"`
	CardNumber   uint32         `json:"CardNumber"`
	Timestamp    types.DateTime `json:"timestamp"`
	Reason       uint8          `json:"reason"`
}

type EventList

type EventList struct {
	Size   uint32  `json:"size"`
	First  uint32  `json:"first"`
	Last   uint32  `json:"last"`
	Index  uint32  `json:"index"`
	Events []Event `json:"events"`
}

func (*EventList) Add

func (l *EventList) Add(event *Event)

TODO: implement Marshal/Unmarshal

func (*EventList) Get

func (l *EventList) Get(index uint32) *Event

func (*EventList) SetIndex

func (l *EventList) SetIndex(index uint32) bool

type Message

type Message struct {
	Destination *net.UDPAddr
	Message     interface{}
}

type Offset

type Offset time.Duration

func (Offset) MarshalJSON

func (t Offset) MarshalJSON() ([]byte, error)

func (*Offset) UnmarshalJSON

func (t *Offset) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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