Skip to content

Commit

Permalink
simulator: add command pause
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Sep 29, 2024
1 parent 7483fa8 commit 13b39eb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions simulator/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void Simulator::onCommand(QStringList tokens)
"RIGHT Rotate right\n"
"ANGLE deg Rotate at angle of deg\n"
"MOVE [dm] Move forward dm or 0 (meters)\n"
"PAUSE [sec] Pause for a tick or duration (1..59 seconds)\n"
"LOAD gpx Load the GPX file\n"
"LIST List all tracks contained in the loaded file\n"
"RUN trkid [speed [pts]] Run the identified track of the loaded file\n"
Expand Down Expand Up @@ -166,6 +167,19 @@ void Simulator::onCommand(QStringList tokens)
&lat, &lon);
_position.resetData(lat, lon, coord.altitude());
}
else if (token.compare("PAUSE", Qt::CaseInsensitive) == 0)
{
if (tokens.isEmpty())
QThread::msleep(_positionSource->updateInterval());
else
{
int sec = tokens.front().toInt();
if (sec > 0 && sec < 60)
QThread::sleep(sec);
else
fprintf(stdout, "Invalid duration specified. A valid range is 1 to 59\n");
}
}
else if (token.compare("LOAD", Qt::CaseInsensitive) == 0 && !tokens.isEmpty())
{
token = tokens.front();
Expand Down

0 comments on commit 13b39eb

Please sign in to comment.