Files
TeslaRel410/restoration/source410/BT/POWERSUB.CPP
T
CydandClaude Fable 5 6e96b5b570 Mech milestone phase 2: reconstruct PoweredSubsystem (roster layer 4)
Fixes the staged POWERSUB.HPP base (HeatableSubsystem -> HeatSink, the real
hierarchy) and reconstructs PoweredSubsystem: a HeatSink that draws electrical
power. Added members (voltageSource = SubsystemConnection, electricalStateAlarm =
AlarmIndicator(5), modeAlarm = AlarmIndicator(3), input/output/ratedVoltage) and
corrected the resource struct (voltageSourceIndex + thermalResistivityCoefficient
+ startTime). Ctor chains HeatSink and primes the electrical state; statics, dtor,
ResetToInitialState, TestClass/TestInstance real.

The voltage-source resolution (indexing the owner mech's subsystem ROSTER for the
powering generator) + master-instance electrical sim + AttachToVoltageSource are
deferred to the segment-walk phase (phase 4) where the roster is populated -- the
subsystem constructs with no attached source until then. Verified slice now:
MechSubsystem -> HeatableSubsystem -> HeatSink -> PoweredSubsystem. Compile-verified
(BT: 26 ok); tree links clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 23:22:49 -05:00

124 lines
3.7 KiB
C++

//===========================================================================//
// File: powersub.cpp //
// Project: BattleTech Brick: Mech subsystems //
// Contents: PoweredSubsystem -- a HeatSink drawing electrical power //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <bt.hpp>
#pragma hdrstop
#if !defined(POWERSUB_HPP)
# include <powersub.hpp>
#endif
#if !defined(MECH_HPP)
# include <mech.hpp>
#endif
//
//#############################################################################
// Shared data support
//#############################################################################
//
Derivation
PoweredSubsystem::ClassDerivations(
HeatSink::ClassDerivations,
"PoweredSubsystem"
);
PoweredSubsystem::SharedData
PoweredSubsystem::DefaultData(
PoweredSubsystem::ClassDerivations,
Subsystem::MessageHandlers,
Subsystem::AttributeIndex,
Subsystem::StateCount
);
//
//#############################################################################
// A HeatSink that draws electrical power from a generator.
//
// The voltage-source resolution (indexing the owner mech's SUBSYSTEM ROSTER to
// find the powering generator) and the master-instance electrical simulation
// need the roster populated -- which happens during the Mech ctor's
// segment-table walk -- so they are deferred to that phase (see MECHSUB.NOTES.md).
// The ctor here chains HeatSink and primes the electrical state; the subsystem
// constructs with no attached source (inputVoltage 0) until the wiring lands.
//#############################################################################
//
PoweredSubsystem::PoweredSubsystem(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data
):
HeatSink(owner, subsystem_ID, subsystem_resource, shared_data),
voltageSource(),
electricalStateAlarm(5),
modeAlarm(3)
{
Check(owner);
Check_Pointer(subsystem_resource);
inputVoltage = 0.0f;
outputVoltage = 0.0f;
ratedVoltage = 0.0f;
Check_Fpu();
}
//
//#############################################################################
//#############################################################################
//
PoweredSubsystem::~PoweredSubsystem()
{
}
//
//#############################################################################
//#############################################################################
//
void
PoweredSubsystem::ResetToInitialState(Logical powered)
{
Check(this);
HeatSink::ResetToInitialState(powered);
inputVoltage = 0.0f;
outputVoltage = 0.0f;
electricalStateAlarm.SetLevel(0);
modeAlarm.SetLevel(0);
}
//
//#############################################################################
//#############################################################################
//
Logical
PoweredSubsystem::TestClass(Mech &)
{
return True;
}
Logical
PoweredSubsystem::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// AttachToVoltageSource Link this subsystem to its powering generator.
// Deferred with the segment-walk (needs the populated roster).
//#############################################################################
//
void
PoweredSubsystem::AttachToVoltageSource(Subsystem *)
{
Fail("PoweredSubsystem::AttachToVoltageSource -- powersub.cpp not yet reconstructed");
}