示例#1
0
/// @brief Wrapper function to call serial integrators
///
/// @callgraph
/// @callergraph
///
/// @details Calls serial integrators based on sim::integrator
///
/// @section License
/// Use of this code, either in source or compiled form, is subject to license from the authors.
/// Copyright \htmlonly &copy \endhtmlonly Richard Evans, 2009-2011. All Rights Reserved.
///
/// @section Information
/// @author  Richard Evans, [email protected]
/// @version 1.1
/// @date    10/06/2015
///
/// @internal
///	Created:		05/02/2011
///	Revision:	  ---
///=====================================================================================
///
void integrate_serial(uint64_t n_steps){

   // Check for calling of function
   if(err::check==true) std::cout << "sim::integrate_serial has been called" << std::endl;

   // Case statement to call integrator
   switch(sim::integrator){

      case 0: // LLG Heun
         for(uint64_t ti=0;ti<n_steps;ti++){
            // Optionally select GPU accelerated version
            if(gpu::acceleration) gpu::llg_heun();
            // Otherwise use CPU version
            else sim::LLG_Heun();
            // Increment time
            increment_time();
         }
         break;

		case 1: // Montecarlo
			for(uint64_t ti=0;ti<n_steps;ti++){
				sim::MonteCarlo();
				// increment time
				increment_time();
			}
			break;

      case 2: // LLG Midpoint
         for(uint64_t ti=0;ti<n_steps;ti++){
            sim::LLG_Midpoint();
            // increment time
            increment_time();
         }
         break;

		case 3: // Constrained Monte Carlo
			for(uint64_t ti=0;ti<n_steps;ti++){
				sim::ConstrainedMonteCarlo();
				// increment time
				increment_time();
			}
			break;

		case 4: // Hybrid Constrained Monte Carlo
			for(uint64_t ti=0;ti<n_steps;ti++){
				sim::ConstrainedMonteCarloMonteCarlo();
				// increment time
				increment_time();
			}
			break;

		default:{
			std::cerr << "Unknown integrator type "<< sim::integrator << " requested, exiting" << std::endl;
         err::vexit();
		}
	}

   return;
}
示例#2
0
/**@brief Provide simulated location and speed.
 */
