Skip to content

Commit

Permalink
Merge pull request #1258 from indy91/RTCCFix
Browse files Browse the repository at this point in the history
RTCC: Insertion state vector from LWP can be send to MPT; vector panel summary properly shows negative GMT values
  • Loading branch information
indy91 authored Jun 24, 2024
2 parents b617889 + a7f4d9e commit 6203edf
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 19 deletions.
52 changes: 39 additions & 13 deletions Orbitersdk/samples/ProjectApollo/src_launch/rtcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,23 @@ using namespace nassp;
void format_time_rtcc(char *buf, double time) {
buf[0] = 0; // Clobber
int hours, minutes, seconds;
if (time < 0) { return; } // don't do that
bool negative = false;
if (time < 0)
{
time = abs(time);
negative = true;
}
hours = (int)(time / 3600);
minutes = (int)((time / 60) - (hours * 60));
seconds = (int)((time - (hours * 3600)) - (minutes * 60));
sprintf_s(buf, 64, "%03d:%02d:%02d", hours, minutes, seconds);
if (negative)
{
sprintf_s(buf, 64, "-%03d:%02d:%02d", hours, minutes, seconds);
}
else
{
sprintf_s(buf, 64, "%03d:%02d:%02d", hours, minutes, seconds);
}
}

//Ephemeris format 2 to format 1
Expand Down Expand Up @@ -19534,6 +19546,20 @@ void RTCC::PMMPAR(VECTOR3 RT, VECTOR3 VT, double TT)
PZSLVTAR.HP_C = INFO[9] / 1852.0;
PZSLVTAR.TA_C = lwp.svtab.sv_C.coe_osc.l*DEG;
PZSLVTAR.DH = lwp.rlott.DH / 1852.0;

//Save insertion state vector in launch interface table
EphemerisData2 sv_ins_ECT, sv_ins_ECI;
int err;

OrbMech::GIMKIC(lwp.svtab.sv_C.coe_osc, OrbMech::mu_Earth, sv_ins_ECT.R, sv_ins_ECT.V);
sv_ins_ECT.GMT = lwp.svtab.sv_C.TS;

err = ELVCNV(sv_ins_ECT, RTCC_COORDINATES_ECT, RTCC_COORDINATES_ECI, sv_ins_ECI);
if (err) return;

GZLTRA.R_T = sv_ins_ECI.R;
GZLTRA.V_T = sv_ins_ECI.V;
GZLTRA.GMT_T = sv_ins_ECI.GMT;
}

