from firebase_admin import db
import datetime

TABLE_VEHICLES_CONST = ""

#as of now, we are operating only on 1 vehicle
#so this is the id of the object we are working on
GAADI_CONST = ""

def connect():
    print("trying to connect to table vehicles\n")
    vehicles = db.reference(TABLE_VEHICLES_CONST)
    if vehicles:
        print("table vehicles connected successfully\n")
    return vehicles

def updating_gps(vehicles, gaadi, latitude, longitude):
    vehicle_child = vehicles.child(gaadi)
    current_latitude = vehicle_child.get()["latitude"]
    current_longitude = vehicle_child.get()["longitude"]

    if(abs(current_latitude - latitude) > 10 or abs(current_longitude - longitude) > 10):
        vehicle_child.update({
            "latitude": latitude,
            "longitude": longitude
        })
        print("updated gps at ", datetime.datetime.now())
        
        if(vehicle_child.get()["status"].lower() == "alert"):
            print("send photo")

def get_gps(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        """
        updating_gps(vehicles, GAADI_CONST, latitude, longitude)

def updating_rfid(vehicles, gaadi, rfid_status):
    vehicle_child = vehicles.child(gaadi)
    vehicle_child.update({
        "rfid": rfid_status
    })
    print("updated rfid at ", datetime.datetime.now())

def get_rfid(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        put an if statement, that if the rfid is detected,
        then only call updating_rfid
        """
        updating_rfid(vehicles, GAADI_CONST, rfid_status)

def printing(vehicles):
    print(vehicles.get())
4ffd54ee6d9dc96c6724b99644fc9ae1466543cd
<mask token>


def get_gps(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        """
        updating_gps(vehicles, GAADI_CONST, latitude, longitude)


<mask token>

<mask token>


def connect():
    print('trying to connect to table vehicles\n')
    vehicles = db.reference(TABLE_VEHICLES_CONST)
    if vehicles:
        print('table vehicles connected successfully\n')
    return vehicles


def updating_gps(vehicles, gaadi, latitude, longitude):
    vehicle_child = vehicles.child(gaadi)
    current_latitude = vehicle_child.get()['latitude']
    current_longitude = vehicle_child.get()['longitude']
    if abs(current_latitude - latitude) > 10 or abs(current_longitude -
        longitude) > 10:
        vehicle_child.update({'latitude': latitude, 'longitude': longitude})
        print('updated gps at ', datetime.datetime.now())
        if vehicle_child.get()['status'].lower() == 'alert':
            print('send photo')


def get_gps(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        """
        updating_gps(vehicles, GAADI_CONST, latitude, longitude)


<mask token>

<mask token>


def connect():
    print('trying to connect to table vehicles\n')
    vehicles = db.reference(TABLE_VEHICLES_CONST)
    if vehicles:
        print('table vehicles connected successfully\n')
    return vehicles


def updating_gps(vehicles, gaadi, latitude, longitude):
    vehicle_child = vehicles.child(gaadi)
    current_latitude = vehicle_child.get()['latitude']
    current_longitude = vehicle_child.get()['longitude']
    if abs(current_latitude - latitude) > 10 or abs(current_longitude -
        longitude) > 10:
        vehicle_child.update({'latitude': latitude, 'longitude': longitude})
        print('updated gps at ', datetime.datetime.now())
        if vehicle_child.get()['status'].lower() == 'alert':
            print('send photo')


def get_gps(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        """
        updating_gps(vehicles, GAADI_CONST, latitude, longitude)


def updating_rfid(vehicles, gaadi, rfid_status):
    vehicle_child = vehicles.child(gaadi)
    vehicle_child.update({'rfid': rfid_status})
    print('updated rfid at ', datetime.datetime.now())


def get_rfid(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        put an if statement, that if the rfid is detected,
        then only call updating_rfid
        """
        updating_rfid(vehicles, GAADI_CONST, rfid_status)


def printing(vehicles):
    print(vehicles.get())

<mask token>
TABLE_VEHICLES_CONST = ''
GAADI_CONST = ''


def connect():
    print('trying to connect to table vehicles\n')
    vehicles = db.reference(TABLE_VEHICLES_CONST)
    if vehicles:
        print('table vehicles connected successfully\n')
    return vehicles


def updating_gps(vehicles, gaadi, latitude, longitude):
    vehicle_child = vehicles.child(gaadi)
    current_latitude = vehicle_child.get()['latitude']
    current_longitude = vehicle_child.get()['longitude']
    if abs(current_latitude - latitude) > 10 or abs(current_longitude -
        longitude) > 10:
        vehicle_child.update({'latitude': latitude, 'longitude': longitude})
        print('updated gps at ', datetime.datetime.now())
        if vehicle_child.get()['status'].lower() == 'alert':
            print('send photo')


def get_gps(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        """
        updating_gps(vehicles, GAADI_CONST, latitude, longitude)


def updating_rfid(vehicles, gaadi, rfid_status):
    vehicle_child = vehicles.child(gaadi)
    vehicle_child.update({'rfid': rfid_status})
    print('updated rfid at ', datetime.datetime.now())


def get_rfid(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        put an if statement, that if the rfid is detected,
        then only call updating_rfid
        """
        updating_rfid(vehicles, GAADI_CONST, rfid_status)


def printing(vehicles):
    print(vehicles.get())

from firebase_admin import db
import datetime

TABLE_VEHICLES_CONST = ""

#as of now, we are operating only on 1 vehicle
#so this is the id of the object we are working on
GAADI_CONST = ""

def connect():
    print("trying to connect to table vehicles\n")
    vehicles = db.reference(TABLE_VEHICLES_CONST)
    if vehicles:
        print("table vehicles connected successfully\n")
    return vehicles

def updating_gps(vehicles, gaadi, latitude, longitude):
    vehicle_child = vehicles.child(gaadi)
    current_latitude = vehicle_child.get()["latitude"]
    current_longitude = vehicle_child.get()["longitude"]

    if(abs(current_latitude - latitude) > 10 or abs(current_longitude - longitude) > 10):
        vehicle_child.update({
            "latitude": latitude,
            "longitude": longitude
        })
        print("updated gps at ", datetime.datetime.now())
        
        if(vehicle_child.get()["status"].lower() == "alert"):
            print("send photo")

def get_gps(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        """
        updating_gps(vehicles, GAADI_CONST, latitude, longitude)

def updating_rfid(vehicles, gaadi, rfid_status):
    vehicle_child = vehicles.child(gaadi)
    vehicle_child.update({
        "rfid": rfid_status
    })
    print("updated rfid at ", datetime.datetime.now())

def get_rfid(vehicles):
    while True:
        """
        fill this function with your code to get gps coordinates
        vehicles is the json file consiting the gaadi details
        put an if statement, that if the rfid is detected,
        then only call updating_rfid
        """
        updating_rfid(vehicles, GAADI_CONST, rfid_status)

def printing(vehicles):
    print(vehicles.get())