void PanelSDK::Load(FILEHANDLE scn) { int id; char *line, buffer[100]; bool dontLoad; // check version dontLoad = true; oapiReadScenario_nextline (scn, line); if (!strnicmp (line, "<VERSION>", 9)) { sscanf(line + 9, "%s", buffer); if (!strnicmp (buffer, PANELSDK_VERSION, strlen(PANELSDK_VERSION))) dontLoad = false; } oapiReadScenario_nextline (scn, line); if (dontLoad) { while (strnicmp(line,"</INTERNALS>",12)) { oapiReadScenario_nextline (scn, line); } return; } while (strnicmp(line,"</INTERNALS>",12)) { if (!strnicmp (line, "<HYDRAULIC>", 11)) HYDRAULIC->Load(scn); else if (!strnicmp (line, "<ELECTRIC>", 10)) ELECTRIC->Load(scn); else if (!strnicmp (line, "<PANEL>", 7)) { sscanf(line + 7, "%i", &id); panels[id]->Load(scn); } oapiReadScenario_nextline (scn, line); } }
void Battery::Load(FILEHANDLE scn) { char *line; oapiReadScenario_nextline (scn, line); sscanf (line," BATTERY %f %f %i", &loading,&power,&c_breaker); load_handle=loading; }
void DockingProbe::LoadState(FILEHANDLE scn) { char *line; int i; while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp(line, DOCKINGPROBE_END_STRING, sizeof(DOCKINGPROBE_END_STRING))) return; else if (!strnicmp (line, "ENABLED", 7)) { sscanf (line+7, "%d", &i); Enabled = (i != 0); } else if (!strnicmp (line, "STATUS", 6)) { sscanf (line+6, "%lf", &Status); } else if (!strnicmp (line, "EXTENDINGRETRACTING", 19)) { sscanf (line+19, "%d", &ExtendingRetracting); } else if (papiReadScenario_int(line, "DOCKPROC", Dockproc)); else if (papiReadScenario_int(line, "CHARGESUSED", RetractChargesUsed)); else if (papiReadScenario_vec(line, "DOCKPARAM0", Dockparam[0])); else if (papiReadScenario_vec(line, "DOCKPARAM1", Dockparam[1])); else papiReadScenario_vec(line, "DOCKPARAM2", Dockparam[2]); } }
void Socket::Load(FILEHANDLE scn) { char *line; oapiReadScenario_nextline (scn, line); sscanf (line," SOCKET %i", &socket_handle); curent=socket_handle+1; //make sure we re-conect }
void Dragonfly::LoadState (FILEHANDLE scn, void *vs) { char *line; while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp (line, "UPPERANT", 8)) { sscanf (line+8, "%f %f %i %i %i", &UP_pos ,&UY_pos,&UP_handle, &UY_handle,&UAnt_handle); } else if (!strnicmp (line, "LOWERANT", 8)) { sscanf (line+8, "%f %f %i %i %i", &LP_pos, &LY_pos,&LP_handle,&LY_handle,&LAnt_handle); //SetGearParameters (gear_proc); } else if (!strnicmp (line, "HATCH", 5)) { sscanf (line+5, "%f %i", &dock_latched, &latch_handle); } else if (!strnicmp (line, "ANTTRG", 6)) { Dock_target_object=oapiGetObjectByName(line+7); //sscanf (line+5, "%f %i", &dock_latched, &latch_handle); } else { ParseScenarioLineEx (line, vs); // unrecognised option - pass to Orbiter's generic parser } } 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)); SetAnimState (anim_UP_ant, UP_pos); SetAnimState (anim_LY_ant, LY_pos); ang=(150-LY_pos*300.0)/180.0*acos(-1); Lower_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); SetAnimState (anim_LP_ant, LP_pos); SetAnimState (anim_latch, dock_latched); };
void ShipInternal::Load(FILEHANDLE scn, void *def_vs) { char *line; oapiReadScenario_nextline (scn, line); if (!strncmp(line,"INTERNAL: v1.0.0B",17)) { oapiReadScenario_nextline (scn, line); H_systems.Load(scn); oapiReadScenario_nextline (scn, line); E_systems.Load(scn); oapiReadScenario_nextline (scn, line); PanelList[0].Load(scn); PanelList[1].Load(scn); PanelList[2].Load(scn); PanelList[3].Load(scn); PanelList[4].Load(scn); } else parent->ParseScenarioLineEx (line, def_vs); };
DLLCLBK void opcLoadState (FILEHANDLE scn) { char *line; while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp (line, "CFG", 3)) { sscanf (line+3, "%s", &g_UFA.cfg); } } ConfigLoaded=TRUE; g_UFA.init(); }
void h_Tank::Load(FILEHANDLE scn) { char *line; h_substance loaded_sub; space.Void(); //empty the space oapiReadScenario_nextline (scn, line); while (strnicmp(line,"</TANK>",7)) { if (!strnicmp (line, "CHM",3 )) { sscanf (line+3, " %i %lf %lf %lf", &loaded_sub.subst_type, &loaded_sub.mass, &loaded_sub.vapor_mass, &loaded_sub.Q); space+=loaded_sub; } oapiReadScenario_nextline (scn, line); } mass = space.GetMass();//get all the mass,etc.. space.GetMaxSub();//recompute sub_number; energy = space.GetQ();//sum up Qs }
// Read current state void Atlantis_SRB::clbkLoadStateEx (FILEHANDLE scn, void *vs) { char *line; while (oapiReadScenario_nextline (scn, line)) { if (!_strnicmp (line, "MET ", 4)) { double met; sscanf (line+4, "%lf", &met); t0 = oapiGetSimTime()-met; bMainEngine = true; } else ParseScenarioLineEx (line, vs); } }
void DSKY::LoadState(FILEHANDLE scn, char *end_str) { char *line; int end_len = strlen (end_str); while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp(line, end_str, end_len)) return; if (!strnicmp (line, "PROG", 4)) { strncpy (Prog, line+5, 2); } else if (!strnicmp (line, "VERB", 4)) { strncpy (Verb, line+5, 2); } else if (!strnicmp (line, "NOUN", 4)) { strncpy (Noun, line+5, 2); } else if (!strnicmp (line, "R1", 2)) { strncpy (R1, line+3, 6); } else if (!strnicmp (line, "R2", 2)) { strncpy (R2, line+3, 6); } else if (!strnicmp (line, "R3", 2)) { strncpy (R3, line+3, 6); } else if (!strnicmp (line, "STATE", 5)) { DSKYState state; sscanf (line+5, "%d", &state.word); VerbFlashing = state.u.VerbFlashing; NounFlashing = state.u.NounFlashing; CompActy = (state.u.CompActy != 0); UplinkLight = state.u.UplinkLight; NoAttLight = state.u.NoAttLight; StbyLight = state.u.StbyLight; KbRelLight = state.u.KbRelLight; OprErrLight = state.u.OprErrLight; TempLight = state.u.TempLight; GimbalLockLight = state.u.GimbalLockLight; ProgLight = state.u.ProgLight; RestartLight = state.u.RestartLight; TrackerLight = state.u.TrackerLight; AltLight = (state.u.AltLight != 0); VelLight = (state.u.VelLight != 0); } } }
void EVA::clbkLoadStateEx(FILEHANDLE scn, void *status) { char *line; while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp (line, "GODOCK", 6)) { int i; sscanf(line + 6, "%d", &i); GoDock1 = (i != 0); } else { ParseScenarioLineEx (line, status); } } }
// -------------------------------------------------------------- // Read status from scenario file // -------------------------------------------------------------- void HST::clbkLoadStateEx (FILEHANDLE scn, void *vs) { char *line; while (oapiReadScenario_nextline (scn, line)) { if (!_strnicmp (line, "ANT", 3)) { sscanf (line+3, "%d%lf", &ant_status, &ant_proc); } else if (!_strnicmp (line, "HATCH", 5)) { sscanf (line+5, "%d%lf", &hatch_status, &hatch_proc); } else if (!_strnicmp (line, "FOLD", 4)) { sscanf (line+5, "%d%lf", &array_status, &array_proc); } else { ParseScenarioLineEx (line, vs); } } SetAnimation (anim_ant, ant_proc); SetAnimation (anim_hatch, hatch_proc); SetAnimation (anim_array, array_proc); }
// ============================================================================================================================================== // void SyncMFD::Read(FILEHANDLE scn) { bool go=true; int tmpi; char *line; while (go) { go=oapiReadScenario_nextline (scn, line); if (go) { if (!_strnicmp (line, "Target", 6)) { usingGS2 = false; trgt = &bstrgt; sscanf (line+6, "%s",bstrgt.name); } else if (!_strnicmp (line, "Reference", 9)) { usingGS2 = false; trgt = &bstrgt; sscanf (line+9, "%s",bstrgt.ref); } else if (!_strnicmp (line, "Data", 4)) { usingGS2 = false; trgt = &bstrgt; sscanf(line+4,"%lg %lg %d %d %lg %d", &bstrgt.lon, &bstrgt.lat, &tmpi, &mode.enc,&sync_line,&sync_num); mode.dir = (tmpi==2); } else go=false; } } unsigned int i; for (i=0;i<strlen(bstrgt.name);i++) if (bstrgt.name[i]=='_') bstrgt.name[i]=' '; for (i=0;i<strlen(bstrgt.ref);i++) if (bstrgt.ref[i]=='_') bstrgt.ref[i]=' '; }
void Panel::Load(FILEHANDLE scn) { instrument_list *runner=instruments; char *line; int int_sv[10]; //int index=0; //read the switches oapiReadScenario_nextline (scn, line); while (strncmp(line,"SW END",6)) { sscanf (line," SW %i %i %i %i %i", &int_sv[0],&int_sv[1],&int_sv[2],&int_sv[3],&int_sv[4]); for (int i=0;i<5;i++) { while ((runner) && (runner->instance->type!=33)) runner=runner->next; ((Switch*)runner->instance)->pos=int_sv[i]; if (int_sv[i+1]==99) break; runner=runner->next; } oapiReadScenario_nextline (scn, line); } //read the rotaries runner=instruments; oapiReadScenario_nextline (scn, line); while (strncmp(line,"ROT END",6)) { sscanf (line," ROT %i %i %i %i %i", &int_sv[0],&int_sv[1],&int_sv[2],&int_sv[3],&int_sv[4]); for (int i=0;i<5;i++) { while ((runner) && (runner->instance->type!=34)) runner=runner->next; ((Rotary*)runner->instance)->set=int_sv[i]; if (int_sv[i+1]==99) break; runner=runner->next; } oapiReadScenario_nextline (scn, line); } //read the extra instruments info runner=instruments; oapiReadScenario_nextline (scn, line); while (strncmp(line,"PAN END",6)) //until we clear this panel { if (!strncmp(line,"ADI",3)) //we have an adi to load { while ((runner) && (runner->instance->type!=44)) runner=runner->next;//go to ADI ADI* adi_p=(ADI*)runner->instance; sscanf(line," ADI %lf %lf %lf %i %i %lf %lf %lf",&(adi_p->now.x),&(adi_p->now.y),&(adi_p->now.z), &(adi_p->orbital_ecliptic),&(adi_p->function_mode), &(adi_p->reference.x),&(adi_p->reference.y),&(adi_p->reference.z)); };//end of adi found ! oapiReadScenario_nextline (scn, line); };//end of while };
void shipptrs::restoreallships(FILEHANDLE scn) { char *buffer,*member; Parser parser; int length; while (oapiReadScenario_nextline(scn,buffer)) { parser.parseline(buffer); bool ok=parser.getlineelement(0,&member,&length); if (!ok) return; if (strcmp("Ship",member)==0) { if (!parser.getlineelement(1,&member,&length)) return;//return if ship label doesn't exist if (length>30) return;//return if ship label is bad class shipptrs *temp=findship(member); if (temp==NULL) { OBJHANDLE temphandle=oapiGetVesselByName(member); if (temphandle!=NULL) temp=new shipptrs(temphandle); } if (temp!=NULL) temp->restorecurrent(scn); } } }
void Fan::Load(FILEHANDLE scn) { char *line; oapiReadScenario_nextline (scn, line); sscanf (line," FAN %i", &on); }
void Heater::Load(FILEHANDLE scn) { char *line; oapiReadScenario_nextline (scn, line); sscanf (line," HT %i", &on); }
void ACbus::Load(FILEHANDLE scn) { char *line; oapiReadScenario_nextline (scn, line); sscanf (line," AC %f", &branch_amps); }
void FCell::Load(FILEHANDLE scn) { char *line; oapiReadScenario_nextline (scn, line); sscanf (line," FCELL %i %f", &status,&clogg); }
void LVIMU::LoadState(FILEHANDLE scn) { char *line; double flt = 0; while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp(line, LVIMU_END_STRING, sizeof(LVIMU_END_STRING))) return; if (!strnicmp (line, "RPX", 3)) { sscanf(line + 3, "%lf", &flt); RemainingPIPA.X = flt; } else if (!strnicmp (line, "RPY", 3)) { sscanf(line + 3, "%lf", &flt); RemainingPIPA.Y = flt; } else if (!strnicmp (line, "RPZ", 3)) { sscanf(line + 3, "%lf", &flt); RemainingPIPA.Z = flt; } else if (!strnicmp (line, "GMX", 3)) { sscanf(line + 3, "%lf", &flt); Gimbal.X = flt; } else if (!strnicmp (line, "GMY", 3)) { sscanf(line + 3, "%lf", &flt); Gimbal.Y = flt; } else if (!strnicmp (line, "GMZ", 3)) { sscanf(line + 3, "%lf", &flt); Gimbal.Z = flt; } else if (!strnicmp (line, "OAX", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.Attitude.X = flt; } else if (!strnicmp (line, "OAY", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.Attitude.Y = flt; } else if (!strnicmp (line, "OAZ", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.Attitude.Z = flt; } else if (!strnicmp (line, "LAX", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.LastAttitude.X = flt; } else if (!strnicmp (line, "LAY", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.LastAttitude.Y = flt; } else if (!strnicmp (line, "LAZ", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.LastAttitude.Z = flt; } else if (!strnicmp(line, "WLX", 3)) { sscanf(line + 3, "%lf", &flt); LastWeightAcceleration.x = flt; } else if (!strnicmp(line, "WLY", 3)) { sscanf(line + 3, "%lf", &flt); LastWeightAcceleration.y = flt; } else if (!strnicmp(line, "WLZ", 3)) { sscanf(line + 3, "%lf", &flt); LastWeightAcceleration.z = flt; } else if (!strnicmp (line, "VLX", 3)) { sscanf(line + 3, "%lf", &flt); LastGlobalVel.x = flt; } else if (!strnicmp (line, "VLY", 3)) { sscanf(line + 3, "%lf", &flt); LastGlobalVel.y = flt; } else if (!strnicmp (line, "VLZ", 3)) { sscanf(line + 3, "%lf", &flt); LastGlobalVel.z = flt; } else if (!strnicmp (line, "M11", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m11 = flt; } else if (!strnicmp (line, "M12", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m12 = flt; } else if (!strnicmp (line, "M13", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m13 = flt; } else if (!strnicmp (line, "M21", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m21 = flt; } else if (!strnicmp (line, "M22", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m22 = flt; } else if (!strnicmp (line, "M23", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m23 = flt; } else if (!strnicmp (line, "M31", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m31 = flt; } else if (!strnicmp (line, "M32", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m32 = flt; } else if (!strnicmp (line, "M33", 3)) { sscanf(line + 3, "%lf", &flt); Orbiter.AttitudeReference.m33 = flt; } else if (!strnicmp (line, "LTM", 3)) { sscanf(line + 3, "%lf", &flt); LastTime = flt; } else if (!strnicmp (line, "STATE", 5)) { IMUState state; sscanf (line+5, "%d", &state.word); Operate = (state.u.Operate != 0); Initialized = (state.u.Initialized != 0); TurnedOn = (state.u.TurnedOn != 0); Caged = (state.u.Caged != 0); } } }
void H_system::Load(FILEHANDLE scn) { ship_object *runner; runner=List.next; char *line; char string1[100]; vector3 pos; double volume, temp, pmax, pmin, flowmax, throttle, ratio, length; int one, two, three, four; float size1, size2, size3, size4; oapiReadScenario_nextline (scn, line); while (strnicmp(line, "</HYDRAULIC>", 12)) { if (!strnicmp (line, "<TANK>", 6)) { sscanf(line + 6, "%s %lf %i %i %i %i %f %f %f %f", string1, &volume, &one, &two, &three, &four, &size1, &size2, &size3, &size4); h_Tank *tank = (h_Tank*) GetSystemByName(string1); if (tank) { tank->Load(scn); tank->space.Volume = volume; tank->IN_valve.open = one; tank->OUT_valve.open = two; tank->OUT2_valve.open = three; tank->LEAK_valve.open = four; tank->IN_valve.size = size1; tank->OUT_valve.size = size2; tank->OUT2_valve.size = size3; tank->LEAK_valve.size = size4; } } else if (!strnicmp (line, "<RADIATOR>", 10)) { sscanf(line + 10, "%s %lf %lf", string1, &temp, &length); h_Radiator *rad = (h_Radiator*) GetSystemByName(string1); if (rad) { rad->SetTemp(temp); rad->rad = length; } } else if (!strnicmp (line, "<CREW>", 6)) { sscanf(line + 6, "%s %i", string1, &one); h_crew *crew = (h_crew*) GetSystemByName(string1); if (crew) { crew->number = one; } } else if (!strnicmp (line, "<PIPE>", 6)) { sscanf(line + 6, "%s %lf %lf %lf", string1, &pmax, &pmin, &flowmax); h_Pipe *pipe = (h_Pipe*) GetSystemByName(string1); if (pipe) { pipe->P_max = pmax; pipe->P_min = pmin; pipe->flowMax = flowmax; } } else if (!strnicmp (line, "<EVAPORATOR>", 12)) { sscanf(line + 12, "%s %i %i %lf", string1, &one, &two, &throttle); h_Evaporator *evap = (h_Evaporator*) GetSystemByName(string1); if (evap) { evap->h_pump = one; evap->h_valve = two; evap->throttle = throttle; } } else if (!strnicmp (line, "<HEATEXCHANGER>", 15)) { sscanf(line + 15, "%s %i %lf %lf %lf %i", string1, &one, &pmin, &pmax, &length, &two); h_HeatExchanger *heatEx = (h_HeatExchanger*) GetSystemByName(string1); if (heatEx) { heatEx->h_pump = one; heatEx->tempMin = pmin; heatEx->tempMax = pmax; heatEx->length = length; heatEx->bypassed = (two != 0); } } else if (!strnicmp (line, "<MIXINGPIPE>", 12)) { sscanf(line + 12, "%s %i %lf", string1, &one, &ratio); h_MixingPipe *mixer = (h_MixingPipe*) GetSystemByName(string1); if (mixer) { mixer->h_pump = one; mixer->ratio = ratio; } } oapiReadScenario_nextline (scn, line); } }