// MyBWRSimulator.Core/Ports/ThermalPort.cs
namespace MyBWRSimulator.Core.Ports
{
using MyBWRSimulator.Core.Components.Abstract;
///
/// Represents an Thermal connection point on a component.
///
public class ThermalPort : Port
{
///
/// Current voltage at this port (e.g., Volts).
///
public double Voltage { get; set; }
///
/// Current amperage at this port (e.g., Amperes).
///
public double Amperage { get; set; }
///
/// True if this port is actively supplying power.
///
public bool IsSupplyingPower { get; set; }
///
/// Constructor for an ThermalPort.
///
/// Unique identifier for the port.
public ThermalPort(string id) : base(id)
{
Voltage = 0.0;
Amperage = 0.0;
IsSupplyingPower = false;
}
///
/// Connects this Thermal port to another Thermal port.
/// Includes basic type checking.
///
/// The port to connect to.
public override void Connect(Port otherPort)
{
if (otherPort is ThermalPort)
{
base.Connect(otherPort);
}
else
{
Console.WriteLine($"Error: Cannot connect ThermalPort {ID} to non-ThermalPort {otherPort.ID}.");
}
}
///
/// Mirrors Thermal properties from this port to its connected port.
/// This is for the direct property assignment data flow model.
///
public void MirrorToConnectedPort()
{
if (ConnectedPort is ThermalPort connectedThermalPort)
{
connectedThermalPort.Voltage = this.Voltage;
connectedThermalPort.Amperage = this.Amperage;
connectedThermalPort.IsSupplyingPower = this.IsSupplyingPower;
}
}
}
}