models

package
v0.0.0-...-947ae56 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const DEFAULT_EXPECT_TIMEOUT = 3 * time.Second

Variables

View Source
var NodeStateStrings = [NodeStateCount]string{
	"unknown",
	"connecting",
	"connected",
	"bootloader",
	"running",
	"programming",
	"unresponsive",
}
View Source
var NullUdid8 = Udid8{0, 0, 0, 0, 0, 0, 0, 0}

Functions

func NodeCacheFile

func NodeCacheFile(file *helpers.FilePath)

func NodeCacheLoad

func NodeCacheLoad() error

func NodeCacheLookup

func NodeCacheLookup(udid Udid8) nocan.NodeId

func NodeCacheReverseLookup

func NodeCacheReverseLookup(node_id nocan.NodeId) bool

func NodeCacheSave

func NodeCacheSave() error

func NodeCacheSetEntry

func NodeCacheSetEntry(udid Udid8, node_id nocan.NodeId) bool

Types

type Channel

type Channel struct {
	Id        nocan.ChannelId
	Name      string
	Value     []byte
	UpdatedAt time.Time
}

Channel

func (*Channel) GetContent

func (c *Channel) GetContent() []byte

func (*Channel) SetContent

func (c *Channel) SetContent(content []byte) bool

func (*Channel) String

func (c *Channel) String() string

func (*Channel) Touch

func (c *Channel) Touch()

type ChannelCollection

type ChannelCollection struct {
	Mutex  sync.RWMutex
	ById   map[nocan.ChannelId]*Channel
	ByName map[string]*Channel
	TopId  nocan.ChannelId
}

ChannelCollection

func NewChannelCollection

func NewChannelCollection() *ChannelCollection

func (*ChannelCollection) Each

func (cc *ChannelCollection) Each(fn func(*Channel))

func (*ChannelCollection) EachOrdered

func (cc *ChannelCollection) EachOrdered(fn func(*Channel))

func (*ChannelCollection) Find

func (cc *ChannelCollection) Find(channelId nocan.ChannelId) *Channel

func (*ChannelCollection) Lookup

func (cc *ChannelCollection) Lookup(channelName string) *Channel

func (*ChannelCollection) Register

func (cc *ChannelCollection) Register(channelName string) (*Channel, error)

func (*ChannelCollection) Unregister

func (cc *ChannelCollection) Unregister(channel *Channel) bool

type JsonCacheEntry

type JsonCacheEntry struct {
	Udid   string
	NodeId nocan.NodeId
}

type Node

type Node struct {
	State           NodeState
	Id              nocan.NodeId
	Udid            Udid8
	LastSeen        time.Time
	FirmwareVersion uint8
	Attributes      map[string]string
}

Node

func NewNode

func NewNode(id nocan.NodeId, udid Udid8, fw_version uint8) *Node

func (*Node) ExpandAttributes

func (n *Node) ExpandAttributes(s string) string

func (*Node) GetAttribute

func (n *Node) GetAttribute(attr string) string

func (*Node) SetAttribute

func (n *Node) SetAttribute(attr string, value string)

func (*Node) String

func (n *Node) String() string

func (*Node) Touch

func (n *Node) Touch()

type NodeCollection

type NodeCollection struct {
	Mutex sync.RWMutex
	Nodes [128]*Node
	Udids map[Udid8]*Node
}

NodeCollection

func NewNodeCollection

func NewNodeCollection() *NodeCollection

func (*NodeCollection) Clear

func (nc *NodeCollection) Clear()

func (*NodeCollection) Each

func (nc *NodeCollection) Each(cb func(node *Node))

func (*NodeCollection) Find

func (nc *NodeCollection) Find(id nocan.NodeId) *Node

func (*NodeCollection) Lookup

func (nc *NodeCollection) Lookup(udid Udid8) *Node

func (*NodeCollection) Register

func (nc *NodeCollection) Register(udid Udid8, fw_version uint8) (*Node, error)

func (*NodeCollection) Unregister

func (nc *NodeCollection) Unregister(node *Node) bool

type NodeState

type NodeState uint

NodeState

const (
	NodeStateUnknown NodeState = iota
	NodeStateConnecting
	NodeStateConnected
	NodeStateBootloader
	NodeStateRunning
	NodeStateProgramming
	NodeStateUnresponsive
	NodeStateCount
)

func (NodeState) MarshalJSON

func (ns NodeState) MarshalJSON() ([]byte, error)

func (NodeState) String

func (ns NodeState) String() string

type Udid8

type Udid8 [8]byte

Udid8

func CreateUdid8

func CreateUdid8(b []byte) Udid8

func (Udid8) DecodeString

func (id Udid8) DecodeString(s string) error

func (Udid8) MarshalJSON

func (id Udid8) MarshalJSON() ([]byte, error)

func (Udid8) String

func (id Udid8) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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