-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSleepCommand.cpp
More file actions
27 lines (25 loc) · 807 Bytes
/
SleepCommand.cpp
File metadata and controls
27 lines (25 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <unistd.h>
#include "SleepCommand.h"
#include "ExpressionUtils.h"
SleepCommand::SleepCommand(DataCommands *dataCommands, DataVars *dataVars) {
this->dataCommands = dataCommands;
this->dataVars = dataVars;
}
void SleepCommand::doCommand() {
// get the index from dataCommands
unsigned long index = this->dataCommands->getIndex();
// skip the command
index++;
// get the numStr from the vector in dataCommands
string numStr = this->dataCommands->getSeparated().at(index);
// skip the numStr
index++;
ExpressionUtils expUtils;
double num = expUtils.calculateInfixStr(numStr,dataVars->getSymbolTable());
if(num<1000){
num=1000;
}
sleep(num /1000);
// set the new index of dataCommands
this->dataCommands->setIndex(index);
}