def testMore(): s = ServerConnection("localhost", 47757, "2", "CathodioN", "test", "DummyDevice", "OpenMoko") try: print "Available groups are: " groups = s.requestGroups() for x in groups: print "\t%s" %x print "Joining group %s" %(groups[0]) s.joinGroup(groups[0]) print "\tOK" pos = Position(23.4545,45.345345,1234.34,89.63,180) print "Sending my position: " + str(pos) s.sendPosition(pos) print "\tOK" wp = Waypoint(23.234,234.34343,125,"Carpool Parking Space") print "Sending my waypoint: " + str(wp) s.sendWaypoint(wp) print "\tOK" posOthers = s.requestPositions() print "Position of others" for pos in posOthers.keys(): print "\t" + pos + ":" + str(posOthers[pos]) wpOthers = s.requestWaypoints() print "Waypoints of others" for wp in wpOthers.keys(): print "\t" + wp + ":" + str(wpOthers[wp]) except pygls.GLSException.GLSException, e: print "Connection error: " + e.getMsg() + "\n\t" + e.getLongMsg()
def moveAround(loops, delay): print "Starting up" print "\tConnection parameters: %s|%s@%s:%d [group:%s]" %( USER , PASSWORD, SERVER, PORT, GROUP) print "\tDoing %d updates with %d seconds delay in between 2 updates." %(loops, delay) s = ServerConnection(SERVER, PORT, PROTOCOL_VERSION, USER, PASSWORD, DEVICE, GROUP) try: print "\n\tJoining group %s" %(GROUP) s.joinGroup(GROUP) print "\t\tOK" print "my speed: %f" %SPEED deltaX = random.random()* SPEED * 200 - (SPEED*100) deltaY = random.random()* SPEED * 200 - (SPEED*100) pos = Position(52.538643+deltaX,13.421938+deltaY,1234.34,89.63,180) # this way, 2 won't start exactly at the same location :) current = 0 while loops == 0 or current < loops: deltaX = random.random()* SPEED - (SPEED/2) deltaY = random.random()* SPEED - (SPEED/2) print "\tMoving %f / %f." %(deltaX, deltaY) pos = Position(pos.getLatitude()+deltaX,pos.getLongitude()+deltaY,1234.34,89.63,180) print "Sending my position: " + str(pos) s.sendPosition(pos) print "\tOK" current +=1 time.sleep(delay) except pygls.GLSException.GLSException, e: print "Connection error: " + e.getMsg() + "\n\t" + e.getLongMsg()