container

package
v0.0.0-...-6312dd6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	SetThingPropertyValue(thingId, propertyName string, value any) (any, error)
	GetThingPropertyValue(thingId, propertyName string) (any, error)
	Publish(topic2 topic.Topic, args ...any)
	Subscribe(topic2 topic.Topic, f any) error
	Unsubscribe(topic2 topic.Topic, f any)
	GetThing(thing string) *Thing
	GetThings() []*Thing
}

type Manager

type Manager interface {
	SetPropertyValue(ctx context.Context, thingId, propertyName string, value any) (any, error)
	GetPropertyValue(thingId, propertyName string) (any, error)
	GetPropertiesValue(thingId string) (map[string]any, error)
	Publish(topic2 topic.Topic, args ...any)
	Subscribe(topic2 topic.Topic, f any) error
}

type Thing

type Thing struct {
	*wot.Thing
	Pin                 *ThingPin `json:"pin,omitempty"`
	CredentialsRequired bool      `json:"credentialsRequired,omitempty"`

	//The state  of the thing
	SelectedCapability string `json:"selectedCapability,omitempty"`
	Connected          bool   `json:"-"`

	//FloorplanVisibility bool `json:"floorplanVisibility"`
	//FloorplanX          uint `json:"floorplanX"`
	//FloorplanY          uint `json:"floorplanY"`
	//LayoutIndex         uint `json:"layoutIndex"`
	GroupId string `json:"groupId,omitempty"`
	// contains filtered or unexported fields
}

func AsWebOfThing

func AsWebOfThing(device devices.Device) *Thing

func NewThing

func NewThing(data []byte, container *ThingsContainer) (*Thing, error)

func (*Thing) AddAction

func (t *Thing) AddAction(name string) bool

func (*Thing) AddEventSubscription

func (t *Thing) AddEventSubscription(f func(message topic.ThingEventMessage))

func (*Thing) GetPropertyValue

func (t *Thing) GetPropertyValue(name string) (any, error)

func (*Thing) OnEvent

func (t *Thing) OnEvent(event *events.EventDescription)

func (*Thing) RemoveAction

func (t *Thing) RemoveAction(name string) bool

func (*Thing) SetSelectedCapability

func (t *Thing) SetSelectedCapability(selectedCapability string)

func (*Thing) SetTitle

func (t *Thing) SetTitle(title string)

func (*Thing) UnmarshalJSON

func (t *Thing) UnmarshalJSON(data []byte) error

type ThingPin

type ThingPin struct {
	Required bool   `json:"required"`
	Pattern  string `json:"pattern"`
}

type ThingsContainer

type ThingsContainer struct {
	bus.ThingsBus
	// contains filtered or unexported fields
}

ThingsContainer 管理所有Thing Models 向外部发送ThingAdded,ThingRemoved,ThingModify,ThingConnected事件

func NewThingsContainerModel

func NewThingsContainerModel(manager Manager, store ThingsStorage) *ThingsContainer

NewThingsContainerModel 管理所有Thing Models

func (*ThingsContainer) CreateThing

func (c *ThingsContainer) CreateThing(data []byte) (*Thing, error)

CreateThing container和store中创建Thing ThingAdded事件

func (*ThingsContainer) GetMapOfThings

func (c *ThingsContainer) GetMapOfThings() map[string]*Thing

func (*ThingsContainer) GetThing

func (c *ThingsContainer) GetThing(id string) *Thing

func (*ThingsContainer) GetThingPropertyValue

func (c *ThingsContainer) GetThingPropertyValue(thingId, propName string) (any, error)

func (*ThingsContainer) GetThings

func (c *ThingsContainer) GetThings() (ts []*Thing)

func (*ThingsContainer) RemoveThing

func (c *ThingsContainer) RemoveThing(thingId string) error

RemoveThing 从container和store中删除Thing 向定阅发送ThingRemoved事件

func (*ThingsContainer) SetThingPropertyValue

func (c *ThingsContainer) SetThingPropertyValue(thingId, propName string, value any) (any, error)

func (*ThingsContainer) UpdateThing

func (c *ThingsContainer) UpdateThing(thing *Thing) error

UpdateThing 在container和Store中更新Thing

type ThingsStorage

type ThingsStorage interface {
	DeleteThing(id string) error
	CreateThing(id string, thing *Thing) error
	UpdateThing(id string, thing *Thing) error
	GetThings() map[string][]byte
}

ThingsStorage CRUD

Jump to

Keyboard shortcuts

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