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>
This commit is contained in:
@@ -121,3 +121,119 @@ void
|
||||
{
|
||||
Fail("PoweredSubsystem::AttachToVoltageSource -- powersub.cpp not yet reconstructed");
|
||||
}
|
||||
|
||||
//###########################################################################
|
||||
//############################## Generator #############################
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// Shared data support
|
||||
//#############################################################################
|
||||
//
|
||||
Derivation
|
||||
Generator::ClassDerivations(
|
||||
HeatSink::ClassDerivations,
|
||||
"Generator"
|
||||
);
|
||||
|
||||
Generator::SharedData
|
||||
Generator::DefaultData(
|
||||
Generator::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
Subsystem::StateCount
|
||||
);
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// The generator -- the voltage source loads tap.
|
||||
//#############################################################################
|
||||
//
|
||||
Generator::Generator(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data
|
||||
):
|
||||
HeatSink(owner, subsystem_ID, subsystem_resource, shared_data),
|
||||
stateAlarm(5)
|
||||
{
|
||||
Check(owner);
|
||||
Check_Pointer(subsystem_resource);
|
||||
|
||||
ratedVoltage = subsystem_resource->ratedVoltage;
|
||||
outputVoltage = ratedVoltage;
|
||||
maxTapCount = subsystem_resource->maxTapCount;
|
||||
currentTapCount = 0;
|
||||
percentVoltageAvailable = 1.0f;
|
||||
startTime = subsystem_resource->startTime;
|
||||
startTimer = startTime;
|
||||
stateAlarm.SetLevel(GeneratorReady);
|
||||
generatorOn = 1;
|
||||
shortRecoveryTime = subsystem_resource->shortRecoveryTime;
|
||||
shortTimer = shortRecoveryTime;
|
||||
|
||||
//
|
||||
// Generator number from the last character of the segment name
|
||||
// ('A' -> 1, 'B' -> 2, ...).
|
||||
//
|
||||
const char *name = GetName();
|
||||
generatorNumber = name[strlen(name) - 1] - 0x40;
|
||||
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Generator::~Generator()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
Logical
|
||||
Generator::TestClass(Mech &)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
Logical
|
||||
Generator::TestInstance() const
|
||||
{
|
||||
return IsDerivedFrom(ClassDerivations);
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
//#############################################################################
|
||||
//
|
||||
void
|
||||
Generator::ResetToInitialState()
|
||||
{
|
||||
Check(this);
|
||||
HeatSink::ResetToInitialState(True);
|
||||
outputVoltage = ratedVoltage;
|
||||
currentTapCount = 0;
|
||||
percentVoltageAvailable = 1.0f;
|
||||
startTimer = startTime;
|
||||
shortTimer = shortRecoveryTime;
|
||||
generatorOn = 1;
|
||||
stateAlarm.SetLevel(GeneratorReady);
|
||||
}
|
||||
|
||||
//
|
||||
//#############################################################################
|
||||
// Per-frame electrical simulation (voltage, short recovery). Not yet
|
||||
// reconstructed -- fires only once the mech is ticking.
|
||||
//#############################################################################
|
||||
//
|
||||
void
|
||||
Generator::GeneratorSimulation(Scalar)
|
||||
{
|
||||
Fail("Generator::GeneratorSimulation -- powersub.cpp not yet reconstructed");
|
||||
}
|
||||
|
||||
@@ -110,4 +110,98 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user