Refactor TelemetryData*dtos for smaller size.

Add protobuf.
This commit is contained in:
Фролов 2021-10-31 16:35:09 +05:00
parent e79cf9f5d1
commit 62a38aeeaf
6 changed files with 240 additions and 100 deletions

View File

@ -22,7 +22,7 @@ namespace AsbCloudApp.Data
/// 6 - "ПОДЪЕМ С ПРОРАБОТКОЙ"
/// 10 - "БЛОКИРОВКА"
/// </summary>
public int? Mode { get; set; }
public short? Mode { get; set; }
/// <summary>
/// telemetry id
@ -37,111 +37,111 @@ namespace AsbCloudApp.Data
/// <summary>
/// Глубина забоя
/// </summary>
public double? WellDepth { get; set; }
public float? WellDepth { get; set; }
/// <summary>
/// Глубина долта
/// </summary>
public double? BitDepth { get; set; }
public float? BitDepth { get; set; }
/// <summary>
/// Талевый блок. Положение
/// </summary>
public double? BlockPosition { get; set; }
public float? BlockPosition { get; set; }
/// <summary>
/// Талевый блок. Мин положение
/// </summary>
public double? BlockPositionMin { get; set; }
public float? BlockPositionMin { get; set; }
/// <summary>
/// Талевый блок. Макс положение
/// </summary>
public double? BlockPositionMax { get; set; }
public float? BlockPositionMax { get; set; }
/// <summary>
/// Талевый блок. Скорость
/// </summary>
public double? BlockSpeed { get; set; }
public float? BlockSpeed { get; set; }
/// <summary>
/// Талевый блок. Задание скорости
/// </summary>
public double? BlockSpeedSp { get; set; }
public float? BlockSpeedSp { get; set; }
/// <summary>
/// Талевый блок. Задание скорости для роторного бурения
/// </summary>
public double? BlockSpeedSpRotor { get; set; }
public float? BlockSpeedSpRotor { get; set; }
/// <summary>
/// Талевый блок. Задание скорости для режима слайда
/// </summary>
public double? BlockSpeedSpSlide { get; set; }
public float? BlockSpeedSpSlide { get; set; }
/// <summary>
/// Талевый блок. Задание скорости для проработки
/// </summary>
public double? BlockSpeedSpDevelop { get; set; }
public float? BlockSpeedSpDevelop { get; set; }
/// <summary>
/// Давтение
/// </summary>
public double? Pressure { get; set; }
public float? Pressure { get; set; }
/// <summary>
/// Давтение при холостом ходе.
/// </summary>
public double? PressureIdle { get; set; }
public float? PressureIdle { get; set; }
public double? PressureSp { get; set; }
public float? PressureSp { get; set; }
public double? PressureSpRotor { get; set; }
public float? PressureSpRotor { get; set; }
public double? PressureSpSlide { get; set; }
public float? PressureSpSlide { get; set; }
public double? PressureSpDevelop { get; set; }
public float? PressureSpDevelop { get; set; }
public double? PressureDeltaLimitMax { get; set; }
public float? PressureDeltaLimitMax { get; set; }
public double? AxialLoad { get; set; }
public float? AxialLoad { get; set; }
public double? AxialLoadSp { get; set; }
public float? AxialLoadSp { get; set; }
public double? AxialLoadLimitMax { get; set; }
public float? AxialLoadLimitMax { get; set; }
public double? HookWeight { get; set; }
public float? HookWeight { get; set; }
public double? HookWeightIdle { get; set; }
public float? HookWeightIdle { get; set; }
public double? HookWeightLimitMin { get; set; }
public float? HookWeightLimitMin { get; set; }
public double? HookWeightLimitMax { get; set; }
public float? HookWeightLimitMax { get; set; }
public double? RotorTorque { get; set; }
public float? RotorTorque { get; set; }
public double? RotorTorqueIdle { get; set; }
public float? RotorTorqueIdle { get; set; }
public double? RotorTorqueSp { get; set; }
public float? RotorTorqueSp { get; set; }
public double? RotorTorqueLimitMax { get; set; }
public float? RotorTorqueLimitMax { get; set; }
public double? RotorSpeed { get; set; }
public float? RotorSpeed { get; set; }
public double? Flow { get; set; }
public float? Flow { get; set; }
public double? FlowIdle { get; set; }
public float? FlowIdle { get; set; }
public double? FlowDeltaLimitMax { get; set; }
public float? FlowDeltaLimitMax { get; set; }
/// <summary>
/// id текущего критерия бурения
/// </summary>
public int? IdFeedRegulator { get; set; }
public short? IdFeedRegulator { get; set; }
/// <summary>
/// Текущее состояние работы MSE
/// </summary>
public int? MseState { get; set; }
public short? MseState { get; set; }
}
}

