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>
This commit is contained in:
@@ -0,0 +1,123 @@
|
|||||||
|
//===========================================================================//
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
@@ -27,9 +27,9 @@
|
|||||||
//###########################################################################
|
//###########################################################################
|
||||||
|
|
||||||
struct PoweredSubsystem__SubsystemResource:
|
struct PoweredSubsystem__SubsystemResource:
|
||||||
public HeatableSubsystem::SubsystemResource
|
public HeatSink::SubsystemResource
|
||||||
{
|
{
|
||||||
int voltageSource;
|
int voltageSourceIndex;
|
||||||
Scalar thermalResistivityCoefficient;
|
Scalar thermalResistivityCoefficient;
|
||||||
int auxScreenNumber;
|
int auxScreenNumber;
|
||||||
int auxScreenPlacement;
|
int auxScreenPlacement;
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
//###########################################################################
|
//###########################################################################
|
||||||
|
|
||||||
class PoweredSubsystem:
|
class PoweredSubsystem:
|
||||||
public HeatableSubsystem
|
public HeatSink
|
||||||
{
|
{
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Shared Data Support
|
// Shared Data Support
|
||||||
@@ -51,7 +51,6 @@
|
|||||||
public:
|
public:
|
||||||
static Derivation ClassDerivations;
|
static Derivation ClassDerivations;
|
||||||
static SharedData DefaultData;
|
static SharedData DefaultData;
|
||||||
static MessageHandlerSet MessageHandlers;
|
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Test Class Support
|
// Test Class Support
|
||||||
@@ -61,6 +60,17 @@
|
|||||||
TestClass(Mech &);
|
TestClass(Mech &);
|
||||||
Logical
|
Logical
|
||||||
TestInstance() const;
|
TestInstance() const;
|
||||||
|
void
|
||||||
|
ResetToInitialState(Logical powered);
|
||||||
|
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// Power support
|
||||||
|
//
|
||||||
|
public:
|
||||||
|
Subsystem*
|
||||||
|
ResolveVoltageSource() { return voltageSource.Resolve(); }
|
||||||
|
void
|
||||||
|
AttachToVoltageSource(Subsystem *source);
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Construction and Destruction
|
// Construction and Destruction
|
||||||
@@ -92,9 +102,12 @@
|
|||||||
// Local Data
|
// Local Data
|
||||||
//
|
//
|
||||||
protected:
|
protected:
|
||||||
Scalar inputVoltage;
|
Scalar inputVoltage;
|
||||||
Scalar outputVoltage;
|
Scalar outputVoltage;
|
||||||
Scalar ratedVoltage;
|
Scalar ratedVoltage;
|
||||||
|
SubsystemConnection voltageSource;
|
||||||
|
AlarmIndicator electricalStateAlarm;
|
||||||
|
AlarmIndicator modeAlarm;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user