static void svr_init(
    svr_state * ns,
    tw_lp * lp)
{
    issue_event(ns, lp);
    return;
}
static void handle_kickoff_event(
	    svr_state * ns,
	    tw_bf * b,
	    svr_msg * m,
	    tw_lp * lp)
{
    char* anno;
    tw_lpid local_dest = -1, global_dest = -1;
   
    svr_msg * m_local = malloc(sizeof(svr_msg));
    svr_msg * m_remote = malloc(sizeof(svr_msg));

    m_local->svr_event_type = LOCAL;
    m_local->src = lp->gid;

    memcpy(m_remote, m_local, sizeof(svr_msg));
    m_remote->svr_event_type = REMOTE;

    assert(net_id == DRAGONFLY); /* only supported for dragonfly model right now. */

    ns->start_ts = tw_now(lp);
    
   codes_mapping_get_lp_info(lp->gid, group_name, &group_index, lp_type_name, &lp_type_index, anno, &rep_id, &offset);
   /* in case of uniform random traffic, send to a random destination. */
   if(traffic == UNIFORM)
   {
   	local_dest = tw_rand_integer(lp->rng, 0, num_nodes - 1);
//	printf("\n LP %ld sending to %d ", lp->gid, local_dest);
   }
   else if(traffic == NEAREST_GROUP)
   {
	local_dest = (rep_id * 2 + offset + num_nodes_per_grp) % num_nodes;
//	printf("\n LP %ld sending to %ld num nodes %d ", rep_id * 2 + offset, local_dest, num_nodes);
   }	
   else if(traffic == NEAREST_NEIGHBOR)
   {
	local_dest =  (rep_id * 2 + offset + 2) % num_nodes;
//	 printf("\n LP %ld sending to %ld num nodes %d ", rep_id * 2 + offset, local_dest, num_nodes);
   }
   assert(local_dest < num_nodes);
   codes_mapping_get_lp_id(group_name, lp_type_name, anno, 1, local_dest / num_servers_per_rep, local_dest % num_servers_per_rep, &global_dest);
  
   ns->msg_sent_count++;
   model_net_event(net_id, "test", global_dest, PAYLOAD_SZ, 0.0, sizeof(svr_msg), (const void*)m_remote, sizeof(svr_msg), (const void*)m_local, lp);
   issue_event(ns, lp);
   return;
}
Пример #3
0
BOOLE kbdDrvEventChecker(kbd_drv_pc_symbol symbol_key)
{
  ULO eol_evpos = kbd_state.eventsEOL.inpos;
  ULO eof_evpos = kbd_state.eventsEOF.inpos;
  
  ULO port, setting;
  
  for (;;)
  {
	
    if (kbd_drv_capture)
    {

#ifdef _DEBUG
      fellowAddLog( "Key captured: %s\n", kbdDrvKeyString( symbol_key ));
#endif

      kbd_drv_captured_key = symbol_key;
      return TRUE;
    }
	
    if (released(PCK_PAGE_DOWN))
    {
      if (ispressed(PCK_HOME))
      {
	issue_event(EVENT_RESOLUTION_NEXT);
      }
      else
      {
	if (ispressed(PCK_END))
	{
	  issue_event(EVENT_SCALEY_NEXT);
	}
      }
    }
    if (released(PCK_PAGE_UP))
    {
      if (ispressed(PCK_HOME))
      {
	issue_event(EVENT_RESOLUTION_PREV);
      }
      else
      {
	if (ispressed(PCK_END))
	{
	  issue_event(EVENT_SCALEY_PREV);
	}
      }
    }

    if(ispressed(PCK_RIGHT_WINDOWS) || ispressed(PCK_START_MENU))
      if(ispressed(PCK_LEFT_WINDOWS))
        if(ispressed(PCK_LEFT_CTRL))
          issue_event(EVENT_HARD_RESET);

    if (ispressed(PCK_PRINT_SCREEN))
      issue_event(EVENT_BMP_DUMP);

#ifdef RETRO_PLATFORM
    if(RP.GetHeadlessMode())
    {
      if( ispressed ( PCK_LEFT_ALT ) )
        if(ispressed ( PCK_F4 ) )
          issue_event(EVENT_EXIT);

      if(!RP.GetEmulationPaused())
      {
	if( pressed ( RP.GetEscapeKey() ))
	{
	  RP.SetEscapeKeyHeld(true);
	  return TRUE;
	}
	if( released ( RP.GetEscapeKey() ))
	{
	  ULONGLONG t = RP.SetEscapeKeyHeld(false);
          
          if((t != 0) && (t < RP.GetEscapeKeyHoldTime())) 
	  {
            UBY a_code = kbd_drv_pc_symbol_to_amiga_scancode[RP.GetEscapeKey()];

	    fellowAddLog("RetroPlatform escape key held shorter than escape interval, simulate key being pressed for %u milliseconds...\n",
              t);
            RP.SetEscapeKeySimulatedTargetTime(RP.GetTime() + RP.GetEscapeKeyHoldTime());
            kbdKeyAdd(a_code); // hold escape key
            return TRUE;
	  }
          else
            return TRUE;
	}
      }
      else 
      {
	if( pressed ( RP.GetEscapeKey() ))
	  RP.PostEscaped();
      }
    }
#endif

#ifdef RETRO_PLATFORM
    if(!RP.GetHeadlessMode())
#endif
    if( released( PCK_F11 ))
    {
      issue_event( EVENT_EXIT );
    }
	
#ifdef RETRO_PLATFORM
    if(!RP.GetHeadlessMode())
#endif
    if( released( PCK_F12 ))
    {
      mouseDrvToggleFocus();
      joyDrvToggleFocus();
      break;
    }
	
    if( ispressed(PCK_HOME) )
    {
      if( released( PCK_F1 )) issue_event( EVENT_INSERT_DF0 );
      if( released( PCK_F2 )) issue_event( EVENT_INSERT_DF1 );
      if( released( PCK_F3 )) issue_event( EVENT_INSERT_DF2 );
      if( released( PCK_F4 )) issue_event( EVENT_INSERT_DF3 );
    }
    else if( ispressed(PCK_END) )
    {
      if( released( PCK_F1 )) issue_event( EVENT_EJECT_DF0 );
      if( released( PCK_F2 )) issue_event( EVENT_EJECT_DF1 );
      if( released( PCK_F3 )) issue_event( EVENT_EJECT_DF2 );
      if( released( PCK_F4 )) issue_event( EVENT_EJECT_DF3 );
    }

    // Check joysticks replacements
    // New here: Must remember last value to decide if a change has happened
	
    for( port = 0; port < 2; port++ )
    {
      for( setting = 0; setting < 2; setting++ )
      {
	if( kbd_drv_joykey_enabled[port][setting] )
	{
	  // Here the gameport is set up for input from the specified set of joykeys 
	  // Check each key for change
	  int direction;
	  for (direction = 0; direction < MAX_JOYKEY_VALUE; direction++)
	  {
	    if (symbol_key == kbd_drv_joykey[setting][direction])
	    {
	      if( pressed( symbol_key ) || released( symbol_key ))
	      {
		kbdEventEOLAdd(kbd_drv_joykey_event[port][pressed(symbol_key)][direction]);
	      }
	    }
	  }
	}
      }
    }
    break;
  }
  
  return (eol_evpos != kbd_state.eventsEOL.inpos) ||
	(eof_evpos != kbd_state.eventsEOF.inpos);
}