model

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChildDeviceMessage

type ChildDeviceMessage struct {
	DeviceKey          string
	Timestamp          int64
	ChildDeviceKey     string
	ChildDeviceMessage Message
}

子设备消息结构体

type ChildDeviceMessageReply

type ChildDeviceMessageReply struct {
	DeviceKey          string
	MessageId          string
	ChildDeviceKey     string
	ChildDeviceMessage Message
}

子设备消息结构体

type Command

type Command struct {
	Name       string      `json:"name"`
	Argument   bool        `json:"argument"`
	Directives []Directive `json:"directives"`
}

Command 命令

type Common

type Common struct {
	H         Header
	DeviceKey string
	MessageId string
	Timestamp int64
}

通用的结构体

type DataPoint

type DataPoint struct {
	Value interface{} `json:"value"`
	Time  time.Time   `json:"time"`
}

type DataType

type DataType int

DataType 数据类型

const (
	//TypeNONE 空类型
	TypeNONE DataType = iota
	TypeBIT
	TypeBYTE
	TypeWORD
	TypeDWORD
	TypeQWORD
	TypeSHORT
	TypeINTEGER
	TypeLONG
	TypeFLOAT
	TypeDOUBLE
)

func (*DataType) Decode

func (dt *DataType) Decode(buf []byte, le bool, precision int) (val interface{}, err error)

Decode 解码

func (*DataType) Default

func (dt *DataType) Default() interface{}

func (*DataType) Encode

func (dt *DataType) Encode(value interface{}, le bool, precision int) []byte

Encode 编码

func (*DataType) MarshalJSON

func (dt *DataType) MarshalJSON() ([]byte, error)

MarshalJSON 序列化

func (*DataType) Normalize

func (dt *DataType) Normalize(val interface{}) interface{}

func (*DataType) Parse

func (dt *DataType) Parse(tp string) error

Parse 解析类型

func (*DataType) Size

func (dt *DataType) Size() int

Size 宽度

func (*DataType) String

func (dt *DataType) String() string

String 转化成字符串

func (*DataType) UnmarshalJSON

func (dt *DataType) UnmarshalJSON(buf []byte) error

UnmarshalJSON 解析

type DefaultDevice

type DefaultDevice struct {
	Station   int    `json:"station"`
	ProductId string `json:"product_id"`
}

type DefaultMessageType

type DefaultMessageType struct {
	ReturnTime string         `json:"return_time"`
	DataType   string         `json:"data_type"`
	DeviceKey  string         `json:"device_key"`
	Data       map[string]any `json:"data"`
}

设备上报的报文解析为平台统一的消息,消息体结构如下

type DefaultReportFormate

type DefaultReportFormate struct {
	Attr       map[string]interface{} `json:"attr"`
	DeviceId   string                 `json:"device_id"`
	ReturnTime string                 `json:"return_time"`
}

type DerivedMetadataMessage

type DerivedMetadataMessage struct {
	DeviceKey string
	Timestamp int64
	Metadata  string
	All       bool
}

设备元信息相关结构体

type Device

type Device struct {
	Id        uint64 `json:"id"`
	TunnelId  uint64 `json:"tunnel_id" boltholdIndex:"TunnelId"`
	ProductId string `json:"product_id"`

	Name    string `json:"name"`
	Station int    `json:"station"`

	Disabled bool      `json:"disabled"`
	Created  time.Time `json:"created" xorm:"created"`
}

Device 设备

type DeviceOfflineMessage

type DeviceOfflineMessage struct {
	DeviceKey string
	Timestamp int64
}

设备上线下线结构体

type DeviceOnlineMessage

type DeviceOnlineMessage struct {
	DeviceKey string
	Timestamp int64
}

设备上线下线结构体

type DeviceRegisterMessage

type DeviceRegisterMessage struct {
	DeviceKey string
	Timestamp int64
}

type Directive

type Directive struct {
	Point string  `json:"point"`
	Value float64 `json:"value"`
	Delay int64   `json:"delay"`

	//使用表达式
	Expression string `json:"expression,omitempty"`
}

Directive 指令

