package controllers import ( "basic.com/gb28181api.git" "basic.com/valib/bhomeclient.git" "basic.com/valib/bhomedbapi.git" "vamicro/config" ) 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 // @Accept json // @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(h *bhomeclient.WrapperHandler, c *bhomeclient.Request) *bhomeclient.Reply{ var param PTZInstruct if err := c.BindJSON(¶m); err != nil { return &bhomeclient.Reply{Success:false, Msg: "参数有误"} } ptzSpeed := config.Server.PTZSpeed if ptzSpeed == 0 { ptzSpeed = 50 } if param.CameraType == 1 { var api bhomedbapi.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 { return &bhomeclient.Reply{Success:false, Msg: "国标配置读取失败"} } } else { return &bhomeclient.Reply{Success:false, Msg: "国标接口查询失败"} } var gbApi gb28181api.Gb28181Api if r := gbApi.SetCameraPtz(param.CameraId, param.PTZType, ptzSpeed); r { return &bhomeclient.Reply{Success:true, Msg: "配置成功"} } else { return &bhomeclient.Reply{Success:true, Msg: "国标接口操作失败"} } } else { return &bhomeclient.Reply{Success:true, Msg: "不支持的摄像机类型"} } }