helper

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: 23 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 EnvConfig config.EnvConfig
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, deviceSn string, raw interface{}) (string, error)

CallLuaEncodeConverter 调用 Lua 脚本编码转换器

func CallLuaMethod added in v0.6.0

func CallLuaMethod(L *lua.LState, method string, args ...lua.LValue) (string, error)

执行指定lua方法

func Close added in v0.6.0

func Close(L *lua.LState)

关闭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 config.ValueType) (interface{}, error)

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

func FileExists

func FileExists(path string) bool

FileExists 判断文件存在

func InitCoreCache

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

InitCoreCache 初始化核心缓存

func InitLogger

func InitLogger(level string) (err error)

New 实例化

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 SafeCallLuaFunc

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

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

func Send

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

Send 向设备发送数据

func SendMultiRead

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

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

func TriggerEvents added in v0.6.0

func TriggerEvents(eventCode string, key string, value interface{})

触发事件

Types

type DeviceProperties added in v0.6.0

type DeviceProperties map[string]string

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 上报设备数据 deviceSn:设备SN,例如:sensor_1 points:点位数据,例如(此时以json格式进行说明,lua实际入参格式为 table 类型):{"onOff":1, "voc": 23}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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