void H_system::Create_h_Vent(char *line) { char name[100]; h_Vent *new_one; vector3 pos=_vector3(0.0, 0.0, 0.0); vector3 dir; double volume,isol = 0; int one, two, three, four; sscanf (line+6, " %s %i %i %i %i", name, &one, &two, &three, &four); new_one = (h_Vent*)AddSystem(new h_Vent(name, pos)); new_one->IN_valve.open = one; new_one->OUT_valve.open = two; new_one->OUT2_valve.open = three; new_one->LEAK_valve.open = four; new_one->space.Void(); //empty the space line = ReadConfigLine(); while (strnicmp(line,"</VENT>",7)) { sscanf (line, "<%lf %lf %lf> <%lf %lf %lf> %lf", &pos.x, &pos.y, &pos.z, &dir.x, &dir.y, &dir.z, &volume); new_one->AddVent(pos,dir,volume); line=ReadConfigLine(); } }
void Dragonfly::Timestep (double simt) { VECTOR3 cg; VECTOR3 dist,pos; double dlevel, ratio; float line; static int vern; static int intr; static int rotmode; // ******************** Set linear, rotation, disabled RCS mode if (NAV_handle<3) {SetAttitudeMode(NAV_handle+1); NAV_handle=3; }; // ******************** Kill rot mode can be called via a CB //sprintf(oapiDebugString(),"%0.4f %0.4f %0.4f",Internals.Valves[23]->Temp,Internals.Tanks[11]->Temp,Internals.Tanks[12]->Temp); if (Kill_rot==1) { if (killset==0) { killset=1; //we've set the killrot rotmode= Internals.Nav_mode_switch->pos; Internals.Nav_mode_switch->pos=0;//go to rot mode oapiTriggerPanelRedrawArea(0,Internals.Nav_mode_switch->idx);//and redraw it vern=VERN_handle; intr=INTR_handle; if (Manual_RCS) { VERN_handle=1;//no vernier Internals.Vern_mode_switch->pos=1;//no vernier oapiTriggerPanelRedrawArea(0,Internals.Vern_mode_switch->idx); INTR_handle=1;//normal mode Internals.Intr_mode_switch->pos=1; oapiTriggerPanelRedrawArea(0,Internals.Intr_mode_switch->idx); SetNormalRCS(); //go to auto mode }; SetAttitudeMode(1);//go to rot mode ActivateNavmode(NAVMODE_KILLROT); //stop all rotation; }//end of killset if (killset==1){ //we are killrotting, monitoring the end of it if (GetNavmodeState(NAVMODE_KILLROT)==0)//no longer killrotting {//go back to previously saved RCS mode Internals.Nav_mode_switch->pos=rotmode; oapiTriggerPanelRedrawArea(0,Internals.Nav_mode_switch->idx); SetAttitudeMode(rotmode+1); Internals.Vern_mode_switch->pos=vern; VERN_handle=vern; oapiTriggerPanelRedrawArea(0,Internals.Vern_mode_switch->idx); Internals.Intr_mode_switch->pos=intr; INTR_handle=intr; oapiTriggerPanelRedrawArea(0,Internals.Intr_mode_switch->idx); //then inform the loop that killrot has ended Kill_rot=0; killset=0; }; }//end of killset }; //end of killrot=0; if ((killset)&&(Kill_rot==0)) //we've been asked to stop killrot {//go back to previously saved RCS mode Internals.Nav_mode_switch->pos=rotmode; oapiTriggerPanelRedrawArea(0,Internals.Nav_mode_switch->idx); SetAttitudeMode(rotmode+1); Internals.Vern_mode_switch->pos=vern; VERN_handle=vern; oapiTriggerPanelRedrawArea(0,Internals.Vern_mode_switch->idx); Internals.Intr_mode_switch->pos=intr; INTR_handle=intr; oapiTriggerPanelRedrawArea(0,Internals.Intr_mode_switch->idx); DeactivateNavmode(NAVMODE_KILLROT); Kill_rot=0; //not doing anything killset=0; }; //********************* Handle the vessel animations. Docking latch mecanism and the 2 antenas if (Dock_target_object) { //Dock_target_object=oapiGetVesselByIndex(1); oapiGetGlobalPos(Dock_target_object,&dist); Global2Local(dist,pos);//now we have a position w.r.t ship line=_vector3(pos.x,pos.y,pos.z).mod(); UP_trg=1-acos(pos.y/line)/acos(-1)*180.0/75.0; UY_trg=atan2(pos.x/line,pos.z/line); if (UY_trg>acos(-1)) UY_trg-=2*acos(-1); UY_trg=0.5-UY_trg/acos(-1)*180.0/300.0; LP_trg=acos(pos.y/line)/acos(-1)*180.0/75.0-1; LY_trg=UY_trg;//same azimuth; if (UAnt_handle==-1) {//Aquire & Track if (UY_trg<UY_pos) UY_handle=-1; if (UY_trg>UY_pos) UY_handle=1; if (UP_trg<UP_pos) UP_handle=-1; if (UP_trg>UP_pos) UP_handle=1; }; if (LAnt_handle==-1) {//Aquire & Track if (LY_trg<LY_pos) LY_handle=-1; if (LY_trg>LY_pos) LY_handle=1; if (LP_trg<LP_pos) LP_handle=-1; if (LP_trg>LP_pos) LP_handle=1; }; LAnt_SStr=1.0-(fabs(LY_trg-LY_pos)+fabs(LP_trg-LP_pos))/0.04; UAnt_SStr=1.0-(fabs(UY_trg-UY_pos)+fabs(UP_trg-UP_pos))/0.04; }; if (UAnt_handle==1) //bring upper antena home { if (UP_pos>0) UP_handle=-1; else UP_handle=0; if (UY_pos>0.51) UY_handle=-1; else if (UY_pos<0.49) UY_handle=1; else {UY_pos=0.5;;UY_handle=0;} }; if (LAnt_handle==1) //bring lower antena home { if (LP_pos>0) LP_handle=-1; else LP_handle=0; if (LY_pos>0.51) LY_handle=-1; else if (LY_pos<0.49) LY_handle=1; else {LY_pos=0.5;;LY_handle=0;} }; //stop all motion if (UAnt_handle==0) {UP_handle=0; UY_handle=0; UAnt_handle=2;}; if (LAnt_handle==0) {LP_handle=0; LY_handle=0; LAnt_handle=2;}; if (latch_handle) { if ((latch_handle<0)&&(dock_latched>0)) dock_latched-=oapiGetSysStep()/10.0; if ((latch_handle>0)&&(dock_latched<1)) dock_latched+=oapiGetSysStep()/10.0; if (dock_latched<0) dock_latched=0; if(dock_latched>1) dock_latched=1; SetAnimState (anim_latch, dock_latched); } if ((*AC_power>0)&&(UY_handle)) {if ((UY_handle<0)&&(UY_pos>0)) UY_pos-=oapiGetSysStep()/18.0; if ((UY_handle>0)&&(UY_pos<1)) UY_pos+=oapiGetSysStep()/18.0; if (UY_pos<0) UY_pos=0; if (UY_pos>1) UY_pos=1; SetAnimState (anim_UY_ant, UY_pos); float ang=(150-UY_pos*300.0)/180.0*acos(-1); Upper_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); }; if ((*AC_power>0)&&(UP_handle)) {if ((UP_handle<0)&&(UP_pos>0)) UP_pos-=oapiGetSysStep()/18.0; if ((UP_handle>0)&&(UP_pos<1)) UP_pos+=oapiGetSysStep()/18.0; if (UP_pos<0) UP_pos=0; if (UP_pos>1) UP_pos=1; SetAnimState (anim_UP_ant, UP_pos); }; if ((*AC_power>0)&&(LY_handle)) {if ((LY_handle<0)&&(LY_pos>0)) LY_pos-=oapiGetSysStep()/18.0; if ((LY_handle>0)&&(LY_pos<1)) LY_pos+=oapiGetSysStep()/18.0; if (LY_pos<0) LY_pos=0; if (LY_pos>1) LY_pos=1; SetAnimState (anim_LY_ant, LY_pos); float ang=(150-LY_pos*300.0)/180.0*acos(-1); Lower_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); }; if ((*AC_power>0)&&(LP_handle)) {if ((LP_handle<0)&&(LP_pos>0)) LP_pos-=oapiGetSysStep()/18.0; if ((LP_handle>0)&&(LP_pos<1)) LP_pos+=oapiGetSysStep()/18.0; if (LP_pos<0) LP_pos=0; if (LP_pos>1) LP_pos=1; SetAnimState (anim_LP_ant, LP_pos); }; signal_flag=0; if ((*AC_power>0)&&((UAnt_SStr>0.9)||(LAnt_SStr>0.9))) { sprintf(Dock_dist,"%5.0f",_vector3(pos.x,pos.y,pos.z).mod());//radar dist VECTOR3 rel_vel; oapiGetRelativeVel(GetHandle(),Dock_target_object,&rel_vel); rel_vel=rel_vel+dist; //this is global; VECTOR3 local_vel; Global2Local(rel_vel,local_vel);//local frame vel local_vel=local_vel-pos; //minus position is actual V vector sprintf(Dock_vel,"%5.2f",_vector3(local_vel.x,local_vel.y,local_vel.z).mod());//total closure sprintf(Dock_x_vel,"%3.0f",fabs(local_vel.x*100)); sprintf(Dock_y_vel,"%3.0f",fabs(local_vel.y*100)); sprintf(Dock_z_vel,"%3.0f",fabs(local_vel.z*100)); signal_flag=1; } //adjust for diferent RCS modes //NAV HANDLE - 1,lin, 0,rot, -1,off //VERN HANDLE - 1,norm, -1,vernier //INTR HANDLE - 1,command, 0, pulse, -1, rate if (Manual_RCS==0) //we are in auto mode {if (VERN_handle<1) DeleteAutoRCS();// go to manual if (INTR_handle<1) DeleteAutoRCS();// go to manual }; double tlevel; double tlevel_r; static int lin_x,lin_y,lin_z; static int rot_x,rot_y,rot_z; if (Manual_RCS) {//now's the tricky part if (INTR_handle>-1) SetZeroManualRCS();//needs to be zeroed;! if ((VERN_handle==1) &&(INTR_handle==1)) SetNormalRCS();//go to auto else { switch (INTR_handle) { case 1: // normal command dlevel=(VERN_handle>0?1:0.1); //vernier or not! :-) must be vernier, or this would not be manual command ... if (Internals.Nav_mode_switch->pos==0){ if (tlevel=GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) SetThrusterGroupLevel(th_rot_up,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) SetThrusterGroupLevel(th_rot_down,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_YAWRIGHT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) SetThrusterGroupLevel(th_rot_right,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_YAWLEFT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) SetThrusterGroupLevel(th_rot_left,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_BANKRIGHT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) SetThrusterGroupLevel(th_rot_rlrgt,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_BANKLEFT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) SetThrusterGroupLevel(th_rot_rllft,tlevel*dlevel); } else if (Internals.Nav_mode_switch->pos==1) { if (tlevel=GetManualControlLevel(THGROUP_ATT_BANKLEFT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) SetThrusterGroupLevel(th_lin_left,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_BANKRIGHT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) SetThrusterGroupLevel(th_lin_right,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) SetThrusterGroupLevel(th_lin_up,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) SetThrusterGroupLevel(th_lin_down,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_YAWLEFT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) SetThrusterGroupLevel(th_lin_forward,tlevel*dlevel); if (tlevel=GetManualControlLevel(THGROUP_ATT_YAWRIGHT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) SetThrusterGroupLevel(th_lin_back,tlevel*dlevel); }//the left/right forward/back are changed a bit.. but there is no "9" key processed break; case 0: //pulse type command dlevel=(VERN_handle>0?1:0.1); //vernier or not! if (Internals.Nav_mode_switch->pos==0){ if ((tlevel=GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!rot_x++)) SetThrusterGroupLevel(th_rot_up,tlevel*dlevel); if ((tlevel_r=GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!rot_x++)) SetThrusterGroupLevel(th_rot_down,tlevel_r*dlevel); if (tlevel+tlevel_r==0) rot_x=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_YAWRIGHT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!rot_z++)) SetThrusterGroupLevel(th_rot_right,tlevel*dlevel); if ((tlevel_r=GetManualControlLevel(THGROUP_ATT_YAWLEFT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!rot_z++)) SetThrusterGroupLevel(th_rot_left,tlevel_r*dlevel); if (tlevel+tlevel_r==0) rot_z=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_BANKRIGHT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!rot_y++)) SetThrusterGroupLevel(th_rot_rlrgt,tlevel*dlevel); if ((tlevel_r=GetManualControlLevel(THGROUP_ATT_BANKLEFT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!rot_y++)) SetThrusterGroupLevel(th_rot_rllft,tlevel_r*dlevel); if (tlevel+tlevel_r==0) rot_y=0; } else if (Internals.Nav_mode_switch->pos==1) { if ((tlevel=GetManualControlLevel(THGROUP_ATT_BANKLEFT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE))&&(!rot_x++)) SetThrusterGroupLevel(th_lin_left,tlevel*dlevel); if ((tlevel_r=GetManualControlLevel(THGROUP_ATT_BANKRIGHT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE))&&(!rot_x++)) SetThrusterGroupLevel(th_lin_right,tlevel_r*dlevel); if (tlevel+tlevel_r==0) rot_x=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ANYDEVICE, MANCTRL_LINMODE))&&(!rot_z++)) SetThrusterGroupLevel(th_lin_up,tlevel*dlevel); if ((tlevel_r=GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ANYDEVICE, MANCTRL_LINMODE))&&(!rot_z++)) SetThrusterGroupLevel(th_lin_down,tlevel_r*dlevel); if (tlevel+tlevel_r==0) rot_z=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_YAWLEFT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE))&&(!rot_y++)) SetThrusterGroupLevel(th_lin_forward,tlevel*dlevel); if ((tlevel_r=GetManualControlLevel(THGROUP_ATT_YAWRIGHT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE))&&(!rot_y++)) SetThrusterGroupLevel(th_lin_back,tlevel_r*dlevel); if (tlevel+tlevel_r==0) rot_y=0; }//the left/right forward/back are changed a bit.. but there is no "9" key processed :-( break; case -1: //rate command.. this is overly-complicated dlevel=(VERN_handle>0?1:0.1); //vernier or not! if (Internals.Nav_mode_switch->pos==0){ //pitch -up if ((tlevel=GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!rot_x++)) { tlevel_r=GetThrusterGroupLevel(th_rot_down); if (tlevel_r) {SetThrusterGroupLevel(th_rot_down,0.0);lin_x++;} else IncThrusterGroupLevel(th_rot_up,tlevel*dlevel/10.0); } if (!tlevel) rot_x=0; //pitch-down if ((tlevel=GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE))&&(!lin_x++)) { tlevel_r=GetThrusterGroupLevel(th_rot_up); if (tlevel_r) {SetThrusterGroupLevel(th_rot_up,0.0);rot_x++;} else IncThrusterGroupLevel(th_rot_down,tlevel*dlevel/10.0); } if(!tlevel) lin_x=0; //yaw right if ((tlevel=GetManualControlLevel(THGROUP_ATT_YAWRIGHT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) &&(!rot_z++)) { tlevel_r=GetThrusterGroupLevel(th_rot_left); if (tlevel_r){ SetThrusterGroupLevel(th_rot_left,0.0);lin_z++;} else IncThrusterGroupLevel(th_rot_right,tlevel*dlevel/10.0); } if (!tlevel) rot_z=0; //yaw right if ((tlevel=GetManualControlLevel(THGROUP_ATT_YAWLEFT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) &&(!lin_z++)) { tlevel_r=GetThrusterGroupLevel(th_rot_right); if (tlevel_r){ SetThrusterGroupLevel(th_rot_right,0.0);rot_z++;} else IncThrusterGroupLevel(th_rot_left,tlevel*dlevel/10.0); } if (!tlevel) lin_z=0; //roll right if ((tlevel=GetManualControlLevel(THGROUP_ATT_BANKRIGHT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) && (!rot_y++)) { tlevel_r=GetThrusterGroupLevel(th_rot_rllft); if (tlevel_r){ SetThrusterGroupLevel(th_rot_rllft,0.0);lin_y++;} else IncThrusterGroupLevel(th_rot_rlrgt,tlevel*dlevel/10.0); } if (!tlevel) rot_y=0; //roll left if ((tlevel=GetManualControlLevel(THGROUP_ATT_BANKLEFT, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) &&(!lin_y++)) { tlevel_r=GetThrusterGroupLevel(th_rot_rlrgt); if (tlevel_r){ SetThrusterGroupLevel(th_rot_rlrgt,0.0);rot_z++;} else IncThrusterGroupLevel(th_rot_rllft,tlevel*dlevel/10.0); } if (!tlevel) lin_y=0; } else if (Internals.Nav_mode_switch->pos==1) { if ((tlevel=GetManualControlLevel(THGROUP_ATT_BANKLEFT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) &&(!rot_x++)) { tlevel_r=GetThrusterGroupLevel(th_lin_right); if (tlevel_r) {SetThrusterGroupLevel(th_lin_right,0.0);lin_x++;} else IncThrusterGroupLevel(th_lin_left,tlevel*dlevel/10.0); } if (!tlevel) rot_x=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_BANKRIGHT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) &&(!lin_x++)) { tlevel_r=GetThrusterGroupLevel(th_lin_left); if (tlevel_r) {SetThrusterGroupLevel(th_lin_left,0.0);rot_x++;} else IncThrusterGroupLevel(th_lin_right,tlevel*dlevel/10.0); } if (!tlevel) lin_x=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) &&(!rot_z++)) { tlevel_r=GetThrusterGroupLevel(th_lin_down); if (tlevel_r) {SetThrusterGroupLevel(th_lin_down,0.0);lin_z++;} else IncThrusterGroupLevel(th_lin_up,tlevel*dlevel/10.0); } if (!tlevel) rot_z=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) &&(!lin_z++)) { tlevel_r=GetThrusterGroupLevel(th_lin_up); if (tlevel_r) {SetThrusterGroupLevel(th_lin_up,0.0);rot_z++;} else IncThrusterGroupLevel(th_lin_down,tlevel*dlevel/10.0); } if (!tlevel) lin_z=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_YAWLEFT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) &&(!rot_y++)) { tlevel_r=GetThrusterGroupLevel(th_lin_back); if (tlevel_r) {SetThrusterGroupLevel(th_lin_back,0.0);lin_y++;} else IncThrusterGroupLevel(th_lin_forward,tlevel*dlevel/10.0); } if (!tlevel) rot_y=0; if ((tlevel=GetManualControlLevel(THGROUP_ATT_YAWRIGHT, MANCTRL_ANYDEVICE, MANCTRL_LINMODE)) && (!lin_y++)) { tlevel_r=GetThrusterGroupLevel(th_lin_forward); if (tlevel_r) {SetThrusterGroupLevel(th_lin_forward,0.0);rot_y++;} else IncThrusterGroupLevel(th_lin_back,tlevel*dlevel/10.0); } if (!tlevel) lin_y=0; }//the left/right forward/back are changed a bit.. but there is no "9" key processed break; };//end INTR switch }//end else }//end manual RCS //******************************* THIS TAKES CARE OF AUTOMATIC GC MANAGEMENT... if (!cgmode) // auto cgofs = (GetSuperstructureCG (cg) ? cg.z : 0.0); if (Manual_RCS==0) { //auto mode we use normal Orbiter channels if (cgofs) { ratio = 2.0*cgofs/(cgofs+11.1); // counter-balance level dlevel = GetThrusterGroupLevel (THGROUP_ATT_LEFT) - GetThrusterGroupLevel (THGROUP_ATT_RIGHT); if (dlevel > 0) IncThrusterLevel_SingleStep (th_ap[0], dlevel*ratio); else if (dlevel < 0) IncThrusterLevel_SingleStep (th_ap[1], -dlevel*ratio); dlevel = GetThrusterGroupLevel (THGROUP_ATT_DOWN) - GetThrusterGroupLevel (THGROUP_ATT_UP); if (dlevel > 0) IncThrusterLevel_SingleStep (th_ap[2], dlevel*ratio); else if (dlevel < 0) IncThrusterLevel_SingleStep (th_ap[3], -dlevel*ratio); }} else { //we are in manual mode, using custom thruster groups if (cgofs) { ratio = 2.0*cgofs/(cgofs+11.1); // counter-balance level dlevel = GetThrusterGroupLevel (th_lin_left) - GetThrusterGroupLevel (th_lin_right); if (dlevel > 0) IncThrusterLevel_SingleStep (th_ap[0], dlevel*ratio); else if (dlevel < 0) IncThrusterLevel_SingleStep (th_ap[1], -dlevel*ratio); dlevel = GetThrusterGroupLevel (th_lin_down) - GetThrusterGroupLevel (th_lin_up); if (dlevel > 0) IncThrusterLevel_SingleStep (th_ap[2], dlevel*ratio); else if (dlevel < 0) IncThrusterLevel_SingleStep (th_ap[3], -dlevel*ratio); } } };
void ShipInternal::Init(VESSEL *vessel) { //3 X 02 cyro tanks parent=vessel; H_systems.AddSystem(Tanks[0]=new Tank(_vector3(0,0,0),4)); Tanks[0]->FillTank(O2_SPECIFICC,130000,170,O2_MMASS,0,600,150); H_systems.AddSystem(Tanks[1]=new Tank(_vector3(0,0,0),4)); Tanks[1]->FillTank(O2_SPECIFICC,130000,170,O2_MMASS,0,600,150); H_systems.AddSystem(Tanks[2]=new Tank(_vector3(0,0,0),4)); Tanks[2]->FillTank(O2_SPECIFICC,130000,170,O2_MMASS,0,600,150); //cyro 02 manifold H_systems.AddSystem(Man[0]=new Manifold(Tanks[0],Tanks[1],Tanks[2],150)); //3 x H2 cyro tanks H_systems.AddSystem(Tanks[3]=new Tank(_vector3(0,0,0),10)); Tanks[3]->FillTank(H2_SPECIFICC,70000,70,H2_MMASS,0,600,150); H_systems.AddSystem(Tanks[4]=new Tank(_vector3(0,0,0),10)); Tanks[4]->FillTank(H2_SPECIFICC,70000,70,H2_MMASS,0,600,150); H_systems.AddSystem(Tanks[5]=new Tank(_vector3(0,0,0),10)); Tanks[5]->FillTank(H2_SPECIFICC,70000,70,H2_MMASS,0,600,150); H_systems.AddSystem(Man[1]=new Manifold(Tanks[3],Tanks[4],Tanks[5],150)); //H20 waste tank for FC1/2 H_systems.AddSystem(Tanks[6]=new Tank(_vector3(0,0,0),8)); Tanks[6]->FillTank(H2O_SPECIFICC,10,70,H2O_MMASS,250,600,150); //2 vent overpressure-valves for H20 waste tank H_systems.AddSystem(Valves[0]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(0.0,-1.0,0.0), 10,0.5,1,2,150,Tanks[6])); H_systems.AddSystem(Valves[1]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(0.0,1.0,0.0), 10,0.5,1,2,150,Tanks[6])); //2 ovb dump valves H_systems.AddSystem(Valves[2]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(-1.0,0.0,0.0), 10,0.5,0,2,450,&Man[0]->OV[2])); H_systems.AddSystem(Valves[3]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(-1.0,0.0,0.0), 10,0.5,0,2,450,&Man[1]->OV[2])); //2 pressure regulators + 2 vent valves for pressure-safe cyro tanks H_systems.AddSystem(Valves[4]=new PValve(1,5,1500,1450,350,&Man[0]->OV[2])); H_systems.AddSystem(Valves[5]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(-1.0,0.0,0.0), 10,0.5,1,2,150,Valves[4])); H_systems.AddSystem(Valves[24]=new PValve(1,5,2500,2450,350,&Man[1]->OV[2])); H_systems.AddSystem(Valves[6]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(-1.0,0.0,0.0), 10,0.5,1,2,150,Valves[24])); // 2 x Fuel cells E_systems.AddSystem(FC[0]=new FCell(_vector3(0,0,0),&Man[0]->OV[0],&Man[1]->OV[0],(VentValve*)Valves[0],Tanks[6],10)); E_systems.AddSystem(FC[1]=new FCell(_vector3(0,0,0),&Man[0]->OV[1],&Man[1]->OV[1],(VentValve*)Valves[0],Tanks[6],10)); // 1 x 30min backup battery E_systems.AddSystem(BT[0]=new Battery(FC[0],5184000)); // 2 x DC busses , 1 back-up + AC buss E_systems.AddSystem(DC[0]=new DCbus(FC[0])); E_systems.AddSystem(DC[1]=new DCbus(FC[0])); E_systems.AddSystem(AC[0]=new ACbus(DC[0])); //link Dragonfly's power source to the AC1 and DC1 ((Dragonfly*)vessel)->AC_power=&AC[0]->Volts; ((Dragonfly*)vessel)->DC_power=&DC[0]->Volts; E_systems.AddSystem(DC[2]=new DCbus(DC[0])); //main heater bus E_systems.AddSystem(DC[3]=new DCbus(DC[0])); //fan bus // all the socks we need E_systems.AddSystem(Sock[0]=new Socket(BT[0],FC[0],FC[0],FC[1])); E_systems.AddSystem(Sock[1]=new Socket(DC[0],FC[0],BT[0],FC[1])); E_systems.AddSystem(Sock[2]=new Socket(DC[1],FC[0],BT[0],FC[1])); E_systems.AddSystem(Sock[3]=new Socket(AC[0],DC[0],BT[0],DC[1])); E_systems.AddSystem(Sock[4]=new Socket(DC[2],DC[0],BT[0],DC[1])); E_systems.AddSystem(Sock[5]=new Socket(DC[3],DC[0],BT[0],DC[1])); // cyro heaters E_systems.AddSystem(HT[0]=new Heater(Tanks[0],&Tanks[0]->Press,470,450, 120,15,DC[2])); E_systems.AddSystem(HT[1]=new Heater(Tanks[1],&Tanks[1]->Press,470,450,120,15,DC[2])); E_systems.AddSystem(HT[2]=new Heater(Tanks[2],&Tanks[2]->Press,470,450,120,15,DC[2])); E_systems.AddSystem(HT[3]=new Heater(Tanks[3],&Tanks[3]->Press,470,450,120,15,DC[2])); E_systems.AddSystem(HT[4]=new Heater(Tanks[4],&Tanks[4]->Press,470,450,120,15,DC[2])); E_systems.AddSystem(HT[5]=new Heater(Tanks[5],&Tanks[5]->Press,470,450,120,15,DC[2])); E_systems.AddSystem(Clk=new Clock()); //N2 pressure supply H_systems.AddSystem(Tanks[7]=new Tank(_vector3(0,0,0),3)); Tanks[7]->FillTank(14,20000,288,N2_MMASS,50,600,150); H_systems.AddSystem(Tanks[8]=new Tank(_vector3(0,0,0),3)); Tanks[8]->FillTank(14,20000,288,N2_MMASS,50,600,150); //a pressure regulator for each tank H_systems.AddSystem(Valves[7]=new PValve(1,5,78.3,70,120,Tanks[7])); H_systems.AddSystem(Valves[8]=new PValve(1,5,78.3,70,120,Tanks[8])); H_systems.AddSystem(Valves[13]=new PValve(1,5,290.0,280.0,120,&Man[0]->OV[2])); //reducing O2 press so we can boil it H_systems.AddSystem(Valves[22]=new Boiler(1,5,120,Valves[13],295.0,O2_BOILING,DC[0]));//heating it to ~22 deg H_systems.AddSystem(Valves[23]=new PValve(1,5,23.0,20.0,120,Valves[22])); //then finnally PP02 ~23kPA //ovb dump for N2 H_systems.AddSystem(Valves[9]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(-1.0,0.0,0.0), 10,0.5,0,2,150,Tanks[7])); H_systems.AddSystem(Valves[10]=new VentValve(vessel,_vector3(3.5,0.0,0.0),_vector3(-1.0,0.0,0.0), 10,0.5,0,2,150,Tanks[8])); //a simple manifold for N2 H_systems.AddSystem(Man[2]=new Manifold(Valves[7],Valves[8],Valves[8],150)); Man[2]->X[2].open=0;Man[2]->OV[2].open=0;Man[2]->X[1].open=1;Man[2]->X[0].open=0; Man[2]->OV[1].open=0;Man[2]->OV[0].open=1; //CO2 colector for LiOH H_systems.AddSystem(Tanks[12]=new Tank(_vector3(0,0,0),30)); Tanks[12]->FillTank(5,4800,295,CO2_MMASS,0,600,150); H_systems.AddSystem(Tanks[16]=new Room(_vector3(0,0,0),5,Tanks[12])); Tanks[16]->FillTank(5,2100,295,CO2_MMASS,2,600,150); //and a manifold for O2 circular; Regulate cyro 02 + refreshed 02 +cooled O2 H_systems.AddSystem(Man[3]=new Manifold(Valves[23],Tanks[16],Tanks[16],150)); Man[3]->X[2].open=0;Man[3]->X[1].open=1;Man[3]->X[0].open=1; Man[3]->OV[2].open=0;Man[3]->OV[1].open=0;Man[3]->OV[0].open=1; //no cooling for now :-( //cabin O2+N2+C02 air H_systems.AddSystem(Tanks[10]=new Room(_vector3(0,0,0),30,&Man[3]->OV[0])); //02 source is Pvalve from cyro02 manifold OV2 Tanks[10]->FillTank(O2_SPECIFICC,9100,295,O2_MMASS,0,600,150); H_systems.AddSystem(Tanks[11]=new Room(_vector3(0,0,0),30,&Man[2]->OV[0])); //Man[2] is N2 Tanks[11]->FillTank(14,27000,295,N2_MMASS,0,600,150); //docking bay atm //first the docking port H_systems.AddSystem(Valves[19]=new Valve(0,2,600,Tanks[10])); Valves[19]->open=0; H_systems.AddSystem(Valves[20]=new Valve(0,2,600,Tanks[11])); H_systems.AddSystem(Valves[21]=new Valve(0,2,600,Tanks[12])); H_systems.AddSystem(Tanks[13]=new Room(_vector3(0,0,0),30,Valves[19])); Tanks[13]->FillTank(O2_SPECIFICC,9100,295,O2_MMASS,0,600,150); H_systems.AddSystem(Tanks[14]=new Room(_vector3(0,0,0),30,Valves[20])); Tanks[14]->FillTank(14,27000,295,N2_MMASS,0,600,150); H_systems.AddSystem(Tanks[15]=new Room(_vector3(0,0,0),30,Valves[21])); Tanks[15]->FillTank(14,4800,295,CO2_MMASS,0,600,150); // Tanks[10]->open=0;Tanks[11]->open=0;Tanks[12]->open=0; //circle is complete, // the docking port can vent all out H_systems.AddSystem(Valves[16]=new VentValve(vessel,_vector3(0.0,0.0,3.2),_vector3(0.0,0.0,1.0), 10,2,0,5,550,Tanks[13])); H_systems.AddSystem(Valves[17]=new VentValve(vessel,_vector3(0.0,0.0,3.2),_vector3(0.0,0.0,1.0), 10,2,0,5,550,Tanks[14])); H_systems.AddSystem(Valves[18]=new VentValve(vessel,_vector3(0.0,0.0,3.2),_vector3(0.0,0.0,1.0), 10,2,0,5,550,Tanks[15])); E_systems.AddSystem(Fans[0]=new Fan(Tanks[12],Tanks[16],-20.0,7,DC[3])); E_systems.AddSystem(Fans[1]=new Fan(Tanks[12],Tanks[16],-20.0,7,DC[3])); DC[0]->PLOAD(70); //DC[1]->PLOAD(80); AC[0]->PLOAD(30); mjd_d=1; };