type EventMessage

type EventMessage struct {
	H         Header
	Event     string
	Data      any
	Timestamp int64
}

type FunctionInvokeMessage

type FunctionInvokeMessage struct {
	Common
	FunctionId string
	Inputs     []FunctionParameter
}

功能消息结构体

type FunctionInvokeMessageReply

type FunctionInvokeMessageReply struct {
	Common
	Success bool
	Output  any
}

功能消息结构体

type FunctionParameter

type FunctionParameter struct {
	Name  string
	Value any
}

功能消息结构体

type Header struct {
	Async                    bool `json:"async" desc:"是否异步"`
	Timeout                  int  `json:"timeout" desc:"超时时间,单位为毫秒"`
	FragMsgId                int  `json:"fragMsgId" desc:"分片主消息ID,为平台下发消息时的消息ID(messageId"`
	FragNum                  int  `json:"fragNum" desc:"分片总数"`
	FragPart                 int  `json:"fragPart" desc:"当前分片索引"`
	FragLast                 int  `` /* 184-byte string literal not displayed */
	KeepOnline               int  `` /* 144-byte string literal not displayed */
	KeepOnlineTimeoutSeconds int  `` /* 147-byte string literal not displayed */
	IgnoreStorage            int  `` /* 161-byte string literal not displayed */
	IgnoreLog                bool `json:"ignoreLog" desc:"不记录此消息的日志。如:设置为true,将不记录此消息的日志。"`
	MergeLatest              bool `` /* 164-byte string literal not displayed */
}

通用的结构体

type HeartBeatPacket

type HeartBeatPacket struct {
	Enable  bool   `json:"enable"`
	Timeout int64  `json:"timeout"`
	Regex   string `json:"regex,omitempty"`
	Hex     string `json:"hex,omitempty"`
	Text    string `json:"text,omitempty"`
	Length  int    `json:"length,omitempty"`
	// contains filtered or unexported fields
}

HeartBeatPacket 心跳包

func (*HeartBeatPacket) Check

func (p *HeartBeatPacket) Check(buf []byte) bool

Check 检查

type Message

type Message any

设备上线下线结构体

type Point

type Point struct {
	Name         string   `json:"name"`
	Label        string   `json:"label"`
	Unit         string   `json:"unit"`
	Type         DataType `json:"type"`
	LittleEndian bool     `json:"le"`
	Precision    int      `json:"precision"`
	Code         string   `json:"code"`
	Address      string   `json:"address"`
	Store        bool     `json:"store"`
}

Point 数据点

type Poller

type Poller struct {
	Disabled bool   `json:"disabled,omitempty"`
	Interval int    `json:"interval"`
	Code     string `json:"code"`
	Address  string `json:"address"`
	Length   int    `json:"length"`
}

Poller 采集器

type Product

type Product struct {
	Id           string   `json:"id" xorm:"pk"`
	Name         string   `json:"name"`
	Manufacturer string   `json:"manufacturer"` //厂家
	Version      string   `json:"version"`      //SEMVER
	Protocol     Protocol `json:"protocol"`

	Tags     []string   `json:"tags,omitempty"`
	Pollers  []*Poller  `json:"pollers"`
	Commands []*Command `json:"commands"`

	Created time.Time `json:"created" xorm:"created"`
}

Product 产品

type Protocol

type Protocol struct {
	Name    string                 `json:"name"`
	Options map[string]interface{} `json:"options"`
}

type ReadPropertyMessage

type ReadPropertyMessage struct {
	Common
	Properties []string
}

读取属性的消息结构体

type ReadPropertyMessageReply

type ReadPropertyMessageReply struct {
	Common
	Success    bool
	Properties map[string]any
}

读取属性的消息结构体

type RegisterPacket

type RegisterPacket struct {
	Regex  string `json:"regex,omitempty"`
	Length int    `json:"length,omitempty"`
	// contains filtered or unexported fields
}

RegisterPacket 注册包

func (*RegisterPacket) Check

func (p *RegisterPacket) Check(buf []byte) (deviceKey string, checkOk bool)

type ReportPropertyMessage

