helper

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoreCache coreCache

CoreCache 核心缓存

View Source
var Crontab crontab.Crontab // 全局定时任务实例
View Source
var DeviceShadow shadow.DeviceShadow // 本地设备影子
View Source
var DriverConfig config.DriverConfig // 驱动配置
View Source
var Exports []export.Export
View Source
var Logger *zap.Logger

Logger 日志记录器

View Source
var PluginCacheMap = &sync.Map{} // 插件通用缓存

Functions

func CallLuaConverter

func CallLuaConverter(L *lua.LState, method string, raw interface{}) ([]plugin.DeviceData, error)

CallLuaConverter 调用 Lua 脚本转换器

func CallLuaEncodeConverter

func CallLuaEncodeConverter(L *lua.LState, deviceName string, raw interface{}) (string, error)

CallLuaEncodeConverter 调用 Lua 脚本编码转换器

func Conv2Float64

func Conv2Float64(value interface{}) (f float64, err error)

Conv2Float64 转换为 float64 类型

func Conv2Int64

func Conv2Int64(value interface{}) (i int64, err error)

Conv2Int64 转换为 int64 类型

func Conv2String

func Conv2String(value interface{}) (s string, err error)

Conv2String 转换为 string 类型

func ConvPointType

func ConvPointType(value interface{}, valueType string) (interface{}, error)

ConvPointType 点位类型转换 仅支持三种数据类型:int、float、string

func FileExists

func FileExists(path string) bool

FileExists 判断文件存在

func GetChildDir

func GetChildDir(path string) (list []string, err error)

GetChildDir 获取指定路径下所有子目录

func GetChildDirName

func GetChildDirName(path string) (list []string, err error)

GetChildDirName 获取指定路径下所有子目录名称

func InitCoreCache

func InitCoreCache(configMap map[string]config.Config) (err error)

InitCoreCache 初始化核心缓存

func InitLogger

func InitLogger(level string) (err error)

InitLogger 初始化日志记录器

func InitLuaVM

func InitLuaVM(scriptDir string) (*lua.LState, error)

InitLuaVM 编译 lua 脚本

func Map2Struct

func Map2Struct(m interface{}, v interface{}) error

Map2Struct map 转 struct,用于解析连接器配置 m:map[string]interface v:&struct{}

func PointCacheFilter

func PointCacheFilter(deviceData *plugin.DeviceData)

func PointValueType2EdgeX

func PointValueType2EdgeX(valueType string) string

PointValueType2EdgeX 点位值类型转换为 EdgeX 数据类型 int => Int64、float => Float64、string => String

func SafeCallLuaFunc

func SafeCallLuaFunc(L *lua.LState, method string) error

SafeCallLuaFunc 安全调用 lua 函数,通过锁机制独占时间片

func Send

func Send(deviceName string, mode plugin.EncodeMode, value plugin.PointData) (err error)

Send 向设备发送数据

func SendMultiRead

func SendMultiRead(deviceNames []string, pointNames []string) (err error)

SendMultiRead 发送多个点位读取命令,多用于 autoEvent

Types

type LuaModule

type LuaModule struct{}

LuaModule go 实现 lua 模块,供脚本内使用

var LuaModuleInstance *LuaModule

func (*LuaModule) GetCache

func (lm *LuaModule) GetCache(L *lua.LState) int

GetCache 获取缓存

func (*LuaModule) Loader

func (lm *LuaModule) Loader(L *lua.LState) int

Loader 模块预加载

func (*LuaModule) SetCache

func (lm *LuaModule) SetCache(L *lua.LState) int

SetCache 设置缓存

func (*LuaModule) WriteToMsgBus

func (lm *LuaModule) WriteToMsgBus(L *lua.LState) int

WriteToMsgBus 上报设备数据 deviceName:设备名称,例如:sensor_1 points:点位数据,例如(此时以json格式进行说明,lua实际入参格式为 table 类型):{"onOff":1, "voc": 23}

type ProtocolProperties

type ProtocolProperties map[string]string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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