om

package
v0.0.0-...-a554094 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_PORT          = 20300 // OM接口默认端口
	DEFAULT_READ_TIMEOUT  = 60    // OM接口默认读超时时间
	DEFAULT_WRITE_TIMEOUT = 10    // OM接口默认写超时时间

	DEFAULT_CERT = "" // OM接口默认认证密码
	/* 128-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func Decode

func Decode(reader io.Reader) (data []byte, err error)

func Encode

func Encode(cmd any) ([]byte, error)

func FormatOmPath

func FormatOmPath(path string) string

func FormatOmPathPrefix

func FormatOmPathPrefix(prefix string) string

func GetFaultCode

func GetFaultCode(code string) string

Types

type Class

type Class string

Class 定义OM接口的消息类型

const (
	CLS_NONE         Class = ""
	CLS_NAME         Class = "name"         // 节点名消息
	CLS_VALUE        Class = "value"        // 节点值消息
	CLS_OBJECT       Class = "object"       // 节点对象消息
	CLS_MODULE       Class = "module"       // 模块消息
	CLS_CERTIFICATE  Class = "certificate"  // 认证消息
	CLS_NOTIFICATION Class = "notification" // 通知消息
)

func (Class) IsLegal

func (own Class) IsLegal() bool

IsLegal 检查当前消息类型是否合法

func (Class) IsMatchCommand

func (own Class) IsMatchCommand(cmd Command) bool

IsMatchCommand 检查当前消息类型是否与指定命令匹配

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 定义OM接口的客户端结构

func NewClient

func NewClient(host string) *Client

NewClient 新建一个OM客户端

func (*Client) ADD

func (own *Client) ADD(object, argument string) error

ADD 添加节点

func (*Client) AUTH

func (own *Client) AUTH(cert string) error

AUTH 认证

func (*Client) Close

func (own *Client) Close() error

Close 关闭OM连接

func (*Client) Connect

func (own *Client) Connect(cert ...string) (err error)

Connect 连接到设备

func (*Client) DELETE

func (own *Client) DELETE(object, argument string) error

ADD 添加节点

func (*Client) FACTORY

func (own *Client) FACTORY(resetAll bool) error

FACTORY 重置设备后,重启设备

func (*Client) GET

func (own *Client) GET(params []string, prefix ...string) (map[string]string, error)

GET 查询,在同一个连接中,一个参数被修改后,查询时的响应命令为:notify,响应类型为:valueChange

func (*Client) INFORM

func (own *Client) INFORM(event InformEvent) error

INFORM 事件通知

func (*Client) REBOOT

func (own *Client) REBOOT() error

REBOOT 重启设备

func (*Client) RELOADSN

func (own *Client) RELOADSN() error

RELOADSN 重新加载设备序列号

func (*Client) RESET

func (own *Client) RESET(module string, action int) error

RESET 重置模块:0-重启模块;1-激活模块;2-去激活模块

func (*Client) Request

func (own *Client) Request(req any) (Response, error)

Request 发起OM请求,并接收响应

func (*Client) SET

func (own *Client) SET(params map[string]string, prefix ...string) error

SET 修改,在同一个连接中,同一个参数,只能被设置一次

func (*Client) WithPort

func (own *Client) WithPort(port int) *Client

WithPort 指定端口

func (*Client) WithPrint

func (own *Client) WithPrint() *Client

func (*Client) WithReadTimeout

func (own *Client) WithReadTimeout(timeout int) *Client

WithReadTimeout 指定读超时时间

func (*Client) WithWriteTimeout

func (own *Client) WithWriteTimeout(timeout int) *Client

WithWriteTimeout 指定写超时时间

type Command

type Command string

Command 定义OM接口的命令类型

const (
	CMD_GET       Command = "get"            // 查询命令
	CMD_SET       Command = "set"            // 修改命令
	CMD_ADD       Command = "add"            // 新增命令
	CMD_DELETE    Command = "delete"         // 删除命令
	CMD_REBOOT    Command = "reboot"         // 重启命令
	CMD_FACTORY   Command = "factory_reboot" // 初始化重启命令
	CMD_DOWNLOAD  Command = "download"       // 下载命令
	CMD_UPLOAD    Command = "upload"         // 上传命令
	CMD_RESET     Command = "reset"          // 模块重置命令
	CMD_INFORM    Command = "inform"         // 消息转发命令
	CMD_RELOAD_SN Command = "snReload"       // 重置SN命令
)

func (Command) IsLegal

func (own Command) IsLegal() bool

IsLegal 检查当前命令类型是否合法

func (Command) IsMatchClass

func (own Command) IsMatchClass(cls Class) bool

IsMatchClass 检查当前命令类型是否与指定消息匹配

type DownloadType

type DownloadType string

********************************************************************************************

const (
	DOWNLOAD_TYPE_1  DownloadType = "1 软件包"
	DOWNLOAD_TYPE_2  DownloadType = "2 配置文件"
	DOWNLOAD_TYPE_3  DownloadType = "3 普通文件"
	DOWNLOAD_TYPE_5  DownloadType = "5 Dt omcore log file"
	DOWNLOAD_TYPE_6  DownloadType = "6 Dt omkeeper log file"
	DOWNLOAD_TYPE_7  DownloadType = "7 Dt omproxy log file"
	DOWNLOAD_TYPE_8  DownloadType = "8 Dt proxy log file"
	DOWNLOAD_TYPE_9  DownloadType = "9 Dt atproxy log file"
	DOWNLOAD_TYPE_10 DownloadType = "10 Dt xds log file"
	DOWNLOAD_TYPE_11 DownloadType = "11 Dt all log file"
	DOWNLOAD_TYPE_12 DownloadType = "12 Data Model File"
	DOWNLOAD_TYPE_14 DownloadType = "14 Dt ordinary log file"
	DOWNLOAD_TYPE_15 DownloadType = "15 All configure File"
	DOWNLOAD_TYPE_18 DownloadType = "18 Dt Alarm Model File"
	DOWNLOAD_TYPE_19 DownloadType = "19 Dt Exception Model File"
	DOWNLOAD_TYPE_20 DownloadType = "20 Dt Alarm File"
	DOWNLOAD_TYPE_21 DownloadType = "21 Dt Exception File"
)

type InformEvent

type InformEvent string
const (
	INFORM_EVENT_1  InformEvent = "1 boot"
	INFORM_EVENT_2  InformEvent = "2 periodic"
	INFORM_EVENT_3  InformEvent = "3 scheduled"
	INFORM_EVENT_4  InformEvent = "4 value_change"
	INFORM_EVENT_6  InformEvent = "6 connection request"
	INFORM_EVENT_8  InformEvent = "8 diagnostics complete"
	INFORM_EVENT_13 InformEvent = "13 downLoad complete"
	INFORM_EVENT_14 InformEvent = "14 upload complete"
	INFORM_EVENT_15 InformEvent = "15 upgrade report"
)

type Request

type Request map[string]string

func (Request) GetClass

func (own Request) GetClass() Class

func (Request) GetCommand

func (own Request) GetCommand() Command

func (Request) String

func (own Request) String() string

type RequestDownloadFile

type RequestDownloadFile struct {
	Key       string       `json:"key"` // 文件唯一识别码
	Url       string       `json:"url"`
	FileType  DownloadType `json:"file_type"` // 文件类型
	FileSize  int64        `json:"file_size"`
	Username  string       `json:"username"`
	Password  string       `json:"password"`
	DelayTime int64        `json:"delay_time"`
}

********************************************************************************************

func (*RequestDownloadFile) Generate

func (own *RequestDownloadFile) Generate() map[string]any

func (*RequestDownloadFile) GetClass

func (own *RequestDownloadFile) GetClass() Class

func (*RequestDownloadFile) GetCommand

func (own *RequestDownloadFile) GetCommand() Command

type RequestUploadFile

type RequestUploadFile struct {
	Key       string     `json:"key"` // 文件唯一识别码
	Url       string     `json:"url"`
	FileType  UploadType `json:"file_type"` // 文件类型
	Username  string     `json:"username"`
	Password  string     `json:"password"`
	DelayTime int64      `json:"delay_time"`
	StartTime string     `json:"start_time"` // 告警异常上传时开始时间
	NumberDay int64      `json:"numberDay"`  // 告警异常上传几天的文件
}

********************************************************************************************

func (*RequestUploadFile) Generate

func (own *RequestUploadFile) Generate() map[string]any

func (*RequestUploadFile) GetClass

func (own *RequestUploadFile) GetClass() Class

func (*RequestUploadFile) GetCommand

func (own *RequestUploadFile) GetCommand() Command

type Response

type Response map[string]any

func (Response) IsStatusOk

func (own Response) IsStatusOk() bool

func (Response) String

func (own Response) String() string

type UploadType

type UploadType string

********************************************************************************************

const (
	UPLOAD_TYPE_1  UploadType = "1 Firmware Upgrade Image"
	UPLOAD_TYPE_2  UploadType = "2 Web Content"
	UPLOAD_TYPE_3  UploadType = "3 Vendor Configuration File"
	UPLOAD_TYPE_13 UploadType = "13 Work Order File"
	UPLOAD_TYPE_16 UploadType = "16 Dt Firmware Upgrade Uu"
	UPLOAD_TYPE_17 UploadType = "17 Dt Firmware Upgrade Hc"
)

Jump to

Keyboard shortcuts

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