diff --git a/Content.Server/Atmos/Monitor/Components/AtmosAlarmingComponent.cs b/Content.Server/Atmos/Monitor/Components/AtmosAlarmingComponent.cs
deleted file mode 100644
index 3ee10cf106..0000000000
--- a/Content.Server/Atmos/Monitor/Components/AtmosAlarmingComponent.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace Content.Server.Atmos.Monitor.Components;
-
-[RegisterComponent]
-public sealed class AtmosAlarmingComponent : Component
-{
- ///
- /// All registered receivers in this alarmer.
- ///
- public HashSet RegisteredReceivers = new();
-
- // Somebody should do this someday. I'll leave it here as a reminder,
- // just in case.
- // public string StationAlarmMonitorFrequencyId
-}
diff --git a/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs b/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs
index d741be8ad1..c91412e1ee 100644
--- a/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs
+++ b/Content.Server/Atmos/Monitor/Components/AtmosMonitorComponent.cs
@@ -71,6 +71,12 @@ namespace Content.Server.Atmos.Monitor.Components
[ViewVariables]
public Dictionary NetworkAlarmStates = new();
+ ///
+ /// Registered devices in this atmos monitor. Alerts will be sent directly
+ /// to these devices.
+ ///
+ [ViewVariables] public HashSet RegisteredDevices = new();
+
// Calculates the highest alarm in the network, including itself.
[ViewVariables]
public AtmosMonitorAlarmType HighestAlarmInNetwork
diff --git a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs
index c8ad762469..ce96bb755b 100644
--- a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs
+++ b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs
@@ -32,7 +32,7 @@ namespace Content.Server.Atmos.Monitor.Systems
public sealed class AirAlarmSystem : EntitySystem
{
[Dependency] private readonly DeviceNetworkSystem _deviceNet = default!;
- [Dependency] private readonly AtmosMonitorSystem _atmosMonitorSystem = default!;
+ [Dependency] private readonly AtmosDeviceNetworkSystem _atmosDevNetSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly AccessReaderSystem _accessSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
@@ -76,54 +76,36 @@ namespace Content.Server.Atmos.Monitor.Systems
/// The data to send to the device.
public void SetData(EntityUid uid, string address, IAtmosDeviceData data)
{
- if (EntityManager.TryGetComponent(uid, out AtmosMonitorComponent? monitor)
- && !monitor.NetEnabled)
- return;
-
- var payload = new NetworkPayload
- {
- [DeviceNetworkConstants.Command] = AirAlarmSetData,
- // [AirAlarmTypeData] = type,
- [AirAlarmSetData] = data
- };
-
- _deviceNet.QueuePacket(uid, address, payload);
+ _atmosDevNetSystem.SetDeviceState(uid, address, data);
+ _atmosDevNetSystem.Sync(uid, address);
}
///
/// Broadcast a sync packet to an air alarm's local network.
///
- public void SyncAllDevices(EntityUid uid)
+ private void SyncAllDevices(EntityUid uid)
{
- if (EntityManager.TryGetComponent(uid, out AtmosMonitorComponent? monitor)
- && !monitor.NetEnabled)
- return;
-
- var payload = new NetworkPayload
- {
- [DeviceNetworkConstants.Command] = AirAlarmSyncCmd
- };
-
- _deviceNet.QueuePacket(uid, null, payload);
+ _atmosDevNetSystem.Sync(uid, null);
}
///
/// Send a sync packet to a specific device from an air alarm.
///
/// The address of the device.
- public void SyncDevice(EntityUid uid, string address)
+ private void SyncDevice(EntityUid uid, string address)
{
- if (EntityManager.TryGetComponent(uid, out AtmosMonitorComponent? monitor)
- && !monitor.NetEnabled)
- return;
+ _atmosDevNetSystem.Sync(uid, address);
+ }
-
- var payload = new NetworkPayload
- {
- [DeviceNetworkConstants.Command] = AirAlarmSyncCmd
- };
-
- _deviceNet.QueuePacket(uid, address, payload);
+ ///
+ /// Register and synchronize with all devices
+ /// on this network.
+ ///
+ ///
+ public void SyncRegisterAllDevices(EntityUid uid)
+ {
+ _atmosDevNetSystem.Register(uid, null);
+ _atmosDevNetSystem.Sync(uid, null);
}
///
@@ -284,7 +266,7 @@ namespace Content.Server.Atmos.Monitor.Systems
component.ScrubberData.Clear();
component.SensorData.Clear();
- SyncAllDevices(uid);
+ SyncRegisterAllDevices(uid);
}
}
@@ -425,7 +407,7 @@ namespace Content.Server.Atmos.Monitor.Systems
switch (cmd)
{
- case AirAlarmSyncData:
+ case AtmosDeviceNetworkSystem.SyncData:
if (!args.Data.TryGetValue(AirAlarmSyncData, out IAtmosDeviceData? data)
|| !controller.CanSync)
break;
@@ -452,16 +434,6 @@ namespace Content.Server.Atmos.Monitor.Systems
UpdateUI(uid, controller);
- return;
- case AirAlarmSetDataStatus:
- if (!args.Data.TryGetValue(AirAlarmSetDataStatus, out bool dataStatus))
- break;
-
- // Sync data to interface.
- // This should say if the result
- // failed, or succeeded. Don't save it.l
- SyncDevice(uid, args.SenderAddress);
-
return;
case AirAlarmSetMode:
if (!args.Data.TryGetValue(AirAlarmSetMode, out AirAlarmMode alarmMode)) break;
diff --git a/Content.Server/Atmos/Monitor/Systems/AtmosAlarmingSystem.cs b/Content.Server/Atmos/Monitor/Systems/AtmosAlarmingSystem.cs
deleted file mode 100644
index 4addc104cb..0000000000
--- a/Content.Server/Atmos/Monitor/Systems/AtmosAlarmingSystem.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Content.Server.Atmos.Monitor.Components;
-
-namespace Content.Server.Atmos.Monitor.Systems;
-
-///
-/// System that alarms AtmosAlarmables via DeviceNetwork.
-/// This is one way, and is usually triggered by an event.
-///
-public sealed class AtmosAlarmingSystem : EntitySystem
-{
- ///
- /// The alarm command key.
- ///
- public const string AtmosAlarmCmd = "atmos_alarming_alarm_cmd";
-
- ///
- /// Register command. Registers this address so that the alarm can send
- /// to the given device.
- ///
- public const string AtmosAlarmRegisterCmd = "atmos_alarming_register_cmd";
-
- ///
- /// Alarm data. Contains the alert passed into this alarmer.
- ///
- public const string AtmosAlarmData = "atmos_alarming_alarm_data";
-
- private void OnAlert(EntityUid uid, AtmosAlarmingComponent component, AtmosMonitorAlarmEvent args)
- {
-
- }
-}
diff --git a/Content.Server/Atmos/Monitor/Systems/AtmosDeviceNetwork.cs b/Content.Server/Atmos/Monitor/Systems/AtmosDeviceNetwork.cs
new file mode 100644
index 0000000000..0262aee0cd
--- /dev/null
+++ b/Content.Server/Atmos/Monitor/Systems/AtmosDeviceNetwork.cs
@@ -0,0 +1,65 @@
+using Content.Server.DeviceNetwork;
+using Content.Server.DeviceNetwork.Systems;
+using Content.Shared.Atmos.Monitor.Components;
+
+namespace Content.Server.Atmos.Monitor.Systems;
+
+///
+/// Generic device network commands useful for atmos devices,
+/// as well as some helper commands.
+///
+public sealed class AtmosDeviceNetworkSystem : EntitySystem
+{
+ ///
+ /// Any information about atmosphere that a device can scan.
+ ///
+ public const string AtmosData = "atmos_atmosphere_data";
+
+ ///
+ /// Register a device's address on this device.
+ ///
+ public const string RegisterDevice = "atmos_register_device";
+
+ ///
+ /// Synchronize the data this device has with the sender.
+ ///
+ public const string SyncData = "atmos_sync_data";
+
+ ///
+ /// Set the state of this device using the contained data.
+ ///
+ public const string SetState = "atmos_set_state";
+
+ [Dependency] private readonly DeviceNetworkSystem _deviceNet = default!;
+
+ public void Register(EntityUid uid, string? address)
+ {
+ var registerPayload = new NetworkPayload
+ {
+ [DeviceNetworkConstants.Command] = RegisterDevice
+ };
+
+ _deviceNet.QueuePacket(uid, address, registerPayload);
+ }
+
+ public void Sync(EntityUid uid, string? address)
+ {
+ var syncPayload = new NetworkPayload
+ {
+ [DeviceNetworkConstants.Command] = SyncData
+ };
+
+ _deviceNet.QueuePacket(uid, address, syncPayload);
+ }
+
+ public void SetDeviceState(EntityUid uid, string address, IAtmosDeviceData data)
+ {
+ var payload = new NetworkPayload()
+ {
+ [DeviceNetworkConstants.Command] = SetState,
+ [SetState] = data
+ };
+
+ _deviceNet.QueuePacket(uid, address, payload);
+ }
+}
diff --git a/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs b/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs
index 493e4d301c..2205547663 100644
--- a/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs
+++ b/Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs
@@ -51,29 +51,14 @@ namespace Content.Server.Atmos.Monitor.Systems
public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold";
- public const string AtmosMonitorGetDataCmd = "atmos_monitor_get_data";
// Packet data
- ///
- /// Data response that contains the threshold types in an atmos monitor alarm.
- ///
- public const string AtmosMonitorAlarmThresholdTypes = "atmos_monitor_alarm_threshold_types";
///
/// Data response that contains the source of an atmos alarm.
///
public const string AtmosMonitorAlarmSrc = "atmos_monitor_alarm_source";
- ///
- /// Data response that contains the maximum alarm in an atmos alarm network.
- ///
- public const string AtmosMonitorAlarmNetMax = "atmos_monitor_alarm_net_max";
-
- ///
- /// Data response that contains the last state recorded by this air monitor.
- ///
- public const string AtmosMonitorAtmosData = "atmos_monitor_atmos_data";
-
public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data";
public const string AtmosMonitorThresholdDataType = "atmos_monitor_threshold_type";
@@ -128,43 +113,20 @@ namespace Content.Server.Atmos.Monitor.Systems
// sync the internal 'last alarm state' from
// the other alarms, so that we can calculate
// the highest network alarm state at any time
- if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string? cmd)
- || !EntityManager.TryGetComponent(uid, out AtmosAlarmableComponent? alarmable)
- || !EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn))
+ if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string? cmd))
+ {
return;
-
- // ignore packets from self, ignore from different frequency
- if (netConn.Address == args.SenderAddress) return;
-
- var responseKey = string.Empty;
+ }
switch (cmd)
{
- /*
- // sync on alarm or explicit sync
- case AtmosMonitorAlarmCmd:
- case AtmosMonitorAlarmSyncCmd:
- if (args.Data.TryGetValue(AtmosMonitorAlarmSrc, out string? src)
- && alarmable.AlarmedByPrototypes.Contains(src)
- && args.Data.TryGetValue(DeviceNetworkConstants.CmdSetState, out AtmosMonitorAlarmType state)
- && !component.NetworkAlarmStates.TryAdd(args.SenderAddress, state))
- component.NetworkAlarmStates[args.SenderAddress] = state;
+ case AtmosDeviceNetworkSystem.RegisterDevice:
+ component.RegisteredDevices.Add(args.SenderAddress);
break;
- */
case AtmosMonitorAlarmResetCmd:
Reset(uid);
// Don't clear alarm states here.
break;
- /*
- case AtmosMonitorAlarmResetAllCmd:
- if (args.Data.TryGetValue(AtmosMonitorAlarmSrc, out string? resetSrc)
- && alarmable.AlarmedByPrototypes.Contains(resetSrc))
- {
- component.LastAlarmState = AtmosMonitorAlarmType.Normal;
- component.NetworkAlarmStates.Clear();
- }
- break;
- */
case AtmosMonitorSetThresholdCmd:
if (args.Data.TryGetValue(AtmosMonitorThresholdData, out AtmosAlarmThreshold? thresholdData)
&& args.Data.TryGetValue(AtmosMonitorThresholdDataType, out AtmosMonitorThresholdType? thresholdType))
@@ -174,9 +136,9 @@ namespace Content.Server.Atmos.Monitor.Systems
}
break;
- case AtmosMonitorGetDataCmd:
+ case AtmosDeviceNetworkSystem.SyncData:
var payload = new NetworkPayload();
- payload.Add(DeviceNetworkConstants.Command, AtmosMonitorAtmosData);
+ payload.Add(DeviceNetworkConstants.Command, AtmosDeviceNetworkSystem.SyncData);
if (component.TileGas != null)
{
var gases = new Dictionary();
@@ -185,7 +147,7 @@ namespace Content.Server.Atmos.Monitor.Systems
gases.Add(gas, component.TileGas.GetMoles(gas));
}
- payload.Add(AtmosMonitorAtmosData, new AtmosSensorData(
+ payload.Add(AtmosDeviceNetworkSystem.SyncData, new AtmosSensorData(
component.TileGas.Pressure,
component.TileGas.Temperature,
component.TileGas.TotalMoles,
@@ -418,12 +380,13 @@ namespace Content.Server.Atmos.Monitor.Systems
{
[DeviceNetworkConstants.Command] = AtmosMonitorAlarmCmd,
[DeviceNetworkConstants.CmdSetState] = monitor.LastAlarmState,
- [AtmosMonitorAlarmNetMax] = monitor.HighestAlarmInNetwork,
- [AtmosMonitorAlarmThresholdTypes] = alarms,
[AtmosMonitorAlarmSrc] = source
};
- _deviceNetSystem.QueuePacket(monitor.Owner, null, payload);
+ foreach (var addr in monitor.RegisteredDevices)
+ {
+ _deviceNetSystem.QueuePacket(monitor.Owner, addr, payload);
+ }
}
///
diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs
index 8da4dc7b95..4507f56dfe 100644
--- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs
+++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs
@@ -188,23 +188,19 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
switch (cmd)
{
- case AirAlarmSystem.AirAlarmSyncCmd:
- payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSyncData);
- payload.Add(AirAlarmSystem.AirAlarmSyncData, component.ToAirAlarmData());
+ case AtmosDeviceNetworkSystem.SyncData:
+ payload.Add(DeviceNetworkConstants.Command, AtmosDeviceNetworkSystem.SyncData);
+ payload.Add(AtmosDeviceNetworkSystem.SyncData, component.ToAirAlarmData());
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, payload, device: netConn);
return;
- case AirAlarmSystem.AirAlarmSetData:
- if (!args.Data.TryGetValue(AirAlarmSystem.AirAlarmSetData, out GasVentPumpData? setData))
+ case AtmosDeviceNetworkSystem.SetState:
+ if (!args.Data.TryGetValue(AtmosDeviceNetworkSystem.SetState, out GasVentPumpData? setData))
break;
component.FromAirAlarmData(setData);
UpdateState(uid, component);
- payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSetDataStatus);
- payload.Add(AirAlarmSystem.AirAlarmSetDataStatus, true);
-
- _deviceNetSystem.QueuePacket(uid, null, payload, device: netConn);
return;
}
diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs
index f1ff71ca64..de3b9b6c4a 100644
--- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs
+++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs
@@ -154,23 +154,19 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
switch (cmd)
{
- case AirAlarmSystem.AirAlarmSyncCmd:
- payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSyncData);
- payload.Add(AirAlarmSystem.AirAlarmSyncData, component.ToAirAlarmData());
+ case AtmosDeviceNetworkSystem.SyncData:
+ payload.Add(DeviceNetworkConstants.Command, AtmosDeviceNetworkSystem.SyncData);
+ payload.Add(AtmosDeviceNetworkSystem.SyncData, component.ToAirAlarmData());
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, payload, device: netConn);
return;
- case AirAlarmSystem.AirAlarmSetData:
- if (!args.Data.TryGetValue(AirAlarmSystem.AirAlarmSetData, out GasVentScrubberData? setData))
+ case AtmosDeviceNetworkSystem.SetState:
+ if (!args.Data.TryGetValue(AtmosDeviceNetworkSystem.SetState, out GasVentScrubberData? setData))
break;
component.FromAirAlarmData(setData);
UpdateState(uid, component);
- payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSetDataStatus);
- payload.Add(AirAlarmSystem.AirAlarmSetDataStatus, true);
-
- _deviceNetSystem.QueuePacket(uid, null, payload, device: netConn);
return;
}