Example #1
0
/*
 *  オーバランタイマの動作開始
 */
void
target_ovrtimer_start(PRCTIM ovrtim)
{
	if (ovrtim == 0) {
		ovr_event_flag = false;
		select_event();
		target_raise_ovr_int();
	}
	else {
		ovr_event_flag = true;
		ovr_event_simtim = current_simtim + ovrtim;
		select_event();
	}
}
Example #2
0
/*
 *  タイムウィンドウタイマの動作開始
 */
void
target_twdtimer_start(PRCTIM twdtim)
{
	if (twdtim == 0) {
		twd_event_flag = false;
		select_event();
		target_raise_twd_int();
	}
	else {
		twd_event_flag = true;
		twd_event_simtim = current_simtim + twdtim;
		select_event();
	}
}
Example #3
0
//=================================================================================================
void Grid::Update(float dt)
{
    if(Key.Focus() && focus)
    {
        if(GUI.cursor_pos.x >= global_pos.x && GUI.cursor_pos.x < global_pos.x+total_width && GUI.cursor_pos.y >= global_pos.y+height && GUI.cursor_pos.y < global_pos.y+size.y)
        {
            int n = (GUI.cursor_pos.y - (global_pos.y+height) + int(scroll.offset))/height;
            if(n >= 0 && n < items)
            {
                if(selection_type != NONE)
                {
                    GUI.cursor_mode = CURSOR_HAND;
                    if(Key.PressedRelease(VK_LBUTTON))
                        selected = n;
                }
                if(select_event)
                {
                    int y = GUI.cursor_pos.x - global_pos.x, ysum=0;
                    int col = -1;

                    for(int i=0; i<(int)columns.size(); ++i)
                    {
                        ysum += columns[i].width;
                        if(y <= ysum)
                        {
                            col = i;
                            break;
                        }
                    }

                    // celowo nie zaznacza 1 kolumny!
                    if(col > 0)
                    {
                        GUI.cursor_mode = CURSOR_HAND;
                        if(Key.PressedRelease(VK_LBUTTON))
                            select_event(n, col, 0);
                        else if(Key.PressedRelease(VK_RBUTTON))
                            select_event(n, col, 1);
                    }
                }
            }
        }

        if(IsInside(GUI.cursor_pos))
            scroll.ApplyMouseWheel();
        scroll.Update(dt);
    }
}
Example #4
0
/*
 *  高分解能タイマへの割込みタイミングの設定
 */
void
target_hrt_set_event(HRTCNT hrtcnt)
{
#ifdef HOOK_HRT_EVENT
	hook_hrt_set_event(hrtcnt);
#endif /* HOOK_HRT_EVENT */

	hrt_event_flag = true;
	hrt_event_simtim = roundup_simtim(current_simtim + hrtcnt);
	select_event();
}
Example #5
0
/*
 *  カーネルのアイドル処理
 */
void
target_custom_idle(void)
{
	lock_cpu();
	if (*p_event_flag) {
		current_simtim = *p_event_simtim;
		*p_event_flag = false;
		(*p_raise_event)();
		select_event();
	}
	unlock_cpu();
}
Example #6
0
/*
 *  オーバランタイマの停止
 *
 *  ここでオーバランタイマ割込み要求をクリアすると,割込み源の特定に失
 *  敗する(QEMUで確認.QEMUだけの問題か,実機にもある問題かは未確認)
 *  ため,クリアしない.
 */
PRCTIM
target_ovrtimer_stop(void)
{
	PRCTIM	ovrtim;

	if (ovr_event_simtim <= current_simtim) {
		ovrtim = 0U;
	}
	else {
		ovrtim = ovr_event_simtim - current_simtim;
	}
	ovr_event_flag = false;
	select_event();
	target_clear_ovr_int();
	return(ovrtim);
}
Example #7
0
/*
 *  タイムウィンドウタイマの停止
 *
 *  ここでタイムウィンドウタイマ割込み要求をクリアすると,割込み源の特
 *  定に失敗する(QEMUで確認.QEMUだけの問題か,実機にもある問題かは未
 *  確認)ため,クリアしない.
 */
PRCTIM
target_twdtimer_stop(void)
{
	PRCTIM	twdtim;

	if (twd_event_simtim <= current_simtim) {
		twdtim = 0U;
	}
	else {
		twdtim = twd_event_simtim - current_simtim;
	}
	twd_event_flag = false;
	select_event();
	target_clear_twd_int();
	return(twdtim);
}
Example #8
0
/*
 *  シミュレーション時刻を進める(テストプログラム用)
 */
