@@ -66,8 +66,8 @@ func closeSerialPortWebHandler(w http.ResponseWriter, r *http.Request) {
66
66
}
67
67
}
68
68
69
- func currentVariablesWebHandler (w http.ResponseWriter , _ * http.Request ) {
70
- b , _ := json .Marshal (datapack .CurrentVariables )
69
+ func variableReadListWebHandler (w http.ResponseWriter , _ * http.Request ) {
70
+ b , _ := json .Marshal (datapack .VariableRead )
71
71
io .WriteString (w , string (b ))
72
72
}
73
73
@@ -84,12 +84,12 @@ func variableTypesWebHandler(w http.ResponseWriter, _ *http.Request) {
84
84
io .WriteString (w , string (b ))
85
85
}
86
86
87
- func variableAddWebHandler (w http.ResponseWriter , r * http.Request ) {
87
+ func variableReadAddWebHandler (w http.ResponseWriter , r * http.Request ) {
88
88
defer r .Body .Close ()
89
89
var newVariable datapack.VariableT
90
90
postData , _ := ioutil .ReadAll (r .Body )
91
91
if json .Unmarshal (postData , & newVariable ) == nil {
92
- for _ , v := range datapack .CurrentVariables .Variables {
92
+ for _ , v := range datapack .VariableRead .Variables {
93
93
if v .Addr == newVariable .Addr {
94
94
io .WriteString (w , "{\" status\" :23}" )
95
95
return
@@ -98,25 +98,25 @@ func variableAddWebHandler(w http.ResponseWriter, r *http.Request) {
98
98
if serialhandle .SerialSendCmd (datapack .ACT_SUBSCRIBE , newVariable ) != nil {
99
99
io .WriteString (w , "{\" status\" :22}" )
100
100
} else {
101
- datapack .CurrentVariables .Variables = append (datapack .CurrentVariables .Variables , newVariable )
101
+ datapack .VariableRead .Variables = append (datapack .VariableRead .Variables , newVariable )
102
102
io .WriteString (w , "{\" status\" :0}" )
103
103
}
104
104
} else {
105
105
io .WriteString (w , "{\" status\" :21}" )
106
106
}
107
107
}
108
108
109
- func variableDelWebHandler (w http.ResponseWriter , r * http.Request ) {
109
+ func variableReadDelWebHandler (w http.ResponseWriter , r * http.Request ) {
110
110
defer r .Body .Close ()
111
111
var oldVariable datapack.VariableT
112
112
postData , _ := ioutil .ReadAll (r .Body )
113
113
if json .Unmarshal (postData , & oldVariable ) == nil {
114
- for i , v := range datapack .CurrentVariables .Variables {
114
+ for i , v := range datapack .VariableRead .Variables {
115
115
if v .Addr == oldVariable .Addr {
116
116
if serialhandle .SerialSendCmd (datapack .ACT_UNSUBSCRIBE , oldVariable ) != nil {
117
117
io .WriteString (w , "{\" status\" :22}" )
118
118
} else {
119
- datapack .CurrentVariables .Variables = append (datapack .CurrentVariables .Variables [:i ], datapack .CurrentVariables .Variables [i + 1 :]... )
119
+ datapack .VariableRead .Variables = append (datapack .VariableRead .Variables [:i ], datapack .VariableRead .Variables [i + 1 :]... )
120
120
io .WriteString (w , "{\" status\" :0}" )
121
121
}
122
122
return
@@ -128,7 +128,7 @@ func variableDelWebHandler(w http.ResponseWriter, r *http.Request) {
128
128
io .WriteString (w , "{\" status\" :21}" )
129
129
}
130
130
131
- func variableModWebHandler (w http.ResponseWriter , r * http.Request ) {
131
+ func variableModiModWebHandler (w http.ResponseWriter , r * http.Request ) {
132
132
defer r .Body .Close ()
133
133
var modVariable datapack.VariableT
134
134
postData , _ := ioutil .ReadAll (r .Body )
@@ -143,32 +143,32 @@ func variableModWebHandler(w http.ResponseWriter, r *http.Request) {
143
143
}
144
144
}
145
145
146
- func variableModAddWebHandler (w http.ResponseWriter , r * http.Request ) {
146
+ func variableModiAddWebHandler (w http.ResponseWriter , r * http.Request ) {
147
147
defer r .Body .Close ()
148
148
var newVariable datapack.VariableT
149
149
postData , _ := ioutil .ReadAll (r .Body )
150
150
if json .Unmarshal (postData , & newVariable ) == nil {
151
- for _ , v := range datapack .ModVariables .Variables {
151
+ for _ , v := range datapack .VariableModi .Variables {
152
152
if v .Addr == newVariable .Addr {
153
153
io .WriteString (w , "{\" status\" :23}" )
154
154
return
155
155
}
156
156
}
157
- datapack .ModVariables .Variables = append (datapack .ModVariables .Variables , newVariable )
157
+ datapack .VariableModi .Variables = append (datapack .VariableModi .Variables , newVariable )
158
158
io .WriteString (w , "{\" status\" :0}" )
159
159
} else {
160
160
io .WriteString (w , "{\" status\" :21}" )
161
161
}
162
162
}
163
163
164
- func variableModDelWebHandler (w http.ResponseWriter , r * http.Request ) {
164
+ func variableModiDelWebHandler (w http.ResponseWriter , r * http.Request ) {
165
165
defer r .Body .Close ()
166
166
var oldVariable datapack.VariableT
167
167
postData , _ := ioutil .ReadAll (r .Body )
168
168
if json .Unmarshal (postData , & oldVariable ) == nil {
169
- for i , v := range datapack .ModVariables .Variables {
169
+ for i , v := range datapack .VariableModi .Variables {
170
170
if v .Addr == oldVariable .Addr {
171
- datapack .ModVariables .Variables = append (datapack .ModVariables .Variables [:i ], datapack .ModVariables .Variables [i + 1 :]... )
171
+ datapack .VariableModi .Variables = append (datapack .VariableModi .Variables [:i ], datapack .VariableModi .Variables [i + 1 :]... )
172
172
io .WriteString (w , "{\" status\" :0}" )
173
173
return
174
174
}
@@ -179,8 +179,8 @@ func variableModDelWebHandler(w http.ResponseWriter, r *http.Request) {
179
179
io .WriteString (w , "{\" status\" :21}" )
180
180
}
181
181
182
- func variableModListWebHandler (w http.ResponseWriter , _ * http.Request ) {
183
- b , _ := json .Marshal (datapack .ModVariables )
182
+ func variableModiListWebHandler (w http.ResponseWriter , _ * http.Request ) {
183
+ b , _ := json .Marshal (datapack .VariableModi )
184
184
io .WriteString (w , string (b ))
185
185
}
186
186
@@ -225,10 +225,10 @@ func fileConfigWebHandler(w http.ResponseWriter, r *http.Request) {
225
225
filehandle .Config .IsSaveDataAddr , _ = strconv .ParseBool (strings .Join (r .Form ["sda" ], "" ))
226
226
}
227
227
if _ , ok := r .Form ["svm" ]; ok {
228
- filehandle .Config .IsSaveVariablesToMod , _ = strconv .ParseBool (strings .Join (r .Form ["svm" ], "" ))
228
+ filehandle .Config .IsSaveVariableModi , _ = strconv .ParseBool (strings .Join (r .Form ["svm" ], "" ))
229
229
}
230
230
if _ , ok := r .Form ["svr" ]; ok {
231
- filehandle .Config .IsSaveVariablesToRead , _ = strconv .ParseBool (strings .Join (r .Form ["svr" ], "" ))
231
+ filehandle .Config .IsSaveVariableRead , _ = strconv .ParseBool (strings .Join (r .Form ["svr" ], "" ))
232
232
}
233
233
filehandle .SaveConfig ()
234
234
io .WriteString (w , "{\" status\" :0}" )
@@ -242,21 +242,21 @@ func Reg() {
242
242
go serialhandle .SerialTransmitThread ()
243
243
go serialhandle .SerialReceiveThread (rxBuff )
244
244
go serialhandle .SerialPraseThread (rxBuff , jsonWS )
245
- WebSocketHandler := makeWebSocketHandler (jsonWS )
245
+ webSocketHandler := makeWebSocketHandler (jsonWS )
246
246
http .HandleFunc ("/serial" , currentSerialPortWebHandler )
247
247
http .HandleFunc ("/serial/list" , listSerialPortsWebHandler )
248
248
http .HandleFunc ("/serial/open" , openSerialPortWebHandler )
249
249
http .HandleFunc ("/serial/close" , closeSerialPortWebHandler )
250
- http .HandleFunc ("/variable" , currentVariablesWebHandler )
251
250
http .HandleFunc ("/variable/types" , variableTypesWebHandler )
252
- http .HandleFunc ("/variable/add" , variableAddWebHandler )
253
- http .HandleFunc ("/variable/del" , variableDelWebHandler )
254
- http .HandleFunc ("/variable/mod" , variableModWebHandler )
255
- http .HandleFunc ("/variable/modadd" , variableModAddWebHandler )
256
- http .HandleFunc ("/variable/moddel" , variableModDelWebHandler )
257
- http .HandleFunc ("/variable/modlist" , variableModListWebHandler )
251
+ http .HandleFunc ("/variable-read/list" , variableReadListWebHandler )
252
+ http .HandleFunc ("/variable-read/add" , variableReadAddWebHandler )
253
+ http .HandleFunc ("/variable-read/del" , variableReadDelWebHandler )
254
+ http .HandleFunc ("/variable-modi/list" , variableModiListWebHandler )
255
+ http .HandleFunc ("/variable-modi/add" , variableModiAddWebHandler )
256
+ http .HandleFunc ("/variable-modi/del" , variableModiDelWebHandler )
257
+ http .HandleFunc ("/variable-modi/mod" , variableModiModWebHandler )
258
258
http .HandleFunc ("/file/upload" , fileUploadWebHandler )
259
259
http .HandleFunc ("/file/variables" , fileVariablesWebHandler )
260
260
http .HandleFunc ("/file/config" , fileConfigWebHandler )
261
- http .HandleFunc ("/ws" , WebSocketHandler )
261
+ http .HandleFunc ("/ws" , webSocketHandler )
262
262
}
0 commit comments