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