2021-06-24 13:02:31 +05:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Services
|
|
|
|
|
{
|
2021-06-25 15:10:05 +05:00
|
|
|
|
public class OperationDetectorService
|
2021-06-24 13:02:31 +05:00
|
|
|
|
{
|
2021-06-25 15:10:05 +05:00
|
|
|
|
private readonly IEnumerable<OperationDetector> detectors;
|
2021-06-24 13:02:31 +05:00
|
|
|
|
|
2021-06-25 15:10:05 +05:00
|
|
|
|
public OperationDetectorService(IEnumerable<Operation> operations)
|
2021-06-24 13:02:31 +05:00
|
|
|
|
{
|
2021-06-25 15:10:05 +05:00
|
|
|
|
detectors = new List<OperationDetector>()
|
2021-06-24 13:02:31 +05:00
|
|
|
|
{
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 1,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("На поверхности")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitDepthLess20 && data.IsHookWeightLess3;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 2,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Удержание в клиньях")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitStandsStill &&
|
|
|
|
|
data.IsBlockStandsStill && data.IsHookWeightLess3;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 3,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с проработкой")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitRising &&
|
|
|
|
|
data.IsBlockRising && data.IsRotorSpeedMore3 && data.IsPressureMore20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 4,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с проработкой")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitGoesDown &&
|
|
|
|
|
data.IsBlockGoesDown && data.IsRotorSpeedMore3 && data.IsPressureMore20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 5,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с промывкой")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitRising &&
|
|
|
|
|
data.IsBlockRising && data.IsRotorSpeedLess3 && data.IsPressureMore20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 6,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с промывкой")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitGoesDown &&
|
|
|
|
|
data.IsBlockGoesDown && data.IsRotorSpeedLess3 && data.IsPressureMore20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 7,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск в скважину")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitGoesDown &&
|
|
|
|
|
data.IsBlockGoesDown && data.IsRotorSpeedLess3 && data.IsPressureLess20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 8,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Спуск с вращением")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitGoesDown &&
|
|
|
|
|
data.IsBlockGoesDown && data.IsRotorSpeedMore3 && data.IsPressureLess20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 9,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем из скважины")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitRising &&
|
|
|
|
|
data.IsBlockRising && data.IsRotorSpeedLess3 && data.IsPressureLess20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 10,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Подъем с вращением")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitRising &&
|
|
|
|
|
data.IsBlockRising && data.IsRotorSpeedMore3 && data.IsPressureLess20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 11,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Промывка в покое")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitStandsStill &&
|
|
|
|
|
data.IsBlockStandsStill && data.IsRotorSpeedLess3 && data.IsPressureMore20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 12,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Промывка с вращением")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitStandsStill &&
|
|
|
|
|
data.IsBlockStandsStill && data.IsRotorSpeedMore3 && data.IsPressureMore20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 13,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Неподвижное состояние")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitStandsStill && data.IsBlockStandsStill
|
|
|
|
|
&& data.IsRotorSpeedLess3 && data.IsPressureLess20 && data.IsHookWeightNotChanges;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 14,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Вращение без циркуляции")),
|
|
|
|
|
Detect = (data) =>
|
|
|
|
|
{
|
|
|
|
|
return data.IsDepthNotChanges && data.IsBitStandsStill &&
|
|
|
|
|
data.IsBlockStandsStill && data.IsRotorSpeedMore3 && data.IsPressureLess20;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new OperationDetector
|
|
|
|
|
{
|
|
|
|
|
Order = 15,
|
|
|
|
|
Operation = operations.FirstOrDefault(o => o.Name.Equals("Невозможно определить операцию")),
|
|
|
|
|
Detect = (data) => true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-06-25 15:10:05 +05:00
|
|
|
|
|
|
|
|
|
public Operation DetectOperation(DrillingAnalysis data) =>
|
|
|
|
|
detectors.OrderBy(d => d.Order).First(o => o.Detect(data)).Operation
|
|
|
|
|
?? new Operation { Id = 1, Name = "Невозможно определить операцию" };
|
2021-06-24 13:02:31 +05:00
|
|
|
|
}
|
|
|
|
|
}
|