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")
View Source
var UnknownDevicePointErr = errors.New("unknown device point")
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device 设备结构
func (*Device) GetDevicePoint ¶ added in v0.7.0
func (d *Device) GetDevicePoint(pointName string) (DevicePoint, bool)
GetDevicePoint 获取设备指定点位数据
func (*Device) GetDevicePointAPI ¶ added in v0.7.0
func (d *Device) GetDevicePointAPI(pointName string) (DevicePointAPI, bool)
GetDevicePointAPI 获取设备指定点位数据(开放 API 使用)
func (*Device) SetOnlineBindPoint ¶
SetOnlineBindPoint 设备在线状态绑定指定点位
func (*Device) ToDeviceAPI ¶ added in v0.7.0
ToDeviceAPI 转换设备 API
type DeviceAPI ¶ added in v0.7.0
type DeviceAPI struct { SN string `json:"sn"` Points []DevicePointAPI `json:"points"` Online bool `json:"online"` TTL string `json:"ttl"` DisconnectTimes int `json:"disconnect_times"` UpdatedAt string `json:"updated_at"` }
DeviceAPI 对外开放设备数据
type DevicePoint ¶
type DevicePoint struct { Name string // 点位名称 Value interface{} // 点位值 UpdatedAt time.Time // 点位最后更新时间(用于点位缓存过期判断) }
DevicePoint 设备点位结构
func (DevicePoint) ToDevicePointAPI ¶ added in v0.7.0
func (dp DevicePoint) ToDevicePointAPI() DevicePointAPI
type DevicePointAPI ¶ added in v0.7.0
type DevicePointAPI struct { Name string `json:"name"` Value any `json:"value"` UpdatedAt string `json:"updated_at"` }
DevicePointAPI 对外开放设备点位
type DeviceShadow ¶
type DeviceShadow interface { AddDevice(device Device) (err error) GetDevice(deviceSn string) (device Device, err error) SetDevicePoint(deviceSn, pointName string, value interface{}) (err error) GetDevicePoint(deviceSn, pointName string) (value interface{}, err error) GetDevicePoints(deviceSn string) (points map[string]DevicePoint, err error) GetDeviceUpdateAt(deviceSn string) (time.Time, error) GetDeviceStatus(deviceSn string) (online bool, err error) SetOnline(deviceSn string) (err error) SetOffline(deviceSn string) (err error) // MayBeOffline 可能离线事件(60秒内超过3次判定离线) MayBeOffline(deviceSn string) (err error) SetOnlineChangeCallback(handlerFunc OnlineChangeCallback) // StopStatusListener 停止设备状态监听 StopStatusListener() // GetDevices 获取所有设备 GetDevices() []Device }
DeviceShadow 设备影子
func NewDeviceShadow ¶
func NewDeviceShadow() DeviceShadow
type OnlineChangeCallback ¶
Click to show internal directories.
Click to hide internal directories.