shadow

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BindPointDataErr = errors.New("bind online point data can't be parsed")
View Source
var DeviceRepeatErr = errors.New("device already exists")
View Source
var UnknownDeviceErr = errors.New("unknown device")

Functions

func SetDefaultDeviceTTL

func SetDefaultDeviceTTL(ttl time.Duration)

SetDefaultDeviceTTL 设置默认设备生命周期

Types

type Device

type Device struct {
	Name      string                 // 设备名称
	ModelName string                 // 设备模型名称
	Points    map[string]DevicePoint // 设备点位列表
	// contains filtered or unexported fields
}

Device 设备结构

func NewDevice

func NewDevice(deviceName string, modelName string, points map[string]DevicePoint) Device

func (*Device) SetOnlineBindPoint

func (d *Device) SetOnlineBindPoint(pointName string)

SetOnlineBindPoint 设备在线状态绑定指定点位

func (*Device) SetTTL

func (d *Device) SetTTL(t time.Duration)

SetTTL 设置设备生命周期(超出周期未上报自动判定为离线)

type DevicePoint

type DevicePoint struct {
	Name  string      // 点位名称
	Value interface{} // 点位值
}

DevicePoint 设备点位结构

func NewDevicePoint

func NewDevicePoint(pointName string, value interface{}) DevicePoint

type DeviceShadow

type DeviceShadow interface {
	AddDevice(device Device) (err error)
	GetDevice(deviceName string) (device Device, err error)

	SetDevicePoint(deviceName, pointName string, value interface{}) (err error)
	GetDevicePoint(deviceName, pointName string) (value interface{}, err error)
	GetDevicePoints(deviceName string) (points map[string]DevicePoint, err error)

	GetDeviceUpdateAt(deviceName string) (time.Time, error)

	GetDeviceStatus(deviceName string) (online bool, err error)

	SetOnline(deviceName string) (err error)
	SetOffline(deviceName string) (err error)

	// MayBeOffline 可能离线事件(60秒内超过3次判定离线)
	MayBeOffline(deviceName string) (err error)

	SetOnlineChangeCallback(handlerFunc OnlineChangeCallback)

	// StopStatusListener 停止设备状态监听
	StopStatusListener()
}

DeviceShadow 设备影子

func NewDeviceShadow

func NewDeviceShadow() DeviceShadow

type OnlineChangeCallback

type OnlineChangeCallback func(deviceName string, online bool) // 设备上/下线回调

Jump to

Keyboard shortcuts

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