View File

@ -11,68 +11,68 @@ namespace AsbCloudApp.Data
public int Id { get; set; }
public int IdTelemetry { get; set; }
public DateTime Date { get; set; }
public double? TopDriveSpeed { get; set; }
public double? TopDriveSpeedMin { get; set; }
public double? TopDriveSpeedMax { get; set; }
public double? TopDriveSpeedOffset { get; set; }
public int? TopDriveSpeedErr { get; set; }
public double? TopDriveTorque { get; set; }
public double? TopDriveTorqueMin { get; set; }
public double? TopDriveTorqueMax { get; set; }
public double? TopDriveTorqueOffset { get; set; }
public int? TopDriveTorqueErr { get; set; }
public double? TopDriveSpeedSpFrom { get; set; }
public double? TopDriveSpeedSpFromMin { get; set; }
public double? TopDriveSpeedSpFromMax { get; set; }
public double? TopDriveSpeedSpFromOffset { get; set; }
public int? TopDriveSpeedSpFromErr { get; set; }
public double? TopDriveTorqueSpFrom { get; set; }
public double? TopDriveTorqueSpFromMin { get; set; }
public double? TopDriveTorqueSpFromMax { get; set; }
public double? TopDriveTorqueSpFromOffset { get; set; }
public int? TopDriveTorqueSpFromErr { get; set; }
public double? TopDriveSpeedSpTo { get; set; }
public double? TopDriveSpeedSpToMin { get; set; }
public double? TopDriveSpeedSpToMax { get; set; }
public double? TopDriveSpeedSpToOffset { get; set; }
public int? TopDriveSpeedSpToErr { get; set; }
public double? TopDriveTorqueSpTo { get; set; }
public double? TopDriveTorqueSpToMin { get; set; }
public double? TopDriveTorqueSpToMax { get; set; }
public double? TopDriveTorqueSpToOffset { get; set; }
public int? TopDriveTorqueSpToErr { get; set; }
public int? W2800 { get; set; }
public int? W2810 { get; set; }
public int? Mode { get; set; }
public int? W2808 { get; set; }
public double? TorqueStarting { get; set; }
public double? RotorTorqueAvg { get; set; }
public double? EncoderResolution { get; set; }
public double? Ratio { get; set; }
public double? TorqueRightLimit { get; set; }
public double? TorqueLeftLimit { get; set; }
public double? RevolsRightLimit { get; set; }
public double? RevolsLeftLimit { get; set; }
public double? SpeedRightSp { get; set; }
public double? SpeedLeftSp { get; set; }
public double? RevolsRightTotal { get; set; }
public double? RevolsLeftTotal { get; set; }
public double? TurnRightOnceByTorque { get; set; }
public double? TurnLeftOnceByTorque { get; set; }
public double? TurnRightOnceByAngle { get; set; }
public double? TurnLeftOnceByAngle { get; set; }
public double? TurnRightOnceByRevols { get; set; }
public double? TurnLeftOnceByRevols { get; set; }
public double? BreakAngleK { get; set; }
public double? ReverseKTorque { get; set; }
public double? PositionZero { get; set; }
public double? PositionRight { get; set; }
public double? TorqueRampTime { get; set; }
public double? Ver { get; set; }
public int? ReverseSpeedSpZeroTime { get; set; }
public double? UnlockBySectorOut { get; set; }
public double? PidMuxTorqueLeftLimit { get; set; }
public int? State { get; set; }
public double? BreakAngleLeft { get; set; }
public float? TopDriveSpeed { get; set; }
public float? TopDriveSpeedMin { get; set; }
public float? TopDriveSpeedMax { get; set; }
public float? TopDriveSpeedOffset { get; set; }
public short? TopDriveSpeedErr { get; set; }
public float? TopDriveTorque { get; set; }
public float? TopDriveTorqueMin { get; set; }
public float? TopDriveTorqueMax { get; set; }
public float? TopDriveTorqueOffset { get; set; }
public short? TopDriveTorqueErr { get; set; }
public float? TopDriveSpeedSpFrom { get; set; }
public float? TopDriveSpeedSpFromMin { get; set; }
public float? TopDriveSpeedSpFromMax { get; set; }
public float? TopDriveSpeedSpFromOffset { get; set; }
public short? TopDriveSpeedSpFromErr { get; set; }
public float? TopDriveTorqueSpFrom { get; set; }
public float? TopDriveTorqueSpFromMin { get; set; }
public float? TopDriveTorqueSpFromMax { get; set; }
public float? TopDriveTorqueSpFromOffset { get; set; }
public short? TopDriveTorqueSpFromErr { get; set; }
public float? TopDriveSpeedSpTo { get; set; }
public float? TopDriveSpeedSpToMin { get; set; }
public float? TopDriveSpeedSpToMax { get; set; }
public float? TopDriveSpeedSpToOffset { get; set; }
public short? TopDriveSpeedSpToErr { get; set; }
public float? TopDriveTorqueSpTo { get; set; }
public float? TopDriveTorqueSpToMin { get; set; }
public float? TopDriveTorqueSpToMax { get; set; }
public float? TopDriveTorqueSpToOffset { get; set; }
public short? TopDriveTorqueSpToErr { get; set; }
public short? W2800 { get; set; }
public short? W2810 { get; set; }
public short? Mode { get; set; }
public short? W2808 { get; set; }
public float? TorqueStarting { get; set; }
public float? RotorTorqueAvg { get; set; }
public float? EncoderResolution { get; set; }
public float? Ratio { get; set; }
public float? TorqueRightLimit { get; set; }
public float? TorqueLeftLimit { get; set; }
public float? RevolsRightLimit { get; set; }
public float? RevolsLeftLimit { get; set; }
public float? SpeedRightSp { get; set; }
public float? SpeedLeftSp { get; set; }
public float? RevolsRightTotal { get; set; }
public float? RevolsLeftTotal { get; set; }
public float? TurnRightOnceByTorque { get; set; }
public float? TurnLeftOnceByTorque { get; set; }
public float? TurnRightOnceByAngle { get; set; }
public float? TurnLeftOnceByAngle { get; set; }
public float? TurnRightOnceByRevols { get; set; }
public float? TurnLeftOnceByRevols { get; set; }
public float? BreakAngleK { get; set; }
public float? ReverseKTorque { get; set; }
public float? PositionZero { get; set; }
public float? PositionRight { get; set; }
public float? TorqueRampTime { get; set; }
public float? Ver { get; set; }
public short? ReverseSpeedSpZeroTime { get; set; }
public float? UnlockBySectorOut { get; set; }
public float? PidMuxTorqueLeftLimit { get; set; }
public short? State { get; set; }
public float? BreakAngleLeft { get; set; }
}
}

