Beispiel #1
0
def saveNewEvent(flight_number, event, data):
    LOG.info("Saving new Event")

    if not isValidEvent(data['event'], event):
        return False

    flight = service.getFlightByNumber(flight_number)

    time_received = int(time.time())

    return service.saveNewEvent(flight, data, time_received)
Beispiel #2
0
def saveNewParameters(flight_number, data):
    flight = service.getFlightByNumber(flight_number)
    # Get modified Flight object from DB

    time_received = int(time.time())
    # Get time of message receive

    service.saveParameterWithValues(flight, data, time_received)
    # Save new parameters

    return True
Beispiel #3
0
def saveNewFlight(number, datetime):
    LOG.info("Saving new Flight")

    datetime = parseHTMLDateTimeToDateTime(datetime)
    # Parse DateTime formated by HTML input tag to Python datetime object

    hash = service.computeHash(number)
    # Compute hash for Flight

    flight = Flight(int(number), hash, datetime)
    # Create new Flight object

    return service.saveNewFlight(flight)
Beispiel #4
0
def getFlightList():
    """
    Returns list of all flights
    @return: array - list of flights
    """
    flightList = service.getFlightList()
    return flightList
Beispiel #5
0
def flightExists(flight_number):
    """
    Checks if Flight with requested Flgiht Number exists in Database
    @param flight_number: Flight Number
    @return: boolean
    """
    flight = service.getFlightByNumber(flight_number)
    if flight is Flight:
        return True
    else:
        return False
Beispiel #6
0
def getBalloonBurst(flight_number):
    position = None

    flight = service.getFlightByNumber(flight_number)
    events = service.getEventsByFlight(flight.id)

    for e in events:
        if e.type == "burst":
            service.fillParametersDictionary(e)
            parameter = e.parametersDict["position"]
            position = {
                'type': "burst",
                'point': {
                    'time': parameter.time_received,
                    'lat': parameter.valuesDict["lat"].value,
                    'lng': parameter.valuesDict["lng"].value
                }
            }

    LOG.debug("BalloonBurst: ", position)

    return position
Beispiel #7
0
def getBalloonStart(flight_number):
    position = None

    # flight = service.getFlightByNumber(flight_number)
    parameter = service.getFlightFirstPosition(flight_number)

    if parameter is not None:
        position = {
            'type': "start",
            'point': {
                'time': parameter.time_received,
                'lat': parameter.valuesDict["lat"].value,
                'lng': parameter.valuesDict["lng"].value
            }
        }

    LOG.debug("BalloonStart: ", position)

    return position
Beispiel #8
0
def getBalloonPath(flight_number):

    # flight = service.getFlightByNumber(flight_number)
    parameters = service.getFlightPath(flight_number)

    path = {'type': "path", 'data': {'points': []}}

    for p in parameters:
        LOG.debug(p)
        point = {
            'time': p.time_received,
            'lat': p.valuesDict["lat"].value,
            'lng': p.valuesDict["lng"].value
        }

        path["data"]["points"].append(point)

    LOG.debug("BalloonPath: ", path)

    return path
Beispiel #9
0
def getFlightAll():
    flights = service.getFlightAll()
    return flights
Beispiel #10
0
def getFlightById(flight_id):
    flight = service.getFlightById(flight_id)
    return flight
Beispiel #11
0
def getEventsAllByFlight(flight_id):
    flight = service.getFlightById(flight_id)
    events = service.getEventsByFlight(flight.id)
    return events
Beispiel #12
0
def getParametersAllByFlight(flight_id):
    flight = service.getFlightById(flight_id)
    parameters = service.getParametersWithValuesByFlight(flight.id)
    return parameters