Mech phase 2: reconstruct Myomers + Condenser leaves
Myomers (: PoweredSubsystem) -- locomotion muscle: seek-voltage drive table (scaled by the generator's rated voltage via ResolveVoltageSource), efficiency + heat-range members; MyomersSimulation staged. Condenser (: HeatSink) -- active refrigeration in a coolant loop; valveState/refrigerationFactor/condenserNumber. Both ctors chain their parents + init from resource; statics/dtor/test real. Heat/power subsystem family now COMPLETE (11 classes): MechSubsystem, HeatableSubsystem, HeatSink, PoweredSubsystem, Generator, Condenser, Sensor, Myomers, HeatWatcher, PowerWatcher, Gyroscope, HUD, Torso. BT: 31 ok. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -330,3 +330,60 @@ void
|
||||
{
|
||||
Fail("HeatWatcher::WatchSimulation -- heat.cpp not yet reconstructed");
|
||||
}
|
||||
|
||||
//###########################################################################
|
||||
//############################## Condenser #############################
|
||||
//###########################################################################
|
||||
|
||||
Derivation
|
||||
Condenser::ClassDerivations(
|
||||
HeatSink::ClassDerivations,
|
||||
"Condenser"
|
||||
);
|
||||
|
||||
Condenser::SharedData
|
||||
Condenser::DefaultData(
|
||||
Condenser::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
Subsystem::StateCount
|
||||
);
|
||||
|
||||
Condenser::Condenser(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data
|
||||
):
|
||||
HeatSink(owner, subsystem_ID, subsystem_resource, shared_data)
|
||||
{
|
||||
Check(owner);
|
||||
Check_Pointer(subsystem_resource);
|
||||
|
||||
valveState = 0;
|
||||
refrigerationFactor = subsystem_resource->refrigerationFactor;
|
||||
|
||||
//
|
||||
// Condenser number from the segment-name suffix ('A' -> 1 ...).
|
||||
//
|
||||
const char *name = GetName();
|
||||
condenserNumber = name[strlen(name) - 1] - 0x40;
|
||||
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
Condenser::~Condenser()
|
||||
{
|
||||
}
|
||||
|
||||
Logical
|
||||
Condenser::TestClass(Mech &)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
Logical
|
||||
Condenser::TestInstance() const
|
||||
{
|
||||
return IsDerivedFrom(ClassDerivations);
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@
|
||||
class HeatSink:
|
||||
public HeatableSubsystem
|
||||
{
|
||||
friend class Condenser;
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Shared Data Support
|
||||
//
|
||||
@@ -256,4 +257,49 @@
|
||||
AverageOf<Scalar> heatFilter;
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
//#################### Condenser Model Resource ########################
|
||||
//###########################################################################
|
||||
|
||||
struct Condenser__SubsystemResource:
|
||||
public HeatSink__SubsystemResource
|
||||
{
|
||||
Scalar refrigerationFactor;
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
//############################## Condenser #############################
|
||||
//###########################################################################
|
||||
//
|
||||
// A HeatSink with active refrigeration (a coolant loop's condenser).
|
||||
//
|
||||
class Condenser:
|
||||
public HeatSink
|
||||
{
|
||||
public:
|
||||
static Derivation ClassDerivations;
|
||||
static SharedData DefaultData;
|
||||
|
||||
static Logical
|
||||
TestClass(Mech &);
|
||||
Logical
|
||||
TestInstance() const;
|
||||
|
||||
public:
|
||||
typedef Condenser__SubsystemResource SubsystemResource;
|
||||
|
||||
Condenser(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data = DefaultData
|
||||
);
|
||||
~Condenser();
|
||||
|
||||
protected:
|
||||
int valveState;
|
||||
int condenserNumber;
|
||||
Scalar refrigerationFactor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
//===========================================================================//
|
||||
// File: myomers.cpp //
|
||||
// Project: BattleTech Brick: Mech subsystems //
|
||||
// Contents: Myomers -- artificial-muscle locomotion 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(MYOMERS_HPP)
|
||||
# include <myomers.hpp>
|
||||
#endif
|
||||
|
||||
#if !defined(MECH_HPP)
|
||||
# include <mech.hpp>
|
||||
#endif
|
||||
|
||||
Derivation
|
||||
Myomers::ClassDerivations(
|
||||
PoweredSubsystem::ClassDerivations,
|
||||
"Myomers"
|
||||
);
|
||||
|
||||
Myomers::SharedData
|
||||
Myomers::DefaultData(
|
||||
Myomers::ClassDerivations,
|
||||
Subsystem::MessageHandlers,
|
||||
Subsystem::AttributeIndex,
|
||||
Subsystem::StateCount
|
||||
);
|
||||
|
||||
Myomers::Myomers(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *resource,
|
||||
SharedData &shared_data
|
||||
):
|
||||
PoweredSubsystem(owner, subsystem_ID, resource, shared_data)
|
||||
{
|
||||
Check(owner);
|
||||
Check_Pointer(resource);
|
||||
|
||||
speedEffect = 1.0f;
|
||||
heatRange = failureTemperature - degradationTemperature;
|
||||
heatRangeSquared = heatRange * heatRange;
|
||||
velocityEfficiency = resource->velocityEfficiency;
|
||||
accelerationEfficiency = resource->accelerationEfficiency;
|
||||
|
||||
//
|
||||
// Build the seek-voltage drive table: each resource fraction scaled by the
|
||||
// powering generator's rated voltage. The voltage source is resolved once
|
||||
// AttachToVoltageSource runs (phase-4 wiring); until then it is null and the
|
||||
// table scales to zero.
|
||||
//
|
||||
Generator *source = (Generator *)ResolveVoltageSource();
|
||||
Scalar srcRated = (source != NULL) ? source->ratedVoltage : 0.0f;
|
||||
|
||||
maxSeekVoltageIndex = -1;
|
||||
int count = 0;
|
||||
while (count < 5)
|
||||
{
|
||||
if (resource->seekVoltage[count] == -1.0f)
|
||||
{
|
||||
maxSeekVoltageIndex = count - 1;
|
||||
break;
|
||||
}
|
||||
seekVoltage[count] = resource->seekVoltage[count] * srcRated;
|
||||
++count;
|
||||
}
|
||||
if (maxSeekVoltageIndex < 0)
|
||||
{
|
||||
maxSeekVoltageIndex = count - 1;
|
||||
}
|
||||
|
||||
minSeekVoltageIndex = 0;
|
||||
recommendedSeekVoltageIndex = resource->seekVoltageRecommendedIndex;
|
||||
currentSeekVoltageIndex = recommendedSeekVoltageIndex;
|
||||
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
Myomers::~Myomers()
|
||||
{
|
||||
}
|
||||
|
||||
Logical
|
||||
Myomers::TestClass(Mech &)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
Logical
|
||||
Myomers::TestInstance() const
|
||||
{
|
||||
return IsDerivedFrom(ClassDerivations);
|
||||
}
|
||||
|
||||
//
|
||||
// Per-frame: convert seek voltage into locomotion speed/acceleration effect.
|
||||
// Not yet reconstructed.
|
||||
//
|
||||
void
|
||||
Myomers::MyomersSimulation(Scalar)
|
||||
{
|
||||
Fail("Myomers::MyomersSimulation -- myomers.cpp not yet reconstructed");
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
//===========================================================================//
|
||||
// File: myomers.hpp //
|
||||
// Project: BattleTech Brick: Mech subsystems //
|
||||
// Contents: Myomers -- the artificial-muscle (locomotion power) subsystem //
|
||||
//---------------------------------------------------------------------------//
|
||||
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
||||
// All Rights reserved worldwide //
|
||||
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
||||
//===========================================================================//
|
||||
|
||||
#if !defined(MYOMERS_HPP)
|
||||
# define MYOMERS_HPP
|
||||
|
||||
# if !defined(POWERSUB_HPP)
|
||||
# include <powersub.hpp>
|
||||
# endif
|
||||
|
||||
//##################### Forward Class Declarations #######################
|
||||
class Mech;
|
||||
|
||||
//###########################################################################
|
||||
//#################### Myomers Model Resource ##########################
|
||||
//###########################################################################
|
||||
|
||||
struct Myomers__SubsystemResource:
|
||||
public PoweredSubsystem::SubsystemResource
|
||||
{
|
||||
Scalar velocityEfficiency;
|
||||
Scalar accelerationEfficiency;
|
||||
Scalar seekVoltage[5];
|
||||
int seekVoltageRecommendedIndex;
|
||||
};
|
||||
|
||||
//###########################################################################
|
||||
//############################## Myomers ###############################
|
||||
//###########################################################################
|
||||
|
||||
class Myomers:
|
||||
public PoweredSubsystem
|
||||
{
|
||||
public:
|
||||
static Derivation ClassDerivations;
|
||||
static SharedData DefaultData;
|
||||
|
||||
typedef void
|
||||
(Myomers::*Performance)(Scalar time_slice);
|
||||
void
|
||||
SetPerformance(Performance performance)
|
||||
{
|
||||
Check(this);
|
||||
activePerformance = (Simulation::Performance)performance;
|
||||
}
|
||||
|
||||
static Logical
|
||||
TestClass(Mech &);
|
||||
Logical
|
||||
TestInstance() const;
|
||||
void
|
||||
MyomersSimulation(Scalar time_slice);
|
||||
|
||||
public:
|
||||
typedef Myomers__SubsystemResource SubsystemResource;
|
||||
|
||||
Myomers(
|
||||
Mech *owner,
|
||||
int subsystem_ID,
|
||||
SubsystemResource *subsystem_resource,
|
||||
SharedData &shared_data = DefaultData
|
||||
);
|
||||
~Myomers();
|
||||
|
||||
protected:
|
||||
Scalar speedEffect;
|
||||
int currentSeekVoltageIndex;
|
||||
int recommendedSeekVoltageIndex;
|
||||
int minSeekVoltageIndex;
|
||||
int maxSeekVoltageIndex;
|
||||
Scalar seekVoltage[5];
|
||||
Scalar heatRange;
|
||||
Scalar heatRangeSquared;
|
||||
Scalar velocityEfficiency;
|
||||
Scalar accelerationEfficiency;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user