View File

@ -28,7 +28,7 @@ namespace AsbCloudInfrastructure.Services
var entities = await (from p in db.DrillFlowChart
where p.IdWell == idWell &&
p.LastUpdate >= updateFrom
orderby p.Id
orderby p.DepthStart, p.Id
select p)
.ToListAsync(token)
.ConfigureAwait(false);

View File

@ -21,6 +21,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.7" />
<PackageReference Include="protobuf-net" Version="3.0.101" />
<PackageReference Include="protobuf-net.AspNetCore" Version="3.0.101" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.1.1" />
</ItemGroup>

View File

@ -0,0 +1,135 @@
using AsbCloudApp.Data;
using ProtoBuf.Meta;
namespace AsbCloudWebApi
{
public static class ProtobufModel
{
public static void EnshureRegistered()
{
EnshureRegisteredDataSpin();
EnshureRegisteredDataSaub();
}
static void EnshureRegisteredDataSpin()
{
var type = typeof(TelemetryDataSpinDto);
if (RuntimeTypeModel.Default.IsDefined(type))
return;
RuntimeTypeModel.Default.Add(type, false)
.Add(1, nameof(TelemetryDataSpinDto.Id))
.Add(2, nameof(TelemetryDataSpinDto.IdTelemetry))
.Add(3, nameof(TelemetryDataSpinDto.Date))
.Add(4, nameof(TelemetryDataSpinDto.TopDriveSpeed))
.Add(5, nameof(TelemetryDataSpinDto.TopDriveSpeedMin))
.Add(6, nameof(TelemetryDataSpinDto.TopDriveSpeedMax))
.Add(7, nameof(TelemetryDataSpinDto.TopDriveSpeedOffset))
.Add(8, nameof(TelemetryDataSpinDto.TopDriveSpeedErr))
.Add(9, nameof(TelemetryDataSpinDto.TopDriveTorque))
.Add(10, nameof(TelemetryDataSpinDto.TopDriveTorqueMin))
.Add(11, nameof(TelemetryDataSpinDto.TopDriveTorqueMax))
.Add(12, nameof(TelemetryDataSpinDto.TopDriveTorqueOffset))
.Add(13, nameof(TelemetryDataSpinDto.TopDriveTorqueErr))
.Add(14, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFrom))
.Add(15, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromMin))
.Add(16, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromMax))
.Add(17, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromOffset))
.Add(18, nameof(TelemetryDataSpinDto.TopDriveSpeedSpFromErr))
.Add(19, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFrom))
.Add(20, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromMin))
.Add(21, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromMax))
.Add(22, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromOffset))
.Add(23, nameof(TelemetryDataSpinDto.TopDriveTorqueSpFromErr))
.Add(24, nameof(TelemetryDataSpinDto.TopDriveSpeedSpTo))
.Add(25, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToMin))
.Add(26, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToMax))
.Add(27, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToOffset))
.Add(28, nameof(TelemetryDataSpinDto.TopDriveSpeedSpToErr))
.Add(29, nameof(TelemetryDataSpinDto.TopDriveTorqueSpTo))
.Add(30, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToMin))
.Add(31, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToMax))
.Add(32, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToOffset))
.Add(33, nameof(TelemetryDataSpinDto.TopDriveTorqueSpToErr))
.Add(34, nameof(TelemetryDataSpinDto.W2800))
.Add(35, nameof(TelemetryDataSpinDto.W2810))
.Add(36, nameof(TelemetryDataSpinDto.Mode))
.Add(37, nameof(TelemetryDataSpinDto.W2808))
.Add(38, nameof(TelemetryDataSpinDto.TorqueStarting))
.Add(39, nameof(TelemetryDataSpinDto.RotorTorqueAvg))
.Add(40, nameof(TelemetryDataSpinDto.EncoderResolution))
.Add(41, nameof(TelemetryDataSpinDto.Ratio))
.Add(42, nameof(TelemetryDataSpinDto.TorqueRightLimit))
.Add(43, nameof(TelemetryDataSpinDto.TorqueLeftLimit))
.Add(44, nameof(TelemetryDataSpinDto.RevolsRightLimit))
.Add(45, nameof(TelemetryDataSpinDto.RevolsLeftLimit))
.Add(46, nameof(TelemetryDataSpinDto.SpeedRightSp))
.Add(47, nameof(TelemetryDataSpinDto.SpeedLeftSp))
.Add(48, nameof(TelemetryDataSpinDto.RevolsRightTotal))
.Add(49, nameof(TelemetryDataSpinDto.RevolsLeftTotal))
.Add(50, nameof(TelemetryDataSpinDto.TurnRightOnceByTorque))
.Add(51, nameof(TelemetryDataSpinDto.TurnLeftOnceByTorque))
.Add(52, nameof(TelemetryDataSpinDto.TurnRightOnceByAngle))
.Add(53, nameof(TelemetryDataSpinDto.TurnLeftOnceByAngle))
.Add(54, nameof(TelemetryDataSpinDto.TurnRightOnceByRevols))
.Add(55, nameof(TelemetryDataSpinDto.TurnLeftOnceByRevols))
.Add(56, nameof(TelemetryDataSpinDto.BreakAngleK))
.Add(57, nameof(TelemetryDataSpinDto.ReverseKTorque))
.Add(58, nameof(TelemetryDataSpinDto.PositionZero))
.Add(59, nameof(TelemetryDataSpinDto.PositionRight))
.Add(60, nameof(TelemetryDataSpinDto.TorqueRampTime))
.Add(61, nameof(TelemetryDataSpinDto.Ver))
.Add(62, nameof(TelemetryDataSpinDto.ReverseSpeedSpZeroTime))
.Add(63, nameof(TelemetryDataSpinDto.UnlockBySectorOut))
.Add(64, nameof(TelemetryDataSpinDto.PidMuxTorqueLeftLimit))
.Add(65, nameof(TelemetryDataSpinDto.State))
.Add(66, nameof(TelemetryDataSpinDto.BreakAngleLeft));
}
static void EnshureRegisteredDataSaub()
{
var type = typeof(TelemetryDataSaubDto);
if (RuntimeTypeModel.Default.IsDefined(type))
return;
RuntimeTypeModel.Default.Add(type, false)
.Add(1, nameof(TelemetryDataSaubDto.Id))
.Add(2, nameof(TelemetryDataSaubDto.Date))
.Add(3, nameof(TelemetryDataSaubDto.Mode))
.Add(4, nameof(TelemetryDataSaubDto.IdTelemetry))
.Add(5, nameof(TelemetryDataSaubDto.User))
.Add(6, nameof(TelemetryDataSaubDto.WellDepth))
.Add(7, nameof(TelemetryDataSaubDto.BitDepth))
.Add(8, nameof(TelemetryDataSaubDto.BlockPosition))
.Add(9, nameof(TelemetryDataSaubDto.BlockPositionMin))
.Add(10, nameof(TelemetryDataSaubDto.BlockPositionMax))
.Add(11, nameof(TelemetryDataSaubDto.BlockSpeed))
.Add(12, nameof(TelemetryDataSaubDto.BlockSpeedSp))
.Add(13, nameof(TelemetryDataSaubDto.BlockSpeedSpRotor))
.Add(14, nameof(TelemetryDataSaubDto.BlockSpeedSpSlide))
.Add(15, nameof(TelemetryDataSaubDto.BlockSpeedSpDevelop))
.Add(16, nameof(TelemetryDataSaubDto.Pressure))
.Add(17, nameof(TelemetryDataSaubDto.PressureIdle))
.Add(18, nameof(TelemetryDataSaubDto.PressureSp))
.Add(19, nameof(TelemetryDataSaubDto.PressureSpRotor))
.Add(20, nameof(TelemetryDataSaubDto.PressureSpSlide))
.Add(21, nameof(TelemetryDataSaubDto.PressureSpDevelop))
.Add(22, nameof(TelemetryDataSaubDto.PressureDeltaLimitMax))
.Add(23, nameof(TelemetryDataSaubDto.AxialLoad))
.Add(24, nameof(TelemetryDataSaubDto.AxialLoadSp))
.Add(25, nameof(TelemetryDataSaubDto.AxialLoadLimitMax))
.Add(26, nameof(TelemetryDataSaubDto.HookWeight))
.Add(27, nameof(TelemetryDataSaubDto.HookWeightIdle))
.Add(28, nameof(TelemetryDataSaubDto.HookWeightLimitMin))
.Add(29, nameof(TelemetryDataSaubDto.HookWeightLimitMax))
.Add(30, nameof(TelemetryDataSaubDto.RotorTorque))
.Add(31, nameof(TelemetryDataSaubDto.RotorTorqueIdle))
.Add(32, nameof(TelemetryDataSaubDto.RotorTorqueSp))
.Add(33, nameof(TelemetryDataSaubDto.RotorTorqueLimitMax))
.Add(34, nameof(TelemetryDataSaubDto.RotorSpeed))
.Add(35, nameof(TelemetryDataSaubDto.Flow))
.Add(36, nameof(TelemetryDataSaubDto.FlowIdle))
.Add(37, nameof(TelemetryDataSaubDto.FlowDeltaLimitMax))
.Add(38, nameof(TelemetryDataSaubDto.IdFeedRegulator))
.Add(39, nameof(TelemetryDataSaubDto.MseState));
}
}
}

View File

@ -23,7 +23,10 @@ namespace AsbCloudWebApi
.AddJsonOptions(new System.Action<Microsoft.AspNetCore.Mvc.JsonOptions>(opts =>
{
opts.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals | System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString;
}));
}))
.AddProtoBufNet(); //adds mediaType "application/protobuf"
ProtobufModel.EnshureRegistered();
services.AddSwagger();