You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/IoTNode/DeviceServices/Onvif/Controllers/OnvifController.cs

133 lines
4.4 KiB

using Application.Models;
using IoTNode.DeviceServices.Onvif;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
namespace IoTNode.Controllers
{
[SwaggerTag("摄像头")]
public class OnvifController : BaseDeviceController
{
private readonly OnvifService _deviceService;
public OnvifController(IServiceProvider applicationServices, OnvifService deviceService) : base(applicationServices)
{
this._deviceService = deviceService;
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse ScreenShot([SwaggerParameter("设备编号")]string number)
{
return this.Action(() =>
{
var data = this._deviceService.ScreenShot(number);
return new ApiResponse
{
code = 0,
format = "image/jpeg",
data = data
};
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Up([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Up(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Down([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Down(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Left([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Left(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Right([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Right(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Zoomin([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.ZoomIn(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Zoomout([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.ZoomOut(number, 0.5f);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Stop([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.Stop(number);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StartPush([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetPush(number, true);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StopPush([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetPush(number, false);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StartRecord([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetRecord(number, true);
});
}
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StopRecord([SwaggerParameter("设备编号")]string number)
{
return this.AsyncAction(() =>
{
this._deviceService.SetRecord(number, false);
});
}
}
}