DD.WellWorkover.Cloud/AsbCloudApp/Data/DetectedOperation/EnabledSubsystems.cs

105 lines
2.8 KiB
C#
Raw Normal View History

namespace AsbCloudApp.Data.DetectedOperation;
/// <summary>
/// Включённые подсистемы
/// </summary>
public struct EnabledSubsystems
{
private int value;
private EnabledSubsystems(int value)
{
this.value = value;
}
/// <inheritdoc/>
public static implicit operator int(EnabledSubsystems param) =>
param.value;
/// <inheritdoc/>
public static implicit operator EnabledSubsystems(int param) =>
new(param);
/// <summary>
/// Бурение ротором
/// </summary>
public bool IsAutoRotor
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoRotor);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoRotor);
}
/// <summary>
/// Бурение слайдом
/// </summary>
public bool IsAutoSlide
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoSlide);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoSlide);
}
/// <summary>
/// ПРОРАБОТКА
/// </summary>
public bool IsAutoConditionig
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoConditionig);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoConditionig);
}
/// <summary>
/// СПУСК СПО
/// </summary>
public bool IsAutoSinking
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoSinking);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoSinking);
}
/// <summary>
/// ПОДЪЕМ СПО
/// </summary>
public bool IsAutoLifting
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoLifting);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoLifting);
}
/// <summary>
/// ПОДЪЕМ С ПРОРАБОТКОЙ
/// </summary>
public bool IsAutoLiftingWithConditionig
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoLiftingWithConditionig);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoLiftingWithConditionig);
}
/// <summary>
/// Блокировка
/// </summary>
public bool IsAutoBlocknig
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoBlocknig);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoBlocknig);
}
/// <summary>
/// Осцилляция
/// </summary>
public bool IsAutoOscillation
{
get => IsEnabledSubsystem(EnabledSubsystemsFlags.AutoOscillation);
set => UpdateEnabledSubsystems(value, EnabledSubsystemsFlags.AutoOscillation);
}
private bool IsEnabledSubsystem(EnabledSubsystemsFlags flag) =>
(value & (int)flag) > 0;
private void UpdateEnabledSubsystems(bool isEnable, EnabledSubsystemsFlags flag)
{
if (isEnable)
value |= (int)flag;
else
value &= ~(int)flag;
}
}