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 Connector ¶
type Connector interface {
// ProtocolAdapter 协议适配器
ProtocolAdapter() ProtocolAdapter
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) (err error)
// Connector 连接器
Connector(deviceId, pointName 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 ProtocolAdapter ¶
type ProtocolAdapter interface {
Encode(deviceId string, mode EncodeMode, values ...PointData) (res interface{}, err error) // 编码,是否支持批量的读写操作,由各插件觉得
Decode(raw interface{}) (res []DeviceData, err error) // 解码
}
ProtocolAdapter 协议适配器 点位数据 <=> 协议数据
Click to show internal directories.
Click to hide internal directories.