Documentation
¶
Index ¶
- Constants
- Variables
- func AddConfig(c config.Config) error
- func AddConnection(plugin string, key string, conn any) error
- func AddModel(plugin string, model config.DeviceModel) error
- func AddOrUpdateDevice(device config.Device) error
- func BatchRemoveDevice(ids []string) error
- func GetConfig(key string) (config.Config, bool)
- func GetConfigKeyByModel(modelName string) string
- func GetConfigs() map[string]config.Config
- func GetConnection(key string) (any, error)
- func GetDevice(modelName string, deviceID string) (config.Device, bool)
- func GetModel(modelName string) (config.DeviceModel, bool)
- func GetPluginNameByConnection(key string) string
- func GetPluginNameByModel(modelName string) string
- func LoadConfig() error
- func RemoveConnection(key string) error
- func RemoveDevice(modelName string, deviceID string) error
- func RemoveDeviceByID(id string) error
- func SetConfigFileName(name string)
- func SetConfigPath(path string)
- func SetScriptFileName(name string)
- type Manager
Constants ¶
View Source
const ( // DefaultConfigPath is the default path to the config directory. DefaultConfigPath string = "./res/driver" // DefaultConfigName is the default name of the config file. DefaultConfigName string = "config.json" // DefaultScriptName is the default name of the script file. DefaultScriptName string = "converter.lua" )
Variables ¶
View Source
var ( // ErrDeviceModelNameNull is the error returned when the device model name is empty. ErrDeviceModelNameNull = errors.New("device model name is null") // ErrUnknownModel is the error returned when the model is unknown. ErrUnknownModel = errors.New("unknown model") // ErrUnknownDevice is the error returned when the device is unknown. ErrUnknownDevice = errors.New("unknown device") // ErrConfigNotExist is the error returned when the config file does not exist. ErrConfigNotExist = errors.New("config not exist") // ErrConfigEmpty is the error returned when the config file is empty. ErrConfigEmpty = errors.New("config is empty") )
Functions ¶
func AddOrUpdateDevice ¶ added in v0.8.0
func BatchRemoveDevice ¶ added in v0.8.0
func GetConfigKeyByModel ¶ added in v0.8.0
func GetConfigs ¶ added in v0.8.0
func GetConnection ¶ added in v0.8.0
func GetPluginNameByConnection ¶ added in v0.8.0
func GetPluginNameByModel ¶ added in v0.8.0
func LoadConfig ¶ added in v0.8.0
func LoadConfig() error
func RemoveConnection ¶ added in v0.8.0
func RemoveDevice ¶ added in v0.8.0
func RemoveDeviceByID ¶ added in v0.8.0
func SetConfigFileName ¶ added in v0.8.0
func SetConfigFileName(name string)
func SetConfigPath ¶ added in v0.8.0
func SetConfigPath(path string)
func SetScriptFileName ¶ added in v0.8.0
func SetScriptFileName(name string)
Types ¶
type Manager ¶
type Manager interface { // SetConfigPath 设置配置目录 SetConfigPath(path string) // SetConfigFileName 设置配置文件名 SetConfigFileName(name string) // SetScriptFileName 设置脚本文件名 SetScriptFileName(name string) // LoadConfig 加载配置 LoadConfig() error // GetConfigs 获取所有配置 GetConfigs() map[string]config.Config // AddConfig 新增配置 AddConfig(c config.Config) error // GetConfig 根据 key 获取配置 GetConfig(key string) (config.Config, bool) // GetConfigKeyByModel 根据模型名获取配置 key GetConfigKeyByModel(modelName string) string // GetModel 获取模型 GetModel(modelName string) (config.DeviceModel, bool) // AddModel 新增模型 AddModel(plugin string, model config.DeviceModel) error // GetDevice 获取设备 GetDevice(modelName string, deviceID string) (config.Device, bool) // AddOrUpdateDevice 新增或更新设备 AddOrUpdateDevice(device config.Device) error // RemoveDevice 删除设备 RemoveDevice(modelName string, deviceID string) error // RemoveDeviceByID 根据 ID 删除设备 RemoveDeviceByID(id string) error // BatchRemoveDevice 批量删除设备 BatchRemoveDevice(ids []string) error // AddConnection 新增连接 AddConnection(plugin string, key string, conn any) error // GetConnection 获取连接信息 GetConnection(key string) (any, error) // RemoveConnection 删除连接 RemoveConnection(key string) error // GetPluginNameByModel 获取模型所属的插件名称 GetPluginNameByModel(modelName string) string // GetPluginNameByConnection 获取连接所属的插件名称 GetPluginNameByConnection(key string) string }
Manager 配置管理器接口
Click to show internal directories.
Click to hide internal directories.