void ElapsedLapTimeTest::testStopRecording() {
        gpsSnap.deltaFirstFix = 3;
        lap_started_normal_event(&gpsSnap);
        CPPUNIT_ASSERT_EQUAL(0, lapstats_elapsed_time());

        gpsSnap.deltaFirstFix = 15;
        update_elapsed_time(&gpsSnap);
        CPPUNIT_ASSERT_EQUAL(12, lapstats_elapsed_time());

        gpsSnap.deltaFirstFix = 122;
        lap_finished_event(&gpsSnap);
        update_elapsed_time(&gpsSnap);
        CPPUNIT_ASSERT_EQUAL(12, lapstats_elapsed_time());
}
void ElapsedLapTimeTest::testSamples() {
        gpsSnap.deltaFirstFix = 3;
        update_elapsed_time(&gpsSnap);
        CPPUNIT_ASSERT_EQUAL(0, lapstats_elapsed_time());

        lap_started_normal_event(&gpsSnap);
        CPPUNIT_ASSERT_EQUAL(0, lapstats_elapsed_time());

        gpsSnap.deltaFirstFix = 15;
        update_elapsed_time(&gpsSnap);
        CPPUNIT_ASSERT_EQUAL(12, lapstats_elapsed_time());

        gpsSnap.deltaFirstFix = 150;
        update_elapsed_time(&gpsSnap);
        CPPUNIT_ASSERT_EQUAL(147, lapstats_elapsed_time());
}
static void lapstats_location_updated(const GpsSnapshot *gps_snapshot)
{
    update_distance(gps_snapshot);

    /* Reset at_* flags on every sample. */
    g_at_sf = false;
    g_at_sector = false;

    if (!g_start_finish_enabled)
        return;

    /* Process data fields first. */
    const GeoPoint *gp = &gps_snapshot->sample.point;
    updateGeoTrigger(&g_start_geo_trigger, gp);
    updateGeoTrigger(&g_finish_geo_trigger, gp);
    update_elapsed_time(gps_snapshot);
    addGpsSample(gps_snapshot);

    /*
     * Now process the sector, finish and start logic in that order.
     * Each processing can invoke their respective event if the logic
     * agrees its time.
     */
    process_sector_logic(gps_snapshot);
    process_finish_logic(gps_snapshot);
    process_start_logic(gps_snapshot);
}
Exemplo n.º 4
0
void android_main(struct android_app* state) {
	LOGD("android_main", "android_main() called");

    engine e;
    app_dummy();
    memset(&e, 0, sizeof(engine));
    state->userData = &e;
    state->onAppCmd = engine_handle_cmd;
    state->onInputEvent = engine_handle_input;
    e.app = state;

	int i = 0;
	int animating = FALSE;

	while (1) {
		int ident, events;
		struct android_poll_source* source;

		while ((ident = ALooper_pollAll(0, NULL, &events, (void**) &source)) >= 0) {

			LOGD("call_order", "while ((ident=ALooper_pollAll...");
			LOGD("ALooper_pollAll", "ALooper_pollAll");
			if (source != NULL) {
				source->process(state, source);
			}
			if (state->destroyRequested != 0) {
				return;
			}
		}

		if (e.animating) {

			if(wake_from_paused)	{
				init_sles_gain_focus(state);
				wake_from_paused = FALSE;
			}

			calc_frame_delta_time();
			update_elapsed_time();
//			calc_frame_rate();
//		    LOGD("android_main", "frame_delta %d", frame_delta);
			draw_frame();

			if(!sles_init_called && elapsed_time > (1*SEC_IN_US)) {
				create_init_sles_thread(state);
				sles_init_called = TRUE;
			    LOGD("android_main", "sles_init_called = TRUE");
			}

			if(!splash_fading_in && elapsed_time > (1*SEC_IN_US	)) {
				splash_fading_in = TRUE;
				screens[0].is_showing = TRUE;
				LOGD("android_main", "splash_fading_in = TRUE");
			}
			if(!splash_bg_fading_in && elapsed_time > (3*SEC_IN_US)) { //3
				splash_bg_fading_in = TRUE;
				screens[1].is_showing = TRUE;
				LOGD("android_main", "splash_bg_fading_in = TRUE");
			}

			if(sles_init_finished && splash_bg_fading_in && screens[1].alpha == 1.0) {
				sles_init_finished = FALSE;
				assign_time(&splash_fadeout_time);
				LOGD("android_main", "sles_init_finished");
			}

			if(!splash_bg_fading_out && compare_times(splash_fadeout_time, (1*SEC_IN_US))) {
				splash_bg_fading_out = TRUE;
				screens[1].fading_in = FALSE;
				screens[1].fading_out = TRUE;
				LOGD("android_main", "splash_bg_fading_out = TRUE");
			}

			if(!splash_fading_out && compare_times(splash_fadeout_time, (4*SEC_IN_US))) {
				splash_fading_out = TRUE;
				screens[0].fading_in = FALSE;
				screens[0].fading_out = TRUE;
				LOGD("android_main", "splash_fading_out = TRUE");
			}

			if(!show_gameplay && compare_times(splash_fadeout_time, (6*SEC_IN_US))) {
				show_gameplay = TRUE;
				assign_time(&touch_enable_time);
				start_loop();
				init_control_loop();
				LOGD("android_main", "show_gameplay = TRUE");
			}

			if(!touch_enabled && compare_times(touch_enable_time, (2*SEC_IN_US))) {
				touch_enabled = TRUE;
				LOGD("android_main", "touch_enabled = TRUE");
			}

			if (show_gameplay && buttons_activated) {
				if (compare_times(buttons_activated_time, INTERACTIVE_TTL)) {
					if (!all_buttons_busy_fading) {
						buttons[2].fading_out = TRUE;
					}
				}
			}

		}
	}
}