model

package
v0.0.0-...-91c7ab2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PS_Running = "running"
	PS_Stopped = "stopped"
)
View Source
const (
	EVENT_LINKUP    = "EVENT_LINKUP"    // 设备接入
	EVENT_LINKDOWN  = "EVNET_LINKDOWN"  // 设备离线
	EVENT_SYS_ALARM = "EVENT_SYS_ALARM" // 设备事件上报

	CMD_SYS_UPGRADE    = "CMD_SYS_UPGRADE"    // 设备升级
	REP_SYS_STATUS     = "REP_SYS_STATUS"     // 设备状态上报
	CMD_SYS_STATUS     = "CMD_SYS_STATUS"     // 设备状态查询
	CMD_INFO_QUERY     = "CMD_INFO_QUERY"     // 设备信息查询
	CMD_SYS_SET_CONFIG = "CMD_SYS_SET_CONFIG" // 设备管理参数修改
	CMD_DATETIME_SYN   = "CMD_DATETIME_SYN"   // 设备请求时间同步
	CMD_SYS_LOG        = "CMD_SYS_LOG"        // 设备日志召回
	CMD_TOPO_ADD       = "CMD_TOPO_ADD"       // 添加端设备
	CMD_TOPO_DEL       = "CMD_TOPO_DEL"       // 删除端设备
	CMD_TOPO_UPDATE    = "CMD_TOPO_UPDATE"    // 更新端设备状态

	CMD_CON_INSTALL    = "CMD_CON_INSTALL"    // 容器安装控制命令
	CMD_CON_UPGRADE    = "CMD_CON_UPGRADE"    // 容器升级控制命令
	CMD_CON_START      = "CMD_CON_START"      // 容器启动控制命令
	CMD_CON_STOP       = "CMD_CON_STOP"       // 容器停止命令
	CMD_CON_REMOVE     = "CMD_CON_REMOVE"     // 容器删除控制命令
	CMD_CON_SET_CONFIG = "CMD_CON_SET_CONFIG" // 容器配置修改命令
	CMD_CON_GET_CONFIG = "CMD_CON_GET_CONFIG" // 容器配置查询命令
	CMD_CON_STATUS     = "CMD_CON_STATUS"     // 容器状态查询命令
	CMD_CON_LOG        = "CMD_CON_LOG"        // 容器日志召回命令
	REP_CON_STATUS     = "REP_CON_STATUS"     // 容器状态上报
	EVENT_CON_ALARM    = "EVENT_CON_ALARM"    // 容器事件上报

	CMD_APP_INSTALL    = "CMD_APP_INSTALL"    // 应用安装
	CMD_APP_UPGRADE    = "CMD_APP_UPGRADE"    // 应用升级
	CMD_APP_START      = "CMD_APP_START"      // 应用启动
	CMD_APP_STOP       = "CMD_APP_STOP"       // 应用停止
	CMD_APP_REMOVE     = "CMD_APP_REMOVE"     // 应用卸载
	CMD_APP_ENABLE     = "CMD_APP_ENABLE"     // 应用使能
	CMD_APP_UNENABLE   = "CMD_APP_UNENABLE"   // 应用去使能
	CMD_APP_STATUS     = "CMD_APP_STATUS"     // 应用状态查询
	CMD_APP_SET_CONFIG = "CMD_APP_SET_CONFIG" // 应用资源配置修改
	CMD_APP_GET_CONFIG = "CMD_APP_GET_CONFIG" // 应用资源配置查询
	CMD_APP_LOG        = "CMD_APP_LOG"        // 应用日志召回命令
	REP_APP_STATUS     = "REP_APP_STATUS"     // 应用状态上报
	EVENT_APP_ALARM    = "EVENT_APP_ALARM"    // 应用事件上报

	CMD_STATUS_QUERY = "CMD_STATUS_QUERY" // 升级状态查询
	REP_JOB_RESULT   = "REP_JOB_RESULT"   // 升级结果上报

	REP_DATA    = "REP_DATA"    // 业务数据上报
	EVENT_DATA  = "EVENT_DATA"  // 业务事件上报
	CMD_SERVICE = "CMD_SERVICE" // 业务命令下发
	CMD_RPC     = "CMD_RPC"     // 数据获取
)
View Source
const (
	TopicInvalid   = ""
	TopicDevice    = "device"
	TopicService   = "service"
	TopicContainer = "container"
	TopicApp       = "app"
	TopicTopo      = "topo"
)
View Source
const (
	//TopicTemplate_Device_Command DOWN;用于物联管理平台向边设备发送设备控制命令,如设备升级、控制设备等
	TopicTemplate_Device_Command  = "/{{ .Version }}/{{ .ID }}/device/command"  //DOWN;用于物联管理平台向边设备发送设备控制命令,如设备升级、控制设备等
	TopicTemplate_Device_Reply    = "/{{ .Version }}/{{ .ID }}/device/reply"    //UP;用于对物联管理平台发送的设备控制命令的响应
	TopicTemplate_Device_Request  = "/{{ .Version }}/{{ .ID }}/device/request"  //UP;用于边设备向物联管理平台发送设备管理相关的请求命令,如请求连接等
	TopicTemplate_Device_Response = "/{{ .Version }}/{{ .ID }}/device/response" //DOWN;用于对边设备发送的设备管理相关的请求命令的响应
	TopicTemplate_Device_Data     = "/{{ .Version }}/{{ .ID }}/device/data"     //UP;用于边设备向物联管理平台主动上报设备相关的状态、事件等
)

