Skip to content

Commit

Permalink
Fix a few details.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoconni committed Dec 30, 2024
1 parent 7d38dc6 commit e0081b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
21 changes: 5 additions & 16 deletions scripts/c172_cruise_8K.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<use aircraft="c172x" initialize="reset01"/>

<run start="0.0" end="50" dt="0.0083333">

<property value="0" persistent="true"> simulation/run_id </property>

<event name="Set Temperature">
Expand All @@ -26,17 +26,17 @@
</set>
<set name="ap/altitude_setpoint" value="4000.0"/>
</event>

<event name="Start engine">
<condition>
simulation/sim-time-sec ge 0.01
</condition>
<set name="fcs/throttle-cmd-norm" action="FG_RAMP" value="0.50" tc="0.05"/>
<set name="fcs/mixture-cmd-norm" action="FG_RAMP" value="1.0" tc="0.05"/>
<set name="fcs/mixture-cmd-norm" action="FG_RAMP" value="1.0" tc="0.05"/>
<set name="propulsion/magneto_cmd" value="3"/>
<set name="propulsion/starter_cmd" value="1"/>
<notify/>
</event>
</event>

<event name="Trim">
<condition>
Expand Down Expand Up @@ -103,7 +103,7 @@
<event name="Reset">
<condition logic="AND">
simulation/sim-time-sec >= 30.0
simulation/terminate != 1
simulation/run_id lt 2
</condition>
<set name="ap/heading_setpoint" value="0"/>
<!-- <set name="ap/altitude_setpoint" value="0"/> -->
Expand All @@ -115,16 +115,5 @@
<property> simulation/run_id </property>
</notify>
</event>

<event name="Terminate on run ID">
<condition>
simulation/run_id ge 3
</condition>
<set name="simulation/terminate" value="1"/>
<notify>
<property caption="Terminate: "> simulation/terminate </property>
</notify>
</event>

</run>
</runscript>
12 changes: 6 additions & 6 deletions src/JSBSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ int real_main(int argc, char* argv[])
FDMExec->GetPropertyManager()->Tie("simulation/frame_start_time", &actual_elapsed_time);
FDMExec->GetPropertyManager()->Tie("simulation/cycle_duration", &cycle_duration);

Timer timer;
auto timer = new Timer;
SGPropertyNode_ptr reset_node = FDMExec->GetPropertyManager()->GetNode("simulation/reset");
reset_node->addChangeListener(&timer);
reset_node->addChangeListener(timer);

// Check whether to disable console highlighting output on Windows.
// Support was added to Windows for Virtual Terminal codes by a particular
Expand Down Expand Up @@ -576,7 +576,7 @@ int real_main(int argc, char* argv[])
else sleep_nseconds = (sleep_period )*1e9; // 0.01 seconds

tzset();
timer.start();
timer->start();

// *** CYCLIC EXECUTION LOOP, AND MESSAGE READING *** //
while (result && FDMExec->GetSimTime() <= end_time) {
Expand All @@ -596,8 +596,8 @@ int real_main(int argc, char* argv[])
if (play_nice) sim_nsleep(sleep_nseconds);

} else { // ------------ RUNNING IN REALTIME MODE
timer.pause(false);
actual_elapsed_time = timer.getElapsedTime();
timer->pause(false);
actual_elapsed_time = timer->getElapsedTime();

double sim_lag_time = actual_elapsed_time - FDMExec->GetSimTime(); // How far behind sim-time is from actual elapsed time.
double cycle_start = getcurrentseconds();
Expand All @@ -617,7 +617,7 @@ int real_main(int argc, char* argv[])
}
}
} else { // Suspended
timer.pause(true);
timer->pause(true);
sim_nsleep(sleep_nseconds);
result = FDMExec->Run();
}
Expand Down

0 comments on commit e0081b3

Please sign in to comment.