Documentation
¶
Overview ¶
Package config 核心配置
Index ¶
Constants ¶
View Source
const ( //资源文件存放目录 ENV_RESOURCE_PATH = "DRIVERBOX_RESOURCE_PATH" //http服务监听端口号 ENV_HTTP_LISTEN = "DRIVERBOX_HTTP_LISTEN" //UDP discover服务监听端口号 ENV_UDP_DISCOVER_LISTEN = "DRIVERBOX_UDP_DISCOVER_LISTEN" //日志文件存放路径 ENV_LOG_PATH = "DRIVERBOX_LOG_PATH" //是否虚拟设备模式: true:是,false:否 ENV_VIRTUAL = "DRIVERBOX_VIRTUAL" //场景联动配置存放目录 ENV_LINKEDGE_CONFIG_PATH = "EXPORT_LINKEDGE_CONFIG_PATH" //镜像设备功能是否可用 ENV_EXPORT_MIRROR_ENABLED = "EXPORT_MIRROR_ENABLED" //镜像设备功能是否可用 ENV_EXPORT_DISCOVER_ENABLED = "EXPORT_DISCOVER_ENABLED" //driver-box默认UI是否可用 ENV_EXPORT_UI_ENABLED = "EXPORT_UI_ENABLED" //driver-box llm-agent是否可用 ENV_EXPORT_LLM_AGENT_ENABLED = "EXPORT_LLM_AGENT_ENABLED" )
环境变量配置项
Variables ¶
View Source
var ( //实时上报,读到数据即触发 ReportMode_Real ReportMode = "realTime" //变化上报,同影子中数值不一致时才触发上报 ReportMode_Change ReportMode = "change" //只读 ReadWrite_R ReadWrite = "R" //只写 ReadWrite_W ReadWrite = "W" //读写 ReadWrite_RW ReadWrite = "RW" //点位类型:整型 ValueType_Int ValueType = "int" //点位类型:浮点型 ValueType_Float ValueType = "float" //点位类型:字符串 ValueType_String ValueType = "string" )
View Source
var ResourcePath = "./res"
资源文件目录
Functions ¶
Types ¶
type Config ¶
type Config struct {
// 设备模型
DeviceModels []DeviceModel `json:"deviceModels" validate:""`
// 连接配置
Connections map[string]interface{} `json:"connections" validate:""`
// 协议名称(通过协议名称区分连接模式:客户端、服务端)
ProtocolName string `json:"protocolName" validate:"required"`
// 配置唯一key,一般对应目录名称
Key string `json:"-" validate:"-"`
// contains filtered or unexported fields
}
Config 配置
func (Config) GetModelIndexes ¶ added in v0.8.0
GetModelIndexes 获取模型索引
func (Config) UpdateIndexAndClean ¶ added in v0.8.0
UpdateIndexAndClean 更新索引并清理无效数据 1. 更新模型、设备索引 2. 移除无效连接
type Device ¶
type Device struct {
// 设备 ID
ID string `json:"id" validate:"required"`
// 模型名称
ModelName string `json:"-" validate:"-"`
// 设备描述
Description string `json:"description" validate:"required"`
// 设备离线阈值,超过该时长没有收到数据视为离线
Ttl string `json:"ttl"`
//设备标签
Tags []string `json:"tags"`
// 连接 Key
ConnectionKey string `json:"connectionKey" validate:"required"`
// 协议参数
Properties map[string]string `json:"properties" validate:"-"`
//设备层驱动的引用
DriverKey string `json:"driverKey"`
}
Device 设备
type DeviceBusinessProp ¶ added in v0.8.0
type DeviceBusinessProp struct {
// SN 设备 SN
SN string
// ParentID 父设备 ID
ParentID string
// SystemID 所属系统 ID
SystemID string
}
DeviceBusinessProp 设备业务属性
type DeviceModel ¶
type DeviceModel struct {
ModelBase
// 模型点位列表
DevicePoints []PointMap `json:"devicePoints" validate:"required"`
// 设备列表
Devices []Device `json:"devices" validate:"required"`
// contains filtered or unexported fields
}
DeviceModel 设备模型
func (DeviceModel) GetDeviceIndexes ¶ added in v0.8.0
func (dm DeviceModel) GetDeviceIndexes() map[string]int
GetDeviceIndexes 获取设备索引
func (DeviceModel) ToModel ¶ added in v1.3.0
func (dm DeviceModel) ToModel() Model
type Metadata ¶ added in v1.4.0
type Metadata struct {
//网关序列号,用于唯一标识网关设备,通常由厂商提供
//示例值: "GW2023123456789"
//注意:
// 1. 序列号应与设备实物标签一致
// 2. 序列号格式通常为: 厂商代码(2字母) + 年份(4数字) + 序列号(6数字)
// 3. 序列号在系统内必须唯一,不可重复
SerialNo string `json:"serialNo"`
//产品型号,标识网关的硬件型号和规格
//示例值:
// - "GW1000": 基础型号,支持基础协议和功能
// - "GW2000": 高级型号,支持所有协议和扩展功能
//注意:
// 1. 型号决定了网关支持的功能和性能参数
// 2. 不同型号可能有不同的固件版本要求
Model string `json:"model"`
//厂商名称,标识网关的生产厂商
//示例值: "Huawei", "ZTE", "Cisco"
//注意:
// 1. 厂商名称应与官方注册名称一致
// 2. 用于区分不同厂商的设备兼容性和支持服务
Vendor string `json:"vendor"`
// 网关硬件唯一编号
HardwareSN string `json:"hardwareSn"`
// 集成电路卡识别码,即 SIM 卡卡号
ICCID string `json:"iccid"`
}
网关元数据
type ModelBase ¶
type ModelBase struct {
// 模型名称
Name string `json:"name" validate:"required"`
// 云端模型 ID
ModelID string `json:"modelId" validate:"required"`
// 模型描述
Description string `json:"description" validate:"required"`
//扩展属性
Attributes map[string]interface{} `json:"attributes"`
}
ModelBase 模型基础信息
type Point ¶
type Point struct {
// 点位名称
Name string `json:"name" validate:"required"`
// 点位描述
Description string `json:"description" validate:"required"`
// 值类型
ValueType ValueType `json:"valueType" validate:"required,oneof=int float string"`
// 读写模式
ReadWrite ReadWrite `json:"readWrite" validate:"required,oneof=R W RW"`
// 单位
Units string `json:"units" validate:"-"`
// 上报模式
ReportMode ReportMode `json:"reportMode" validate:"required"`
//数值精度
Scale float64 `json:"scale"`
//保留小数位数
Decimals int `json:"decimals"`
//点位枚举表
Enums []PointEnum `json:"enums"`
// 扩展参数
Extends map[string]interface{} `json:"-" validate:"-"`
}
Point 点位数据
type ReadPointsAction ¶
Click to show internal directories.
Click to hide internal directories.