Merge pull request #10721 from vulppine/air-alarm-fixup
Air sensors & air alarm fixup
This commit is contained in:
267
Content.Shared/Atmos/Monitor/AtmosAlarmThreshold.cs
Normal file
267
Content.Shared/Atmos/Monitor/AtmosAlarmThreshold.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.Monitor;
|
||||
|
||||
// mostly based around floats and percentages, no literals
|
||||
// except for the range boundaries
|
||||
[Prototype("alarmThreshold")]
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
|
||||
{
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
[ViewVariables]
|
||||
[DataField("ignore")]
|
||||
public bool Ignore;
|
||||
|
||||
// zero bounds are not allowed - just
|
||||
// set the bound to null if you want
|
||||
// to disable it
|
||||
[ViewVariables]
|
||||
[DataField("upperBound")]
|
||||
public float? UpperBound { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("lowerBound")]
|
||||
public float? LowerBound { get; private set; }
|
||||
|
||||
// upper warning percentage
|
||||
// must always cause UpperWarningBound
|
||||
// to be smaller
|
||||
[ViewVariables]
|
||||
[DataField("upperWarnAround")]
|
||||
public float? UpperWarningPercentage { get; private set; }
|
||||
|
||||
// lower warning percentage
|
||||
// must always cause LowerWarningBound
|
||||
// to be larger
|
||||
[ViewVariables]
|
||||
[DataField("lowerWarnAround")]
|
||||
public float? LowerWarningPercentage { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public float? UpperWarningBound => CalculateWarningBound(AtmosMonitorThresholdBound.Upper);
|
||||
|
||||
[ViewVariables]
|
||||
public float? LowerWarningBound => CalculateWarningBound(AtmosMonitorThresholdBound.Lower);
|
||||
|
||||
public AtmosAlarmThreshold()
|
||||
{
|
||||
}
|
||||
|
||||
public AtmosAlarmThreshold(AtmosAlarmThreshold other)
|
||||
{
|
||||
Ignore = other.Ignore;
|
||||
UpperBound = other.UpperBound;
|
||||
LowerBound = other.LowerBound;
|
||||
UpperWarningPercentage = other.UpperWarningPercentage;
|
||||
LowerWarningPercentage = other.LowerWarningPercentage;
|
||||
}
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
if (UpperBound <= LowerBound)
|
||||
UpperBound = null;
|
||||
|
||||
if (LowerBound >= UpperBound)
|
||||
LowerBound = null;
|
||||
|
||||
if (UpperWarningPercentage != null)
|
||||
TrySetWarningBound(AtmosMonitorThresholdBound.Upper, UpperBound * UpperWarningPercentage);
|
||||
|
||||
if (LowerWarningPercentage != null)
|
||||
TrySetWarningBound(AtmosMonitorThresholdBound.Lower, LowerBound * LowerWarningPercentage);
|
||||
}
|
||||
|
||||
// utility function to check a threshold against some calculated value
|
||||
public bool CheckThreshold(float value, out AtmosAlarmType state)
|
||||
{
|
||||
state = AtmosAlarmType.Normal;
|
||||
if (Ignore)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value >= UpperBound || value <= LowerBound)
|
||||
{
|
||||
state = AtmosAlarmType.Danger;
|
||||
return true;
|
||||
}
|
||||
if (value >= UpperWarningBound || value <= LowerWarningBound)
|
||||
{
|
||||
state = AtmosAlarmType.Warning;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// set the primary bound, takes a hard value
|
||||
public bool TrySetPrimaryBound(AtmosMonitorThresholdBound bound, float? input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
UpperBound = null;
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
LowerBound = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var value = (float) input;
|
||||
|
||||
if (value <= 0f || float.IsNaN(value))
|
||||
return false;
|
||||
|
||||
(float target, int compare)? targetValue = null;
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
if (float.IsPositiveInfinity(value))
|
||||
return false;
|
||||
|
||||
if (LowerBound != null)
|
||||
targetValue = ((float) LowerBound, -1);
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
if (float.IsNegativeInfinity(value))
|
||||
return false;
|
||||
|
||||
if (UpperBound != null)
|
||||
targetValue = ((float) UpperBound, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
var isValid = true;
|
||||
if (targetValue != null)
|
||||
{
|
||||
var result = targetValue.Value.target.CompareTo(value);
|
||||
isValid = targetValue.Value.compare == result;
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
UpperBound = value;
|
||||
return true;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
LowerBound = value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// set the warning bound, takes a hard value
|
||||
//
|
||||
// this will always set the percentage and
|
||||
// the raw value at the same time
|
||||
public bool TrySetWarningBound(AtmosMonitorThresholdBound bound, float? input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
UpperWarningPercentage = null;
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
LowerWarningPercentage = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
if (UpperBound == null)
|
||||
return false;
|
||||
|
||||
var upperWarning = (float) (input / UpperBound);
|
||||
var upperTestValue = upperWarning * (float) UpperBound;
|
||||
|
||||
if (upperWarning > 1f
|
||||
|| upperTestValue < LowerWarningBound
|
||||
|| upperTestValue < LowerBound)
|
||||
return false;
|
||||
|
||||
UpperWarningPercentage = upperWarning;
|
||||
|
||||
return true;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
if (LowerBound == null)
|
||||
return false;
|
||||
|
||||
var lowerWarning = (float) (input / LowerBound);
|
||||
var testValue = lowerWarning * (float) LowerBound;
|
||||
|
||||
if (lowerWarning < 1f
|
||||
|| testValue > UpperWarningBound
|
||||
|| testValue > UpperBound)
|
||||
return false;
|
||||
|
||||
LowerWarningPercentage = lowerWarning;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public float? CalculateWarningBound(AtmosMonitorThresholdBound bound)
|
||||
{
|
||||
float? value = null;
|
||||
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
if (UpperBound == null || UpperWarningPercentage == null)
|
||||
break;
|
||||
|
||||
value = UpperBound * UpperWarningPercentage;
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
if (LowerBound == null || LowerWarningPercentage == null)
|
||||
break;
|
||||
|
||||
value = LowerBound * LowerWarningPercentage;
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum AtmosMonitorThresholdBound
|
||||
{
|
||||
Upper,
|
||||
Lower
|
||||
}
|
||||
|
||||
// not really used in the prototype but in code,
|
||||
// to differentiate between the different
|
||||
// fields you can find this prototype in
|
||||
public enum AtmosMonitorThresholdType
|
||||
{
|
||||
Temperature,
|
||||
Pressure,
|
||||
Gas
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum AtmosMonitorVisuals : byte
|
||||
{
|
||||
AlarmType,
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.Monitor
|
||||
{
|
||||
// mostly based around floats and percentages, no literals
|
||||
// except for the range boundaries
|
||||
[Prototype("alarmThreshold")]
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AtmosAlarmThreshold : IPrototype, ISerializationHooks
|
||||
{
|
||||
[IdDataFieldAttribute]
|
||||
public string ID { get; } = default!;
|
||||
[ViewVariables]
|
||||
[DataField("ignore")]
|
||||
public bool Ignore = false;
|
||||
|
||||
// zero bounds are not allowed - just
|
||||
// set the bound to null if you want
|
||||
// to disable it
|
||||
[ViewVariables]
|
||||
[DataField("upperBound")]
|
||||
public float? UpperBound { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("lowerBound")]
|
||||
public float? LowerBound { get; private set; }
|
||||
|
||||
// upper warning percentage
|
||||
// must always cause UpperWarningBound
|
||||
// to be smaller
|
||||
[ViewVariables]
|
||||
[DataField("upperWarnAround")]
|
||||
public float? UpperWarningPercentage { get; private set; }
|
||||
|
||||
// lower warning percentage
|
||||
// must always cause LowerWarningBound
|
||||
// to be larger
|
||||
[ViewVariables]
|
||||
[DataField("lowerWarnAround")]
|
||||
public float? LowerWarningPercentage { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public float? UpperWarningBound
|
||||
{
|
||||
get => CalculateWarningBound(AtmosMonitorThresholdBound.Upper);
|
||||
}
|
||||
|
||||
[ViewVariables]
|
||||
public float? LowerWarningBound
|
||||
{
|
||||
get => CalculateWarningBound(AtmosMonitorThresholdBound.Lower);
|
||||
}
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
if (UpperBound <= LowerBound)
|
||||
UpperBound = null;
|
||||
|
||||
if (LowerBound >= UpperBound)
|
||||
LowerBound = null;
|
||||
|
||||
if (UpperWarningPercentage != null)
|
||||
TrySetWarningBound(AtmosMonitorThresholdBound.Upper, UpperBound * UpperWarningPercentage);
|
||||
|
||||
if (LowerWarningPercentage != null)
|
||||
TrySetWarningBound(AtmosMonitorThresholdBound.Lower, LowerBound * LowerWarningPercentage);
|
||||
}
|
||||
|
||||
// utility function to check a threshold against some calculated value
|
||||
public bool CheckThreshold(float value, out AtmosMonitorAlarmType state)
|
||||
{
|
||||
state = AtmosMonitorAlarmType.Normal;
|
||||
if (Ignore) return false;
|
||||
|
||||
if (value >= UpperBound || value <= LowerBound)
|
||||
{
|
||||
state = AtmosMonitorAlarmType.Danger;
|
||||
return true;
|
||||
}
|
||||
if (value >= UpperWarningBound || value <= LowerWarningBound)
|
||||
{
|
||||
state = AtmosMonitorAlarmType.Warning;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// set the primary bound, takes a hard value
|
||||
public bool TrySetPrimaryBound(AtmosMonitorThresholdBound bound, float? input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
UpperBound = null;
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
LowerBound = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float value = (float) input;
|
||||
|
||||
if (value <= 0f || float.IsNaN(value))
|
||||
return false;
|
||||
|
||||
(float target, int compare)? targetValue = null;
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
if (float.IsPositiveInfinity(value))
|
||||
return false;
|
||||
|
||||
if (LowerBound != null)
|
||||
targetValue = ((float) LowerBound, -1);
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
if (float.IsNegativeInfinity(value))
|
||||
return false;
|
||||
|
||||
if (UpperBound != null)
|
||||
targetValue = ((float) UpperBound, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
bool isValid = true;
|
||||
if (targetValue != null)
|
||||
{
|
||||
var result = targetValue.Value.target.CompareTo(value);
|
||||
isValid = targetValue.Value.compare == result;
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
UpperBound = value;
|
||||
return true;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
LowerBound = value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// set the warning bound, takes a hard value
|
||||
//
|
||||
// this will always set the percentage and
|
||||
// the raw value at the same time
|
||||
public bool TrySetWarningBound(AtmosMonitorThresholdBound bound, float? input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
UpperWarningPercentage = null;
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
LowerWarningPercentage = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
if (UpperBound == null)
|
||||
return false;
|
||||
|
||||
float upperWarning = (float) (input / UpperBound);
|
||||
float upperTestValue = (upperWarning * (float) UpperBound);
|
||||
|
||||
if (upperWarning > 1f
|
||||
|| upperTestValue < LowerWarningBound
|
||||
|| upperTestValue < LowerBound)
|
||||
return false;
|
||||
|
||||
UpperWarningPercentage = upperWarning;
|
||||
|
||||
return true;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
if (LowerBound == null)
|
||||
return false;
|
||||
|
||||
float lowerWarning = (float) (input / LowerBound);
|
||||
float testValue = (lowerWarning * (float) LowerBound);
|
||||
|
||||
if (lowerWarning < 1f
|
||||
|| testValue > UpperWarningBound
|
||||
|| testValue > UpperBound)
|
||||
return false;
|
||||
|
||||
LowerWarningPercentage = lowerWarning;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public float? CalculateWarningBound(AtmosMonitorThresholdBound bound)
|
||||
{
|
||||
float? value = null;
|
||||
|
||||
switch (bound)
|
||||
{
|
||||
case AtmosMonitorThresholdBound.Upper:
|
||||
if (UpperBound == null || UpperWarningPercentage == null)
|
||||
break;
|
||||
|
||||
value = UpperBound * UpperWarningPercentage;
|
||||
break;
|
||||
case AtmosMonitorThresholdBound.Lower:
|
||||
if (LowerBound == null || LowerWarningPercentage == null)
|
||||
break;
|
||||
|
||||
value = LowerBound * LowerWarningPercentage;
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum AtmosMonitorThresholdBound
|
||||
{
|
||||
Upper,
|
||||
Lower
|
||||
}
|
||||
|
||||
// not really used in the prototype but in code,
|
||||
// to differentiate between the different
|
||||
// fields you can find this prototype in
|
||||
public enum AtmosMonitorThresholdType
|
||||
{
|
||||
Temperature,
|
||||
Pressure,
|
||||
Gas
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum AtmosMonitorVisuals : byte
|
||||
{
|
||||
Offset,
|
||||
AlarmType,
|
||||
}
|
||||
}
|
||||
12
Content.Shared/Atmos/Monitor/AtmosAlarmType.cs
Normal file
12
Content.Shared/Atmos/Monitor/AtmosAlarmType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.Monitor;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum AtmosAlarmType : sbyte
|
||||
{
|
||||
Normal = 0,
|
||||
Warning = 1,
|
||||
Danger = 2, // 1 << 1 is the exact same thing and we're not really doing **bitmasking** are we?
|
||||
Emagged = 3,
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.Monitor
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum AtmosMonitorAlarmType : sbyte
|
||||
{
|
||||
Normal = 0,
|
||||
Warning = 1,
|
||||
Danger = 2, // 1 << 1 is the exact same thing and we're not really doing **bitmasking** are we?
|
||||
Emagged = 3,
|
||||
}
|
||||
}
|
||||
51
Content.Shared/Atmos/Monitor/AtmosSensorData.cs
Normal file
51
Content.Shared/Atmos/Monitor/AtmosSensorData.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Content.Shared.Atmos.Monitor.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.Monitor;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AtmosSensorData : IAtmosDeviceData
|
||||
{
|
||||
public AtmosSensorData(float pressure, float temperature, float totalMoles, AtmosAlarmType alarmState, Dictionary<Gas, float> gases, AtmosAlarmThreshold pressureThreshold, AtmosAlarmThreshold temperatureThreshold, Dictionary<Gas, AtmosAlarmThreshold> gasThresholds)
|
||||
{
|
||||
Pressure = pressure;
|
||||
Temperature = temperature;
|
||||
TotalMoles = totalMoles;
|
||||
AlarmState = alarmState;
|
||||
Gases = gases;
|
||||
PressureThreshold = pressureThreshold;
|
||||
TemperatureThreshold = temperatureThreshold;
|
||||
GasThresholds = gasThresholds;
|
||||
}
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
public bool Dirty { get; set; }
|
||||
public bool IgnoreAlarms { get; set; }
|
||||
|
||||
/// Most fields are readonly, because it's data that's meant to be transmitted.
|
||||
|
||||
/// <summary>
|
||||
/// Current pressure detected by this sensor.
|
||||
/// </summary>
|
||||
public float Pressure { get; }
|
||||
/// <summary>
|
||||
/// Current temperature detected by this sensor.
|
||||
/// </summary>
|
||||
public float Temperature { get; }
|
||||
/// <summary>
|
||||
/// Current amount of moles detected by this sensor.
|
||||
/// </summary>
|
||||
public float TotalMoles { get; }
|
||||
/// <summary>
|
||||
/// Current alarm state of this sensor. Does not reflect the highest alarm state on the network.
|
||||
/// </summary>
|
||||
public AtmosAlarmType AlarmState { get; }
|
||||
/// <summary>
|
||||
/// Current number of gases on this sensor.
|
||||
/// </summary>
|
||||
public Dictionary<Gas, float> Gases { get; }
|
||||
|
||||
public AtmosAlarmThreshold PressureThreshold { get; }
|
||||
public AtmosAlarmThreshold TemperatureThreshold { get; }
|
||||
public Dictionary<Gas, AtmosAlarmThreshold> GasThresholds { get; }
|
||||
}
|
||||
@@ -1,130 +1,129 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.Monitor.Components
|
||||
namespace Content.Shared.Atmos.Monitor.Components;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum SharedAirAlarmInterfaceKey
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum SharedAirAlarmInterfaceKey
|
||||
{
|
||||
Key
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum AirAlarmMode
|
||||
{
|
||||
None,
|
||||
Filtering,
|
||||
Fill,
|
||||
Panic,
|
||||
Replace
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum AirAlarmWireStatus
|
||||
{
|
||||
Power,
|
||||
Access,
|
||||
Panic,
|
||||
DeviceSync
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public readonly struct AirAlarmAirData
|
||||
{
|
||||
public readonly float? Pressure { get; }
|
||||
public readonly float? Temperature { get; }
|
||||
public readonly float? TotalMoles { get; }
|
||||
public readonly AtmosMonitorAlarmType AlarmState { get; }
|
||||
|
||||
private readonly Dictionary<Gas, float>? _gases;
|
||||
public readonly IReadOnlyDictionary<Gas, float>? Gases { get => _gases; }
|
||||
|
||||
public AirAlarmAirData(float? pressure, float? temperature, float? moles, AtmosMonitorAlarmType state, Dictionary<Gas, float>? gases)
|
||||
{
|
||||
Pressure = pressure;
|
||||
Temperature = temperature;
|
||||
TotalMoles = moles;
|
||||
AlarmState = state;
|
||||
_gases = gases;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IAtmosDeviceData
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public bool Dirty { get; set; }
|
||||
public bool IgnoreAlarms { get; set; }
|
||||
}
|
||||
|
||||
// would be nice to include the entire state here
|
||||
// but it's already handled by messages
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUIState : BoundUserInterfaceState
|
||||
{}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmResyncAllDevicesMessage : BoundUserInterfaceMessage
|
||||
{}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmSetAddressMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Address { get; }
|
||||
|
||||
public AirAlarmSetAddressMessage(string address)
|
||||
{
|
||||
Address = address;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUpdateAirDataMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public AirAlarmAirData AirData;
|
||||
|
||||
public AirAlarmUpdateAirDataMessage(AirAlarmAirData airData)
|
||||
{
|
||||
AirData = airData;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUpdateAlarmModeMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public AirAlarmMode Mode { get; }
|
||||
|
||||
public AirAlarmUpdateAlarmModeMessage(AirAlarmMode mode)
|
||||
{
|
||||
Mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUpdateDeviceDataMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Address { get; }
|
||||
public IAtmosDeviceData Data { get; }
|
||||
|
||||
public AirAlarmUpdateDeviceDataMessage(string addr, IAtmosDeviceData data)
|
||||
{
|
||||
Address = addr;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUpdateAlarmThresholdMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public AtmosAlarmThreshold Threshold { get; }
|
||||
public AtmosMonitorThresholdType Type { get; }
|
||||
public Gas? Gas { get; }
|
||||
|
||||
public AirAlarmUpdateAlarmThresholdMessage(AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null)
|
||||
{
|
||||
Threshold = threshold;
|
||||
Type = type;
|
||||
Gas = gas;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Key
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum AirAlarmMode
|
||||
{
|
||||
None,
|
||||
Filtering,
|
||||
Fill,
|
||||
Panic,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum AirAlarmWireStatus
|
||||
{
|
||||
Power,
|
||||
Access,
|
||||
Panic,
|
||||
DeviceSync
|
||||
}
|
||||
|
||||
public interface IAtmosDeviceData
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public bool Dirty { get; set; }
|
||||
public bool IgnoreAlarms { get; set; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUIState : BoundUserInterfaceState
|
||||
{
|
||||
public AirAlarmUIState(string address, int deviceCount, float pressureAverage, float temperatureAverage, Dictionary<string, IAtmosDeviceData> deviceData, AirAlarmMode mode, AirAlarmTab tab, AtmosAlarmType alarmType)
|
||||
{
|
||||
Address = address;
|
||||
DeviceCount = deviceCount;
|
||||
PressureAverage = pressureAverage;
|
||||
TemperatureAverage = temperatureAverage;
|
||||
DeviceData = deviceData;
|
||||
Mode = mode;
|
||||
Tab = tab;
|
||||
AlarmType = alarmType;
|
||||
}
|
||||
|
||||
public string Address { get; }
|
||||
public int DeviceCount { get; }
|
||||
public float PressureAverage { get; }
|
||||
public float TemperatureAverage { get; }
|
||||
/// <summary>
|
||||
/// Every single device data that can be seen from this
|
||||
/// air alarm. This includes vents, scrubbers, and sensors.
|
||||
/// The device data you get, however, depends on the current
|
||||
/// selected tab.
|
||||
/// </summary>
|
||||
public Dictionary<string, IAtmosDeviceData> DeviceData { get; }
|
||||
public AirAlarmMode Mode { get; }
|
||||
public AirAlarmTab Tab { get; }
|
||||
public AtmosAlarmType AlarmType { get; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmTabSetMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public AirAlarmTabSetMessage(AirAlarmTab tab)
|
||||
{
|
||||
Tab = tab;
|
||||
}
|
||||
|
||||
public AirAlarmTab Tab { get; }
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmResyncAllDevicesMessage : BoundUserInterfaceMessage
|
||||
{}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUpdateAlarmModeMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public AirAlarmMode Mode { get; }
|
||||
|
||||
public AirAlarmUpdateAlarmModeMessage(AirAlarmMode mode)
|
||||
{
|
||||
Mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUpdateDeviceDataMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Address { get; }
|
||||
public IAtmosDeviceData Data { get; }
|
||||
|
||||
public AirAlarmUpdateDeviceDataMessage(string addr, IAtmosDeviceData data)
|
||||
{
|
||||
Address = addr;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AirAlarmUpdateAlarmThresholdMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Address { get; }
|
||||
public AtmosAlarmThreshold Threshold { get; }
|
||||
public AtmosMonitorThresholdType Type { get; }
|
||||
public Gas? Gas { get; }
|
||||
|
||||
public AirAlarmUpdateAlarmThresholdMessage(string address, AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null)
|
||||
{
|
||||
Address = address;
|
||||
Threshold = threshold;
|
||||
Type = type;
|
||||
Gas = gas;
|
||||
}
|
||||
}
|
||||
|
||||
public enum AirAlarmTab
|
||||
{
|
||||
Vent,
|
||||
Scrubber,
|
||||
Sensors,
|
||||
Settings
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.Monitor.Components
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum FireAlarmWireStatus
|
||||
{
|
||||
Power,
|
||||
Alarm
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,17 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
ExternalPressureBound = Atmospherics.OneAtmosphere,
|
||||
InternalPressureBound = 0f
|
||||
};
|
||||
|
||||
public static GasVentPumpData ReplaceModePreset = new GasVentPumpData
|
||||
{
|
||||
Enabled = false,
|
||||
IgnoreAlarms = true,
|
||||
Dirty = true,
|
||||
PumpDirection = VentPumpDirection.Releasing,
|
||||
PressureChecks = VentPressureBound.ExternalBound,
|
||||
ExternalPressureBound = Atmospherics.OneAtmosphere,
|
||||
InternalPressureBound = 0f
|
||||
};
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
public static GasVentScrubberData FilterModePreset = new GasVentScrubberData
|
||||
{
|
||||
Enabled = true,
|
||||
FilterGases = GasVentScrubberData.DefaultFilterGases,
|
||||
FilterGases = new(GasVentScrubberData.DefaultFilterGases),
|
||||
PumpDirection = ScrubberPumpDirection.Scrubbing,
|
||||
VolumeRate = 200f,
|
||||
WideNet = false
|
||||
@@ -40,7 +40,7 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
{
|
||||
Enabled = false,
|
||||
Dirty = true,
|
||||
FilterGases = GasVentScrubberData.DefaultFilterGases,
|
||||
FilterGases = new(GasVentScrubberData.DefaultFilterGases),
|
||||
PumpDirection = ScrubberPumpDirection.Scrubbing,
|
||||
VolumeRate = 200f,
|
||||
WideNet = false
|
||||
@@ -50,7 +50,18 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
||||
{
|
||||
Enabled = true,
|
||||
Dirty = true,
|
||||
FilterGases = GasVentScrubberData.DefaultFilterGases,
|
||||
FilterGases = new(GasVentScrubberData.DefaultFilterGases),
|
||||
PumpDirection = ScrubberPumpDirection.Siphoning,
|
||||
VolumeRate = 200f,
|
||||
WideNet = false
|
||||
};
|
||||
|
||||
public static GasVentScrubberData ReplaceModePreset = new GasVentScrubberData
|
||||
{
|
||||
Enabled = true,
|
||||
IgnoreAlarms = true,
|
||||
Dirty = true,
|
||||
FilterGases = new(GasVentScrubberData.DefaultFilterGases),
|
||||
PumpDirection = ScrubberPumpDirection.Siphoning,
|
||||
VolumeRate = 200f,
|
||||
WideNet = false
|
||||
|
||||
Reference in New Issue
Block a user