plugin

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ReadMode       EncodeMode = "read"           // 读模式
	WriteMode      EncodeMode = "write"          // 写模式
	RealTimeExport ExportType = "realTimeExport" //实时上报
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConnection added in v1.0.0

type BaseConnection struct {
	ConnectionKey string //连接标识
	ProtocolKey   string `json:"protocolKey"` //协议驱动库标识
	Discover      bool   `json:"discover"`    //是否支持设备发现
	Enable        bool   `json:"enable"`      //是否启用
}

连接配置基础模型

type Connection added in v0.8.0

type Connection struct {
	ConnectionKey string
	ScriptEnable  bool //是否存在动态脚本
	//当前连接的 lua 虚拟机
	Ls *lua.LState
}

type Connector

type Connector interface {
	Encode(deviceId string, mode EncodeMode, values ...PointData) (res interface{}, err error) // 编码,是否支持批量的读写操作,由各插件觉得
	Decode(raw interface{}) (res []DeviceData, err error)                                      // 解码
	Send(data interface{}) (err error)                                                         // 发送数据
	Release() (err error)                                                                      // 释放连接资源
}

Connector 连接器

type DeviceData

type DeviceData struct {
	ID         string       `json:"id"`
	Values     []PointData  `json:"values"`
	Events     []event.Data `json:"events"`
	ExportType ExportType   //上报类型,底层的变化上报和实时上报等同于RealTimeExport
}

DeviceData 设备数据

func (DeviceData) ToJSON

func (d DeviceData) ToJSON() string

ToJSON 设备数据转 json

type EncodeMode

type EncodeMode string

EncodeMode 编码模式

type ExportType added in v0.6.0

type ExportType string

触发 ExportTo 的类型

type Plugin

type Plugin interface {
	// Initialize 初始化日志、配置、接收回调
	Initialize(logger *zap.Logger, c config.Config, ls *lua.LState)
	// Connector 连接器
	Connector(deviceId string) (connector Connector, err error)
	// Destroy 销毁驱动
	Destroy() error
}

Plugin 驱动插件

type PointData

type PointData struct {
	PointName string      `json:"name"`  // 点位名称
	Value     interface{} `json:"value"` // 点位值
}

PointData 点位数据

type PointReadValue added in v0.8.0

type PointReadValue struct {
	//设备 ID
	ID string `json:"id"`
	// PointName 点位名称
	PointName string `json:"pointName"`
	// Value 点位值
	Value interface{} `json:"value"`
}

PointReadValue 点位读操作的结构体

type PointWriteValue added in v0.8.0

type PointWriteValue struct {
	// PointName 点位名称
	PointName string `json:"pointName"`
	// Value 点位值
	Value interface{} `json:"value"`
	//模型名称,某些驱动解析需要根据模型作区分
	ModelName string `json:"modelName"`
	//前置操作,例如空开要先解锁,空调要先开机
	PreOp []PointWriteValue `json:"preOp"`
}

PointWriteValue 点位写操作的结构体

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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