示例#1
0
    def run(self):
        global navi
        global skip_init
        global isNextPathNeeded
        global nextPathSema
        global data
        global newLevelReached

        initialResponseIsLow = True
        while 1:
##            if isNextPathNeeded:
##                print self.threadName, "blocking"
##                nextPathSema.acquire()

            locationTrackerLock.acquire()
            curX = locationTracker.getXCoord()
            curY = locationTracker.getYCoord()
            heading = locationTracker.getHeadingInDeg()
            locationTrackerLock.release()
            navi.updateCurLocation(curX, curY, heading)
            isNavigationDone = navi.fullNavigate()

            # push button for switching to next node

            response = keypad.get_binary_response_timed(initialResponseIsLow, 0.1)
            initialResponseIsLow = response[1]
            if response[0]:
                navi.reroutePath()

            if isNavigationDone is True :
                print ("\n\n\n\n\nLE SWITCHEROO\n\n\n\n")
                if navi.hasNextPath() is True :
                    isNextPathNeeded = True
                    # userInputLock.acquire()
                    
                    print "press start to continue"
                    UISpeaker.speak("Now entering new map. Press start to continue.")
                    while keypad.get_binary_response():
                        pass

                    # print "data in serial / data before flush:", dataFeeder.serialPort.inWaiting(), len(data[2]), len(data[3])

                    # data = [deque() for x in range(NUM_QUEUED_ID)]
                    # data_single = [0 for x in range(NUM_SINGLE_ID)]
                    # data.extend(data_single)

                    # dataFeeder.serialPort.flushInput()
                    # dataFeeder.serialPort.flushOutput()

                    # print "data in serial / data after flush:", dataFeeder.serialPort.inWaiting(), len(data[2]), len(data[3])

                    navi.switchToNextPathList()

                    # update location tracker initial heading/coordinates
                    locationTracker.updateMapNorth(navi.getNorthDifference())
                    (initX, initY) = navi.getFirstCoordinates()
                    locationTracker.setLocation(initX, initY)
                    newLevelReached = navi.isDifferentLevel()

                    isNextPathNeeded = False

                    # turn on location tracker and receive data threads
                    # userInputLock.release()

                    # for thread in mainThreads:
                    #     if thread.threadID != 6 and thread.threadID != 5:
                    #         nextPathSema.release()
                else :
                    return
            time.sleep(3)
示例#2
0
newLevelReached = False

UIThreads = []

if not skip_init:
    # UI threads
    UIThreads.append(UIThread(-2, "Run UI"))

    for thread in UIThreads:
       thread.start()

    for thread in UIThreads:
       thread.join()

if not skip_init:
    locationTracker.setLocation(startLocation.getLocationXCoord(), startLocation.getLocationYCoord())
else:
    locationTracker.setLocation(11815, 406)

# Navigation initialization
naviCount = 0
navi = fullNavi.fullNavi(voiceQueue, voiceSema)
# navi.generateFullPath(startBuilding, startLevel, start, endBuilding, endLevel, end)
# navi.generateFullPath("com1", 2, 1, "com1", 2, 10)

if skip_init:
    navi.generateFullPath("com1", 2, 31, "com2", 2, 17)
else:
    navi.generateFullPath(startLocation.getBuildingName(),
        startLocation.getLevelNumber(),
        startLocation.getLocationPointIndex(),