type ReportPropertyMessage struct {
	Common
	Properties map[string]any
}

写属性消息结构体

type Retry

type Retry struct {
	Enable  bool `json:"enable"`
	Timeout int  `json:"timeout"`
	Maximum int  `json:"maximum"`
}

type SerialOptions

type SerialOptions struct {
	Port     string `json:"port"`      // /dev/tty.usb.. COM1
	BaudRate uint   `json:"baud_rate"` //9600 ... 115200 ...
	DataBits uint   `json:"data_bits"` //5 6 7 8
	StopBits uint   `json:"stop_bits"` //1 2
	Parity   uint   `json:"parity"`    // 0:NONE 1:ODD 2:EVEN

}

SerialOptions 串口参数

type Server

type Server struct {
	Id        int               `json:"id"`
	Name      string            `json:"name"`
	Type      string            `json:"type"` //tcp udp
	Addr      string            `json:"addr"`
	Register  RegisterPacket    `json:"register"`
	Heartbeat HeartBeatPacket   `json:"heartbeat"`
	Options   map[string]string `json:"options"`
	Protocol  Protocol          `json:"protocol"`
	Devices   []DefaultDevice   `json:"devices"` //默认设备
	Disabled  bool              `json:"disabled"`
	Created   time.Time         `json:"created" xorm:"created"`
}

func (*Server) Open

func (s *Server) Open()

type Tunnel

type Tunnel struct {
	Id        uint64          `json:"id"`
	ServerId  int             `json:"server_id" boltholdIndex:"ServerId"`
	Name      string          `json:"name"`
	SN        string          `json:"sn" boltholdIndex:"Addr"`
	Type      string          `json:"type"` //serial tcp-client tcp-server udp-client udp-server server-tcp server-udp
	Addr      string          `json:"addr"`
	Remote    string          `json:"remote"`
	Retry     Retry           `json:"retry"`     //重试
	Heartbeat HeartBeatPacket `json:"heartbeat"` // 主要是检查设备的心跳,过滤掉心跳数据
	Serial    SerialOptions   `json:"serial"`    // 串口通信配置参数
	Protocol  Protocol        `json:"protocol"`  //协议配置,包含协议名称和配置
	//Devices   []DefaultDevice  `json:"devices"` //默认设备
	Disabled bool      `json:"disabled"`
	Last     time.Time `json:"last"`
	Created  time.Time `json:"created" xorm:"created"`
}

boltholdIndex 标签是嵌入式数据库 BoltDB 上面的query layer需要的一个特殊标记

Tunnel 通道模型

type TunnelEx

type TunnelEx struct {
	Tunnel  `xorm:"extends"`
	Running bool   `json:"running"`
	Online  bool   `json:"online"`
	Server  string `json:"server"`
}

func (*TunnelEx) TableName

func (tunnel *TunnelEx) TableName() string

type UpdateTagMessage

type UpdateTagMessage struct {
	DeviceKey string
	Timestamp int64
	// contains filtered or unexported fields
}

设备元信息相关结构体

type UpgradeFirmwareMessage

type UpgradeFirmwareMessage struct {
	DeviceKey  string
	Timestamp  int64
	Url        string
	Version    string
	Parameters map[string]any
	Sign       string
	SignMethod string
	FirmwareId string
	Size       float64
}

更新相关消息结构体

type UpgradeFirmwareMessageReply

type UpgradeFirmwareMessageReply struct {
	DeviceKey string
	Timestamp int64
	Success   bool
}

更新相关消息结构体

type UpgradeFirmwareProgressMessage

type UpgradeFirmwareProgressMessage struct {
	DeviceKey   string
	Progress    int
	Complete    bool
	Version     string
	Success     bool
	ErrorReason string
	FirmwareId  string
}

更新相关消息结构体

type WritePropertyMessage

type WritePropertyMessage struct {
	Common
	Properties map[string]any
}

写属性消息结构体

type WritePropertyMessageReply

type WritePropertyMessageReply struct {
	Common
	Success    bool
	Properties map[string]any
}

写属性消息结构体

Jump to

Keyboard shortcuts

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