设备管理

View Source
const (
	TopicTemplate_Topo_Request      = "/{{ .Version }}/{{ .ID }}/topo/request"      //UP;用于边设备向物联管理平台发送拓扑信息的请求命令
	TopicTemplate_Topo_Response     = "/{{ .Version }}/{{ .ID }}/topo/response"     //DOWN;用于对边设备发送的拓扑信息的请求命令的响应
	TopicTemplate_Container_Command = "/{{ .Version }}/{{ .ID }}/container/command" //DOWN;用于物联管理平台向边设备发送的容器控制请求命令,如容器安装、启动、停止等
	TopicTemplate_Container_Reply   = "/{{ .Version }}/{{ .ID }}/container/reply"   //UP;用于对物联管理平台的容器控制请求命令的响应
	TopicTemplate_Container_Data    = "/{{ .Version }}/{{ .ID }}/container/data"    //UP;用于边设备向物联管理平台主动上报容器相关的状态、事件等
)

容器管理

View Source
const (
	TopicTemplate_App_Command = "/{{ .Version }}/{{ .ID }}/app/command" //DOWN;用于物联管理平台向边设备发送应用控制请求命令,如应用安装、启动、停止等
	TopicTemplate_App_Reply   = "/{{ .Version }}/{{ .ID }}/app/reply"   //UP;用于对物联管理平台发送的应用控制请求命令的响应
	TopicTemplate_App_Data    = "/{{ .Version }}/{{ .ID }}/app/data"    //UP; 用于边设备向物联管理平台主动上报应用相关的状态、事件等
)

应用管理

View Source
const (
	TopicTemplate_Service_Command  = "/{{ .Version }}/{{ .ID }}/service/command"  //DOWN;用于物联管理向边设备发送业务交互请求命令
	TopicTemplate_Service_Reply    = "/{{ .Version }}/{{ .ID }}/service/reply"    //UP;用于对物联管理的业务交互请求命令的响应
	TopicTemplate_Service_Data     = "/{{ .Version }}/{{ .ID }}/service/data"     //UP;用于边设备向物联管理平台主动上报业务相关的数据
	TopicTemplate_Service_Event    = "/{{ .Version }}/{{ .ID }}/service/event"    //UP;用于边设备向物联管理平台主动上报业务相关的事件
	TopicTemplate_Service_File     = "/{{ .Version }}/{{ .ID }}/service/file"     //UP;用于边设备向物联管理平台上报业务、事件等文件传输的元信息
	TopicTemplate_Service_Request  = "/{{ .Version }}/{{ .ID }}/service/request"  //DOWN;用于物联管理向边设备发送请求
	TopicTemplate_Service_Response = "/{{ .Version }}/{{ .ID }}/service/response" //UP;用于边设备响应物联管理平台的请求
)

业务交互

Variables

This section is empty.

Functions

func RegisterMessage

func RegisterMessage(tt TopicType, mt MessageType, desc string, publishTopic, subscribeTopic TopicTemplate)

Types

type AppConfig

type AppConfig struct {
	Cpu int
	Mem UM

	CpuLmt UP
	MemLmt UP
}

