cmanager

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

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 AddConfig added in v0.8.0

func AddConfig(c config.Config) error

func AddConnection added in v0.8.0

func AddConnection(plugin string, key string, conn any) error

func AddModel added in v0.8.0

func AddModel(plugin string, model config.DeviceModel) error

func AddOrUpdateDevice added in v0.8.0

func AddOrUpdateDevice(device config.Device) error

func BatchRemoveDevice added in v0.8.0

func BatchRemoveDevice(ids []string) error

func GetConfig added in v0.8.0

func GetConfig(key string) (config.Config, bool)

func GetConfigKeyByModel added in v0.8.0

func GetConfigKeyByModel(modelName string) string

func GetConfigs added in v0.8.0

func GetConfigs() map[string]config.Config

func GetConnection added in v0.8.0

func GetConnection(key string) (any, error)

func GetDevice added in v0.8.0

func GetDevice(modelName string, deviceID string) (config.Device, bool)

func GetModel added in v0.8.0

func GetModel(modelName string) (config.DeviceModel, bool)

func GetPluginNameByConnection added in v0.8.0

func GetPluginNameByConnection(key string) string

func GetPluginNameByModel added in v0.8.0

func GetPluginNameByModel(modelName string) string

func LoadConfig added in v0.8.0

func LoadConfig() error

func RemoveConnection added in v0.8.0

func RemoveConnection(key string) error

func RemoveDevice added in v0.8.0

func RemoveDevice(modelName string, deviceID string) error

func RemoveDeviceByID added in v0.8.0

func RemoveDeviceByID(id string) error

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 配置管理器接口

func New added in v0.8.0

func New() Manager

New 创建配置管理器实例

Jump to

Keyboard shortcuts

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