void RTCC::PMMIEV(int L, double T_L)
Expand Down Expand Up @@ -36333,7 +36359,7 @@ void RTCC::BMDVPS()
{
mpt = &PZMPTLEM;
}
if (mpt->GMTAV > 0)
if (mpt->GMTAV != 0.0)
{
VectorPanelSummaryBuffer.AnchorVectorID[i] = mpt->StationID;
format_time_rtcc(Buff, mpt->GMTAV);
Expand Down Expand Up @@ -36370,7 +36396,7 @@ void RTCC::BMDVPS()
}
VectorPanelSummaryBuffer.CompTelemetryLowGMT[i][j] = ""; //TBD
}
if (BZUSEVEC.data[6 * i + 4].Vector.GMT > 0)
if (BZUSEVEC.data[6 * i + 4].Vector.RBI != -1)
{
VectorPanelSummaryBuffer.HSRID[i] = BZUSEVEC.data[6 * i + 4].VectorCode;
format_time_rtcc(Buff, BZUSEVEC.data[6 * i + 4].Vector.GMT);
Expand All @@ -36381,7 +36407,7 @@ void RTCC::BMDVPS()
VectorPanelSummaryBuffer.HSRID[i] = "";
VectorPanelSummaryBuffer.HSRGMT[i] = "";
}
if (BZUSEVEC.data[6 * i + 5].Vector.GMT > 0)
if (BZUSEVEC.data[6 * i + 5].Vector.RBI != -1)
{
VectorPanelSummaryBuffer.DCID[i] = BZUSEVEC.data[6 * i + 5].VectorCode;
format_time_rtcc(Buff, BZUSEVEC.data[6 * i + 5].Vector.GMT);
Expand All @@ -36407,7 +36433,7 @@ void RTCC::BMDVPS()
}

}
if (BZSTLM.HighSpeedCMCCSMVector.GMT > 0)
if (BZSTLM.HighSpeedCMCCSMVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedCMCCSMVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][0].assign(Buff);
Expand All @@ -36416,7 +36442,7 @@ void RTCC::BMDVPS()
{
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][0] = "";
}
if (BZSTLM.HighSpeedLGCCSMVector.GMT > 0)
if (BZSTLM.HighSpeedLGCCSMVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedLGCCSMVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][1].assign(Buff);
Expand All @@ -36425,7 +36451,7 @@ void RTCC::BMDVPS()
{
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][1] = "";
}
if (BZSTLM.HighSpeedAGSCSMVector.GMT > 0)
if (BZSTLM.HighSpeedAGSCSMVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedAGSCSMVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][2].assign(Buff);
Expand All @@ -36434,7 +36460,7 @@ void RTCC::BMDVPS()
{
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][2] = "";
}
if (BZSTLM.HighSpeedIUVector.GMT > 0)
if (BZSTLM.HighSpeedIUVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedIUVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][3].assign(Buff);
Expand All @@ -36443,7 +36469,7 @@ void RTCC::BMDVPS()
{
VectorPanelSummaryBuffer.CompTelemetryHighGMT[0][3] = "";
}
if (BZSTLM.HighSpeedCMCLEMVector.GMT > 0)
if (BZSTLM.HighSpeedCMCLEMVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedCMCLEMVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[1][0].assign(Buff);
Expand All @@ -36452,7 +36478,7 @@ void RTCC::BMDVPS()
{
VectorPanelSummaryBuffer.CompTelemetryHighGMT[1][0] = "";
}
if (BZSTLM.HighSpeedLGCLEMVector.GMT > 0)
if (BZSTLM.HighSpeedLGCLEMVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedLGCLEMVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[1][1].assign(Buff);
Expand All @@ -36461,7 +36487,7 @@ void RTCC::BMDVPS()
{
VectorPanelSummaryBuffer.CompTelemetryHighGMT[1][1] = "";
}
if (BZSTLM.HighSpeedAGSLEMVector.GMT > 0)
if (BZSTLM.HighSpeedAGSLEMVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedAGSLEMVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[1][2].assign(Buff);
Expand All @@ -36470,7 +36496,7 @@ void RTCC::BMDVPS()
{
VectorPanelSummaryBuffer.CompTelemetryHighGMT[1][2] = "";
}
if (BZSTLM.HighSpeedIUVector.GMT > 0)
if (BZSTLM.HighSpeedIUVector.RBI != -1)
{
format_time_rtcc(Buff, BZSTLM.HighSpeedIUVector.GMT);
VectorPanelSummaryBuffer.CompTelemetryHighGMT[1][3].assign(Buff);
Expand Down
33 changes: 30 additions & 3 deletions Orbitersdk/samples/ProjectApollo/src_rtccmfd/ApolloRTCCMFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4573,7 +4573,7 @@ bool DifferentialCorrectionSolutionLEMInput(void* id, char *str, void *data)
bool ApolloRTCCMFD::set_DifferentialCorrectionSolution(char *str, bool csm)
{
//To update display immediately
GC->rtcc->VectorPanelSummaryBuffer.gmt = -1.0;
GC->rtcc->VectorPanelSummaryBuffer.gmt = -10000000000000.0;

OBJHANDLE hVessel = oapiGetVesselByName(str);
if (hVessel)
Expand Down Expand Up @@ -4844,7 +4844,7 @@ bool EphemerisUpdateLEMInput(void* id, char *str, void *data)
void ApolloRTCCMFD::VectorControlPBI(int code)
{
//To update display immediately
GC->rtcc->VectorPanelSummaryBuffer.gmt = -1.0;
GC->rtcc->VectorPanelSummaryBuffer.gmt = -10000000000000.0;

GC->rtcc->BMSVPS(0, code);
}
Expand Down Expand Up @@ -5306,6 +5306,33 @@ void ApolloRTCCMFD::menuSLVLaunchTargeting()
G->SkylabSaturnIBLaunchCalc();
}

void ApolloRTCCMFD::menuSLVInsertionSVtoMPT()
{
if (GC->MissionPlanningActive == false) return;
if (GC->rtcc->GZLTRA.GMT_T == 0.0) return;

StateVectorTableEntry sv0;
int L;

if (GC->rtcc->PZSLVCON.Pad == 1)
{
L = RTCC_MPT_CSM;
}
else
{
L = RTCC_MPT_LM;
}

sv0.VectorCode = "NOMINS";
sv0.LandingSiteIndicator = false;
sv0.Vector.R = GC->rtcc->GZLTRA.R_T;
sv0.Vector.V = GC->rtcc->GZLTRA.V_T;
sv0.Vector.GMT = GC->rtcc->GZLTRA.GMT_T;
sv0.Vector.RBI = BODY_EARTH;

GC->rtcc->PMSVCT(0, L, sv0);
}

void ApolloRTCCMFD::menuSLVLaunchUplink()
{
G->SkylabSaturnIBLaunchUplink();
Expand Down Expand Up @@ -9099,7 +9126,7 @@ void ApolloRTCCMFD::menuSLVNavigationUpdateUplink()
void ApolloRTCCMFD::menuGetOnboardStateVectors()
{
//To update display immediately
GC->rtcc->VectorPanelSummaryBuffer.gmt = -1.0;
GC->rtcc->VectorPanelSummaryBuffer.gmt = -10000000000000.0;

G->GetStateVectorFromAGC(true, true);
G->GetStateVectorFromAGC(true, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class ApolloRTCCMFD: public MFD2 {
void CycleThroughVessels(VESSEL **v) const;
void menuSLVLaunchTargetingPad();
void menuSLVLaunchTargeting();
void menuSLVInsertionSVtoMPT();
void menuSLVLaunchUplink();
void menuVoid();
void menuSetLambertPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4160,7 +4160,7 @@ ApolloRTCCMFDButtons::ApolloRTCCMFDButtons()
{ "Select IU vessel", 0, 'Q' },

{ "Calculate LWP", 0, 'C' },
{ "", 0, ' ' },
{ "Insertion state vector to MPT", 0, 'A' },
{ "", 0, ' ' },
{ "", 0, ' ' },
{ "", 0, ' ' },
Expand All @@ -4177,7 +4177,7 @@ ApolloRTCCMFDButtons::ApolloRTCCMFDButtons()
RegisterFunction("IU", OAPI_KEY_Q, &ApolloRTCCMFD::set_IUVessel);

RegisterFunction("CLC", OAPI_KEY_C, &ApolloRTCCMFD::menuSLVLaunchTargeting);
RegisterFunction("", OAPI_KEY_A, &ApolloRTCCMFD::menuVoid);
RegisterFunction("MPT", OAPI_KEY_A, &ApolloRTCCMFD::menuSLVInsertionSVtoMPT);
RegisterFunction("", OAPI_KEY_Q, &ApolloRTCCMFD::menuVoid);
RegisterFunction("", OAPI_KEY_R, &ApolloRTCCMFD::menuVoid);
RegisterFunction("UPL", OAPI_KEY_U, &ApolloRTCCMFD::menuSLVLaunchUplink);
Expand Down
2 changes: 1 addition & 1 deletion Orbitersdk/samples/ProjectApollo/src_rtccmfd/LWP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ void LaunchWindowProcessor::TARGT()
AZL = inp.LAZCOE[0] + inp.LAZCOE[1] * IIGM + inp.LAZCOE[2] * TIGM + inp.LAZCOE[3] * IIGM*TIGM;

aegdata.coe_osc.i = IIGM;
aegdata.coe_osc.h = DN + PI + inp.DELNO + GLOCON.w_E*GMTLO;
aegdata.coe_osc.h = DN + PI + inp.DELNO + GLOCON.w_E*TGRR;
OrbMech::GIMKIC(aegdata.coe_osc, GLOCON.mu, RP, VP);
//Compute GPAZ
TRS = DN / (GLOCON.w_E + sv_T.h_dot) + TINS;
Expand Down

0 comments on commit 6203edf

Please sign in to comment.