-
Notifications
You must be signed in to change notification settings - Fork 11
/
fanuc.go
123 lines (107 loc) · 1.57 KB
/
fanuc.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package fanuc
import (
"fmt"
"strconv"
)
type Type uint
const (
Invalid Type = iota
Numreg
Posreg
Sreg
Ualm
Ain
Aout
Din
Dout
Flag
Gin
Gout
Rin
Rout
Sin
Sout
Uin
Uout
UserFrame
ToolFrame
JogFrame
)
var names = [...]string{
Numreg: "R",
Posreg: "PR",
Sreg: "SR",
Ualm: "UALM",
Ain: "AI",
Aout: "AO",
Din: "DI",
Dout: "DO",
Flag: "F",
Gin: "GI",
Gout: "GO",
Rin: "RI",
Rout: "RO",
Sin: "SI",
Sout: "SO",
Uin: "UI",
Uout: "UO",
ToolFrame: "UTOOL",
UserFrame: "UFRAME",
JogFrame: "JOG",
}
var verboseNames = [...]string{
Numreg: "Numeric Register",
Posreg: "Position Register",
Sreg: "String Register",
Ualm: "User Alarm",
Ain: "Analog Input",
Aout: "Analog Output",
Din: "Digital Input",
Dout: "Digital Output",
Flag: "Flag",
Gin: "Group Input",
Gout: "Group Output",
Rin: "Robot Input",
Rout: "Robot Output",
Sin: "SOP Input",
Sout: "SOP Output",
Uin: "UOP Input",
Uout: "UOP Output",
ToolFrame: "Tool Frame",
UserFrame: "User Frame",
JogFrame: "Jog Frame",
}
func (t Type) String() string {
s := ""
if 0 < t && t < Type(len(names)) {
s = names[t]
}
if s == "" {
s = "Invalid(" + strconv.Itoa(int(t)) + ")"
}
return s
}
func (t Type) VerboseName() string {
s := ""
if 0 < t && t < Type(len(verboseNames)) {
s = verboseNames[t]
}
if s == "" {
s = "Invalid(" + strconv.Itoa(int(t)) + ")"
}
return s
}
type device int
const (
MD device = iota
KAREL
)
func (d device) String() string {
switch d {
case MD:
return "MD"
case KAREL:
return "KAREL"
}
return fmt.Sprintf("device(%d)", d)
}