package nvcs import ( "fmt" "net/http" "time" "gat1400Exchange/config" "gat1400Exchange/pkg/logger" "github.com/gin-gonic/gin" ) /* 485平层传感器 + 485转以太网模块 */ type a3ElevatorData struct { Id string `json:"id"` Time string `json:"time"` Total int `json:"total"` Status int `json:"status"` Floor int `json:"floor"` } func a3WebServer() { r := gin.Default() r.POST("/", func(c *gin.Context) { var req a3ElevatorData err := c.BindJSON(&req) if err != nil { c.JSON(http.StatusBadRequest, nil) return } logger.Debug("Received A3 report data %+v", req) floor := fmt.Sprintf("%dF", req.Floor) var runState = ElevatorRunData{ Device: req.Id, Timestamp: time.Now().Unix(), Floor: floor, RunState: req.Status, } queue.put(runState) c.JSON(http.StatusOK, "ok") }) err := r.Run(fmt.Sprintf(":%s", config.NVCSConf.Port)) if err != nil { logger.Warn("Start NVCS WebServer error, %s", err.Error()) } }