plugin

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

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

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 {
	SN         string      `json:"sn"`
	Values     []PointData `json:"values"`
	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 H

type H map[string]interface{}

H map[string]interface{} 别名

type OnReceiveHandler

type OnReceiveHandler func(plugin Plugin, raw interface{}) (result interface{}, err error)

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(deviceSn, 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 ProtocolAdapter

type ProtocolAdapter interface {
	Encode(deviceSn string, mode EncodeMode, value PointData) (res interface{}, err error) // 编码
	Decode(raw interface{}) (res []DeviceData, err error)                                  // 解码
}

ProtocolAdapter 协议适配器 点位数据 <=> 协议数据

Jump to

Keyboard shortcuts

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