-
Notifications
You must be signed in to change notification settings - Fork 6
/
xml.go
94 lines (81 loc) · 2.53 KB
/
xml.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import "encoding/xml"
type Channel struct {
DeviceID string `xml:"DeviceID"`
Name string `xml:"Name,omitempty"`
Manufacturer string `xml:"Manufacturer,omitempty"`
Model string `xml:"Model,omitempty"`
Owner string `xml:"Owner,omitempty"`
CivilCode string `xml:"CivilCode,omitempty"`
Block string `xml:"Block,omitempty"`
Address string `xml:"Address,omitempty"`
Parental string `xml:"Parental,omitempty"`
ParentID string `xml:"ParentID,omitempty"`
SafetyWay string `xml:"SafetyWay,omitempty"`
RegisterWay string `xml:"RegisterWay,omitempty"`
CertNum string `xml:"CertNum,omitempty"`
Certifiable string `xml:"Certifiable,omitempty"`
ErrCode string `xml:"ErrCode,omitempty"`
EndTime string `xml:"EndTime,omitempty"`
Secrecy string `xml:"Secrecy,omitempty"`
IPAddress string `xml:"IPAddress,omitempty"`
Port string `xml:"Port,omitempty"`
Password string `xml:"Password,omitempty"`
Status string `xml:"Status,omitempty"`
Longitude string `xml:"Longitude,omitempty"`
Latitude string `xml:"Latitude,omitempty"`
}
type BaseMessageGetter interface {
GetDeviceID() string
GetCmdType() string
GetSN() int
}
type BaseMessage struct {
CmdType string `xml:"CmdType"`
SN int `xml:"SN"`
DeviceID string `xml:"DeviceID"`
}
func (b BaseMessage) GetDeviceID() string {
return b.DeviceID
}
func (b BaseMessage) GetCmdType() string {
return b.CmdType
}
func (b BaseMessage) GetSN() int {
return b.SN
}
type DeviceList struct {
Num int `xml:"Num,attr"`
Devices []*Channel `xml:"Item"`
}
type ExtendedInfo struct {
Info string `xml:"Info,omitempty"`
}
type BaseResponse struct {
XMLName xml.Name `xml:"Response"`
BaseMessage
Result string `xml:"Result,omitempty"`
ExtendedInfo
}
type CatalogResponse struct {
BaseResponse
SumNum int `xml:"SumNum"`
DeviceList DeviceList `xml:"DeviceList"`
}
type DeviceInfoResponse struct {
BaseResponse
DeviceName string `xml:"DeviceName,omitempty"`
Manufacturer string `xml:"Manufacturer,omitempty"`
Model string `xml:"Model,omitempty"`
Firmware string `xml:"Firmware,omitempty"`
Channel string `xml:"Channel,omitempty"` //通道数
}
type DeviceStatusResponse struct {
BaseResponse
Online string `xml:"Online"` //ONLINE/OFFLINE
Status string `xml:"Status"` //OK/ERROR
Reason string `xml:"Reason"` //OK/ERROR
Encode string `xml:"Encode"` //ON/OFF
Record string `xml:"Record"` //ON/OFF
DeviceTime string `xml:"DeviceTime"`
}