diff --git a/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.cpp b/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.cpp index 7b418a8850..728b8e96f3 100644 --- a/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.cpp +++ b/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.cpp @@ -680,6 +680,20 @@ TradeoffDataDisplayBuffer::TradeoffDataDisplayBuffer() } } +MPTVehicleDataBlock::MPTVehicleDataBlock() +{ + ConfigChangeInd = 0; + TUP = 0; + CSMArea = 0.0; + SIVBArea = 0.0; + LMAscentArea = 0.0; + LMDescentArea = 0.0; + CSMMass = 0.0; + SIVBMass = 0.0; + LMAscentMass = 0.0; + LMDescentMass = 0.0; +} + void MPTVehicleDataBlock::SaveState(FILEHANDLE scn) { oapiWriteScenario_int(scn, "ConfigCode", ConfigCode.to_ulong()); @@ -21559,6 +21573,73 @@ MissionPlanTable* RTCC::GetMPTPointer(int L) } } +MPTVehicleDataBlock *RTCC::MPTDockingManeuver(int L, double GMT_BO, PLAWDTOutput &plawdtout) +{ + //Returns weight table from other MPT at desired (GMT_BO) time + + PLAWDTInput plawdtin; + unsigned int N, M, I, block; + MissionPlanTable *other_mpt; + MPTVehicleDataBlock *OtherCommonBlock; + + other_mpt = GetMPTPointer(4 - L); + N = other_mpt->ManeuverNum; + M = N; + I = 0; + + //Find MPT block on other MPT before maneuver + if (N > 0) + { + do + { + //Is burnout of maneuver before burnout of maneuver on other MPT? + if (GMT_BO <= other_mpt->mantable[I].GMT_BO) + { + //Yes + //Is burnout of maneuver before ignition of maneuver on other MPT? + if (GMT_BO < other_mpt->mantable[I].GMT_1) + { + //Yes + M = M - 1; + } + break; + } + if (M == 1) break; + M = M - 1; + I = I + 1; + } while (true); + } + block = N - M; + if (block == 0U) + { + plawdtin.Num = (unsigned int)other_mpt->CommonBlock.ConfigCode.to_ulong(); + plawdtin.T_IN = GMTfromGET(other_mpt->SIVBVentingBeginGET); + OtherCommonBlock = &other_mpt->CommonBlock; + } + else + { + //Maneuver block + plawdtin.Num = (unsigned int)other_mpt->mantable[block - 1].CommonBlock.ConfigCode.to_ulong(); + plawdtin.T_IN = other_mpt->mantable[block - 1].GMT_BO; + OtherCommonBlock = &other_mpt->mantable[block - 1].CommonBlock; + } + plawdtin.T_UP = GMT_BO; + plawdtin.TableCode = -(4 - L); + plawdtin.CSMArea = OtherCommonBlock->CSMArea; + plawdtin.SIVBArea = OtherCommonBlock->SIVBArea; + plawdtin.LMAscArea = OtherCommonBlock->LMAscentArea; + plawdtin.LMDscArea = OtherCommonBlock->LMDescentArea; + plawdtin.CSMWeight = OtherCommonBlock->CSMMass; + plawdtin.SIVBWeight = OtherCommonBlock->SIVBMass; + plawdtin.LMAscWeight = OtherCommonBlock->LMAscentMass; + plawdtin.LMDscWeight = OtherCommonBlock->LMDescentMass; + + //Update from t_wts to t_end + PLAWDT(plawdtin, plawdtout); + + return OtherCommonBlock; +} + OBJHANDLE RTCC::GetGravref(int body) { if (body == BODY_EARTH) @@ -21772,7 +21853,7 @@ int RTCC::PMMXFR(int id, void *data) CCP = mpt->mantable.back().CommonBlock.ConfigCode; } CC = inp->EndConfiguration; - err = PMMXFRCheckConfigThruster(true, inp->ConfigurationChangeIndicator, CCP, TVC, inp->ThrusterCode, CC, CCMI); + err = PMMXFRCheckConfigThruster(true, inp->GMTI, inp->TableCode, inp->ConfigurationChangeIndicator, CCP, TVC, inp->ThrusterCode, CC, CCMI); if (err) { return 1; @@ -22087,7 +22168,7 @@ int RTCC::PMMXFR(int id, void *data) CCP = mpt->mantable.back().CommonBlock.ConfigCode; } CC = CCMI = CCP; - err = PMMXFRCheckConfigThruster(false, 0, CCP, TVC, inp->ManData[working_man - 1].Thruster, CC, CCMI); + err = PMMXFRCheckConfigThruster(false, 0.0, 0, 0, CCP, TVC, inp->ManData[working_man - 1].Thruster, CC, CCMI); //Is attitude mode an AGS? if (inp->ManData[working_man - 1].Attitude == 5) { @@ -22261,7 +22342,7 @@ int RTCC::PMMXFR(int id, void *data) err = PMMXFRFormatManeuverCode(med_m86.Veh, RTCC_ENGINETYPE_LMDPS, RTCC_ATTITUDE_PGNS_DESCENT, CurMan, purpose, TVC, code); //Check configuration and thrust CC = CCP; - err = PMMXFRCheckConfigThruster(true, 0, CCP, TVC, RTCC_ENGINETYPE_LMDPS, CC, CCMI); + err = PMMXFRCheckConfigThruster(true, 0.0, 0, 0, CCP, TVC, RTCC_ENGINETYPE_LMDPS, CC, CCMI); man.code = code; mpt->mantable.push_back(man); @@ -22315,7 +22396,7 @@ int RTCC::PMMXFR(int id, void *data) err = PMMXFRFormatManeuverCode(med_m85.VEH, RTCC_ENGINETYPE_LMAPS, RTCC_ATTITUDE_PGNS_ASCENT, CurMan, purpose, TVC, code); //Check configuration and thrust CC[RTCC_CONFIG_A] = true; - err = PMMXFRCheckConfigThruster(true, RTCC_CONFIGCHANGE_UNDOCKING, CCP, TVC, RTCC_ENGINETYPE_LMAPS, CC, CCMI); + err = PMMXFRCheckConfigThruster(true, 0.0, 0, RTCC_CONFIGCHANGE_UNDOCKING, CCP, TVC, RTCC_ENGINETYPE_LMAPS, CC, CCMI); man.code = code; man.GMTMAN = man.GMTI; @@ -22559,18 +22640,27 @@ int RTCC::PMMXFRFormatManeuverCode(int Table, int Thruster, int Attitude, unsign return 0; } -int RTCC::PMMXFRCheckConfigThruster(bool CheckConfig, int CCI, const std::bitset<4> &CCP, int TVC, int Thruster, std::bitset<4> &CC, std::bitset<4> &CCMI) +int RTCC::PMMXFRCheckConfigThruster(bool CheckConfig, double GMT, int L, int CCI, const std::bitset<4> &CCP, int TVC, int Thruster, std::bitset<4> &CC, std::bitset<4> &CCMI) { + //CCI: Configuration change indicator (0 = no change, 1 = undocking, 2 = docking) + //CCP: Configuration code prior to maneuver + //CC: Configuration code at end of maneuver + //CCMI: Configuration code at start maneuver + //TVC: Thrusting Vehicle Code (0 = CSM, 1 = LM, 2 = S-IVB) + if (CheckConfig) { if (CCI > 1) { + //Docking CCMI = CCP; } else { + //No change or undocking if (CCI < 1) { + //No change CC = CCP; } @@ -22616,13 +22706,15 @@ int RTCC::PMMXFRCheckConfigThruster(bool CheckConfig, int CCI, const std::bitset } } - //No configuration change + //Configuration Change if (CCI < 1) { + //No configuration change return 0; } else if (CCI == 1) { + //Undocking if (CCP == CC) { PMXSPT("PMMXFR", 6); @@ -22638,8 +22730,39 @@ int RTCC::PMMXFRCheckConfigThruster(bool CheckConfig, int CCI, const std::bitset return 0; } } + else + { + //Docking + //Obtain CCPP from other MPT + MissionPlanTable *mpt = GetMPTPointer(4 - L); + std::bitset<4> CCPP = mpt->CommonBlock.ConfigCode; - //TBD: Docking + for (unsigned i = 0; i < mpt->mantable.size(); i++) + { + if (GMT > mpt->mantable[i].GMTMAN) + { + CCPP = mpt->mantable[i].CommonBlock.ConfigCode; + } + } + //Are CCP and CCPP disjoint? + std::bitset<4> TEMP; + + TEMP = CCP & CCPP; + if (TEMP != 0) + { + //No + PMXSPT("PMMXFR", 6); + return 6; + } + //Is union of CCP and CCPP = CC? + TEMP = CCP | CCPP; + if (TEMP != CC) + { + //No + PMXSPT("PMMXFR", 6); + return 6; + } + } return 0; } @@ -34686,10 +34809,12 @@ void RTCC::PMMDMT(int L, unsigned man, RTCCNIAuxOutputTable *aux) //mptman->StationIDFrozen = mpt->StationID; mptman->CommonBlock.TUP = abs(mpt->CommonBlock.TUP); - double W_S_Prior, S_Fuel, WDOT, T, F; + //Update fuel masses + double WDOT, T, F; MPTVehicleDataBlock *CommonBlockBefore; + //Get previous fuel masses. Either initial masses or at the end of the previous maneuver. if (man == 1) { CommonBlockBefore = &mpt->CommonBlock; @@ -34698,66 +34823,50 @@ void RTCC::PMMDMT(int L, unsigned man, RTCCNIAuxOutputTable *aux) { CommonBlockBefore = &mpt->mantable[man - 2].CommonBlock; } + //Copy over previous fuel masses + mptman->CommonBlock.SIVBFuelRemaining = CommonBlockBefore->SIVBFuelRemaining; + mptman->CommonBlock.SPSFuelRemaining = CommonBlockBefore->SPSFuelRemaining; + mptman->CommonBlock.CSMRCSFuelRemaining = CommonBlockBefore->CSMRCSFuelRemaining; + mptman->CommonBlock.LMRCSFuelRemaining = CommonBlockBefore->LMRCSFuelRemaining; + mptman->CommonBlock.LMAPSFuelRemaining = CommonBlockBefore->LMAPSFuelRemaining; + mptman->CommonBlock.LMDPSFuelRemaining = CommonBlockBefore->LMDPSFuelRemaining; - W_S_Prior = CommonBlockBefore->SIVBMass; - S_Fuel = CommonBlockBefore->SIVBFuelRemaining; - - //S-IVB in configuration at init? - if (mptman->ConfigCodeBefore[RTCC_CONFIG_S]) + //Account for S-IVB venting + if (mptman->CommonBlock.ConfigCode[RTCC_CONFIG_S]) { //Weight loss due to continuous venting - double DW = W_S_Prior - aux->W_SIVB; + double DW = CommonBlockBefore->SIVBMass - aux->W_SIVB; //Subtract from S-IVB fuel remaining before maneuver - S_Fuel = S_Fuel - DW; - //S-IVB maneuver? - if (mptman->TVC == 2) - { - mptman->CommonBlock.SIVBFuelRemaining = S_Fuel - aux->MainFuelUsed; - - T = SystemParameters.MCTSAV; - WDOT = SystemParameters.MCTWAV; - F = mptman->CommonBlock.SIVBFuelRemaining; - - mptman->CommonBlock.SPSFuelRemaining = CommonBlockBefore->SPSFuelRemaining; - mptman->CommonBlock.CSMRCSFuelRemaining = CommonBlockBefore->CSMRCSFuelRemaining; - mptman->CommonBlock.LMRCSFuelRemaining = CommonBlockBefore->LMRCSFuelRemaining; - mptman->CommonBlock.LMAPSFuelRemaining = CommonBlockBefore->LMAPSFuelRemaining; - mptman->CommonBlock.LMDPSFuelRemaining = CommonBlockBefore->LMDPSFuelRemaining; - } + mptman->CommonBlock.SIVBFuelRemaining -= DW; } - if (mptman->TVC != 2) + //Update fuels + if (mptman->TVC == RTCC_MANVEHICLE_CSM) + { + //CSM maneuver + mptman->CommonBlock.SPSFuelRemaining -= aux->MainFuelUsed; + mptman->CommonBlock.CSMRCSFuelRemaining -= aux->RCSFuelUsed; + } + else if (mptman->TVC == RTCC_MANVEHICLE_LM) { - if (mptman->TVC == 1) + mptman->CommonBlock.LMRCSFuelRemaining -= aux->RCSFuelUsed; + if (mptman->Thruster == RTCC_ENGINETYPE_LMAPS) { - mptman->CommonBlock.SPSFuelRemaining = CommonBlockBefore->SPSFuelRemaining - aux->MainFuelUsed; - mptman->CommonBlock.CSMRCSFuelRemaining = CommonBlockBefore->CSMRCSFuelRemaining - aux->RCSFuelUsed; - mptman->CommonBlock.LMRCSFuelRemaining = CommonBlockBefore->LMRCSFuelRemaining; - mptman->CommonBlock.LMAPSFuelRemaining = CommonBlockBefore->LMAPSFuelRemaining; - mptman->CommonBlock.LMDPSFuelRemaining = CommonBlockBefore->LMDPSFuelRemaining; + mptman->CommonBlock.LMAPSFuelRemaining -= aux->MainFuelUsed; + mptman->CommonBlock.LMDPSFuelRemaining = 0.0; } - else + else if (mptman->Thruster == RTCC_ENGINETYPE_LMDPS) { - mptman->CommonBlock.SPSFuelRemaining = CommonBlockBefore->SPSFuelRemaining; - mptman->CommonBlock.CSMRCSFuelRemaining = CommonBlockBefore->CSMRCSFuelRemaining; - mptman->CommonBlock.LMRCSFuelRemaining = CommonBlockBefore->LMRCSFuelRemaining - aux->RCSFuelUsed; - if (mptman->Thruster == RTCC_ENGINETYPE_LMAPS) - { - mptman->CommonBlock.LMAPSFuelRemaining = CommonBlockBefore->LMAPSFuelRemaining - aux->MainFuelUsed; - mptman->CommonBlock.LMDPSFuelRemaining = 0.0; - } - else if (mptman->Thruster == RTCC_ENGINETYPE_LMDPS) - { - mptman->CommonBlock.LMDPSFuelRemaining = CommonBlockBefore->LMDPSFuelRemaining - aux->MainFuelUsed; - mptman->CommonBlock.LMAPSFuelRemaining = CommonBlockBefore->LMAPSFuelRemaining; - } - else - { - mptman->CommonBlock.LMDPSFuelRemaining = CommonBlockBefore->LMDPSFuelRemaining; - mptman->CommonBlock.LMAPSFuelRemaining = CommonBlockBefore->LMAPSFuelRemaining; - } + mptman->CommonBlock.LMDPSFuelRemaining -= aux->MainFuelUsed; } + } + else + { + mptman->CommonBlock.SIVBFuelRemaining -= aux->MainFuelUsed; + } + if (mptman->TVC != RTCC_MANVEHICLE_SIVB) + { //Get engine parameters double OnboardThrust; EngineParametersTable(mptman->Thruster, T, WDOT, OnboardThrust); @@ -34788,62 +34897,34 @@ void RTCC::PMMDMT(int L, unsigned man, RTCCNIAuxOutputTable *aux) break; } } - - if (mptman->CommonBlock.ConfigChangeInd == RTCC_CONFIGCHANGE_DOCKING) + else { - //TBD: Docking maneuver + T = SystemParameters.MCTSAV; + WDOT = SystemParameters.MCTWAV; + F = mptman->CommonBlock.SIVBFuelRemaining; } //Mass Maintenance - mptman->TotalMassAfter = 0.0; - mptman->CommonBlock.CSMMass = 0.0; - mptman->CommonBlock.LMAscentMass = 0.0; - mptman->CommonBlock.LMDescentMass = 0.0; - mptman->CommonBlock.SIVBMass = 0.0; - mptman->TotalAreaAfter = 0.0; - mptman->CommonBlock.CSMArea = 0.0; - mptman->CommonBlock.LMAscentArea = 0.0; - mptman->CommonBlock.LMDescentArea = 0.0; - mptman->CommonBlock.SIVBArea = 0.0; - if (mptman->CommonBlock.ConfigCode[RTCC_CONFIG_C]) + for (int i = 0; i < 4; i++) { - //Was it an CSM engine? - if (mptman->Thruster == RTCC_ENGINETYPE_CSMSPS || mptman->Thruster == RTCC_ENGINETYPE_CSMRCSMINUS2 || mptman->Thruster == RTCC_ENGINETYPE_CSMRCSMINUS4 || mptman->Thruster == RTCC_ENGINETYPE_CSMRCSPLUS2 || mptman->Thruster == RTCC_ENGINETYPE_CSMRCSPLUS4) + if (mptman->CommonBlock.ConfigCode[i]) { - mptman->CommonBlock.CSMMass = aux->W_CSM - aux->MainFuelUsed - aux->RCSFuelUsed; + mptman->CommonBlock.Masses[i] = CommonBlockBefore->Masses[i]; + mptman->CommonBlock.Areas[i] = CommonBlockBefore->Areas[i]; } else { - mptman->CommonBlock.CSMMass = aux->W_CSM; - } - mptman->TotalMassAfter += mptman->CommonBlock.CSMMass; - - mptman->CommonBlock.CSMArea = CommonBlockBefore->CSMArea; - if (mptman->CommonBlock.CSMArea > mptman->TotalAreaAfter) - { - mptman->TotalAreaAfter = mptman->CommonBlock.CSMArea; + mptman->CommonBlock.Masses[i] = 0.0; + mptman->CommonBlock.Areas[i] = 0.0; } } - if (mptman->CommonBlock.ConfigCode[RTCC_CONFIG_A]) - { - //Was it an LM ascent stage engine? - if (mptman->Thruster == RTCC_ENGINETYPE_LMAPS || mptman->Thruster == RTCC_ENGINETYPE_LMRCSMINUS2 || mptman->Thruster == RTCC_ENGINETYPE_LMRCSMINUS4 || mptman->Thruster == RTCC_ENGINETYPE_LMRCSPLUS2 || mptman->Thruster == RTCC_ENGINETYPE_LMRCSPLUS4) - { - mptman->CommonBlock.LMAscentMass = aux->W_LMA - aux->MainFuelUsed - aux->RCSFuelUsed; - } - else - { - mptman->CommonBlock.LMAscentMass = aux->W_LMA; - } - mptman->TotalMassAfter += mptman->CommonBlock.LMAscentMass; - mptman->CommonBlock.LMAscentArea = CommonBlockBefore->LMAscentArea; - if (mptman->CommonBlock.LMAscentArea > mptman->TotalAreaAfter) - { - mptman->TotalAreaAfter = mptman->CommonBlock.LMAscentArea; - } + //Account for mass loss + if (mptman->TVC == RTCC_MANVEHICLE_CSM) + { + mptman->CommonBlock.CSMMass = aux->W_CSM - aux->MainFuelUsed - aux->RCSFuelUsed; } - if (mptman->CommonBlock.ConfigCode[RTCC_CONFIG_D]) + else if (mptman->TVC == RTCC_MANVEHICLE_LM) { if (mptman->Thruster == RTCC_ENGINETYPE_LMDPS) { @@ -34852,36 +34933,66 @@ void RTCC::PMMDMT(int L, unsigned man, RTCCNIAuxOutputTable *aux) } else { - mptman->CommonBlock.LMDescentMass = aux->W_LMD; + mptman->CommonBlock.LMAscentMass = aux->W_LMA - aux->MainFuelUsed - aux->RCSFuelUsed; } - - mptman->TotalMassAfter += mptman->CommonBlock.LMDescentMass; + } + else + { + mptman->CommonBlock.SIVBMass = aux->W_SIVB - aux->MainFuelUsed - aux->RCSFuelUsed; + } + + //Docking maneuver + if (mptman->CommonBlock.ConfigChangeInd == RTCC_CONFIGCHANGE_DOCKING) + { + //Search other MPT for the specified vehicle areas and weights prior to this maneuver + PLAWDTOutput plawdtout; + MPTVehicleDataBlock *OtherCommonBlock; + + OtherCommonBlock = MPTDockingManeuver(L, mptman->GMT_BO, plawdtout); + //TBD: Process PLAWDT error? - mptman->CommonBlock.LMDescentArea = CommonBlockBefore->LMDescentArea; - if (mptman->CommonBlock.LMDescentArea > mptman->TotalAreaAfter) + //CSM in CC? + if (plawdtout.CC[RTCC_CONFIG_C]) { - mptman->TotalAreaAfter = mptman->CommonBlock.LMDescentArea; + //Store CSM area, weight, RCS fuel, SPS fuel + mptman->CommonBlock.CSMArea = plawdtout.CSMArea; + mptman->CommonBlock.CSMMass = plawdtout.CSMWeight; + mptman->CommonBlock.CSMRCSFuelRemaining = OtherCommonBlock->CSMRCSFuelRemaining; + mptman->CommonBlock.SPSFuelRemaining = OtherCommonBlock->SPSFuelRemaining; } - } - if (mptman->CommonBlock.ConfigCode[RTCC_CONFIG_S]) - { - if (mptman->Thruster == RTCC_ENGINETYPE_LOX_DUMP || mptman->Thruster == RTCC_ENGINETYPE_SIVB_MAIN) + if (plawdtout.CC[RTCC_CONFIG_S]) { - mptman->CommonBlock.SIVBMass = aux->W_SIVB - aux->MainFuelUsed - aux->RCSFuelUsed; + //Store S-IVB area, weight. Adjust S-IVB fuel for venting + mptman->CommonBlock.SIVBArea = plawdtout.SIVBArea; + mptman->CommonBlock.SIVBMass = plawdtout.SIVBWeight; + double DW = OtherCommonBlock->SIVBMass - plawdtout.SIVBWeight; + mptman->CommonBlock.SIVBFuelRemaining = OtherCommonBlock->SIVBFuelRemaining - DW; } - else + if (plawdtout.CC[RTCC_CONFIG_A]) { - mptman->CommonBlock.SIVBMass = aux->W_SIVB; + //Store LM ascent area, weight, RCS fuel, APS fuel + mptman->CommonBlock.LMAscentArea = plawdtout.LMAscArea; + mptman->CommonBlock.LMAscentMass = plawdtout.LMAscWeight; + mptman->CommonBlock.LMRCSFuelRemaining = OtherCommonBlock->LMRCSFuelRemaining; + mptman->CommonBlock.LMAPSFuelRemaining = OtherCommonBlock->LMAPSFuelRemaining; } - - mptman->TotalMassAfter += mptman->CommonBlock.SIVBMass; - - mptman->CommonBlock.SIVBArea = CommonBlockBefore->SIVBArea; - if (mptman->CommonBlock.SIVBArea > mptman->TotalAreaAfter) + if (plawdtout.CC[RTCC_CONFIG_A]) { - mptman->TotalAreaAfter = mptman->CommonBlock.SIVBArea; + //Store LM ascent area, weight, DPS fuel + mptman->CommonBlock.LMDescentArea = plawdtout.LMDscArea; + mptman->CommonBlock.LMDescentMass = plawdtout.LMDscWeight; + mptman->CommonBlock.LMDPSFuelRemaining = OtherCommonBlock->LMDPSFuelRemaining; } } + + //Sum weights of vehicles in configuration at end of maneuver + mptman->TotalMassAfter = mptman->CommonBlock.CSMMass + mptman->CommonBlock.LMAscentMass + mptman->CommonBlock.LMDescentMass + mptman->CommonBlock.SIVBMass; + + //Compute maximum area + mptman->TotalAreaAfter = mptman->CommonBlock.CSMArea; + if (mptman->CommonBlock.LMAscentArea > mptman->TotalAreaAfter) mptman->TotalAreaAfter = mptman->CommonBlock.LMAscentArea; + if (mptman->CommonBlock.LMDescentArea > mptman->TotalAreaAfter) mptman->TotalAreaAfter = mptman->CommonBlock.LMDescentArea; + if (mptman->CommonBlock.SIVBArea > mptman->TotalAreaAfter) mptman->TotalAreaAfter = mptman->CommonBlock.SIVBArea; mpt->WeightAfterManeuver[man - 1] = mptman->TotalMassAfter; mpt->AreaAfterManeuver[man - 1] = mptman->TotalAreaAfter; diff --git a/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.h b/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.h index 522d0cff80..1a2828c7a4 100644 --- a/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.h +++ b/Orbitersdk/samples/ProjectApollo/src_launch/rtcc.h @@ -1242,31 +1242,40 @@ struct DetailedManeuverTable struct MPTVehicleDataBlock { + MPTVehicleDataBlock(); void SaveState(FILEHANDLE scn); void LoadState(char *line, int &inttemp); //Word 12 (Bytes 1, 2) std::bitset<4> ConfigCode; //Word 12 (Bytes 3, 4) - int ConfigChangeInd = 0; + int ConfigChangeInd; //Word 12 (Bytes 5, 6) - int TUP = 0; - //Word 13 - double CSMArea = 0.0; - //Word 14 - double SIVBArea = 0.0; - //Word 15 - double LMAscentArea = 0.0; - //Word 16 - double LMDescentArea = 0.0; - //Word 17 - double CSMMass = 0.0; - //Word 18 - double SIVBMass = 0.0; - //Word 19 - double LMAscentMass = 0.0; - //Word 20 - double LMDescentMass = 0.0; + int TUP; + //Words 13-16 + union + { + double Areas[4]; + struct + { + double CSMArea; + double SIVBArea; + double LMAscentArea; + double LMDescentArea; + }; + }; + //Words 17-20 + union + { + double Masses[4]; + struct + { + double CSMMass; + double SIVBMass; + double LMAscentMass; + double LMDescentMass; + }; + }; //Word 21 double CSMRCSFuelRemaining = 0.0; //Word 22 @@ -5141,12 +5150,13 @@ class RTCC { void MPTGetConfigFromString(const std::string &str, std::bitset<4> &cfg); void MPTGetStringFromConfig(const std::bitset<4> &cfg, char *str); MissionPlanTable *GetMPTPointer(int L); + MPTVehicleDataBlock *MPTDockingManeuver(int L, double GMT_BO, PLAWDTOutput &plawdtout); protected: //Auxiliary subroutines int PMMXFRGroundRules(MissionPlanTable * mpt, double GMTI, unsigned ReplaceMan, bool &LastManReplaceFlag, double &LowerLimit, double &UpperLimit, unsigned &CurMan, double &VectorFetchTime); int PMMXFRFormatManeuverCode(int Table, int Thruster, int Attitude, unsigned Maneuver, std::string ID, int &TVC, std::string &code); - int PMMXFRCheckConfigThruster(bool CheckConfig, int CCI, const std::bitset<4> &CCP, int TVC, int Thruster, std::bitset<4> &CC, std::bitset<4> &CCMI); + int PMMXFRCheckConfigThruster(bool CheckConfig, double GMT, int L, int CCI, const std::bitset<4> &CCP, int TVC, int Thruster, std::bitset<4> &CC, std::bitset<4> &CCMI); int PMMXFRFetchVector(double GMTI, int L, EphemerisData &sv); int PMMXFRFetchAnchorVector(int L, EphemerisData &sv); void PMMXFRWeightAtInitiation(int CCI, int CCMI, double &weight); diff --git a/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCCTables.h b/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCCTables.h index 333919c06c..16c68fc8d7 100644 --- a/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCCTables.h +++ b/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCCTables.h @@ -181,7 +181,7 @@ struct RTCCNIAuxOutputTable double DV_U; //Words 40-41: Open (CSM and LM weight?) double W_CSM, W_LMA, W_LMD; - //Word 42: S-IVB weighr at maneuver initiation + //Word 42: S-IVB weight at maneuver initiation double W_SIVB; //Word 43, total configuration weight at maneuver initiation double WTINIT; diff --git a/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.cpp b/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.cpp index e5ab08f45a..62036ab136 100644 --- a/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.cpp +++ b/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.cpp @@ -223,6 +223,10 @@ void RTCC_EMSMISS::CutoffModeLogic() CallManeuverIntegrator(); + if (ErrorCode) + { + return; + } //Maneuver error if (nierror) { @@ -326,8 +330,6 @@ void RTCC_EMSMISS::UpdateWeightsTableAndSVAfterManeuver() state.StateVector.GMT = AuxTableIndicator.GMT_BO; state.StateVector.RBI = AuxTableIndicator.RBI; - //TBD: Docking maneuver - double dmass = AuxTableIndicator.MainFuelUsed + AuxTableIndicator.RCSFuelUsed; switch (mpt->mantable[i].TVC) { @@ -349,8 +351,69 @@ void RTCC_EMSMISS::UpdateWeightsTableAndSVAfterManeuver() break; } + //Docking maneuver logic (but skip if integration is cut off at end of maneuver) + if (intab->ManCutoffIndicator == 1 && mpt->mantable[i].CommonBlock.ConfigChangeInd == RTCC_CONFIGCHANGE_DOCKING) + { + //Get weights from other MPT at desired time + PLAWDTOutput plawdtout; + MPTVehicleDataBlock *OtherCommonBlock; + + OtherCommonBlock = pRTCC->MPTDockingManeuver(intab->VehicleCode, state.StateVector.GMT, plawdtout); + + if (plawdtout.Err) + { + ErrorCode = 4; + return; + } + //Check for inconsistent configuration codes + std::bitset<4> TEMP; + //Do the two codes have any vehicle in common? + TEMP = state.WeightsTable.CC & plawdtout.CC; + if (TEMP != 0) + { + //Yes + ErrorCode = 4; + return; + } + //Unexpected final configuration? + TEMP = state.WeightsTable.CC | plawdtout.CC; + if (TEMP != mpt->mantable[i].CommonBlock.ConfigCode) + { + //Yes + ErrorCode = 4; + return; + } + + //Add weights from other table + if (plawdtout.CC[0]) + { + state.WeightsTable.CSMWeight = plawdtout.CSMWeight; + state.WeightsTable.CSMArea = plawdtout.CSMArea; + } + if (plawdtout.CC[1]) + { + state.WeightsTable.SIVBWeight = plawdtout.SIVBWeight; + state.WeightsTable.SIVBArea = plawdtout.SIVBArea; + } + if (plawdtout.CC[2]) + { + state.WeightsTable.LMAscWeight = plawdtout.LMAscWeight; + state.WeightsTable.LMAscArea = plawdtout.LMAscArea; + } + if (plawdtout.CC[3]) + { + state.WeightsTable.LMDscWeight = plawdtout.LMDscWeight; + state.WeightsTable.LMDscArea = plawdtout.LMDscArea; + } + //Change configuration code + state.WeightsTable.CC = TEMP; + //Update areas + UpdateConfigArea(state.WeightsTable); + } + state.WeightsTable.ConfigWeight = state.WeightsTable.CSMWeight + state.WeightsTable.SIVBWeight + state.WeightsTable.LMAscWeight + state.WeightsTable.LMDscWeight; + //Update maneuver times table MANTIMESData data; data.ManData[0] = AuxTableIndicator.GMT_1; @@ -761,7 +824,7 @@ void RTCC_EMSMISS::CallManeuverIntegrator() return; } - //Update weights table and SV + //Update weights table and state vector after the maneuver UpdateWeightsTableAndSVAfterManeuver(); } @@ -814,10 +877,15 @@ void RTCC_EMSMISS::WeightsAtManeuverBegin() state.WeightsTable = CurrentWeightsTable; } - else if (mpt->mantable[i].CommonBlock.ConfigChangeInd == RTCC_CONFIGCHANGE_DOCKING) - { - //TBD - } +} + +void RTCC_EMSMISS::UpdateConfigArea(PLAWDTOutput &tab) const +{ + tab.ConfigArea = 0.0; + if (tab.CC[RTCC_CONFIG_C] && tab.CSMArea > tab.ConfigArea) tab.ConfigArea = tab.CSMArea; + if (tab.CC[RTCC_CONFIG_S] && tab.SIVBArea > tab.ConfigArea) tab.ConfigArea = tab.SIVBArea; + if (tab.CC[RTCC_CONFIG_A] && tab.LMAscArea > tab.ConfigArea) tab.ConfigArea = tab.LMAscArea; + if (tab.CC[RTCC_CONFIG_D] && tab.LMDscArea > tab.ConfigArea) tab.ConfigArea = tab.LMDscArea; } void RTCC_EMSMISS::CallCSMLMIntegrator() diff --git a/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.h b/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.h index 6e7c191d7b..7ee16aa99f 100644 --- a/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.h +++ b/Orbitersdk/samples/ProjectApollo/src_rtccmfd/RTCC_EMSMISS.h @@ -63,6 +63,7 @@ class RTCC_EMSMISS : public RTCCModule void UpdateWeightsTableAndSVAfterManeuver(); void WriteNIAuxOutputTable(); void WeightsAtManeuverBegin(); + void UpdateConfigArea(PLAWDTOutput &tab) const; void WriteEphemerisHeaders(); bool InitEphemTables();