Rise
The Vieneo Province
Loading...
Searching...
No Matches
Tests/OrbitHandoffTests.h

Source at documentation-generation time. See Test catalog for fixture associations.

1#pragma once
2
3void OrbitHandoffTests()
4{
5 struct Controls {bool DorOn=true,TvmOn=false;float DesiredClosingSpeed=.25f;};
6 auto in=Fixture();in.vehicle=42;in.targetId=7;
7 auto finish=[&](Input input,Mode mode,Guidance& g,bool freeze,Controls& controls,int& sounds) {
8 return FinishExecution(input,mode,g,freeze,controls,[&] {
9 Check(!controls.TvmOn,"TVM handoff follows DOR cleanup");
10 controls.DorOn=false;controls.DesiredClosingSpeed=-1;
11 ++sounds; // production callback uses TurnOffDOR(true), including its disconnect sound
12 });
13 };
14 for(auto kind:{TargetKind::Station,TargetKind::Vessel}) for(bool simulator:{false,true}) {
15 in.targetKind=kind;in.simulator=simulator;
16 Controls c;Guidance g;g.phase=Phase::Complete;int sounds=0;
17 Check(finish(in,Mode::Rendezvous,g,false,c,sounds),"completed station/ship rendezvous hands off in real/simulator flight");
18 Check(!c.DorOn&&c.TvmOn&&c.DesiredClosingSpeed==0&&sounds==1,"DOR cleanup once, TVM engaged at exactly zero");
19 Check(g.phase==Phase::Complete&&g.status==L"RENDEZVOUS COMPLETE / TVM","completion annunciates actual TVM handoff");
20 Check(in.targetId==7,"handoff does not change selected target");
21 Check(!finish(in,Mode::Rendezvous,g,false,c,sounds)&&sounds==1,"completed handoff cannot rearm after DOR drops");
22 c.TvmOn=false;
23 Check(!finish(in,Mode::Rendezvous,g,false,c,sounds)&&!c.TvmOn,"pilot TVM disconnect stays off");
24 }
25 in=Fixture();
26 for(auto mode:{Mode::Adjust,Mode::Overfly,Mode::Return,Mode::Target}) {
27 Controls c;Guidance g;g.phase=Phase::Complete;int sounds=0;
28 Check(!finish(in,mode,g,false,c,sounds)&&!c.TvmOn&&sounds==1,"other objectives finish with normal DOR disconnect");
29 }
30 for(auto phase:{Phase::Abort,Phase::Off,Phase::Wait,Phase::Align,Phase::Depart,Phase::Coast,Phase::Arrive}) {
31 Controls c;Guidance g;g.phase=phase;g.status=L"DOR: CORRECTION MARGIN LOST";int sounds=0;
32 Check(!finish(in,Mode::Rendezvous,g,false,c,sounds)&&!c.TvmOn&&sounds==1,
33 "failed or incomplete execution never disguises itself as arrival handoff");
34 Check(g.status==L"DOR: CORRECTION MARGIN LOST","abort reason retained");
35 }
36 for(int invalid=0;invalid<9;++invalid) {
37 auto input=in;Controls c;Guidance g;g.phase=Phase::Complete;int sounds=0;bool freeze=false;
38 if(invalid==0) input.onGround=true;
39 if(invalid==1) input.freeFlight=false;
40 if(invalid==2) input.powered=false;
41 if(invalid==3) input.supported=false;
42 if(invalid==4) input.targetKind=TargetKind::None;
43 if(invalid==5) input.targetKind=TargetKind::Surface;
44 if(invalid==6) input.target.v.x=NAN;
45 if(invalid==7) input.own.v.x=NAN;
46 if(invalid==8) freeze=true;
47 Check(!finish(input,Mode::Rendezvous,g,freeze,c,sounds)&&!c.TvmOn,"invalid flight/target state does not engage TVM");
48 }
49 Controls manual;manual.DorOn=false;Guidance g;g.phase=Phase::Complete;int sounds=0;
50 Check(!finish(in,Mode::Rendezvous,g,false,manual,sounds)&&!manual.TvmOn&&sounds==0,
51 "manual DOR cancellation never engages TVM");
52 Controls flying;g={};g.valid=true;g.phase=Phase::Arrive;
53 Check(!finish(in,Mode::Rendezvous,g,false,flying,sounds)&&flying.DorOn&&!flying.TvmOn&&sounds==0,
54 "ongoing final manoeuvring stays DOR until settled");
55}