Files
TeslaRel410/restoration/source410/BT/POWERSUB.HPP
T
CydandClaude Fable 5 b5e0c10737 Mech milestone phase 2: reconstruct Generator (power source) -- power pair complete
Generator : public HeatSink (classID 0xBC3) -- the voltage SOURCE that
PoweredSubsystems tap (currentTapCount = attached loads). Reconstructed from the
BT411 decomp + the surviving GNRATOR.TCP partial: ctor chains HeatSink, seeds
ratedVoltage/outputVoltage/maxTapCount/startTime/shortRecoveryTime + stateAlarm(5)
= AlarmIndicator, derives generatorNumber from the segment-name suffix. Statics,
dtor, TestClass/TestInstance/ResetToInitialState real (ResetToInitialState mirrors
the .TCP); GeneratorSimulation (per-frame voltage/short) staged. Master-instance
SetPerformance install deferred (per-frame sim staged anyway).

Power system pair now in place: Generator (source) + PoweredSubsystem (load).
Roster classes so far: MechSubsystem, HeatableSubsystem, HeatSink,
PoweredSubsystem, Sensor, Generator. BT: 27 ok; tree links clean.

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

208 lines
6.0 KiB
C++

//===========================================================================//
// File: powersub.hpp //
// Project: BattleTech //
// Contents: Implementation details for powered subsystems //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(POWERSUB_HPP)
# define POWERSUB_HPP
# if !defined(HEAT_HPP)
# include <heat.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
//###########################################################################
//################### PoweredSubsystem Model Resource ###################
//###########################################################################
struct PoweredSubsystem__SubsystemResource:
public HeatSink::SubsystemResource
{
int voltageSourceIndex;
Scalar thermalResistivityCoefficient;
int auxScreenNumber;
int auxScreenPlacement;
char auxScreenLabel[64];
char engScreenLabel[64];
Scalar startTime;
};
//###########################################################################
//######################### PoweredSubsystem ############################
//###########################################################################
class PoweredSubsystem:
public HeatSink
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 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);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Power support
//
public:
Subsystem*
ResolveVoltageSource() { return voltageSource.Resolve(); }
void
AttachToVoltageSource(Subsystem *source);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction
//
public:
typedef PoweredSubsystem__SubsystemResource SubsystemResource;
PoweredSubsystem(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data = DefaultData
);
~PoweredSubsystem();
static int
CreateStreamedSubsystem(
NotationFile *model_file,
const char *model_name,
const char *subsystem_name,
SubsystemResource *subsystem_resource,
NotationFile *subsystem_file,
const ResourceDirectories *directories,
int passes = 1
);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local Data
//
protected:
Scalar inputVoltage;
Scalar outputVoltage;
Scalar ratedVoltage;
SubsystemConnection voltageSource;
AlarmIndicator electricalStateAlarm;
AlarmIndicator modeAlarm;
};
//###########################################################################
//#################### Generator Model Resource ########################
//###########################################################################
struct Generator__SubsystemResource:
public HeatSink::SubsystemResource
{
Scalar ratedVoltage;
int maxTapCount;
Scalar startTime;
Scalar shortRecoveryTime;
};
//###########################################################################
//############################## Generator #############################
//###########################################################################
//
// The voltage SOURCE a PoweredSubsystem attaches to (currentTapCount tracks
// attached loads). A HeatSink that produces power.
//
class Generator:
public HeatSink
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
enum {
GeneratorOff = 0,
GeneratorStarting,
GeneratorReady,
GeneratorShorted,
GeneratorFailed,
GeneratorStateCount
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Test / reset
//
public:
static Logical
TestClass(Mech &);
Logical
TestInstance() const;
void
ResetToInitialState();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Power interface
//
public:
Scalar MeasuredVoltage() { Check(this); return outputVoltage; }
Scalar RatedVoltageOf() { Check(this); return ratedVoltage; }
int GetGeneratorNumber(){ Check(this); return generatorNumber; }
void
GeneratorSimulation(Scalar time_slice);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction
//
public:
typedef Generator__SubsystemResource SubsystemResource;
Generator(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data = DefaultData
);
~Generator();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local Data
//
public:
Scalar percentVoltageAvailable;
int generatorOn;
Scalar ratedVoltage;
Scalar outputVoltage;
int generatorNumber;
int maxTapCount;
int currentTapCount;
Scalar startTime;
Scalar startTimer;
Scalar shortRecoveryTime;
Scalar shortTimer;
AlarmIndicator stateAlarm;
};
#endif