Example #1
0
def get_gps():
    gps = gpsp.get_gps_data()
    app.logger.debug(("GPS coordinates: ", gps))
    nord_direction = magnetic_compass.get_north_direction()
    app.logger.debug("north direction: {}".format(nord_direction))

    X, Y = geodesy.BLtoXY.get_XY(gps["lat"], gps["lon"])
    # X, Y = random.randint(1000000, 9999999), random.randint(1000000, 9999999)
    app.logger.debug("X={0} Y={1}".format(X, Y))

    gps["X"] = X
    gps["Y"] = Y
    gps["nord_direction"] = nord_direction
    gps["error"] = False
    app.logger.debug(gps)
    return make_response(jsonify(gps), 200)
Example #2
0
def get_adjustment_settings(B, L, shell_id='m21'):
    adj_set = {}
    current_shell = __import__('ballistic.m21of_no_ring', fromlist=[''])

    if shell_id != current_shell.ID:
        for shell in ballistic.shells:
            mod_name = '{0}.{1}'.format('ballistic', shell)
            cur_module = __import__(mod_name, fromlist=[''])
            if cur_module.ID == shell_id:
                current_shell = cur_module
                break

    distance, azimuth = distance_and_azimuth.get_direction_and_azimuth(L, B)
    distance = math.floor(distance)

    rest.app.logger.debug("distance: {0}".format(distance))
    rest.app.logger.debug("azimuth: {0}".format(azimuth))

    if distance > current_shell.MAX_DISTANCE:
        raise DistanceRangeException("Гарантирован недолет",
                                     distance - current_shell.MAX_DISTANCE)

    if distance < current_shell.MIN_DISTANCE:
        raise DistanceRangeException("Гарантирован перелет",
                                     current_shell.MIN_DISTANCE - distance)

    adj_set['distance'] = distance
    adj_set['azimuth'] = azimuth

    nord_direction = magnetic_compass.get_north_direction()

    packet_turn_degree = azimuth - nord_direction
    if packet_turn_degree > 180:
        packet_turn_degree -= 360

    if packet_turn_degree < -102 or packet_turn_degree > 70:
        rest.app.logger.debug("packet_turn_degree: {0}".format(packet_turn_degree))
        print(packet_turn_degree)
        raise HorizontalRangeException(("Угол наведения недопустим, "
                                        "переставьте машину"))

    adj_set['packet_turn_degree'] = packet_turn_degree

    keys = list(current_shell.distances.keys())
    keys.sort()

    sight = 0

    for key in keys:
        if key >= distance:
            sight = current_shell.distances[key]
            break

    packet_turn_degree_mdu = math.floor(packet_turn_degree / 0.06)
    h_fast_phase = packet_turn_degree_mdu - 10
    v_fast_phase = sight - 10

    v_fast_time = v_fast_phase / settings.PACKET_CLIMB_FAST_MDU_PER_SECOND
    vertical_precise_time = 10 / settings.PACKET_CLIMB_PRECISE_MDU_PER_SECOND

    h_fast_time = h_fast_phase / settings.PACKET_TURN_FAST_MDU_PER_SECOND
    horizontal_precise_time = 10 / settings.PACKET_TURN_PRECISE_MDU_PER_SECOND
    adj_set['sight'] = sight
    adj_set['v_fast_time'] = v_fast_time
    adj_set['vertical_precise_time'] = vertical_precise_time
    adj_set['h_fast_time'] = h_fast_time
    adj_set['horizontal_precise_time'] = horizontal_precise_time

    return adj_set