-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.go
67 lines (52 loc) · 1.17 KB
/
program.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
package main
import (
"encoding/json"
"net/http"
log "github.com/sirupsen/logrus"
)
var soilTypes map[int]string = map[int]string{
0: "None",
1: "Clay",
2: "Sand",
3: "Other",
}
// ProgramInfoHandler returns information about the request program
func ProgramInfoHandler(w http.ResponseWriter, r *http.Request) {
log.Info("Request Program Info")
response, err := rpcCommand("getProgramInfo", map[string]interface{}{})
if err != nil {
log.Error(err)
}
programSoilTypes := response.Result["SoilTypes"].([]interface{})
programs := map[int]map[string]interface{}{
0: {
"FlowRate": 0,
"FlowUnit": 0,
"SoilType": "",
},
1: {
"FlowRate": 0,
"FlowUnit": 0,
"SoilType": "",
},
2: {
"FlowRate": 0,
"FlowUnit": 0,
"SoilType": "",
},
3: {
"FlowRate": 0,
"FlowUnit": 0,
"SoilType": "",
},
}
//soilTypeList := make([]string, 0)
log.Debug(programSoilTypes)
for index, soilType := range programSoilTypes {
log.Debug(soilType)
soilTypeInt := int(soilType.(float64))
programs[index]["SoilType"] = soilTypes[soilTypeInt]
//soilTypeList = append(soilTypeList, soilTypes[index])
}
json.NewEncoder(w).Encode(programs)
}