![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
First version
Dependencies: mbed EthernetInterface mbed-rto
Diff: Interpreter.cpp
- Revision:
- 18:5ee34e60a31d
- Child:
- 20:fe6a58e84929
diff -r df5bd29cf9a9 -r 5ee34e60a31d Interpreter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Interpreter.cpp Wed Apr 18 13:37:35 2018 +0000 @@ -0,0 +1,34 @@ +#include "Interpreter.h" + +Interpreter::Interpreter(int* LEDinput){ + LED=LEDinput; +} + +void Interpreter::executeCommand(char* command){ + char *ID=strtok(command,","); + char *direction=strtok(NULL," "); + while((ID!=NULL)&&(direction!=NULL)){ + int IDNumber=atoi(ID); + int directionNumber=directionToNumber(direction); + if((IDNumber>=0)&&(IDNumber<=11)&&(directionNumber>=-1)&&(directionNumber<=3)){ + //lock->lock(); + LED[IDNumber]=directionNumber; + //lock->unlock(); + } + ID=strtok(NULL,","); + direction=strtok(NULL," "); + } +} + +int Interpreter::directionToNumber(char* direction){ + if(strcmp(direction,"links")==0) + return 0; + else if(strcmp(direction,"rechts")==0) + return 1; + else if(strcmp(direction,"boven")==0) + return 2; + else if(strcmp(direction,"onder")==0) + return 3; + else + return -1; +} \ No newline at end of file