コード例 #1
0
    def __init__(self):
        from actuators.SSD1306 import SSD1306

        self.rfm96w = Pilix_RFM96W(sender=False)
        self.udp = UDP()
        self.__lock = threading.Lock()
        self.display_pilix = Display1306(address=SSD1306.I2C_BASE_ADDRESS,
                                         lock=self.__lock)
        self.display_local = Display1306(address=SSD1306.I2C_SECONDARY_ADDRESS,
                                         lock=self.__lock)

        self.display_local.print(datetime.now().strftime("%Y%m%d %H:%M:%S"),
                                 "RFM96 initialized", f"IP: {MyIP()}")
        self.display_local_thread = self.LocalData(self.display_local,
                                                   self.__lock)
        self.display_local_thread.start()

        self.shutdown = self.Shutdown()
        self.shutdown.start()

        from gps3.agps3threaded import AGPS3mechanism
        self.gps = AGPS3mechanism()
        self.gps.stream_data()
        self.gps.run_thread()

        self._running = True
コード例 #2
0
 def __init__(self):
     self.agps_thread = AGPS3mechanism()  # Instantiate AGPS3 Mechanisms
     self.agps_thread.stream_data(
     )  # From localhost (), or other hosts, by example, (host='gps.ddns.net')
     self.agps_thread.run_thread(
     )  # Throttle time to sleep after an empty lookup, default 0.2 second, default daemon=True
     self.mytimezone = pytz.timezone("Asia/Singapore")
コード例 #3
0
    def __init__(self, drone_state_dict, pipe):
        self.pipe = pipe
        self.drone = ps_drone.Drone()
        self.modem = ec25_modem.Modem("/dev/ttyUSB2")
        self.gps = AGPS3mechanism()

        self.control_state = ControlState()
        self.drone_state = DroneState()
        self.drone_state_dict = drone_state_dict
        self.prev_data_count = 0
        self.app_connected = False
        self.app_disconnected_timer = None
        self.drone_connected = False
        self.drone_calibrated = False
        self.returning = False
        self.modem_connected = False
        self.gps_l80 = True
        self.autonomous_sigs = None

        self.running = True

        i = 0
        while os.path.exists(os.path.expanduser("~/dronelog/log_%s.csv") % i):
            i += 1
        self.logfile = open(
            os.path.expanduser("~/dronelog/log_%s.csv") % i, "w")
        self.logwriter = csv.writer(self.logfile)
コード例 #4
0
 def __init__(self):
     # Instantiate AGPS3 Mechanisms
     self.gps3_thread = AGPS3mechanism()
     # From localhost (), or other hosts, by example, (host='gps.ddns.net')
     self.gps3_thread.stream_data()
     # Used for debugging purposes
     fake_location = glider_config.get("gps", "fake_location")
     if fake_location and os.path.exists(fake_location):
         LOG.warning("Using fake data file! %s" % fake_location)
         self.fake_location_file = fake_location
コード例 #5
0
    def __init__(self, hass, name, host, port):
        """Initialize the GPSD sensor."""
        self.hass = hass
        self._name = name
        self._host = host
        self._port = port

        self.agps_thread = AGPS3mechanism()
        self.agps_thread.stream_data(host=self._host, port=self._port)
        self.agps_thread.run_thread()
コード例 #6
0
    def __init__(self, gpsEngine):
        super(GPSThread, self).__init__()
        self.signalStop = False
        self.threadRunning = False
        self.mainEngine = gpsEngine

        self.agps_thread = AGPS3mechanism()  # Instantiate AGPS3 Mechanisms
        self.agps_thread.stream_data()  # From localhost (), or other hosts, by example, (host='gps.ddns.net')
        self.agps_thread.run_thread()  # Throttle time to sleep after an empty lookup, default '()' 0.2 two tenths of a second
        self.daemon = True
コード例 #7
0
ファイル: GPSMouse.py プロジェクト: jwmarcus/packetpi
    def __init__(self, port='/dev/ttyUSB0'):
        # Kill everything that might be using gpsd
        os.system("killall gpsd")
        time.sleep(1)
        os.system("gpsd {}".format(port))
        time.sleep(1)

        # The socket takes care of HW interaction, we read from the stream
        self.agps_thread = AGPS3mechanism()
        self.agps_thread.stream_data()
        self.agps_thread.run_thread()
コード例 #8
0
    def start(self):
        self.init_database()

        self.obd = obd.Async(self.port)

        for command in OBD_COMMANDS:
            self.obd.watch(command)

        self.loop = asyncio.get_event_loop()

        self.agps_thread = AGPS3mechanism()
        self.agps_thread.stream_data(host='localhost', port=2947)
        self.agps_thread.run_thread()

        self.obd.start()
        self.loop.call_soon(self.handle_interval)
        self.loop.run_forever()