static void loc_speed_simulation_update(void)
{
    // ugly updating of status
    m_sim_location_speed.position_status  = (ble_lns_pos_status_type_t)
                                            (
                                                ( (uint32_t) m_sim_location_speed.position_status + 1) %
                                                ( (uint32_t) BLE_LNS_LAST_KNOWN_POSITION + 1)
                                            );
    m_sim_location_speed.data_format      = (ble_lns_speed_distance_format_t)
                                            (
                                                ( (uint32_t) m_sim_location_speed.data_format + 1) %
                                                ( (uint32_t) BLE_LNS_SPEED_DISTANCE_FORMAT_3D + 1)
                                            );
    m_sim_location_speed.elevation_source = (ble_lns_elevation_source_t)
                                            (
                                                ( (uint32_t) m_sim_location_speed.elevation_source + 1) %
                                                ( (uint32_t) BLE_LNS_ELEV_SOURCE_OTHER + 1)
                                            );
    m_sim_location_speed.heading_source   = (ble_lns_heading_source_t)
                                            (
                                                ( (uint32_t) m_sim_location_speed.heading_source + 1) %
                                                ( (uint32_t) BLE_LNS_HEADING_SOURCE_COMPASS + 1)
                                            );
    m_sim_location_speed.total_distance++;
    m_sim_location_speed.latitude++;
    m_sim_location_speed.longitude++;
    m_sim_location_speed.elevation++;
    m_sim_location_speed.heading++;
    m_sim_location_speed.rolling_time++;

    increment_time(&m_sim_location_speed.utc_time);
}
示例#3
0
static void navigation_simulation_update(void)
{
    // ugly updating of status
    m_sim_navigation.position_status           = (ble_lns_pos_status_type_t)
                                                 (
                                                    ( (uint32_t) m_sim_navigation.position_status + 1) %
                                                    ( (uint32_t) BLE_LNS_LAST_KNOWN_POSITION + 1)
                                                 );
    m_sim_navigation.heading_source            = (ble_lns_heading_source_t)
                                                 (
                                                    ( (uint32_t) m_sim_navigation.heading_source  + 1) %
                                                    ( (uint32_t) BLE_LNS_HEADING_SOURCE_COMPASS + 1)
                                                 );
    m_sim_navigation.navigation_indicator_type = (ble_lns_nav_indicator_type_t)
                                                 (
                                                    ( (uint32_t) m_sim_navigation.navigation_indicator_type + 1) %
                                                    ( (uint32_t) BLE_LNS_NAV_TO_DESTINATION + 1)
                                                 );

    m_sim_navigation.waypoint_reached    = !m_sim_navigation.waypoint_reached;
    m_sim_navigation.destination_reached = !m_sim_navigation.destination_reached;
    m_sim_navigation.bearing++;
    m_sim_navigation.heading++;
    m_sim_navigation.remaining_distance++;
    m_sim_navigation.remaining_vert_distance++;

    increment_time(&m_sim_navigation.eta);
}
示例#4
0
/* clock_task: clock task */ 
void clock_task(void) 
{

    si_time next_time;
    /* local copies of the current time */ 
    int alarm_hours, alarm_minutes, alarm_seconds, hours, minutes, seconds, enable; 
    si_get_current_time(&next_time);
    /* infinite loop */ 
    while (1)
    {
        /* increment time */
		//printf("%d\n",1);
		increment_time();

        /* read and display current time */ 
		get_time(&hours, &minutes, &seconds, &enable);
		get_alarm_time(&alarm_hours, &alarm_minutes, &alarm_seconds);
		display_time(hours, minutes, seconds);
		
		if (enable && alarm_hours == hours && alarm_minutes == minutes && alarm_seconds == seconds)
		{
			enable_alarm();
		}
		si_time_add_n_ms(&next_time,1000);
        /* wait one second */ 
		si_wait_until_time(&next_time);
    }
}
示例#5
0
/* clock_task: clock task */ 
void clock_task(void) 
{
    /* local copies of the current time */ 
    int hours, minutes, seconds; 

    /* infinite loop */ 
    while (1)
    {
        /* read and display current time */ 
        get_time(&hours, &minutes, &seconds); 
        display_time(hours, minutes, seconds); 

        /* increment time */ 
        increment_time(); 

        /* wait one second */ 
        si_wait_n_ms(500); 
    }
}
示例#6
0
//function to handle running the simulation
Queue* Simulation::run_sim()
{
	order_out = new Queue;
	
	//time loop
	//Exit Condition: The order_takers has no more orders in queue AND
	//the fetching unit is free AND the packing unit is done)
	while (!order_takers->is_done() || !fetch_bot.unit_free() ||
		  !pack_chief.all_done()){
		
		pack_chief_loop();
		
		fetch_bot_loop();
		
		order_takers_loop();
		
		increment_time();
	};
	
	return order_out;
}
示例#7
0
static void on_timeout (void)
{
    if (_mode != TIME_CONFIG)
        increment_time (&_time);

    if (_mode != NORMAL)
    {
        _alarm_on = 0;
        led_off ();
        return;
    }

    /* Normal mode */

    print_time ();

    // Alarm triggered?
    if (_alarm_set && time_equals (&_time, &_alarm))
    {
        _alarm_on = 1;
        _alarm_duration = 0;
    }

    if (_alarm_on)
    {
        // Shut down the alarm
        if (ALARM_MAX_DURATION <= _alarm_duration)
        {
            _alarm_on = 0;
            led_off ();
        }

        // Continue the alarm
        else
        {
            _alarm_duration++;
            led_toggle ();
        }
    }
}
示例#8
0
文件: clock.c 项目: danfa688/TSEA81
/* clock_task: clock task */ 
void *clock_thread(void *unused) 
{
    /* local copies of the current time */ 
    int hours, minutes, seconds;

    /* infinite loop */ 
    while (1)
    {
        /* read and display current time */ 
        clock_get_time(&hours, &minutes, &seconds); 
        display_time(hours, minutes, seconds);
        
        /* check alarm */
        clock_check_and_sound_alarm();

        /* increment time */ 
        increment_time(); 

        /* wait one second */ 
        usleep(1000000);
    }
}
示例#9
0
/// @brief Wrapper function to call MPI parallel integrators
///
/// @callgraph
/// @callergraph
///
/// @details Calls parallel integrators based on sim::integrator
///
/// @section License
/// Use of this code, either in source or compiled form, is subject to license from the authors.
/// Copyright \htmlonly &copy \endhtmlonly Richard Evans, 2009-2011. All Rights Reserved.
///
/// @section Information
/// @author  Richard Evans, [email protected]
/// @version 1.0
/// @date    07/03/2011
///
/// @return EXIT_SUCCESS
///
/// @internal
///	Created:		07/03/2011
///	Revision:	  ---
///=====================================================================================
///
int integrate_mpi(uint64_t n_steps){

	// Check for calling of function
	if(err::check==true) std::cout << "sim::integrate_mpi has been called" << std::endl;

	// Case statement to call integrator
	switch(sim::integrator){
		case 0: // LLG Heun
			for(uint64_t ti=0;ti<n_steps;ti++){
			#ifdef MPICF
				// Select CUDA version if supported
				#ifdef CUDA
					//sim::LLG_Heun_cuda_mpi();
				#else
					sim::LLG_Heun_mpi();
				#endif
			#endif
				// increment time
				increment_time();
			}
			break;

		case 1: // Montecarlo
			for(uint64_t ti=0;ti<n_steps;ti++){
				terminaltextcolor(RED);
				std::cerr << "Error - Monte Carlo Integrator unavailable for parallel execution" << std::endl;
				terminaltextcolor(WHITE);
				err::vexit();
				// increment time
				increment_time();
			}
			break;

		case 2: // LLG Midpoint
			for(uint64_t ti=0;ti<n_steps;ti++){
			#ifdef MPICF
			// Select CUDA version if supported
				#ifdef CUDA
					//sim::LLG_Midpoint_cuda_mpi();
				#else
					sim::LLG_Midpoint_mpi();
				#endif
			#endif
				// increment time
				increment_time();
			}
			break;

		case 3: // Constrained Monte Carlo
			for(uint64_t ti=0;ti<n_steps;ti++){
				terminaltextcolor(RED);
				std::cerr << "Error - Constrained Monte Carlo Integrator unavailable for parallel execution" << std::endl;
				terminaltextcolor(WHITE);
				err::vexit();
				// increment time
				increment_time();
			}
			break;

		default:{
			terminaltextcolor(RED);
			std::cerr << "Unknown integrator type "<< sim::integrator << " requested, exiting" << std::endl;
			terminaltextcolor(WHITE);
			exit (EXIT_FAILURE);
			}
	}

	return EXIT_SUCCESS;
}