Trigger Type

This commit is contained in:
Supan Adit Pratama 2019-12-27 17:34:01 +07:00
parent 98ca740a7e
commit 8a8364da2c
2 changed files with 13 additions and 12 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/supanadit/geo-smart-system/model/tile38"
"log"
"net/http"
"strings"
)
func main() {
@ -86,7 +87,8 @@ func main() {
hookID := "HOOK-" + xid.New().String()
fmt.Printf("Set HOOK with ID : %s \n", hookID)
hookURL := "http://192.168.99.1:" + port + "/detection/call"
client.Do("SETHOOK", hookID, hookURL, "NEARBY", detection.Type, "FENCE", "DETECT", "enter", "COMMANDS", "set", "POINT", detection.Lat, detection.Lng)
trigger := strings.Join(detection.TriggerType, ",")
client.Do("SETHOOK", hookID, hookURL, "NEARBY", detection.Type, "FENCE", "DETECT", trigger, "COMMANDS", "set", "POINT", detection.Lat, detection.Lng)
var status map[string]interface{}
var httpStatus int
if err != nil {

View File

@ -1,18 +1,17 @@
package model
type Trigger string
// Trigger Type
const (
inside Trigger = "inside" // when an object is inside the specified area
outside Trigger = "outside" // when an object is outside the specified area
enter Trigger = "enter" // when an object that was not previously in the fence has entered the area
exit Trigger = "exit" // when an object that was previously in the fence has exited the area
cross Trigger = "cross" // when an object that was not previously in the fence has entered and exited the area
inside string = "inside" // when an object is inside the specified area
outside string = "outside" // when an object is outside the specified area
enter string = "enter" // when an object that was not previously in the fence has entered the area
exit string = "exit" // when an object that was previously in the fence has exited the area
cross string = "cross" // when an object that was not previously in the fence has entered and exited the area
)
type Detection struct {
Type string `json:"type"`
Lat string `json:"lat"`
Lng string `json:"lng"`
TriggerType []Trigger `json:"trigger_type"`
Type string `json:"type"`
Lat string `json:"lat"`
Lng string `json:"lng"`
TriggerType []string `json:"trigger"`
}