Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface {
Send(data interface{}) (err error) // 发送数据
Release() (err error) // 释放连接资源
}
Connector 连接器
type DeviceData ¶
type DeviceData struct {
DeviceName string `json:"device_name"`
Values []PointData `json:"values"`
}
DeviceData 设备数据
type EncodeMode ¶
type EncodeMode string
EncodeMode 编码模式
const ( ReadMode EncodeMode = "read" // 读模式 WriteMode EncodeMode = "write" // 写模式 )
type OnReceiveHandler ¶
OnReceiveHandler 接收数据回调函数
type Plugin ¶
type Plugin interface {
// Initialize 初始化日志、配置、接收回调
Initialize(logger *zap.Logger, c config.Config, handler OnReceiveHandler, ls *lua.LState) (err error)
// ProtocolAdapter 协议适配器
ProtocolAdapter() ProtocolAdapter
// Connector 连接器
Connector(deviceName, pointName string) (connector Connector, err error)
// Destroy 销毁驱动
Destroy() error
}
Plugin 驱动插件
type PointData ¶
type PointData struct {
PointName string `json:"name"` // 点位名称
Type string `json:"type"` // 点位值类型
Value interface{} `json:"value"` // 点位值
}
PointData 点位数据
type ProtocolAdapter ¶
type ProtocolAdapter interface {
Encode(deviceName string, mode EncodeMode, value PointData) (res interface{}, err error) // 编码
Decode(raw interface{}) (res []DeviceData, err error) // 解码
}
ProtocolAdapter 协议适配器 点位数据 <=> 协议数据
Click to show internal directories.
Click to hide internal directories.