Mech phase 2: reconstruct PowerWatcher (: HeatWatcher)

Base of the Torso/HUD/Gyroscope cockpit subsystems. Ctor chains HeatWatcher +
watchdogAlarm(5) + minVoltage; statics/dtor/test/reset real; Simulation staged.
BT: 27 ok.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-19 23:59:28 -05:00
co-authored by Claude Fable 5
parent 999c98fe91
commit 84d43e6512
2 changed files with 119 additions and 0 deletions
+70
View File
@@ -237,3 +237,73 @@ void
{
Fail("Generator::GeneratorSimulation -- powersub.cpp not yet reconstructed");
}
//###########################################################################
//############################ PowerWatcher ############################
//###########################################################################
Derivation
PowerWatcher::ClassDerivations(
HeatWatcher::ClassDerivations,
"PowerWatcher"
);
PowerWatcher::SharedData
PowerWatcher::DefaultData(
PowerWatcher::ClassDerivations,
Subsystem::MessageHandlers,
Subsystem::AttributeIndex,
Subsystem::StateCount
);
PowerWatcher::PowerWatcher(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data
):
HeatWatcher(owner, subsystem_ID, subsystem_resource, shared_data),
watchdogAlarm(5)
{
Check(owner);
Check_Pointer(subsystem_resource);
//
// minVoltage is a scaled fraction of the watched supply; the exact scale
// constant is a tuning value (stored 1:1 here until located).
//
minVoltage = subsystem_resource->minVoltagePercent;
Check_Fpu();
}
PowerWatcher::~PowerWatcher()
{
}
Logical
PowerWatcher::TestClass(Mech &)
{
return True;
}
Logical
PowerWatcher::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
void
PowerWatcher::ResetToInitialState(Logical powered)
{
Check(this);
HeatWatcher::ResetToInitialState(powered);
watchdogAlarm.SetLevel(0);
}
//
// Per-frame supply-voltage watchdog. Not yet reconstructed.
//
void
PowerWatcher::Simulation(Scalar)
{
Fail("PowerWatcher::Simulation -- powersub.cpp not yet reconstructed");
}
+49
View File
@@ -110,6 +110,55 @@
AlarmIndicator modeAlarm;
};
//###########################################################################
//################### PowerWatcher Model Resource ######################
//###########################################################################
struct PowerWatcher__SubsystemResource:
public HeatWatcher::SubsystemResource
{
Scalar minVoltagePercent;
};
//###########################################################################
//############################ PowerWatcher ############################
//###########################################################################
//
// A HeatWatcher that also watches its subject's supply voltage. Base of the
// Torso / HUD / Gyroscope cockpit subsystems.
//
class PowerWatcher:
public HeatWatcher
{
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static Logical
TestClass(Mech &);
Logical
TestInstance() const;
void
ResetToInitialState(Logical powered);
void
Simulation(Scalar time_slice);
public:
typedef PowerWatcher__SubsystemResource SubsystemResource;
PowerWatcher(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data = DefaultData
);
~PowerWatcher();
protected:
Scalar minVoltage;
AlarmIndicator watchdogAlarm;
};
//###########################################################################
//#################### Generator Model Resource ########################
//###########################################################################