-
Notifications
You must be signed in to change notification settings - Fork 4
/
dic_types.go
101 lines (89 loc) · 1.48 KB
/
dic_types.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
package canopen
import (
"github.com/angelodlfrtr/go-canopen/utils"
)
const (
DicVar byte = 0x07
DicArr byte = 0x08
DicRec byte = 0x09
)
const (
Boolean byte = 0x1
Integer8 byte = 0x2
Integer16 byte = 0x3
Integer32 byte = 0x4
Integer64 byte = 0x15
Unsigned8 byte = 0x5
Unsigned16 byte = 0x6
Unsigned32 byte = 0x7
Unsigned64 byte = 0x1b
Real32 byte = 0x8
Real64 byte = 0x11
VisibleString byte = 0x9
OctetString byte = 0xa
UnicodeString byte = 0xb
Domain byte = 0xf
)
func IsSignedType(t byte) bool {
return utils.ContainsByte([]byte{
Integer8,
Integer16,
Integer32,
Integer64,
}, t)
}
func IsUnsignedType(t byte) bool {
return utils.ContainsByte([]byte{
Unsigned8,
Unsigned16,
Unsigned32,
Unsigned64,
}, t)
}
func IsIntegerType(t byte) bool {
return utils.ContainsByte([]byte{
Unsigned8,
Unsigned16,
Unsigned32,
Unsigned64,
Integer8,
Integer16,
Integer32,
Integer64,
}, t)
}
func IsFloatType(t byte) bool {
return utils.ContainsByte([]byte{
Real32,
Real64,
}, t)
}
func IsNumberType(t byte) bool {
return utils.ContainsByte([]byte{
Unsigned8,
Unsigned16,
Unsigned32,
Unsigned64,
Integer8,
Integer16,
Integer32,
Integer64,
Real32,
Real64,
}, t)
}
func IsStringType(t byte) bool {
return utils.ContainsByte([]byte{
VisibleString,
OctetString,
UnicodeString,
}, t)
}
func IsDataType(t byte) bool {
return utils.ContainsByte([]byte{
VisibleString,
OctetString,
UnicodeString,
Domain,
}, t)
}