void
simtim_advance(uint_t time)
{
	bool_t	locked;

	locked = sns_loc();
	if (!locked) {
		loc_cpu();
	}

	while (*p_event_flag && *p_event_simtim <= current_simtim + time) {
		/*
		 *  時刻をtime進めると,高分解能タイマ割込みの発生時刻を過ぎ
		 *  る場合
		 */
		if (current_simtim < *p_event_simtim) {
			time -= (*p_event_simtim - current_simtim);
			current_simtim = *p_event_simtim;
		}
		*p_event_flag = false;
		(*p_raise_event)();
		select_event();

		/*
		 *  ここで割込みを受け付ける.
		 */
		if (!locked) {
			unl_cpu();
			delay_for_interrupt();
			loc_cpu();
		}
	}	 
	current_simtim += time;

	if (!locked) {
		unl_cpu();
	}
}
Example #9
0
int main(int argc, char **argv)
{
#if DEBUG
  feenableexcept(FE_DIVBYZERO| FE_INVALID|FE_OVERFLOW); // enable exceptions
#endif
  if(argc ^ 2){
    printf("Usage: ./sa sa.config\n");
    exit(1);
  }
  if(read_config(argv[1])){           // read config
    printf("READDATA: Can't process %s \n", argv[1]);
    return 1;
  }  
  T = T+SKIP;               // increase T by SKIP to go from 0 to T all the way in time units
  
  // precomputing  
  I_Gamma = 1.0/Gamma;
  I_Alpha = 1.0/Alpha;    
  Bo = B;    
  X0_Be = pow(X0, Beta);
  GaBe  = Gamma * Beta;

  // event probabilites scaling by G;
  PE[0] = PE[0]*(double)G;
  PE[1] = PE[1]*(double)G;
  PE[2] = PE[2]*(double)G;
  
  initrand(Seed);
  init();          // note: method is in init.c  // allocate memory at initial  
  
  int i, j, ev, k = 0; // m;
  unsigned long seed;
  double dt, ct, tt;      // tt: time of simulation; dt: delta time after which next event occurs; ct: counter time to check with skip time for stat calculation
  time_t now;   
 
  for( i = 0; i < Runs; i++){
    tt = 0.0, ct = 0.0;
    k = 0; //m = 0;
    if(Seed == 0){      
      now = time(0);
      seed = ((unsigned long)now);  
      seed = 1454011037;
      initrand(seed);
      printf("\n run: %d rand seed: %lu\n",i+1, seed);
    }
    set_init_xrvpi();   // sets initial strategies vector, roles, valuations and payoffs       
     
    calc_stat(0, i);
    
    for( j = 0; j < N; j++) printf("%.4lf  ", V[0][j]); printf("\n");
    
    // Gillespie's stochastic simulation 
    while(tt < T){     
      // calc lambda; lambda = summation of P[j]s
      for(Lambda = 0, j = EVENTS; j--;)
	Lambda += PE[j];
      // select time for next event
      dt = randexp(Lambda); //printf("dt: %.4lf\n", dt);
      // select next event
      ev = select_event();
      // play the event      
      play_event(ev);
      // update time
      tt += dt;
      // calc stat
      ct += dt;
      if(ct >= SKIP){
        calc_stat(++k, i); // calculates all the stats	
	ct = 0.0;
      }
      // update events associated probabilites if necessary
    }
#if ALLDATAFILE
    calc_stat(-1, -1);    // free file pointers for individual run data files
#if !CLUSTER
    plotallIndividualRun(i, 0);      // note: method is in dataplot.c  
#if GRAPHS
    plotallIndividualRun(i, 1);      // note: method is in dataplot.c
#endif
#endif
    // write traits of final state
    {
      int m, n;
      char tstr[200], str[100];
      sprintf(str, "traits%d.dat", i);
      sprintf(str, "traits%d.dat", i); prep_file(tstr, str);
      FILE *fp = fopen(tstr, "w");
      for(m = 0; m < G; m++){
	for( n = 0; n < GS[m]; n++){
	  fprintf(fp, "%.4lf %.4lf    ", dxi[m][n], dsi[m][n]);
	}
	fprintf(fp, "\n");
      }
      fclose(fp);
    }
#if PUNISH
#if DISP_MATRIX
    plotTraits(i, 0);   // note: method is in dataplot.c
#endif
#if GRAPHS
    plotTraits(i, 1);   // note: method is in dataplot.c
#endif
#endif
#endif
  }  
  // write effort and payoff data
  writefile_effort_fertility();              // note: method is in dataplot.c
  writefile_threshold_aggressiveness();      // note: method is in dataplot.c
  // plot data with graphics using gnuplot
  if(!CLUSTER){    
    plotall(0);                              // note: method is in dataplot.c
#if GRAPHS
    plotall(1);                              // note: method is in dataplot.c
#endif
  }
#if PUNISH
#if DISP_MATRIX
  displayMatrix();                           
#endif  
#endif
  
  cleanup();                                 // note: method is in init.c
  return 0;
}