-
Notifications
You must be signed in to change notification settings - Fork 5
/
wolfGuiDescription.go
163 lines (153 loc) · 6.53 KB
/
wolfGuiDescription.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package main
import (
"github.com/jedib0t/go-pretty/table"
log "github.com/sirupsen/logrus"
"time"
)
/* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
type ParameterDescriptor struct {
ValueID int64 `json:"ValueId"`
SortID int `json:"SortId"`
SubBundleID int `json:"SubBundleId"`
ParameterID int64 `json:"ParameterId"`
IsReadOnly bool `json:"IsReadOnly"`
NoDataPoint bool `json:"NoDataPoint"`
IsExpertProtectable bool `json:"IsExpertProtectable"`
Name string `json:"Name"`
Group string `json:"Group"`
ProtGrp string `json:"ProtGrp,omitempty"`
ControlType int `json:"ControlType"`
Value string `json:"Value"`
ValueState int `json:"ValueState"`
HasDependentParameter bool `json:"HasDependentParameter"`
Unit string `json:"Unit,omitempty"`
Decimals int `json:"Decimals,omitempty"`
ListItems []struct {
Value string `json:"Value"`
DisplayText string `json:"DisplayText"`
IsSelectable bool `json:"IsSelectable"`
HighlightIfSelected bool `json:"HighlightIfSelected"`
} `json:"ListItems,omitempty"`
MinValueCondition string `json:"MinValueCondition,omitempty"`
MaxValueCondition string `json:"MaxValueCondition,omitempty"`
MinValue float64 `json:"MinValue,omitempty"`
MaxValue float64 `json:"MaxValue,omitempty"`
StepWidth float64 `json:"StepWidth,omitempty"`
ChildParameterDescriptors []struct {
ValueID int64 `json:"ValueId"`
SortID int `json:"SortId"`
SubBundleID int `json:"SubBundleId"`
ParameterID int64 `json:"ParameterId"`
IsReadOnly bool `json:"IsReadOnly"`
NoDataPoint bool `json:"NoDataPoint"`
IsExpertProtectable bool `json:"IsExpertProtectable"`
Name string `json:"Name"`
ControlType int `json:"ControlType"`
ValueState int `json:"ValueState"`
HasDependentParameter bool `json:"HasDependentParameter"`
ChildParameterDescriptors []struct {
ValueID int64 `json:"ValueId"`
SortID int `json:"SortId"`
SubBundleID int `json:"SubBundleId"`
ParameterID int64 `json:"ParameterId"`
IsReadOnly bool `json:"IsReadOnly"`
NoDataPoint bool `json:"NoDataPoint"`
IsExpertProtectable bool `json:"IsExpertProtectable"`
Name string `json:"Name"`
Group string `json:"Group"`
ControlType int `json:"ControlType"`
ValueState int `json:"ValueState"`
HasDependentParameter bool `json:"HasDependentParameter"`
Unit string `json:"Unit"`
MinValueCondition string `json:"MinValueCondition"`
MaxValueCondition string `json:"MaxValueCondition"`
MinValue float64 `json:"MinValue"`
MaxValue float64 `json:"MaxValue"`
StepWidth float64 `json:"StepWidth"`
Decimals int `json:"Decimals"`
} `json:"ChildParameterDescriptors"`
} `json:"ChildParameterDescriptors,omitempty"`
}
type GuiDescription struct {
MenuItems []struct {
Name string `json:"Name"`
SortID string `json:"SortId"`
SubMenuEntries []interface{} `json:"SubMenuEntries"`
ParameterNode bool `json:"ParameterNode"`
ImageName string `json:"ImageName"`
TabViews []struct {
IsExpertView bool `json:"IsExpertView"`
TabName string `json:"TabName"`
GuiID int `json:"GuiId"`
BundleID int `json:"BundleId"`
ParameterDescriptors []ParameterDescriptor `json:"ParameterDescriptors"`
ViewType int `json:"ViewType"`
SvgSchemaDeviceID int `json:"SvgSchemaDeviceId"`
GetValueLastAccess time.Time `json:"GetValueLastAccess"`
TabViewGroups []struct {
GroupName string `json:"GroupName"`
IsTitleEditable bool `json:"IsTitleEditable"`
} `json:"TabViewGroups"`
} `json:"TabViews"`
} `json:"MenuItems"`
DynFaultMessageDevices []interface{} `json:"DynFaultMessageDevices"`
SystemHasWRSClassicDevices bool `json:"SystemHasWRSClassicDevices"`
}
func getPollParams(d GuiDescription) []ParameterDescriptor {
var params []ParameterDescriptor
for _, menuItem := range d.MenuItems {
for _, tabView := range menuItem.TabViews {
for _, parmeterDescriptor := range tabView.ParameterDescriptors {
params = append(params, parmeterDescriptor)
}
}
}
return params
}
func printGuiParameters(d GuiDescription) {
t := table.NewWriter()
t.AppendHeader(table.Row{"Menu", "Tab", "ValueID", "ParameterID", "Name", "Group", "Unit", "Value", "(Options)"})
for _, menuItem := range d.MenuItems {
for _, tabView := range menuItem.TabViews {
for _, parameterDescriptor := range tabView.ParameterDescriptors {
t.AppendRow(table.Row{
menuItem.Name,
tabView.TabName,
parameterDescriptor.ValueID,
parameterDescriptor.ParameterID,
parameterDescriptor.Name,
parameterDescriptor.Group,
parameterDescriptor.Unit,
parameterDescriptor.Value,
"",
})
if parameterDescriptor.ListItems != nil {
for _, listItem := range parameterDescriptor.ListItems {
t.AppendRow(table.Row{
"-", "-", "-->", "-",
parameterDescriptor.Name,
"-",
"-",
"-",
listItem.Value + "-> " + listItem.DisplayText,
})
}
}
//ignoring ChildParameters, I've only seen this used
//for schedules which is not interesting for this applications
}
}
}
t.SetStyle(table.StyleLight)
log.Info("GUI Description:\n", t.Render())
}