forked from IOT-DSA/sdk-dslink-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.go
112 lines (102 loc) · 3.08 KB
/
const.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
package dslink
import (
"fmt"
"strings"
)
// ValueType represents the type of value stored by the Node
type ValueType string
const (
// ValueBool indicates this value type is a boolean
ValueBool ValueType = "bool"
// ValueNum indicates this value type is a number (integer or double)
ValueNum ValueType = "num"
// ValueString indicates this value type is a String
ValueString ValueType = "string"
// ValueDynamic indicates this value type is of an undetermined type
ValueDynamic ValueType = "dynamic"
// ValueDynamic indicates this value type is a Map
ValueMap ValueType = "map"
// ValueDynamic indicates this value type is an Array
ValueArray ValueType = "array"
)
func GenerateEnumValue(options ...string) ValueType {
return ValueType(fmt.Sprintf("enum[%s]", strings.Join(options, ",")))
}
const (
ResultValues = "values"
ResultTable = "table"
ResultStream = "stream"
)
// PermType is the Permission type.
type PermType string
func (p PermType) Level() int {
switch p {
case PermNone:
return 0
case PermRead:
return 1
case PermWrite:
return 2
case PermConfig:
return 3
case PermNever:
return 4
default:
return -1
}
}
const (
// PermNone is permission none.
PermNone PermType = "none"
// PermRead is permission Read only
PermRead PermType = "read"
// PermWrite is permission write
PermWrite PermType = "write"
// PermConfig is permission config
PermConfig PermType = "config"
// PermNever is permission never
PermNever PermType = "never"
)
type NodeConfig string
const (
ConfigBase NodeConfig = "$base"
ConfigIs NodeConfig = "$is"
ConfigInterface NodeConfig = "$interface"
ConfigDisconnected NodeConfig = "$disconnectedTs"
ConfigPermission NodeConfig = "$permission"
ConfigPermissions NodeConfig = "$$permissions"
ConfigName NodeConfig = "$name"
ConfigType NodeConfig = "$type"
ConfigWritable NodeConfig = "$writable"
ConfigSetings NodeConfig = "$settings"
ConfigParams NodeConfig = "$params"
ConfigColumns NodeConfig = "$columns"
ConfigResult NodeConfig = "$result"
ConfigStreamMeta NodeConfig = "$streamMeta"
ConfigInvokable NodeConfig = "$invokable"
)
type ParamVal string
const (
// ParamName is the name of the parameter. Used in Invoke actions.
ParamName ParamVal = "name"
// ParamType is the type of the parameter. Used in Invoke actions.
ParamType ParamVal = "type"
// ParamDef is the default value of the parameter. Used in Invoke actions.
ParamDef ParamVal = "default"
// ParamEditor is the editor for the type. Used in Invoke actions.
ParamEditor ParamVal = "editor"
// ParamHolder is the placeholder for the value. Used in Invoke actions.
ParamHolder ParamVal = "placeholder"
// ParamDesc is the parameter description. Used in Invoke actions.
ParamDesc ParamVal = "description"
)
type MethodType string;
const (
MethodList MethodType = "list"
MethodSub MethodType = "subscribe"
MethodUnsub MethodType = "unsubscribe"
MethodClose MethodType = "close"
MethodSet MethodType = "set"
MethodRemove MethodType = "remove"
MethodInvoke MethodType = "invoke"
)