if (!_pumps.TryGetValue(addr, out var pumpControl))
{
var control= new PumpControl(pump, addr);
- control.PumpDataChanged += AtmosDeviceDataChanged!.Invoke;
- control.PumpDataCopied += AtmosDeviceDataCopied!.Invoke;
+ control.PumpDataChanged += AtmosDeviceDataChanged;
+ control.PumpDataCopied += AtmosDeviceDataCopied;
_pumps.Add(addr, control);
CVentContainer.AddChild(control);
}
if (!_scrubbers.TryGetValue(addr, out var scrubberControl))
{
var control = new ScrubberControl(scrubber, addr);
- control.ScrubberDataChanged += AtmosDeviceDataChanged!.Invoke;
- control.ScrubberDataCopied += AtmosDeviceDataCopied!.Invoke;
+ control.ScrubberDataChanged += AtmosDeviceDataChanged;
+ control.ScrubberDataCopied += AtmosDeviceDataCopied;
_scrubbers.Add(addr, control);
CScrubberContainer.AddChild(control);
}
{
var control = new SensorInfo(sensor, addr);
control.OnThresholdUpdate += AtmosAlarmThresholdChanged;
+ control.SensorDataCopied += AtmosDeviceDataCopied;
_sensors.Add(addr, control);
CSensorContainer.AddChild(control);
}
PumpDataChanged?.Invoke(_address, _data);
};
- _copySettings.OnPressed += _ =>
- {
- PumpDataCopied?.Invoke(_data);
- };
+ _copySettings.OnPressed += _ =>
+ {
+ PumpDataCopied?.Invoke(_data);
+ };
}
public void ChangeData(GasVentPumpData data)
ScrubberDataChanged?.Invoke(_address, _data);
};
- _copySettings.OnPressed += _ =>
- {
- ScrubberDataCopied?.Invoke(_data);
- };
+ _copySettings.OnPressed += _ =>
+ {
+ ScrubberDataCopied?.Invoke(_data);
+ };
foreach (var value in Enum.GetValues<Gas>())
{
<CollapsibleHeading Name="SensorAddress" />
<CollapsibleBody Margin="20 2 2 2">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
+ <BoxContainer Orientation="Horizontal" Margin ="0 0 0 2">
+ <Button Name="CCopySettings" Text="{Loc 'air-alarm-ui-thresholds-copy'}" ToolTip="{Loc 'air-alarm-ui-thresholds-copy-tooltip'}" />
+ </BoxContainer>
<BoxContainer Orientation="Vertical" Margin="0 0 2 0" HorizontalExpand="True">
<RichTextLabel Name="AlarmStateLabel" />
<RichTextLabel Name="PressureLabel" />
public sealed partial class SensorInfo : BoxContainer
{
public Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? OnThresholdUpdate;
+ public event Action<AtmosSensorData>? SensorDataCopied;
private string _address;
private ThresholdControl _pressureThreshold;
private ThresholdControl _temperatureThreshold;
private Dictionary<Gas, ThresholdControl> _gasThresholds = new();
private Dictionary<Gas, RichTextLabel> _gasLabels = new();
+ private Button _copySettings => CCopySettings;
public SensorInfo(AtmosSensorData data, string address)
{
gasThresholdControl.Margin = new Thickness(20, 2, 2, 2);
gasThresholdControl.ThresholdDataChanged += (type, alarmThreshold, arg3) =>
{
- OnThresholdUpdate!(_address, type, alarmThreshold, arg3);
+ OnThresholdUpdate?.Invoke(_address, type, alarmThreshold, arg3);
};
_gasThresholds.Add(gas, gasThresholdControl);
_pressureThreshold.ThresholdDataChanged += (type, threshold, arg3) =>
{
- OnThresholdUpdate!(_address, type, threshold, arg3);
+ OnThresholdUpdate?.Invoke(_address, type, threshold, arg3);
};
_temperatureThreshold.ThresholdDataChanged += (type, threshold, arg3) =>
{
- OnThresholdUpdate!(_address, type, threshold, arg3);
+ OnThresholdUpdate?.Invoke(_address, type, threshold, arg3);
+ };
+
+ _copySettings.OnPressed += _ =>
+ {
+ SensorDataCopied?.Invoke(data);
};
}
SyncDevice(uid, address);
}
+ private void SetAllThresholds(EntityUid uid, string address, AtmosSensorData data)
+ {
+ var payload = new NetworkPayload
+ {
+ [DeviceNetworkConstants.Command] = AtmosMonitorSystem.AtmosMonitorSetAllThresholdsCmd,
+ [AtmosMonitorSystem.AtmosMonitorAllThresholdData] = data
+ };
+
+ _deviceNet.QueuePacket(uid, address, payload);
+
+ SyncDevice(uid, address);
+ }
+
/// <summary>
/// Sync this air alarm's mode with the rest of the network.
/// </summary>
SetData(uid, addr, args.Data);
}
break;
+
+ case AtmosSensorData sensorData:
+ foreach (string addr in component.SensorData.Keys)
+ {
+ SetAllThresholds(uid, addr, sensorData);
+ }
+ break;
}
}
// Commands
public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold";
+ public const string AtmosMonitorSetAllThresholdsCmd = "atmos_monitor_set_all_thresholds";
// Packet data
public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data";
-
+ public const string AtmosMonitorAllThresholdData = "atmos_monitor_all_threshold_data";
public const string AtmosMonitorThresholdDataType = "atmos_monitor_threshold_type";
public const string AtmosMonitorThresholdGasType = "atmos_monitor_threshold_gas";
args.Data.TryGetValue(AtmosMonitorThresholdGasType, out Gas? gas);
SetThreshold(uid, thresholdType.Value, thresholdData, gas);
}
-
+ break;
+ case AtmosMonitorSetAllThresholdsCmd:
+ if (args.Data.TryGetValue(AtmosMonitorAllThresholdData, out AtmosSensorData? allThresholdData))
+ {
+ SetAllThresholds(uid, allThresholdData);
+ }
break;
case AtmosDeviceNetworkSystem.SyncData:
var payload = new NetworkPayload();
}
}
+
+ /// <summary>
+ /// Sets all of a monitor's thresholds at once according to the incoming
+ /// AtmosSensorData object's thresholds.
+ /// </summary>
+ /// <param name="uid">The entity's uid</param>
+ /// <param name="allThresholdData">An AtmosSensorData object from which the thresholds will be loaded.</param>
+ public void SetAllThresholds(EntityUid uid, AtmosSensorData allThresholdData)
+ {
+ SetThreshold(uid, AtmosMonitorThresholdType.Temperature, allThresholdData.TemperatureThreshold);
+ SetThreshold(uid, AtmosMonitorThresholdType.Pressure, allThresholdData.PressureThreshold);
+ foreach (var gas in Enum.GetValues<Gas>())
+ {
+ SetThreshold(uid, AtmosMonitorThresholdType.Gas, allThresholdData.GasThresholds[gas], gas);
+ }
+ }
}
air-alarm-ui-thresholds-lower-bound = Danger below
air-alarm-ui-thresholds-upper-warning-bound = Warning above
air-alarm-ui-thresholds-lower-warning-bound = Warning below
+air-alarm-ui-thresholds-copy = Copy thresholds to all devices
+air-alarm-ui-thresholds-copy-tooltip = Copies the sensor thresholds of this device to all devices in this air alarm tab.