fix: camera Pan-Tilt control
| | |
| | | - |
| | | value: 100 |
| | | color: '#5d0000' |
| | | ptzSpeed: 50 |
| | | database: |
| | | driver: sqlite |
| | | name: sqlite3 |
New file |
| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "basic.com/gb28181api.git" |
| | | |
| | | "webserver/extend/code" |
| | | "webserver/extend/config" |
| | | "webserver/extend/util" |
| | | |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type PanTiltZoomController struct { |
| | | } |
| | | |
| | | type PTZInstruct struct { |
| | | CameraId string `json:"cameraId"` //摄像机id |
| | | CameraType int `json:"cameraType"` //摄像机类型 |
| | | PTZType string `json:"ptzType"` //控制类型 left right top ... stop |
| | | } |
| | | |
| | | // @Summary 云台 |
| | | // @Description 摄像机云台控制 |
| | | // @Security ApiKeyAuth |
| | | // @Produce json |
| | | // @Tags camera |
| | | // @Param ptzBody body controllers.PTZInstruct true "控制类型:up,down,left,right,zoomin,zoomout,stop" |
| | | // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" |
| | | // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" |
| | | // @Router /data/api-v/camera/ptzControl [post] |
| | | func (ptz PanTiltZoomController) Move(c *gin.Context) { |
| | | var param PTZInstruct |
| | | if err := c.BindJSON(¶m); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数有误") |
| | | return |
| | | } |
| | | |
| | | ptzSpeed := config.Server.PTZSpeed |
| | | if ptzSpeed == 0 { |
| | | ptzSpeed = 50 |
| | | } |
| | | |
| | | if param.CameraType == 1 { |
| | | var api dbapi.SysSetApi |
| | | r, gb28182Config := api.Gb28181ConfigShow() |
| | | |
| | | if r { |
| | | conf, ok := gb28182Config.(map[string]interface{}) |
| | | if ok { |
| | | gb28181api.Init(conf["ServerIp"].(string), int(conf["ServerPort"].(float64))) |
| | | } else { |
| | | util.ResponseFormat(c, code.ComError, "国标配置读取失败") |
| | | return |
| | | } |
| | | |
| | | } else { |
| | | util.ResponseFormat(c, code.ComError, "国标接口查询失败") |
| | | return |
| | | } |
| | | |
| | | var gbApi gb28181api.Gb28181Api |
| | | if r := gbApi.SetCameraPtz(param.CameraId, param.PTZType, ptzSpeed); r { |
| | | util.ResponseFormat(c, code.Success, "") |
| | | } else { |
| | | util.ResponseFormat(c, code.Success, "国标接口操作失败") |
| | | } |
| | | } else { |
| | | util.ResponseFormat(c, code.Success, "不支持的摄像机类型") |
| | | } |
| | | } |
| | |
| | | ChannelCount string `mapstructure: "channelCount"` //通道个数 |
| | | DiskCount string `mapstructure: "diskCount"` //硬盘个数 |
| | | |
| | | SudoPassword string `mapstructure: "sudoPassword"` |
| | | SudoPassword string `mapstructure: "sudoPassword"` //系统密码 |
| | | SysThresholds []threshold `mapstructure: "sysThresholds"` |
| | | PTZSpeed int `mapstructure: "ptzSpeed"` // 云台移动速度 |
| | | } |
| | | |
| | | var Server = &server{} |
| | |
| | | func NTPConfig() (bool, string, string) { |
| | | status, server, interval := false, "", "" |
| | | |
| | | cron, _ := execRootCommand("crontab -l | grep ntpdate | sed -z -r 's/([^0-9* ]+)(.+)//g'") |
| | | cron, _ := execRootCommand("crontab -l | grep ntpdate | tr -d '\n'") |
| | | if task := string(cron); task != "" { |
| | | status = true |
| | | slice := strings.Split(task, " ") |
| | |
| | | sysMenuController := new(controllers.SysMenuController) |
| | | clusterController := new(controllers.ClusterController) |
| | | sysRoleController := new(controllers.RoleController) |
| | | ptController := new(controllers.PanTiltController) |
| | | ptzController := new(controllers.PanTiltZoomController) |
| | | |
| | | sysApi := r.Group("/data/api-u/sys") |
| | | { |
| | |
| | | camera.POST("/changeRunType", cameraController.ChangeRunType) |
| | | camera.GET("/getAllCamerasByServer", cameraController.GetAllCamerasByServer) |
| | | |
| | | camera.POST("/ptControl", ptController.Controlling) |
| | | camera.POST("/ptzControl", ptzController.Move) |
| | | camera.GET("/statisticRunInfo", cameraController.StatisticRunInfo) |
| | | } |
| | | |