68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
// MyBWRSimulator.Core/Ports/ThermalPort.cs
|
|
namespace MyBWRSimulator.Core.Ports
|
|
{
|
|
using MyBWRSimulator.Core.Components.Abstract;
|
|
|
|
/// <summary>
|
|
/// Represents an Thermal connection point on a component.
|
|
/// </summary>
|
|
public class ThermalPort : Port
|
|
{
|
|
/// <summary>
|
|
/// Current voltage at this port (e.g., Volts).
|
|
/// </summary>
|
|
public double Voltage { get; set; }
|
|
|
|
/// <summary>
|
|
/// Current amperage at this port (e.g., Amperes).
|
|
/// </summary>
|
|
public double Amperage { get; set; }
|
|
|
|
/// <summary>
|
|
/// True if this port is actively supplying power.
|
|
/// </summary>
|
|
public bool IsSupplyingPower { get; set; }
|
|
|
|
/// <summary>
|
|
/// Constructor for an ThermalPort.
|
|
/// </summary>
|
|
/// <param name="id">Unique identifier for the port.</param>
|
|
public ThermalPort(string id) : base(id)
|
|
{
|
|
Voltage = 0.0;
|
|
Amperage = 0.0;
|
|
IsSupplyingPower = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Connects this Thermal port to another Thermal port.
|
|
/// Includes basic type checking.
|
|
/// </summary>
|
|
/// <param name="otherPort">The port to connect to.</param>
|
|
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}.");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mirrors Thermal properties from this port to its connected port.
|
|
/// This is for the direct property assignment data flow model.
|
|
/// </summary>
|
|
public void MirrorToConnectedPort()
|
|
{
|
|
if (ConnectedPort is ThermalPort connectedThermalPort)
|
|
{
|
|
connectedThermalPort.Voltage = this.Voltage;
|
|
connectedThermalPort.Amperage = this.Amperage;
|
|
connectedThermalPort.IsSupplyingPower = this.IsSupplyingPower;
|
|
}
|
|
}
|
|
}
|
|
} |