Mech phase 2: reconstruct HeatWatcher (: MechSubsystem) subsystem
Watches another subsystem's temperature, drives a 3-level alarm. Sibling branch to HeatableSubsystem (derives straight from MechSubsystem). Ctor + statics + dtor + TestClass/TestInstance/ResetToInitialState real; WatchSimulation (per-frame) staged. Unblocks PowerWatcher -> Torso/HUD/Gyroscope. BT: 27 ok. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -250,3 +250,83 @@ Scalar
|
||||
Fail("HeatSink::DrawCoolant -- heat.cpp not yet reconstructed");
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
//###########################################################################
|
||||
//############################# HeatWatcher #############################
|
||||
//###########################################################################
|
||||
|
||||
Derivation
|
||||
HeatWatcher::ClassDerivations(
|
||||
MechSubsystem::ClassDerivations,
|
||||
"HeatWatcher"
|
||||
);
|
||||
|
||||
HeatWatcher::SharedData
|
||||
HeatWatcher::DefaultData(
|
||||
HeatWatcher::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
Subsystem::StateCount
|
||||
);
|
||||
|
||||
HeatWatcher::HeatWatcher(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data
|
||||
):
|
||||
MechSubsystem(
|
||||
owner,
|
||||
subsystem_ID,
|
||||
(MechSubsystem::SubsystemResource *)subsystem_resource,
|
||||
shared_data
|
||||
),
|
||||
watchedLink(),
|
||||
heatAlarm(3)
|
||||
{
|
||||
Check(owner);
|
||||
Check_Pointer(subsystem_resource);
|
||||
|
||||
degradationTemperature = subsystem_resource->degradationTemperature;
|
||||
failureTemperature = subsystem_resource->failureTemperature;
|
||||
watchedSubsystem = subsystem_resource->watchedSubsystem;
|
||||
|
||||
//
|
||||
// The master instance runs WatchSimulation per-frame; the install is
|
||||
// deferred with that (staged) method.
|
||||
//
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
HeatWatcher::~HeatWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
Logical
|
||||
HeatWatcher::TestClass(Mech &)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
Logical
|
||||
HeatWatcher::TestInstance() const
|
||||
{
|
||||
return IsDerivedFrom(ClassDerivations);
|
||||
}
|
||||
|
||||
void
|
||||
HeatWatcher::ResetToInitialState(Logical /*powered*/)
|
||||
{
|
||||
Check(this);
|
||||
heatAlarm.SetLevel(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Per-frame: resolve the watched subsystem, read its temperature, drive the
|
||||
// 3-level alarm. Not yet reconstructed.
|
||||
//
|
||||
void
|
||||
HeatWatcher::WatchSimulation(Scalar)
|
||||
{
|
||||
Fail("HeatWatcher::WatchSimulation -- heat.cpp not yet reconstructed");
|
||||
}
|
||||
|
||||
@@ -132,6 +132,61 @@
|
||||
//############################## HeatSink ###############################
|
||||
//###########################################################################
|
||||
|
||||
//###########################################################################
|
||||
//################### HeatWatcher Model Resource #######################
|
||||
//###########################################################################
|
||||
|
||||
struct HeatWatcher__SubsystemResource:
|
||||
public MechSubsystem__SubsystemResource
|
||||
{
|
||||
int watchedSubsystem;
|
||||
Scalar degradationTemperature;
|
||||
Scalar failureTemperature;
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
//############################# HeatWatcher #############################
|
||||
//###########################################################################
|
||||
//
|
||||
// Watches another subsystem's temperature and drives a 3-level alarm. A
|
||||
// sibling branch to HeatableSubsystem (derives straight from MechSubsystem);
|
||||
// PowerWatcher and the Torso/HUD/Gyroscope leaves descend from it.
|
||||
//
|
||||
class HeatWatcher:
|
||||
public MechSubsystem
|
||||
{
|
||||
public:
|
||||
static Derivation ClassDerivations;
|
||||
static SharedData DefaultData;
|
||||
|
||||
static Logical
|
||||
TestClass(Mech &);
|
||||
Logical
|
||||
TestInstance() const;
|
||||
void
|
||||
ResetToInitialState(Logical powered);
|
||||
void
|
||||
WatchSimulation(Scalar time_slice);
|
||||
|
||||
public:
|
||||
typedef HeatWatcher__SubsystemResource SubsystemResource;
|
||||
|
||||
HeatWatcher(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data = DefaultData
|
||||
);
|
||||
~HeatWatcher();
|
||||
|
||||
protected:
|
||||
SubsystemConnection watchedLink;
|
||||
int watchedSubsystem;
|
||||
Scalar degradationTemperature;
|
||||
Scalar failureTemperature;
|
||||
AlarmIndicator heatAlarm;
|
||||
};
|
||||
|
||||
class HeatSink:
|
||||
public HeatableSubsystem
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user