type AppInfo

type AppInfo struct {
	ContainerName string
	AppName       string
	AppVersion    string
	AppHash       string
}

type AppStatus

type AppStatus struct {
	ProcessList []ProcessStatus
	CreatedTime time.Time
	StartedTime time.Time
	LifeTime    time.Duration
}

type ContainerConfig

type ContainerConfig struct {
	Cpus int `json:"cpus"`
	Mem  UM  `json:"mem"`
	Disk UM  `json:"disk"`

	CpusLmt UP `json:"cpus_lmt"`
	MemLmt  UP `json:"mem_lmt"`
	DiskLmt UP `json:"disk_lmt"`

	Port        string
	Mount       []string    // 映射的本地文件目录资源配置参数
	Dev         []string    // 映射的本地文件目录资源配置参数
	NetworkMode NetworkMode // 网络模式,缺省值为bridge
	Env         string      `json:"env"` // 容器环境变量
}

type ContainerInfo

type ContainerInfo struct {
	ImageName     string `json:"image_name"`
	ImageTag      string `json:"image_tag"`
	ContainerName string `json:"container_name"`
}

type ContainerState

type ContainerState string
const (
	ContainerRunning ContainerState = "running"
	ContainerStopped ContainerState = "stopped"
	ContainerDelete  ContainerState = "delete"
)

type ContainerStatus

type ContainerStatus struct {
	State    ContainerState `json:"state"`
	CpuUsed  UP             `json:"cpu_used"`
	MemUsed  UP             `json:"mem_used"`
	DiskUsed UP             `json:"disk_used"`
	Ip       string         `json:"ip"`
	Created  time.Time      `json:"created"`
	Started  time.Time      `json:"started"`
	LifeTime time.Duration  `json:"life_time"`
}

type CpuInfo

type CpuInfo struct {
	Cpus  int    `json:"cpus"`            //CPU核数
	MHz   UM     `json:"frequency"`       //CPU主频MHz为单位
	Cache UM     `json:"cache,omitempty"` // CPU缓存以MB/核为单位
	Arch  string `json:"arch,omitempty"`  // CPU架构
}

type DevInfo

type DevInfo struct {
	DevSN   string `json:"devSN"`             //边设备序列号(厂家自定义)
	EdgeID  string `json:"edgeID"`            //物联平台边设备id
	DevType string `json:"devType,omitempty"` //边设备类型
	DevName string `json:"devName"`           //边设备名称(厂家自定义)
	MfgInfo string `json:"mfgInfo"`           //边设备厂商信息(工商全称)
	MfgCode string `json:"mfgCode"`           // 边设备厂商
}

type DeviceStatus

type DeviceStatus string
const (
	OFFLINE DeviceStatus = "OFFLINE" // 设备离线
	ONLINE  DeviceStatus = "ONLINE"  // 设备在线
)

type DiskInfo

type DiskInfo struct {
	Disk UM `json:"disk"` //磁盘空间,以 M 为单位
}

type DistroType

type DistroType string
const (
	Os_Distro_Ubunut      DistroType = "Ubunut"
	Os_Distro_Redhat      DistroType = "Redhat"
	Os_Distro_Centos      DistroType = "CentOS"
	Os_Distro_PCLinuxOs   DistroType = "PCLinuxOS"
	Os_Distro_OpenSUSE    DistroType = "openSUSE"
	Os_Distro_Mandriva    DistroType = "Mandriva"
	Os_Distro_Puppy_Linux DistroType = "Puppy Linux"
)

type EventType

