Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import weDoCalls
- import time
- print "hello manager"
- weDo=weDoCalls.WeDoTalk()
- print "weDo connection"
- argBuffer=sys.stdin.readline()
- tokenList=[]
- tokenList=argBuffer.rsplit(",")
- tokenList.pop(len(tokenList)-1)
- print tokenList
- i=0
- while tokenList[i] is not None :#i < (len(tokenList)-1)
- print "manager->"+tokenList[i]
- if tokenList[i].strip() == "MON":
- weDo.SetMotors(tokenList[i+1].strip())
- j=i+1
- elif tokenList[i].strip() == "FORWARD":
- weDo.Forward(tokenList[i+1].strip())
- j=i+1
- elif tokenList[i].strip() == "BACKWARD":
- weDo.Backward(tokenList[i+1].strip())
- j=i+1
- elif tokenList[i].strip() == "MOF":
- weDo.SetMotors(0)
- j=i+1
- elif tokenList[i].strip() == "TURN RIGHT":
- weDo.TurnRight(tokenList[i+1].strip())
- j=i+1
- elif tokenList[i].strip() == "TURN LEFT":
- weDo.TurnLeft(tokenList[i+1].strip())
- j=i+1
- elif tokenList[i].strip() == "BEEP":
- weDo.Beep()
- j=i
- elif tokenList[i].strip() == "SING":
- weDo.Sing()
- j=i
- elif tokenList[i].strip() == "SHAKE":
- weDo.Shake()
- j=i
- elif tokenList[i].strip() == "SPIN":
- weDo.Spin()
- j=i
- elif tokenList[i].strip() == "WAIT":
- weDo.Wait(tokenList[i+1].strip())
- j=i+1
- elif tokenList[i].strip() == "REP":
- j=i+2
- str=tokenList[i+1].strip()
- #while j<len(tokenList):
- while tokenList[j] != "ENDREPBLOCK":
- str=str+","
- str=str+tokenList[j].strip()
- j= j+1
- # while tokenList[j] != "ENDREP":
- # str=str+","
- # str=str+tokenList[j].strip()
- # j= j+1
- # str=str+","
- ## str=str+tokenList[j].strip()
- weDo.Repeat(str)
- elif tokenList[i].strip() == "IF":
- j=i+2
- str=tokenList[i+1].strip()
- #while j<len(tokenList):
- while tokenList[j] != "ENDIFBLOCK":
- str=str+","
- str=str+tokenList[j].strip()
- j= j+1
- # while tokenList[j] != "ENDIF":
- # str=str+","
- # str=str+tokenList[j].strip()
- # j= j+1
- # str=str+","
- # str=str+tokenList[j].strip()
- # if j< (len(tokenList)-1):
- # if (tokenList[j+1] == "ELSE"):
- # j=j+1
- # while tokenList[j] != "END-ELSE":
- # str=str+","
- # str=str+tokenList[j].strip()
- # j= j+1
- # str=str+","
- # str=str+tokenList[j].strip()
- # print "from manager " + str
- weDo.If(str)
- i=j+1
- time.sleep(0.2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement