예제 #1
0
def desplegar_incendios_activos(fecha_actual):

    met_database = leer_db("meteorologia.csv", Meteorologia)
    inc_db = leer_db("incendios.csv", Incendio)
    for inc in inc_db:
        if inc.fecha_inicio < fecha_actual:
            inc.simular(met_database, fecha_actual)
            if inc.activo:
                print(inc)
예제 #2
0
def desplegar_base_incendios(fecha_actual):

    Incendio.fecha_actual = fecha_actual
    base_incendios = leer_db("incendios.csv", Incendio)
    met_database = leer_db("meteorologia.csv", Meteorologia)

    inc_id = str(input("Ingrese el id del incendio: "))

    try:
        incendio = [inc for inc in base_incendios if inc.id == inc_id].pop()
    except IndexError:
        print("Id no valido")
        return False

    if incendio.fecha_inicio < fecha_actual:
        incendio.simular(met_database, fecha_actual)
        print(incendio)
예제 #3
0
def agregar_recurso():

    tipo = input("Ingrese el tipo: ")
    lat = input("Ingrese la latitud: ")
    lon = input("Ingrese la longitud: ")
    vel = input("Ingrese la velocidad: ")
    auto = input("Ingrese la autonomia: ")
    delay = input("Ingrese el delay: ")
    t_ext = input("Ingrese la tasa de extincion: ")
    costo = input("Ingrese el costo: ")

    base_recursos = leer_db("recursos.csv", Recurso)
    id = 0
    for rec in base_recursos:
        if int(rec.id) > id:
            id = int(rec.id)
    id += 1

    with open("recursos.csv", "r") as af:
        header = af.readline().strip().split(",")
        keys = [f.split(":")[0] for f in header]

        i_id = keys.index("id")
        i_tipo = keys.index("tipo")
        i_lat = keys.index("lat")
        i_lon = keys.index("lon")
        i_velocidad = keys.index("velocidad")
        i_autonomia = keys.index("autonomia")
        i_delay = keys.index("delay")
        i_tasa_extincion = keys.index("tasa_extincion")
        i_costo = keys.index("costo")

        orden = []
        orden.append((i_id, id))
        orden.append((i_tipo, tipo))
        orden.append((i_lat, lat))
        orden.append((i_lon, lon))
        orden.append((i_velocidad, vel))
        orden.append((i_autonomia, auto))
        orden.append((i_delay, delay))
        orden.append((i_tasa_extincion, t_ext))
        orden.append((i_costo, costo))

        orden.sort()

        msg = ""
        for i, o in orden:
            msg += str(o)
            msg += ","
        msg = msg[:-1]

    with open("recursos.csv", "a") as af:
        print(msg, file=af)

    print("Recurso agregado exitosamente")
    print("*" * 20)
예제 #4
0
def leer_info_incendio(user):

    if user.asignado:
        id_rec = user.recurso_id
        rec_db = leer_db("recursos.csv", Recurso)
        rec_de_user = [rec for rec in rec_db if rec.id == id_rec].pop()
        print(rec_de_user.incedios_trabajados[-1])

    else:
        print("Usuario no asignado a un incendio")
예제 #5
0
def desplegar_base_recursos(fecha_actual):

    Recurso.fecha_actual = fecha_actual
    base_recursos = leer_db("recursos.csv", Recurso)

    rec_id = str(input("Ingrese el id del recurso: "))

    recurso = [rec for rec in base_recursos if rec.id == rec_id].pop()

    print(recurso)
예제 #6
0
def agregar_meteorologia():

    fecha_i = str(
        input("Ingrese fecha de inicio en formato aaaa-mm-dd hh:mm:ss : "))
    fecha_t = str(
        input("Ingrese fecha de termino en formato aaaa-mm-dd hh:mm:ss : "))
    tipo = input("Ingrese el tipo (TEMPERATURA, VIENTO, LLUVIAS o NUBES): ")
    valor = input("Ingrese el valor: ")
    lat = input("Ingrese la latitud: ")
    lon = input("Ingrese la longitud: ")
    radio = input("Ingrese el radio: ")

    base_meteorologia = leer_db("meteorologia.csv", Meteorologia)
    id = 0
    for met in base_meteorologia:
        if int(met.id) > id:
            id = int(met.id)
    id += 1

    with open("meteorologia.csv", "r") as af:
        header = af.readline().strip().split(",")
        keys = [f.split(":")[0] for f in header]

        i_id = keys.index("id")
        i_fecha_inicio = keys.index("fecha_inicio")
        i_fecha_termino = keys.index("fecha_termino")
        i_tipo = keys.index("tipo")
        i_valor = keys.index("valor")
        i_lat = keys.index("lat")
        i_lon = keys.index("lon")
        i_radio = keys.index("radio")

        orden = []
        orden.append((i_id, id))
        orden.append((i_fecha_inicio, fecha_i))
        orden.append((i_fecha_termino, fecha_t))
        orden.append((i_tipo, tipo))
        orden.append((i_valor, valor))
        orden.append((i_lat, lat))
        orden.append((i_lon, lon))
        orden.append((i_radio, radio))

        orden.sort()

        msg = ""
        for i, o in orden:
            msg += str(o)
            msg += ","
        msg = msg[:-1]

    with open("meteorologia.csv", "a") as af:
        print(msg, file=af)

    print("Meteorologia agregado exitosamente")
    print("*" * 20)
예제 #7
0
def desplegar_incendios_apagados(fecha_actual):

    inc_db = leer_db("incendios.csv", Incendio)
    for inc in inc_db:
        if inc.fecha_inicio < fecha_actual:
            inc.simular(fecha_actual)
            if not inc.activo:
                msg = str(inc)
                msg += "|Fecha de cese: ".format(inc.fecha_cese) + "|"
                msg += "|Recursos utilizados: ".format(
                    [repr(rec) for rec in inc.recursos_utilizados])

                print(msg)
예제 #8
0
def agregar_incendio():

    lat = input("Ingrese la latitud: ")
    lon = input("Ingrese la longitud: ")
    pot = input("Ingrese la potencia: ")
    fecha_inicio = input(
        "Ingrese fecha de inicio en formato aaaa-mm-dd hh:mm:ss :")

    base_incendios = leer_db("incendios.csv", Incendio)
    id = 0
    for inc in base_incendios:
        if int(inc.id) > int(id):
            id = int(inc.id)
    id += 1

    with open("incendios.csv", "r") as af:
        header = af.readline().strip().split(",")
        keys = [f.split(":")[0] for f in header]

        i_id = keys.index("id")
        i_fecha_inicio = keys.index("fecha_inicio")
        i_lat = keys.index("lat")
        i_lon = keys.index("lon")
        i_potencia = keys.index("potencia")

        orden = []
        orden.append((i_id, id))
        orden.append((i_fecha_inicio, fecha_inicio))
        orden.append((i_lat, lat))
        orden.append((i_lon, lon))
        orden.append((i_potencia, pot))

        orden.sort()

        msg = ""
        for i, o in orden:
            msg += str(o)
            msg += ","
        msg = msg[:-1]

    with open("incendios.csv", "a") as af:
        print(msg, file=af)

    print("Incendio agregado exitosamente")
    print("*" * 20)
예제 #9
0
def leer_info_recurso(user):

    id_rec = user.recurso_id
    rec_db = leer_db("recursos.csv", Recurso)
    rec_to_print = [rec for rec in rec_db if rec.id == id_rec].pop()
    print(rec_to_print)
예제 #10
0
def desplegar_base_meteorologia(fecha_actual):

    Meteorologia.fecha_actual = fecha_actual
    base_meteorologia = leer_db("meteorologia.csv", Meteorologia)
    for met in base_meteorologia:
        print(met)