コード例 #9
0
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        Style.insert_logo(self)

        self.serial_conn = False
        self.drone = Drone()

        # agps thread
        self.agps_thread = AGPS3mechanism()
        self.agps_thread.stream_data()
        self.agps_thread.run_thread()

        # Valores de los sensores
        self.temperatura = tk.StringVar()
        self.ph = tk.StringVar()
        self.oxigeno = tk.StringVar()
        self.conductividad = tk.StringVar()

        self.latitud = tk.StringVar()
        self.longitud = tk.StringVar()

        self.velocidad = tk.StringVar()
        self.nivel = tk.StringVar()
        self.bomba = tk.StringVar()

        self.nivel.set('0 ml')
        self.nivel_totalizado = 0.0
        self.time_start_pump = 0.0

        if self.drone.bomba:
            self.bomba.set('Encendida')
        else:
            self.bomba.set('Apagada')

        # Secciones de la aplicación
        self.seccion_sensores()
        self.seccion_gps()
        self.seccion_controles()
        self.seccion_bomba()
        self.seccion_camara()
コード例 #10
0
    def __init__(self, real):
        "listen to gps data and emit some if anything new arrives"
        super(Gps, self).__init__()

        self.test = not real

        # self.gps_socket = gps3.GPSDSocket()
        # self.data_stream = gps3.DataStream()
        # self.gps_socket.connect()
        # self.gps_socket.watch()
        self.agps_thread = AGPS3mechanism()  # Instantiate AGPS3 Mechanisms
        self.agps_thread.stream_data(
        )  # From localhost (), or other hosts, by example, (host='gps.ddns.net')

        self.newData = signal('Gps')
        self.Doit = True
        self.init = True

        self.dummyLat = 43.168583333
        self.dummyLon = 1.191853333
        print("GPS init done")
コード例 #11
0
    def initializeSensors(self):
        # Instantiate GPS data retrieval mechanism
        try:
            self.agps_thread = AGPS3mechanism()
            self.agps_thread.stream_data()
            self.agps_thread.run_thread()
        except:
            print("Failed initializing GPS")
            pass

        self.sense = None
        self.pressureSensor = None
        try:
            self.sense = SenseHat()
        except:
            print("Failed initializing Sense Hat")
            pass

        try:
            self.pressureSensor = BMP280.BMP280()
        except:
            print("Failed initializing Pressure Sensor")
            pass
コード例 #12
0
ファイル: PidShowDialog.py プロジェクト: alferbus/TFGv3
 def start_gps(self):
     """GPS FIX"""
     #R-pi GPSD needs to be disabled as well:
     os.system('sudo systemctl stop gpsd.socket')
     os.system('sudo systemctl disable gpsd.socket')
     #Check if the fix is ready:
     #TODO: MENSAJE: espere al fix del GPS. Quitar boton de comenzar y dejar sólo el
     #de ir atrás
     try:
         self.agps_thread = AGPS3mechanism()  # Instantiate AGPS3 Mechanisms
         self.agps_thread.stream_data(
         )  # From localhost (), or other hosts, by example, (host='gps.ddns.net')
         self.agps_thread.run_thread(
         )  # Throttle time to sleep after an empty lookup, default '()' 0.2 two tenths of a second
     except (OSError, IOError):
         mb = QtGui.QMessageBox(u'Advertencia',
                                u'Compruebe la conexión del GPS',
                                QtGui.QMessageBox.Warning,
                                QtGui.QMessageBox.Ok, 0, 0)
         mb.setWindowFlags(QtCore.Qt.FramelessWindowHint)
         mb.setAttribute(QtCore.Qt.WA_DeleteOnClose,
                         True)  # delete dialog on close
         mb.exec_()  #prevent focus loss
         raise SystemExit  #No gps device found -- QUIT
コード例 #13
0
    total_satellites = 0
    used_satellites = 0

    if not isinstance(feed, list):
        return 0, 0

    for satellites in feed:
        total_satellites += 1
        if satellites['used'] is True:
            used_satellites += 1
    return total_satellites, used_satellites