type EventType int
const (
	SysCpuExceedAlarm            EventType = 1001 // cpu利用率超过阀值
	SysCpuExceedRecovered        EventType = 1002 // cpu利用率超过阀值恢复
	SysMemExceedAlarm            EventType = 1003 // 内存使用率超过阀值
	SysMemExceedRecovered        EventType = 1004 // 内存使用率超过阀值恢复
	SysDiskExceedAlarm           EventType = 1005 // 磁盘空间使用率超过阀值
	SysOpeningIllegalPort        EventType = 2001 // 开放非法端口
	SysOutgoingNetworkConnection EventType = 2002 // 网络外联事件
	SysUSBIllegalInserted        EventType = 2003 // USB存储设备非法插入
	SysSerialPortOccupancy       EventType = 2004 // 串口占用
	SysFanStop                   EventType = 3001 // 散热风扇停止运行
	SysOutDeviceException        EventType = 3002 // 外接装置异常
	SysTempHighExceed            EventType = 3003 // 超高温
	SysTempHighExceedRecovered   EventType = 3004 // 超高温回复
	SysTempLowExceed             EventType = 3005 // 超低温
	SysTempLowExceedRecovered    EventType = 3006 // 超低温恢复
	SysPowerFailure              EventType = 3007 // 掉电
	SysUpperCoverOpens           EventType = 3008 // 上盖开盖
	SysTerminalCoverOpens        EventType = 3009 // 端盖开盖
	SysComposeRestart            EventType = 3010 // 重要组件异常重启
	SysSystemRestart             EventType = 3011 // 终端重启上报

	ContCpuExceedAlarm     EventType = 4001 // cpu利用率超过阀值
	ContCpuExceedRecovered EventType = 4002 // cpu利用率超过阀值恢复
	ContMemExceedAlarm     EventType = 4003 // 内存使用率超过阀值
	ContMemExceedRecovered EventType = 4004 // 内存使用率超过阀值恢复
	ContDiskExceedAlarm    EventType = 4005 // 磁盘空间使用率超过阀值
	ContRestart            EventType = 4006 // 容器异常重启
	ContFault              EventType = 4007 // 容器故障

	AppCpuExceedAlarm     EventType = 5001 // cpu利用率超过阀值
	AppCpuExceedRecovered EventType = 5002 // cpu利用率超过阀值恢复
	AppMemExceedAlarm     EventType = 5003 // 内存使用率超过阀值
	AppMemExceedRecovered EventType = 5004 // 内存使用率超过阀值恢复
	AppUpgrade            EventType = 5005 // 应用升级
	AppRestart            EventType = 5006 // App异常重启
)

type LinkEnable

type LinkEnable string
const (
	LinkUp   LinkEnable = "up"
	LinkDown LinkEnable = "down"
)

type LinkInfo

type LinkInfo struct {
	Type LinkType `json:"type"`          //接口的类型,如以太网口、4G、“Ethernet”、”4G”
	ID   string   `json:"id,omitempty"`  //接口的 ID,主要用于 HPLC 和 4G 等外部模块
	Name string   `json:"name"`          //接口的名称如为以太网口、4G,则形如 “eth1”、 ”ppp-0”
	Mac  string   `json:"mac,omitempty"` //如接口为以太网、4G,则添加 mac地址,形如 “B8-85-74-15-A5-3E”
}

type LinkState

type LinkState struct {
	Name   LinkType   `json:"name"`
	Status LinkEnable `json:"status"`
}

type LinkType

type LinkType string
const (
	Eth   LinkType = "Ethernet"
	SIM4G LinkType = "4G"
)

type LocationInfo

type LocationInfo struct {
	Longitude string // 地理位置信息经度
	Latitude  string // 地址位置信息纬度
}

type LogType

type LogType uint8
const (
	LogType_All       LogType = 0 // 全部类型日志
	LogType_System    LogType = 1 // 系统日志
	LogType_Operation LogType = 2 // 操作日志
	LogType_Secure    LogType = 3 //  安全日志
	LogType_Driver    LogType = 4 // 驱动日志
	LogType_Broker    LogType = 5 // broker日志
	LogType_Audit     LogType = 6 // 审计日志
	LogType_Debug     LogType = 7 // 调试日志
	LogType_Extend    LogType = 8 // 扩展日志
)

type MemInfo

type MemInfo struct {
	Phy  UM `json:"phy"`            //物理内存,以 M 为单位
	Virt UM `json:"virt,omitempty"` //虚拟内存,以 M 为单位
}

type Message

type Message struct {
	Desc           string
	TopicType      TopicType
	MessageType    MessageType
	PublishTopic   TopicTemplate
	SubscribeTopic TopicTemplate
}

func GetAllMessage

func GetAllMessage() []Message

func GetMessage

func GetMessage(tt TopicType, mt MessageType) Message

type MessageType

type MessageType string

type NetworkMode

type NetworkMode string
const (
	NMHost   NetworkMode = "host"
	NMBridge NetworkMode = "bridge"
	NMNone   NetworkMode = "none"
)

type OnSysSetConfigHandler

