Skip to content

Commit

Permalink
Merge pull request #1260 from indy91/CSMO2Hose
Browse files Browse the repository at this point in the history
Save/load state of CSM O2 hose
  • Loading branch information
indy91 authored Jun 26, 2024
2 parents 6203edf + 6828725 commit 2516ecf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
34 changes: 31 additions & 3 deletions Orbitersdk/samples/ProjectApollo/src_csm/ecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,8 @@ SaturnForwardHatch::SaturnForwardHatch(Sound &opensound, Sound &closesound) :
{
open = false;
toggle = 0;
isHoseConnected = false;
FirstTimeStepDone = false;
pipe = NULL;
saturn = NULL;

Expand Down Expand Up @@ -1408,6 +1410,11 @@ void SaturnForwardHatch::Toggle()

void SaturnForwardHatch::Timestep(double simdt) {

if (!FirstTimeStepDone) {
DoFirstTimeStep();
FirstTimeStepDone = true;
}

if (toggle > 0) {
toggle--;
if (toggle == 0) {
Expand All @@ -1419,19 +1426,40 @@ void SaturnForwardHatch::Timestep(double simdt) {
saturn->SetAnimation(anim_pressequalvlv, equalvalve_state / 3);
}

void SaturnForwardHatch::DoFirstTimeStep()
{
if (isHoseConnected)
{
saturn->ConnectCSMO2Hose();
}
}

void SaturnForwardHatch::LoadState(char *line) {

int i1;
int i1, i2;

i2 = 0;

sscanf(line + 12, "%d %d", &i1, &toggle);
sscanf(line + 12, "%d %d %d", &i1, &toggle, &i2);
open = (i1 != 0);
isHoseConnected = (i2 != 0);
}

void SaturnForwardHatch::SaveState(FILEHANDLE scn) {

char buffer[100];
bool hose;

if (saturn->GetCSMO2Hose()->out != NULL)
{
hose = true;
}
else
{
hose = false;
}

sprintf(buffer, "%i %i", (open ? 1 : 0), toggle);
sprintf(buffer, "%i %i %i", (open ? 1 : 0), toggle, (hose ? 1 : 0));
oapiWriteScenario_string(scn, "FORWARDHATCH", buffer);
}

Expand Down
4 changes: 4 additions & 0 deletions Orbitersdk/samples/ProjectApollo/src_csm/ecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,12 @@ class SaturnForwardHatch

void DefineAnimationsVC(UINT idx);
protected:
void DoFirstTimeStep();

bool open;
int toggle;
bool isHoseConnected; //Only used as a temporary variable to store the state of the hose connection from LoadState to clbkPostCreation, doesn't keep track of the connection after loading
bool FirstTimeStepDone;

Saturn *saturn;
h_Pipe *pipe;
Expand Down
8 changes: 8 additions & 0 deletions Orbitersdk/samples/ProjectApollo/src_csm/saturn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4903,6 +4903,14 @@ h_Pipe* Saturn::GetCSMO2Hose()
return (h_Pipe*)Panelsdk.GetPointerByString("HYDRAULIC:CSMTOLMO2HOSE");
}

void Saturn::ConnectCSMO2Hose()
{
if (ForwardHatch.IsOpen())
{
lemECSConnector.ConnectCSMO2Hose();
}
}

bool Saturn::GetLMDesBatLVOn()
{
return LMPowerSwitch.IsDown() && MnbLMPWR2CircuitBraker.IsPowered();
Expand Down
1 change: 1 addition & 0 deletions Orbitersdk/samples/ProjectApollo/src_csm/saturn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ class Saturn: public ProjectApolloConnectorVessel, public PanelSwitchListener {
//CSM to LM interface functions
h_Pipe* GetCMTunnelPipe() { return CMTunnel; }
h_Pipe* GetCSMO2Hose();
void ConnectCSMO2Hose();
void ConnectTunnelToCabinVent();
bool GetLMDesBatLVOn();
bool GetLMDesBatLVHVOffA();
Expand Down

0 comments on commit 2516ecf

Please sign in to comment.