BIG. Add timescaleDB into DB.

Adapt contect to use hypertables.
Refactor TelemetryDataBaseService to avoid duplicate keys and try to save as more as posible
This commit is contained in:
Фролов 2021-11-13 18:47:11 +05:00
parent 4d9dc72bd4
commit 864d851b6a
17 changed files with 3127 additions and 172 deletions

View File

@ -2,7 +2,7 @@
namespace AsbCloudApp.Data namespace AsbCloudApp.Data
{ {
public interface ITelemetryData: IId public interface ITelemetryData
{ {
int IdTelemetry { get; set; } int IdTelemetry { get; set; }
DateTime Date { get; set; } DateTime Date { get; set; }

View File

@ -7,8 +7,6 @@ namespace AsbCloudApp.Data
/// </summary> /// </summary>
public class TelemetryDataSaubDto : ITelemetryData public class TelemetryDataSaubDto : ITelemetryData
{ {
public int Id { get; set; }
//[JsonPropertyName("date")]
public DateTime Date { get; set; } public DateTime Date { get; set; }
/// <summary> /// <summary>

View File

@ -8,7 +8,6 @@ namespace AsbCloudApp.Data
{ {
public class TelemetryDataSpinDto : ITelemetryData public class TelemetryDataSpinDto : ITelemetryData
{ {
public int Id { get; set; }
public int IdTelemetry { get; set; } public int IdTelemetry { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
public float? TopDriveSpeed { get; set; } public float? TopDriveSpeed { get; set; }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,92 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace AsbCloudDb.Migrations
{
public partial class Replace_PK_of_telemetryData_to_compositeKey : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_t_telemetry_data_spin",
table: "t_telemetry_data_spin");
migrationBuilder.DropIndex(
name: "IX_t_telemetry_data_spin_id_telemetry",
table: "t_telemetry_data_spin");
migrationBuilder.DropPrimaryKey(
name: "PK_t_telemetry_data_saub",
table: "t_telemetry_data_saub");
migrationBuilder.DropIndex(
name: "IX_t_telemetry_data_saub_id_telemetry",
table: "t_telemetry_data_saub");
migrationBuilder.DropColumn(
name: "id",
table: "t_telemetry_data_spin");
migrationBuilder.DropColumn(
name: "id",
table: "t_telemetry_data_saub");
migrationBuilder.AddPrimaryKey(
name: "PK_t_telemetry_data_spin",
table: "t_telemetry_data_spin",
columns: new[] { "id_telemetry", "date" });
migrationBuilder.AddPrimaryKey(
name: "PK_t_telemetry_data_saub",
table: "t_telemetry_data_saub",
columns: new[] { "id_telemetry", "date" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_t_telemetry_data_spin",
table: "t_telemetry_data_spin");
migrationBuilder.DropPrimaryKey(
name: "PK_t_telemetry_data_saub",
table: "t_telemetry_data_saub");
migrationBuilder.AddColumn<int>(
name: "id",
table: "t_telemetry_data_spin",
type: "integer",
nullable: false,
defaultValue: 0)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AddColumn<int>(
name: "id",
table: "t_telemetry_data_saub",
type: "integer",
nullable: false,
defaultValue: 0)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AddPrimaryKey(
name: "PK_t_telemetry_data_spin",
table: "t_telemetry_data_spin",
column: "id");
migrationBuilder.AddPrimaryKey(
name: "PK_t_telemetry_data_saub",
table: "t_telemetry_data_saub",
column: "id");
migrationBuilder.CreateIndex(
name: "IX_t_telemetry_data_spin_id_telemetry",
table: "t_telemetry_data_spin",
column: "id_telemetry");
migrationBuilder.CreateIndex(
name: "IX_t_telemetry_data_saub_id_telemetry",
table: "t_telemetry_data_saub",
column: "id_telemetry");
}
}
}

View File

@ -893,11 +893,14 @@ namespace AsbCloudDb.Migrations
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaub", b => modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSaub", b =>
{ {
b.Property<int>("Id") b.Property<int>("IdTelemetry")
.ValueGeneratedOnAdd()
.HasColumnType("integer") .HasColumnType("integer")
.HasColumnName("id") .HasColumnName("id_telemetry");
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone")
.HasColumnName("date")
.HasComment("'2021-10-19 18:23:54+05'");
b.Property<float?>("AxialLoad") b.Property<float?>("AxialLoad")
.HasColumnType("real") .HasColumnType("real")
@ -959,11 +962,6 @@ namespace AsbCloudDb.Migrations
.HasColumnName("block_speed_sp_slide") .HasColumnName("block_speed_sp_slide")
.HasComment("Талевый блок. Задание скорости для режима слайда"); .HasComment("Талевый блок. Задание скорости для режима слайда");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone")
.HasColumnName("date")
.HasComment("'2021-10-19 18:23:54+05'");
b.Property<float?>("Flow") b.Property<float?>("Flow")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("flow") .HasColumnName("flow")
@ -1004,10 +1002,6 @@ namespace AsbCloudDb.Migrations
.HasColumnName("id_feed_regulator") .HasColumnName("id_feed_regulator")
.HasComment("Текущий критерий бурения"); .HasComment("Текущий критерий бурения");
b.Property<int>("IdTelemetry")
.HasColumnType("integer")
.HasColumnName("id_telemetry");
b.Property<int?>("IdUser") b.Property<int?>("IdUser")
.HasColumnType("integer") .HasColumnType("integer")
.HasColumnName("id_user") .HasColumnName("id_user")
@ -1088,9 +1082,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("well_depth") .HasColumnName("well_depth")
.HasComment("Глубина забоя"); .HasComment("Глубина забоя");
b.HasKey("Id"); b.HasKey("IdTelemetry", "Date");
b.HasIndex("IdTelemetry");
b.ToTable("t_telemetry_data_saub"); b.ToTable("t_telemetry_data_saub");
@ -1100,11 +1092,14 @@ namespace AsbCloudDb.Migrations
modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSpin", b => modelBuilder.Entity("AsbCloudDb.Model.TelemetryDataSpin", b =>
{ {
b.Property<int>("Id") b.Property<int>("IdTelemetry")
.ValueGeneratedOnAdd()
.HasColumnType("integer") .HasColumnType("integer")
.HasColumnName("id") .HasColumnName("id_telemetry");
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone")
.HasColumnName("date")
.HasComment("'2021-10-19 18:23:54+05'");
b.Property<float?>("BreakAngleK") b.Property<float?>("BreakAngleK")
.HasColumnType("real") .HasColumnType("real")
@ -1116,20 +1111,11 @@ namespace AsbCloudDb.Migrations
.HasColumnName("break_angle_left") .HasColumnName("break_angle_left")
.HasComment("Угол торможения влево при работе по моменту"); .HasComment("Угол торможения влево при работе по моменту");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone")
.HasColumnName("date")
.HasComment("'2021-10-19 18:23:54+05'");
b.Property<float?>("EncoderResolution") b.Property<float?>("EncoderResolution")
.HasColumnType("real") .HasColumnType("real")
.HasColumnName("encoder_resolution ") .HasColumnName("encoder_resolution ")
.HasComment(" Разрешение энкодера"); .HasComment(" Разрешение энкодера");
b.Property<int>("IdTelemetry")
.HasColumnType("integer")
.HasColumnName("id_telemetry");
b.Property<short?>("Mode") b.Property<short?>("Mode")
.HasColumnType("smallint") .HasColumnType("smallint")
.HasColumnName("mode") .HasColumnName("mode")
@ -1409,9 +1395,7 @@ namespace AsbCloudDb.Migrations
.HasColumnName("w2810") .HasColumnName("w2810")
.HasComment(" автоматический сброс блокировки"); .HasComment(" автоматический сброс блокировки");
b.HasKey("Id"); b.HasKey("IdTelemetry", "Date");
b.HasIndex("IdTelemetry");
b.ToTable("t_telemetry_data_spin"); b.ToTable("t_telemetry_data_spin");
@ -2431,16 +2415,16 @@ namespace AsbCloudDb.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("AsbCloudDb.Model.User", "Author") b.HasOne("AsbCloudDb.Model.User", "User")
.WithMany("FileMarks") .WithMany("FileMarks")
.HasForeignKey("IdUser") .HasForeignKey("IdUser")
.HasConstraintName("t_user_t_file_mark_fk") .HasConstraintName("t_user_t_file_mark_fk")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Author");
b.Navigation("FileInfo"); b.Navigation("FileInfo");
b.Navigation("User");
}); });
modelBuilder.Entity("AsbCloudDb.Model.Measure", b => modelBuilder.Entity("AsbCloudDb.Model.Measure", b =>

View File

@ -105,6 +105,8 @@ namespace AsbCloudDb.Model
.HasForeignKey(d => d.IdTelemetry) .HasForeignKey(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk"); .HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk");
entity.HasKey(nameof(ITelemetryData.IdTelemetry), nameof(ITelemetryData.Date));
}); });
modelBuilder.Entity<TelemetryDataSpin>(entity => modelBuilder.Entity<TelemetryDataSpin>(entity =>
@ -114,6 +116,8 @@ namespace AsbCloudDb.Model
.HasForeignKey(d => d.IdTelemetry) .HasForeignKey(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk"); .HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk");
entity.HasKey(nameof(ITelemetryData.IdTelemetry), nameof(ITelemetryData.Date));
}); });
modelBuilder.Entity<TelemetryMessage>(entity => modelBuilder.Entity<TelemetryMessage>(entity =>

View File

@ -2,7 +2,7 @@
namespace AsbCloudDb.Model namespace AsbCloudDb.Model
{ {
public interface ITelemetryData: IId public interface ITelemetryData
{ {
int IdTelemetry { get; set; } int IdTelemetry { get; set; }
DateTime Date { get; set; } DateTime Date { get; set; }

View File

@ -11,10 +11,6 @@ namespace AsbCloudDb.Model
[Table("t_telemetry_data_saub"), Comment("набор основных данных по SAUB")] [Table("t_telemetry_data_saub"), Comment("набор основных данных по SAUB")]
public partial class TelemetryDataSaub : ITelemetryData public partial class TelemetryDataSaub : ITelemetryData
{ {
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_telemetry")] [Column("id_telemetry")]
public int IdTelemetry { get; set; } public int IdTelemetry { get; set; }

View File

@ -9,10 +9,6 @@ namespace AsbCloudDb.Model
[Table("t_telemetry_data_spin"), Comment("набор основных данных по SpinMaster")] [Table("t_telemetry_data_spin"), Comment("набор основных данных по SpinMaster")]
public class TelemetryDataSpin : ITelemetryData public class TelemetryDataSpin : ITelemetryData
{ {
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_telemetry")] [Column("id_telemetry")]
public int IdTelemetry { get; set; } public int IdTelemetry { get; set; }
[Column("date", TypeName = "timestamp with time zone"), Comment("'2021-10-19 18:23:54+05'")] [Column("date", TypeName = "timestamp with time zone"), Comment("'2021-10-19 18:23:54+05'")]

View File

@ -16,7 +16,8 @@ dotnet ef migrations remvoe <MigrationName> --project AsbCloudDb
#backup #backup
``` ```
sudo -u postgres pg_dump -U postgres postgres -W | gzip > 2021-09-27_dump.sql.gz sudo -u postgres pg_dump -Fc -U postgres postgres -W | gzip > 2021-09-27_dump.sql.gz
sudo -u postgres pg_dump -Fc -U postgres postgres -W > 2021-11-13_dump.sql.gz
``` ```
#restore #restore

View File

@ -0,0 +1,8 @@
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
SELECT create_hypertable(
'tsd.t_tele',
'time',
'id_t',
1500,
chunk_time_interval => interval '92 day');

View File

@ -0,0 +1,48 @@
# install postgresql
```
sudo apt install postgresql-common
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt install postgresql-14
```
# install timescaledb
Add repo:
```
sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/timescale.keyring] https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main' > /etc/apt/sources.list.d/timescaledb.list"
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/timescale.keyring
sudo apt-get update
sudo apt install timescaledb-2-postgresql-14
```
## config timescale
Run configurator/installer
```
sudo service postgresql stop
sudo timescaledb-tune
```
## change postgres default password
```
sudo service postgresql start
sudo -u postgres psql postgres -p 5499
alter user postgres with password 'q';
```
## External access to postgres
### in config file
**/etc/postgresql/14/main/postgresql.conf**
allow external access - replace `listen_addresses = 'local'` to `listen_addresses = '*'`
change port - replace `port = '5433'` to `port = '5499'`
### in config file
**/etc/postgresql/14/main/pg_hba.conf**
Add line to allow your IP:
`host all all <your ip>/32 scram-sha-256`
### check connection:
`psql -h <server ip> -p 5499 -d postgres -U postgres -W`

View File

@ -90,7 +90,7 @@ namespace AsbSaubReport
orderby item.Date orderby item.Date
select new DataSaubReport select new DataSaubReport
{ {
Id = item.Id, //Id = item.Id,
Date = item.Date, Date = item.Date,
Mode = item.Mode, Mode = item.Mode,
WellDepth = item.WellDepth, WellDepth = item.WellDepth,

View File

@ -42,7 +42,6 @@ namespace AsbCloudInfrastructure.Services.Analysis
where d.IdTelemetry == telemetryId where d.IdTelemetry == telemetryId
select new select new
{ {
d.Id,
d.WellDepth, d.WellDepth,
d.BitDepth, d.BitDepth,
d.Date d.Date
@ -51,7 +50,7 @@ namespace AsbCloudInfrastructure.Services.Analysis
var m = (int)Math.Round(1d * depthToTimeData.Count() / 2048); var m = (int)Math.Round(1d * depthToTimeData.Count() / 2048);
if (m > 1) if (m > 1)
depthToTimeData = depthToTimeData.Where(d => d.Id % m == 0); depthToTimeData = depthToTimeData.Where((d, i) => (((d.Date.DayOfYear * 24 + d.Date.Hour) * 60 + d.Date.Minute) * 60 + d.Date.Second) % m == 0);
return await depthToTimeData.Select(d => new WellDepthToDayDto return await depthToTimeData.Select(d => new WellDepthToDayDto
{ {

View File

@ -3,8 +3,10 @@ using AsbCloudApp.Services;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services.Cache; using AsbCloudInfrastructure.Services.Cache;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -21,6 +23,7 @@ namespace AsbCloudInfrastructure.Services
protected readonly CacheTable<Telemetry> cacheTelemetry; protected readonly CacheTable<Telemetry> cacheTelemetry;
protected readonly CacheTable<TelemetryUser> cacheTelemetryUsers; protected readonly CacheTable<TelemetryUser> cacheTelemetryUsers;
protected readonly CacheTable<Well> cacheWells; protected readonly CacheTable<Well> cacheWells;
private static int disorderId = (int)DateTime.Now.Ticks % 99;
public TelemetryDataBaseService( public TelemetryDataBaseService(
IAsbCloudDbContext db, IAsbCloudDbContext db,
@ -40,30 +43,96 @@ namespace AsbCloudInfrastructure.Services
{ {
if (dtos == default || !dtos.Any()) if (dtos == default || !dtos.Any())
return 0; return 0;
var idTelemetry = telemetryService.GetOrCreateTemetryIdByUid(uid); var idTelemetry = telemetryService.GetOrCreateTemetryIdByUid(uid);
var dtoMinDate = dtos.Min(d => d.Date); var lastTelemetryDate = telemetryService.GetLastTelemetryDate(uid);
var dtoMaxDate = dtos.Max(d => d.Date); var dtosList = dtos.OrderBy(d => d.Date).ToList();
telemetryService.SaveRequestDate(uid, dtoMaxDate); var dtoMinDate = dtosList.First().Date;
var dtoMaxDate = dtosList.Last().Date;
if (dtosList.Count > 1)
{
var duplicates = new List<TDto>(8);
for (int i = 1; i < dtosList.Count; i++)
if (dtosList[i - 1].Date == dtosList[i].Date || lastTelemetryDate == dtosList[i - 1].Date)
duplicates.Add(dtosList[i - 1]);
foreach (var duplicate in duplicates)
dtosList.Remove(duplicate);
}
var dataSet = db.Set<TModel>(); var dataSet = db.Set<TModel>();
//var oldData = dataSet.Where(d=> d.IdTelemetry == idTelemetry if(lastTelemetryDate > dtoMinDate)
// && d.Date > dtoMinDate
// && d.Date < dtoMaxDate);
//dataSet.RemoveRange(oldData);
foreach (var dto in dtos)
{ {
dto.IdTelemetry = idTelemetry; var oldData = dataSet.Where(d => d.IdTelemetry == idTelemetry
var data = Convert(dto); && d.Date > dtoMinDate
data.Id = 0; && d.Date < dtoMaxDate);
dataSet.Add(data); dataSet.RemoveRange(oldData);
await db.SaveChangesAsync(token).ConfigureAwait(false);
} }
return await db.SaveChangesAsync(token).ConfigureAwait(false); telemetryService.SaveRequestDate(uid, dtoMaxDate);
var entities = new List<EntityEntry<TModel>>(dtosList.Count);
try
{
foreach (var dto in dtosList)
{
dto.IdTelemetry = idTelemetry;
dto.Date = dto.Date.AddMilliseconds((disorderId++) % 99);
var data = Convert(dto);
var entry = dataSet.Add(data);
entities.Add(entry);
}
return await db.SaveChangesAsync(token).ConfigureAwait(false);
}
catch (DbUpdateException ex)
{
Trace.WriteLine(ex.Message);
foreach (var entity in entities)
entity.State = EntityState.Detached;
foreach (var dto in dtosList)
{
dto.IdTelemetry = idTelemetry;
dto.Date = dto.Date.AddMilliseconds((disorderId++) % 100);
var data = Convert(dto);
var entry = dataSet.Add(data);
entities.Add(entry);
}
try
{
return await db.SaveChangesAsync(token).ConfigureAwait(false);
}
catch (DbUpdateException ex2)
{
Trace.WriteLine("2-nd :" + ex2.Message);
foreach (var entity in entities)
entity.State = EntityState.Detached;
entities.Clear();
int i = 0;
foreach (var dto in dtosList)
{
dto.IdTelemetry = idTelemetry;
dto.Date = dto.Date.AddMilliseconds((disorderId++) % 100);
var data = Convert(dto);
dataSet.Add(data);
try
{
i += await db.SaveChangesAsync(token).ConfigureAwait(false);
}
catch
{
Trace.WriteLine($"Fail to save data telemerty uid: {uid}, idTelemetry {idTelemetry} count: {data.Date}.");
}
}
return i;
}
}
} }
public virtual async Task<IEnumerable<TDto>> GetAsync(int idWell, public virtual async Task<IEnumerable<TDto>> GetAsync(int idWell,
@ -105,7 +174,7 @@ namespace AsbCloudInfrastructure.Services
{ {
var m = (int)Math.Round(1d * fullDataCount / approxPointsCount); var m = (int)Math.Round(1d * fullDataCount / approxPointsCount);
if (m > 1) if (m > 1)
query = query.Where(d => d.Id % m == 0); query = query.Where((d) => (((d.Date.DayOfYear*24 + d.Date.Hour)*60 + d.Date.Minute)*60 + d.Date.Second) % m == 0);
} }
var entities = await query var entities = await query

View File

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