DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/TelemetryController.cs

61 lines
2.1 KiB
C#
Raw Normal View History

2021-04-07 18:01:56 +05:00
using AsbCloudApp.Data;
using AsbCloudApp.Services;
2021-04-08 17:54:02 +05:00
using AsbCloudWebApi.WebSocket;
2021-04-07 18:01:56 +05:00
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
2021-04-08 17:54:02 +05:00
using Microsoft.AspNetCore.SignalR;
2021-04-07 18:01:56 +05:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
/// <summary>
/// Контроллер сбора данных от буровых
/// </summary>
[Route("api/telemetry")]
[ApiController]
public class TelemetryController : ControllerBase
{
private readonly ITelemetryService telemetryService;
2021-04-08 17:54:02 +05:00
private readonly IHubContext<TelemetryHub> telemetryHubContext;
2021-04-07 18:01:56 +05:00
2021-04-08 17:54:02 +05:00
public TelemetryController(ITelemetryService telemetryService, IHubContext<TelemetryHub> telemetryHubContext)
2021-04-07 18:01:56 +05:00
{
this.telemetryService = telemetryService;
2021-04-08 17:54:02 +05:00
this.telemetryHubContext = telemetryHubContext;
2021-04-07 18:01:56 +05:00
}
/// <summary>
/// Принимает общую информацию по скважине
/// </summary>
2021-04-08 17:54:02 +05:00
/// <param name="uid">Уникальный идентификатор отправителя</param>
/// <param name="info">нформация об отправителе</param>
2021-04-07 18:01:56 +05:00
/// <returns></returns>
[HttpPost]
[Route("{uid}/info")]
public IActionResult Info(string uid, [FromBody] TelemetryInfoDto info)
{
telemetryService.UpdateInfo(uid, info);
return Ok();
}
/// <summary>
/// Принимает данные от разных систем по скважине
/// </summary>
2021-04-08 17:54:02 +05:00
/// <param name="uid">Уникальный идентификатор отправителя</param>
/// <param name="data">Данные</param>
2021-04-07 18:01:56 +05:00
/// <returns></returns>
[HttpPost]
[Route("{uid}/data")]
public IActionResult Data(string uid, [FromBody] TelemetryDataDto data)
{
telemetryService.UpdateData(uid, data);
2021-04-08 17:54:02 +05:00
//telemetryHubContext.Clients.Group("").
2021-04-07 18:01:56 +05:00
return Ok();
}
}
}