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 //连接标识
//ScriptEnable bool //是否存在动态脚本
////当前连接的 lua 虚拟机
//Ls *lua.LState
ProtocolKey string `json:"protocolKey"` //协议驱动库标识
Discover bool `json:"discover"` //是否支持设备发现
Enable bool `json:"enable"` //是否启用
Virtual bool `json:"virtual"` //虚拟设备功能
}
连接配置基础模型
type Connector ¶
type Connector interface {
Encode(deviceId string, mode EncodeMode, values ...PointData) (res interface{}, 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 设备数据
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 点位写操作的结构体
type SimpleEncodeStruct ¶ added in v1.3.0
type SimpleEncodeStruct struct {
// 设备 ID
ID string `json:"id"`
// 点位名称
Mode EncodeMode `json:"mode"`
// 点位值
Values []PointData `json:"values"`
}
简单的编码结构体,对于无Encode实现的插件,可以使用该结构体
Click to show internal directories.
Click to hide internal directories.