type OnSysSetConfigHandler func(SystemConfig) error

type OsInfo

type OsInfo struct {
	Distro      DistroType `json:"distro"`      //操作系统名称
	Version     string     `json:"version"`     //操作系统版本,如“18.10”
	Kernel      string     `json:"kernel"`      //操作系统内核,如“3.10-17”
	SoftVersion string     `json:"softVersion"` //平台软件组件版本,如“V01.024
}

type ProcessState

type ProcessState string

type ProcessStatus

type ProcessStatus struct {
	ProcessName string // 进程名称
	Enable      bool
	State       ProcessState
	CpuUsed     UP
	MemUsed     UP
	StartTime   time.Time
}

type RepPeriod

type RepPeriod struct {
	DevPeriod time.Duration // 终端状态主动上报的时间间隔
	ConPeriod time.Duration // 容器状态主动上报的时间间隔
	AppPeriod time.Duration // APP状态主动上报的时间间隔
}

type ResponseCode

type ResponseCode int
const (
	ResponseCode_Successful              ResponseCode = 200 //请求成功
	ResponseCode_ReqAcceptedAndInProcess ResponseCode = 202 //请求被接受,但是服务器未处理完
	ResponseCode_ReqFail                 ResponseCode = 400 //请求失败
	ResponseCode_AuthFail                ResponseCode = 401 //认证失败
	ResponseCode_ReqRefused              ResponseCode = 403 //请求被拒绝
	ResponseCode_ResourcesNotExist       ResponseCode = 404 //请求资源不存在
	ResponseCode_OtherErr                ResponseCode = 600 //其他错误
)

func (ResponseCode) String

func (r ResponseCode) String() string

type SystemConfig

type SystemConfig struct {
	CpuLmt    UP            `json:"cpuLmt"`    // CPU监控阀值
	MemLmt    UP            `json:"memLmt"`    // 内存监控阀值
	DiskLmt   UP            `json:"diskLmt"`   // 磁盘监控阀值
	RepPeriod RepPeriod     `json:"repPeriod"` // 状态主动上报的上报时间间隔
	DevPeriod time.Duration // 终端状态主动上报的时间间隔
	ConPeriod time.Duration // 容器状态主动上报的时间间隔
	AppPeriod time.Duration // APP状态主动上报的时间间隔
}

type TerminalInfo

type TerminalInfo struct {
	DeviceSN    string `json:"deviceSN"`          // 端设备唯一标识
	Name        string `json:"name"`              // 端设备名称
	Description string `json:"description"`       // 端设备描述
	MfgInfo     string `json:"mfgInfo"`           // 端设备厂商信息
	Model       string `json:"model"`             // 端设备型号
	ModelID     string `json:"modelId,omitempty"` // 端设备模型编号
}

type TopicTemplate

type TopicTemplate string

func (TopicTemplate) GenRealTopic

func (tt TopicTemplate) GenRealTopic(id, version string) string

type TopicType

type TopicType string

func GetTopicType

func GetTopicType(topic string) TopicType

type UCD

type UCD int // 摄氏度

type UG

type UG int64

type UM

type UM int64 // 兆

type UP

type UP int // 百分比

type UTMill

type UTMill int //  毫秒

type UTs

type UTs int // 秒

type UpgradeDeviceType

type UpgradeDeviceType uint8
const (
	UpgradeDeviceTypePatch      UpgradeDeviceType = 0 // 补丁升级
	UpgradeDeviceTypeFileSystem UpgradeDeviceType = 1 // 文件系统
	UpgradeDeviceTypeKernel     UpgradeDeviceType = 2 // 内核升级
)

type UpgradeState

type UpgradeState string
const (
	UpgradeState_Invalid      UpgradeState = "0"
	UpgradeState_WaitDownload UpgradeState = "1"
	UpgradeState_DownLoading  UpgradeState = "2"
	UpgradeState_WaitInstall  UpgradeState = "3"
	UpgradeState_Installing   UpgradeState = "4"
	UpgradeState_InstallDone  UpgradeState = "5"
	UpgradeState_Failed       UpgradeState = "6"
)

func (UpgradeState) Desc

func (s UpgradeState) Desc() string

func (UpgradeState) Int

func (s UpgradeState) Int() int

func (UpgradeState) String

func (s UpgradeState) String() string

Jump to

Keyboard shortcuts

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