add some debugging
This commit is contained in:
parent
5f8fcea155
commit
dc6936912e
7
main.go
7
main.go
|
|
@ -561,24 +561,31 @@ func WriteDatapoint(mytime int64, deveui string, devaddr string, v uint8, h uint
|
||||||
}
|
}
|
||||||
|
|
||||||
// minmax Alert
|
// minmax Alert
|
||||||
|
fmt.Println("debug minmax alert")
|
||||||
minmax := getDevMinmax(deveui)
|
minmax := getDevMinmax(deveui)
|
||||||
|
fmt.Printf("debug getDevMinmax: minmax = %s\n", minmax)
|
||||||
if minmax != "0,0" {
|
if minmax != "0,0" {
|
||||||
tokens := strings.Split(minmax, ",")
|
tokens := strings.Split(minmax, ",")
|
||||||
if len(tokens) == 2 {
|
if len(tokens) == 2 {
|
||||||
min, _ := strconv.ParseInt(tokens[0], 10, 32)
|
min, _ := strconv.ParseInt(tokens[0], 10, 32)
|
||||||
max, _ := strconv.ParseInt(tokens[1], 10, 32)
|
max, _ := strconv.ParseInt(tokens[1], 10, 32)
|
||||||
|
fmt.Printf("debug min: %d, max: %d\n", min, max)
|
||||||
minmaxstatus := GetMinMaxStatus(deveui)
|
minmaxstatus := GetMinMaxStatus(deveui)
|
||||||
|
fmt.Printf("debug minmaxstatus: %s\n", minmaxstatus)
|
||||||
if (w_gram < uint32(min)) && (minmaxstatus != "MINALERT") {
|
if (w_gram < uint32(min)) && (minmaxstatus != "MINALERT") {
|
||||||
|
fmt.Printf("debug minalert\n")
|
||||||
SetMinMaxStatus(deveui, "MINALERT")
|
SetMinMaxStatus(deveui, "MINALERT")
|
||||||
alertLogMap[deveui] = fmt.Sprintf("alert,deveui=%s reason=\"minmaxlarm\",w=%di,w_min=%di %d\n", deveui, w_gram, min, mytime*60*1000*1000*1000)
|
alertLogMap[deveui] = fmt.Sprintf("alert,deveui=%s reason=\"minmaxlarm\",w=%di,w_min=%di %d\n", deveui, w_gram, min, mytime*60*1000*1000*1000)
|
||||||
location, _ := time.LoadLocation("Europe/Zurich")
|
location, _ := time.LoadLocation("Europe/Zurich")
|
||||||
alertMap[deveui] = fmt.Sprintf("*** Min/Max-Alarm ***\n%s\n%s\nUnterschreiten des Minimalgewichts: %d g (Minimal: %d g)", getDevAlias(deveui), time.Unix(mytime*60, 0).In(location).Format("02.01.2006 15:04"), w_gram, min)
|
alertMap[deveui] = fmt.Sprintf("*** Min/Max-Alarm ***\n%s\n%s\nUnterschreiten des Minimalgewichts: %d g (Minimal: %d g)", getDevAlias(deveui), time.Unix(mytime*60, 0).In(location).Format("02.01.2006 15:04"), w_gram, min)
|
||||||
} else if (w_gram > uint32(max)) && (minmaxstatus != "MAXALERT") {
|
} else if (w_gram > uint32(max)) && (minmaxstatus != "MAXALERT") {
|
||||||
|
fmt.Printf("debug maxalert\n")
|
||||||
SetMinMaxStatus(deveui, "MAXALERT")
|
SetMinMaxStatus(deveui, "MAXALERT")
|
||||||
alertLogMap[deveui] = fmt.Sprintf("alert,deveui=%s reason=\"minmaxlarm\",w=%di,w_max=%di %d\n", deveui, w_gram, max, mytime*60*1000*1000*1000)
|
alertLogMap[deveui] = fmt.Sprintf("alert,deveui=%s reason=\"minmaxlarm\",w=%di,w_max=%di %d\n", deveui, w_gram, max, mytime*60*1000*1000*1000)
|
||||||
location, _ := time.LoadLocation("Europe/Zurich")
|
location, _ := time.LoadLocation("Europe/Zurich")
|
||||||
alertMap[deveui] = fmt.Sprintf("*** Min/Max-Alarm ***\n%s\n%s\nUeberschreiten des Maximalgewichts: %d g (Maximal: %d g)", getDevAlias(deveui), time.Unix(mytime*60, 0).In(location).Format("02.01.2006 15:04"), w_gram, max)
|
alertMap[deveui] = fmt.Sprintf("*** Min/Max-Alarm ***\n%s\n%s\nUeberschreiten des Maximalgewichts: %d g (Maximal: %d g)", getDevAlias(deveui), time.Unix(mytime*60, 0).In(location).Format("02.01.2006 15:04"), w_gram, max)
|
||||||
} else if (w_gram > uint32(min+100)) && (w_gram < uint32(max-100)) {
|
} else if (w_gram > uint32(min+100)) && (w_gram < uint32(max-100)) {
|
||||||
|
fmt.Printf("debug resettonormal\n")
|
||||||
SetMinMaxStatus(deveui, "NORMAL")
|
SetMinMaxStatus(deveui, "NORMAL")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue