Beispiel #1
0
def main():
    rpc.set_name("rpcsender")
   
    #context = gpsbt.start()
    # ensure that GPS device is ready to connect and to receive commands
    time.sleep(2)
    #gpsdevice = gpsbt.gps()

    start_lon = 15.5775752
    start_lat = 58.4065800
    rad = 0.003
    angle_step = 0.1
    angle = 0
    rad2 = 0.005
    angle_step2 = 0.04
    angle2 = 0
    
    while True:
        '''
        #read 3 times and show information
        for a in range(4):
            gpsdevice.get_fix()
            time.sleep(15)
        while gpsdevice.get_position() == (0,0):
            time.sleep(1)  
        lat,lon = gpsdevice.get_position()
        print lon
        print lat
        '''
        lon = start_lon + 2*rad*math.sin(angle)
        lon = lon + 2*rad2*math.sin(angle2)
        print "lon:",lon
        lat = start_lat + rad*math.cos(angle)
        lat = lat + rad2*math.cos(angle2)
        print "lat:",lat
        angle = angle + angle_step
        if angle > 2*math.pi:
            angle - 2*math.pi
        angle2 = angle2 + angle_step2
        if angle2 > 2*math.pi:
            angle2 - 2*math.pi
        time.sleep(1)
        session = get_session()
        for units in session.query(Unit).filter(Unit.is_self==True):
            print "Skickar koordinater", time.time()
            rpc.send("main", "ping_with_coordinates", lon=lon, lat=lat)
            #gobject.timeout_add(0, rpc.send, "main", "ping_with_coordinates", {"lon":lon, "lat":lat})

            print "Klar med skickar koordinater", time.time()
Beispiel #2
0
def main():
    rpc.set_name("rpcsender")
    context = gpsbt.start()
    # ensure that GPS device is ready to connect and to receive commands
    time.sleep(2)
    gpsdevice = gpsbt.gps()
    while True:
        # read 3 times and show information
        for a in range(4):
            gpsdevice.get_fix()
            time.sleep(15)
        while gpsdevice.get_position() == (0,0):
            time.sleep(1)  
        lon, lat = gpsdevice.get_position()
        print rpc.send("main", "ping_with_coordinates", lon=lon, lat=lat)
    #stop gps devices
    gpsbt.stop(context)
Beispiel #3
0
import time
import sys
import os
import gui
import data_storage
import map_xml_reader
from shared import data, rpc
#from shared import data
from shared.data import get_session, create_tables
from shared.data.defs import *
import logging
if sys.version_info[1] == 3:
    print "nu glömde du skriva python2.5... trooooooliiiigt"
    sys.exit(0)

rpc.set_name("main")

# Kartan
mapxml = map_xml_reader.MapXML("static/kartdata/map.xml")

map = data_storage.MapData(mapxml.get_name(),
                           mapxml.get_levels())
map.set_focus(15.5726, 58.4035)
session = get_session()
create_tables()
units = session.query(Unit).all()
types = session.query(UnitType).all()
if "exempeldata" in sys.argv and len(types) == 0:
    #Om du behöver fylla på databasen igen gör dessa nedanför
    #skapar olika unittypes
    a=UnitType(u"Ambulans1", "static/ikoner/ambulans.png")
Beispiel #4
0
import threading
import gtk
import time
from shared import rpc, buffrify
from shared.packet import Packet
from simplejson import loads, dumps
import subprocess
from shared.data import get_session, create_tables
from shared.data.defs import *
from shared.settings import HOST_IP, HOST_PORT
import logging
import gobject

#subprocess.call('ssh -f [email protected] -L 2345:127.0.0.1:2345 -N sleep 1', shell=True)

rpc.set_name("qos")
 
if "--no-connect" in sys.argv:
    no_connect = True
 
network_listeners = {}
 
def read_keys():
    global connection
    while connection.connected:
        input = raw_input()
        connection.out_queue.put(Packet("chat",
            message=input))
 
 
class Connection(object):