Mech milestone phase 2: reconstruct HeatSink (roster layer 3)
HeatSink : public HeatableSubsystem (confirmed hierarchy) -- a thermal mass with a coolant loop. Added to HEAT.HPP/.CPP: the class + its SubsystemConnection slot helper + HeatSink__SubsystemResource. Ctor chains HeatableSubsystem and seeds the thermal state from the resource (startingTemperature/degradation/failure/ thermalConductance/thermalMass), heatAlarm(3) = AlarmIndicator, heatFilter = AverageOf<Scalar>(15). Statics, dtor, ResetToInitialState, TestClass/TestInstance real; the per-frame thermal sim (HeatSinkSimulation/DrawCoolant) staged. Also reconciled HeatableSubsystem to the 4.10 fields: its resource struct now carries startingTemperature/degradationTemperature/failureTemperature/ thermalConductance/thermalMass (was the BT411-mislabeled thermalMass/degrade/fail/ coolingLoop set), and degradationTemperature/failureTemperature are base members (HeatSink reads them). Verified slice now: MechSubsystem -> HeatableSubsystem -> HeatSink. Compile-verified (BT: 25 ok); tree links clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -118,3 +118,135 @@ int
|
||||
Fail("HeatableSubsystem::CreateStreamedSubsystem -- heat.cpp not yet reconstructed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//###########################################################################
|
||||
//############################## HeatSink ###############################
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// Shared data support
|
||||
//#############################################################################
|
||||
//
|
||||
Derivation
|
||||
HeatSink::ClassDerivations(
|
||||
HeatableSubsystem::ClassDerivations,
|
||||
"HeatSink"
|
||||
);
|
||||
|
||||
HeatSink::SharedData
|
||||
HeatSink::DefaultData(
|
||||
HeatSink::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
Subsystem::StateCount
|
||||
);
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// The heat sink -- a thermal mass with a coolant loop. A master sink drives
|
||||
// the per-frame thermal simulation.
|
||||
//#############################################################################
|
||||
//
|
||||
HeatSink::HeatSink(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data
|
||||
):
|
||||
HeatableSubsystem(owner, subsystem_ID, subsystem_resource, shared_data),
|
||||
linkedSinks(),
|
||||
heatAlarm(3)
|
||||
{
|
||||
Check(owner);
|
||||
Check_Pointer(subsystem_resource);
|
||||
|
||||
currentTemperature = subsystem_resource->startingTemperature;
|
||||
degradationTemperature = subsystem_resource->degradationTemperature;
|
||||
failureTemperature = subsystem_resource->failureTemperature;
|
||||
|
||||
heatLoad = 0.0f;
|
||||
coolantEfficiency = 0.5f;
|
||||
thermalCapacity = 1.0f;
|
||||
coolantLevel = thermalCapacity;
|
||||
coolantDraw = 0.0f;
|
||||
coolantAvailable = 1;
|
||||
coolantActive = 0;
|
||||
|
||||
startingTemperature = currentTemperature;
|
||||
thermalConductance = subsystem_resource->thermalConductance;
|
||||
|
||||
heatFilter.SetSize(15, 0.0f);
|
||||
filterDecay = 0.4f;
|
||||
thermalMass = subsystem_resource->thermalMass;
|
||||
heatEnergy = thermalMass * startingTemperature;
|
||||
coolantFlowScale = 1.0f;
|
||||
massScale = 1.0f;
|
||||
|
||||
pendingHeat = 0.0f;
|
||||
radiatedHeat = 0.0f;
|
||||
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
HeatSink::~HeatSink()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
void
|
||||
HeatSink::ResetToInitialState(Logical /*powered*/)
|
||||
{
|
||||
Check(this);
|
||||
currentTemperature = startingTemperature;
|
||||
heatLoad = 0.0f;
|
||||
coolantLevel = thermalCapacity;
|
||||
coolantDraw = 0.0f;
|
||||
coolantActive = 0;
|
||||
heatEnergy = thermalMass * startingTemperature;
|
||||
pendingHeat = 0.0f;
|
||||
radiatedHeat = 0.0f;
|
||||
heatAlarm.SetLevel(0);
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Logical
|
||||
HeatSink::TestClass(Mech &)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
Logical
|
||||
HeatSink::TestInstance() const
|
||||
{
|
||||
return IsDerivedFrom(ClassDerivations);
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// Per-frame thermal simulation (heat conduction, coolant draw, radiation).
|
||||
// Not yet reconstructed -- fires only once the mech is ticking.
|
||||
//#############################################################################
|
||||
//
|
||||
void
|
||||
HeatSink::HeatSinkSimulation(Scalar)
|
||||
{
|
||||
Fail("HeatSink::HeatSinkSimulation -- heat.cpp not yet reconstructed");
|
||||
}
|
||||
|
||||
Scalar
|
||||
HeatSink::DrawCoolant(Scalar)
|
||||
{
|
||||
Fail("HeatSink::DrawCoolant -- heat.cpp not yet reconstructed");
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
# include <mechsub.hpp>
|
||||
# endif
|
||||
|
||||
# if !defined(AVERAGE_HPP)
|
||||
# include <average.hpp>
|
||||
# endif
|
||||
|
||||
//##################### Forward Class Declarations #######################
|
||||
class Mech;
|
||||
|
||||
@@ -29,10 +33,11 @@
|
||||
struct HeatableSubsystem__SubsystemResource:
|
||||
public MechSubsystem::SubsystemResource
|
||||
{
|
||||
Scalar startingTemperature;
|
||||
Scalar degradationTemperature;
|
||||
Scalar failureTemperature;
|
||||
Scalar thermalConductance;
|
||||
Scalar thermalMass;
|
||||
Scalar degradeTemperature;
|
||||
Scalar failTemperature;
|
||||
int coolingLoop;
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
@@ -92,6 +97,108 @@
|
||||
protected:
|
||||
Scalar currentTemperature;
|
||||
Scalar heatLoad;
|
||||
Scalar degradationTemperature;
|
||||
Scalar failureTemperature;
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
//########################## SubsystemConnection ########################
|
||||
//###########################################################################
|
||||
//
|
||||
// A slot linking a heat sink to its master / linked heat sink.
|
||||
//
|
||||
class SubsystemConnection
|
||||
{
|
||||
public:
|
||||
SubsystemConnection() { linked = NULL; }
|
||||
void Add(Subsystem *s) { linked = s; }
|
||||
Subsystem* Resolve() const { return linked; }
|
||||
void Clear() { linked = NULL; }
|
||||
protected:
|
||||
Subsystem *linked;
|
||||
int reserved[2];
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
//####################### HeatSink Model Resource #######################
|
||||
//###########################################################################
|
||||
|
||||
struct HeatSink__SubsystemResource:
|
||||
public HeatableSubsystem__SubsystemResource
|
||||
{
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
//############################## HeatSink ###############################
|
||||
//###########################################################################
|
||||
|
||||
class HeatSink:
|
||||
public HeatableSubsystem
|
||||
{
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Shared Data Support
|
||||
//
|
||||
public:
|
||||
static Derivation ClassDerivations;
|
||||
static SharedData DefaultData;
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Test Class Support
|
||||
//
|
||||
public:
|
||||
static Logical
|
||||
TestClass(Mech &);
|
||||
Logical
|
||||
TestInstance() const;
|
||||
void
|
||||
ResetToInitialState(Logical powered);
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Simulation Support
|
||||
//
|
||||
public:
|
||||
void
|
||||
HeatSinkSimulation(Scalar time_slice);
|
||||
virtual Scalar
|
||||
DrawCoolant(Scalar requested);
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Construction and Destruction
|
||||
//
|
||||
public:
|
||||
typedef HeatSink__SubsystemResource SubsystemResource;
|
||||
|
||||
HeatSink(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data = DefaultData
|
||||
);
|
||||
|
||||
~HeatSink();
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Local Data
|
||||
//
|
||||
protected:
|
||||
Scalar coolantEfficiency;
|
||||
Scalar thermalCapacity;
|
||||
Scalar coolantLevel;
|
||||
Scalar coolantDraw;
|
||||
int coolantAvailable;
|
||||
int coolantActive;
|
||||
Scalar startingTemperature;
|
||||
Scalar thermalConductance;
|
||||
Scalar filterDecay;
|
||||
Scalar thermalMass;
|
||||
Scalar heatEnergy;
|
||||
Scalar coolantFlowScale;
|
||||
Scalar massScale;
|
||||
Scalar pendingHeat;
|
||||
Scalar radiatedHeat;
|
||||
SubsystemConnection linkedSinks;
|
||||
AlarmIndicator heatAlarm;
|
||||
AverageOf<Scalar> heatFilter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user