try:
    # Process the raw GPS info in a background thread
    gps3_thread = AGPS3mechanism()
    gps3_thread.stream_data()
    gps3_thread.run_thread()

    while True:
        curtime = datetime.now().second
        now = datetime.now().strftime('%H:%M')

        if curtime == 10:
            with canvas(virtual) as draw:
                show_message(device,
                             "GPS: Using " + str(
                                 satellites_used(
                                     gps3_thread.data_stream.satellites)[1]) +
                             " of " + str(
                                 satellites_used(
コード例 #14
0
ファイル: Pilix.py プロジェクト: thomaspfeiffer-git/raspberry

def shutdown_application():
    """cleanup stuff"""
    Log("Stopping application")
    stop_threads()
    Log("Application stopped")
    sys.exit(0)


###############################################################################
## main #######################################################################
if __name__ == "__main__":
    shutdown_application = Shutdown(shutdown_func=shutdown_application)

    gps = AGPS3mechanism()
    gps.stream_data()
    gps.run_thread()

    display = Display1306()

    livetracking_udp = Livetracking.Sender_UDP()
    livetracking_udp.start()
    livetracking_lora = Livetracking.Sender_LoRa()
    livetracking_lora.start()

    control = Control()
    control.start()

    camera = Camera()
    camera.start()
コード例 #15
0
# -*- coding: utf-8 -*-
from gps3.agps3threaded import AGPS3mechanism
import time
import os
from measurement.measures import Distance



agps_thread = AGPS3mechanism()
agps_thread.stream_data()
agps_thread.run_thread()



while 1:
	callsign = "DL3KB" #change to your callsign

	time.sleep(10) #change to your prefered interval
	dlat = agps_thread.data_stream.lat
	dlon = agps_thread.data_stream.lon
	
	if dlat == "n/a":
		continue
		
	is_positive = dlat >= 0
	dlat = abs(dlat)
	minuteslat,secondslat = divmod(dlat*3600,60)
	degreeslat,minuteslat = divmod(minuteslat,60)
	degreeslat = degreeslat if is_positive else -degreeslat
	
コード例 #16
0
    formatter = "[%(asctime)s] %(name)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
    logging.basicConfig(level=logging.INFO, format=formatter)
    logging.info("Starting logger")

    #logging.info("Connecting to InfluxDB")
    #influx_client = InfluxDBClient(host='localhost', port=8086, database='skimon')
    #logging.info("Connected to Influx")

    mqtt_client = mqtt.Client("GPS Logger Daemon")
    mqtt_client.on_connect = on_connect
    mqtt_client.enable_logger()

    mqtt_client.connect("localhost")

    agps_thread = AGPS3mechanism()  # Instantiate AGPS3 Mechanisms
    agps_thread.stream_data(
    )  # From localhost (), or other hosts, by example, (host='gps.ddns.net')
    agps_thread.run_thread(
    )  # Throttle time to sleep after an empty lookup, default '()' 0.2 two tenths of a second

    try:

        while True:  # All data is available via instantiated thread data stream attribute.
            # line #140-ff of /usr/local/lib/python3.5/dist-packages/gps3/agps.py
            logging.debug("({0}: {1},{2}) @ {3} m/s to {4} degrees".format(
                agps_thread.data_stream.time, agps_thread.data_stream.lat,
                agps_thread.data_stream.lon, agps_thread.data_stream.speed,
                agps_thread.data_stream.track))
            #print('---------------------')
            #print(                   agps_thread.data_stream.time)
コード例 #17
0
from pymongo import MongoClient
from bmp280 import BMP280
import time

from gps3.agps3threaded import AGPS3mechanism

agps_thread = AGPS3mechanism(
)  # This instantiate the mechanism, as I believe it's called.
agps_thread.stream_data()  #  Stream the data from host, port, devicepath.
agps_thread.run_thread(
)  #  Iterate stream as a thread with throttle control for empty look ups.

try:
    from smbus2 import SMBus
except ImportError:
    from smbus import SMBus

bus = SMBus(1)
bmp280 = BMP280(i2c_dev=bus)

# Connect to db
client = MongoClient(
    "mongodb+srv://root:[email protected]/test?retryWrites=true&w=majority"
)
db = client.ssar
sensors = db.sensors
while (True):
    temperature = bmp280.get_temperature()
    pressure = bmp280.get_pressure()
    altitude = bmp280.get_altitude()
    gpsLat = agps_thread.data_stream.lat
コード例 #18
0
ファイル: GPS.py プロジェクト: eric-d-rachell/521S
 def __init__(self):
     self.agps_thread = AGPS3mechanism()  # Instantiate AGPS3 Mechanisms
     self.agps_thread.stream_data()  # From localhost (), or other hosts,
     # by example, (host='gps.ddns.net')
     self.agps_thread.run_thread(
     )  # Throttle time to sleep after an empty lookup,
コード例 #19
0
	def __init__(self):
		self.agps_thread = AGPS3mechanism()
		self.agps_thread.stream_data()
		self.agps_thread.run_thread()
コード例 #20
0
GPSSensor.climb = property(
    lambda self: self.data_stream.climb)  # Climb rate in m/s
GPSSensor.epc = property(
    lambda self: self.data_stream.epc)  # Climb error in m/s


# Create functions that will be used as methods of GPSSensor objects
def initialise(self):
    self.stream_data()
    self.run_thread()
    print("GPS set up.")


# Assign functions as methods of GPSSensor
GPSSensor.initialise = initialise

if __name__ == '__main__':

    from time import sleep

    gps1 = GPSSensor()
    gps1.initialise()

    try:
        while gps1.mode != 1 and gps1.mode != 0:
            print(gps1.lat, gps1.lon)
            sleep(1)
    except KeyboardInterrupt:
        print("Exiting...")