-
Notifications
You must be signed in to change notification settings - Fork 0
/
szl.go
80 lines (67 loc) · 1.47 KB
/
szl.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
// Copyright 2024 shiyuecamus. All Rights Reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package core
import (
"encoding/json"
"github.com/shiyuecamus/gs7/common"
)
type Catalog struct {
OrderCode string
Version string
}
func (c Catalog) String() string {
bytes, _ := json.Marshal(c)
return string(bytes)
}
// UnitInfo unit info
type UnitInfo struct {
ModuleTypeName string
SerialNumber string
ASName string
Copyright string
ModuleName string
}
func (c UnitInfo) String() string {
bytes, _ := json.Marshal(c)
return string(bytes)
}
// CommunicationInfo communication info
type CommunicationInfo struct {
MaxPduLength int
MaxConnections int
MaxMpiRate int
MaxBusRate int
}
func (c CommunicationInfo) String() string {
bytes, _ := json.Marshal(c)
return string(bytes)
}
// ProtectionInfo protection info
type ProtectionInfo struct {
Level uint16
ParameterLevel common.ParameterProtectionLevel
CpuLevel common.CpuProtectionLevel
SelectorSetting common.SelectorSetting
StartupSwitch common.StartupSwitch
}
func (c ProtectionInfo) String() string {
bytes, _ := json.Marshal(c)
return string(bytes)
}
type PlcStatus byte
const (
PsUnknown PlcStatus = 0x00
PsRun = 0x08
PsStop = 0x04
)
func (c PlcStatus) String() string {
switch c {
case PsRun:
return "RUN"
case PsStop:
return "STOP"
default:
return "Unknown"
}
}