Esempio n. 1
0
int main(int argc, char *argv[])
{
	if(argc != 3)
	{
		printf("Incorrect set of arguments\n");
		printf("Usage:\n./player <master-machine-name> <port-number>\n");
		exit(-1);
	}

	initPlayer(argv);	//this will start the player initializing the data structures and variables
	
	if(pthread_create(&left_thread,NULL,leftNeighborConn,NULL) !=0 )	{
		printf("Thread creation failed\n");
		exit(-1);
	}	
	
	#ifdef DEBUG
		printf("Left Thread created\n");	
	#endif
	
	setupNetwork();

	#ifdef DEBUG
		printPlayerInfo();	
		printf("Out here\n");
	#endif
	
	wait_for_message();

	#ifdef DEBUG
		printf("Exiting program\n");
	#endif

	return 0;
}
void VoiceReceiver::initialize() throw( NetworkSoundExpection )
{
    try
    {
        setupSound();
        setupNetwork();
    }
    catch ( const NetworkSoundExpection& e )
    {
        log_error << "Error initializing voice receiver " << std::endl;
        log_error << "   reason: " << e.what() << std::endl;
        return;
    }
}
Esempio n. 3
0
RegistrationClient::RegistrationClient(const char* pIp_address, int sfid, int portnum, bool bIsEndpoint, const char* friendlyname)
{
	// TODO Auto-generated constructor stub
	stringstream intconv;

	publicPairs.clear();

	ip_address = pIp_address;
	port_to_use = portnum;

	response[0] = 0;
	respLength = 0;

	// Form URL
	url = "http://" + ip_address;
	url += ":";
	intconv << portnum;

	url += intconv.str();

	if (bIsEndpoint)
	{
		assert(friendlyname);
		url += "/neuron-ep?ep_friendly_name=\"";
		url += friendlyname;
		url += "\"";
	}
	else
	{
		url += "/neuron-sf?sfid=";
		url += ToString<int>(sfid);
	}

	cout << "URL being formed is:" << endl << "  '" << url << "'" << endl;

	if (!setupNetwork())
		throw;

}
Esempio n. 4
0
void Dialog::tabChanged(int index)
{
#ifdef QTM_EXAMPLES_SMALL_SCREEN
    switch(index) {
    case 0:
        setupGeneral();
        break;
    case 1:
        setupGeneral();
        break;
    case 2:
        setupDevice();
        break;
    case 3:
        setupDevice();
        break;
    case 4:
        setupDevice();
        break;
    case 5:
        setupDisplay();
        break;
    case 6:
        setupStorage();
        break;
    case 7:
        setupNetwork();
        break;
    case 8:
        setupNetwork();
        break;
    case 9:
        setupNetwork();
        break;
    case 10:
        setupSaver();
        break;
    };
#else
    switch(index) {
    case 0:
        setupGeneral();
        break;
    case 1:
        setupDevice();
        break;
    case 2:
        setupDisplay();
        break;
    case 3:
        setupStorage();
        break;
    case 4:
        setupNetwork();
        break;
    case 5:
        setupSaver();
        break;
    };
#endif
}
void Tresenv::run()
{
    // '-c' and '-r' option: configuration to activate, and run numbers to run.
    // Both command-line options take precedence over inifile settings.
    // (NOTE: inifile settings *already* got read at this point! as EnvirBase::setup()
    // invokes readOptions()).
    
    const char *configname = args->optionValue('c');
    if (configname)
        opt_configname = configname;
    if (opt_configname.empty())
        opt_configname = "General";
    
    const char *runstoexec = args->optionValue('r');
    if (runstoexec)
        opt_runstoexec = runstoexec;
    
    // if the list of runs is not given explicitly, must execute all runs
    if (opt_runstoexec.empty())
    {
        int n = cfg->getNumRunsInConfig(opt_configname.c_str());  //note: may throw exception
        if (n==0)
        {
            ev.printfmsg("Error: Configuration `%s' generates 0 runs", opt_configname.c_str());
            exitcode = 1;
            return;
        }
        else
        {
            char buf[32];
            sprintf(buf, (n==1 ? "%d" : "0..%d"), n-1);
            opt_runstoexec = buf;
        }
    }
    
    ::fflush(fout);
    
    setupnetwork_done = false;
    startrun_done = false;
    
    ::fflush(fout);
    
    cfg->activateConfig(opt_configname.c_str(), 0);
    
    const char *itervars = cfg->getVariable(CFGVAR_ITERATIONVARS2);
    if (itervars && strlen(itervars)>0)
        ::fprintf(fout, "Scenario: %s\n", itervars);
    ::fprintf(fout, "Assigned runID=%s\n", cfg->getVariable(CFGVAR_RUNID));
    
    readPerRunOptions();
    
    // find network
    cModuleType *network = resolveNetwork(opt_network_name.c_str());
    ASSERT(network);
    
    // set up network
    ::fprintf(fout, "Setting up network `%s'...\n", opt_network_name.c_str());
    ::fflush(fout);
    
    setupNetwork(network);
    setupnetwork_done = true;
    
    // prepare for simulation run
    ::fprintf(fout, "Initializing...\n");
    ::fflush(fout);
    
    disable_tracing = opt_expressmode;
    startRun();
    startrun_done = true;
    
    // run the simulation
    ::fprintf(fout, "\nRunning simulation...\n");
    ::fflush(fout);
    
}