Example #1
0
void Clock::alarmTime()
{
    qDebug()<<"alarmTime";
    startNetwork();
    readNetwork();
    runClock = false;
}
int main(int argc, char** argv) {
    // setup basic vehicles
    initBaseVehicles();
    
    /// OpenMP may or may not immediately start execution of a task... the
    /// runtime is free to decide. Using the section construct is better.
    
    // accept connection
    #pragma omp parallel num_threads(2)
    #pragma omp sections
{
    #pragma omp section
    {
    printf("net started\n");
    startNetwork(8866);
    }

    #pragma omp section
    {
    printf("not net running\n");
    // run simulation
    while(1) {
        // handle the move phase
        updateSettings();
        updateLocations();
        processCollisions();
    }
    }
}
}
MarOscInWindow::MarOscInWindow(string fileName)
{
	QWidget *w = new QWidget;
	setCentralWidget(w);

	QLabel  *gainLabel1  = new QLabel("gain");
	gainSlider_ = new QSlider(Qt::Horizontal);

	gainSlider_->setValue(100);

	createNetwork();

	QGridLayout *gridLayout = new QGridLayout;

	gridLayout->addWidget(gainLabel1, 2, 1);
	gridLayout->addWidget(gainSlider_, 3, 1);

	connect(gainSlider_, SIGNAL(valueChanged(int)), this, SLOT(gainChanged(int)));

	w->setLayout(gridLayout);

	startNetwork();

 	cout << "Playing file=(" << fileName << ")" << endl;
 	play(fileName);

}
bool FileProvider::scan( NetworkType &network ) {
	bool result=false;
	_scan++;
	if (_files.size() > static_cast<size_t>(_scan)) {
		network = _files[_scan];
		result=startNetwork( network );
	}
	printf( "[FileProvider] Scan %d: %s\n", _scan, network.c_str() );
	return result;
}
Example #5
0
void Player::setGameMode(std::string myip, unsigned short myport , bool startmode, std::string otherip, unsigned short otherport, int _numPlayers, int _numAIs) {
	if(startmode)
	{
		startNetwork(myip, myport);
		numPlayers = _numPlayers;
		numAIs = _numAIs;
		nameAI = settings->name;
		didStart = true;
	}
	else
	{
		connectToNetwork(otherip, otherport, myip, myport);
		didStart = false;
	}
}
int main(int argc, char** argv) {
    // setup basic vehicles
    initBaseVehicles();
    
    tbb::parallel_invoke( 
        [] {
            // accept connection
            startNetwork(8866);
        }, 
        [] {
            // run simulation
            while(1) {
                // handle the move phase
                updateSettings();
                updateLocations();
                processCollisions();
            }
        } 
    );
}
Example #7
0
void RuntimeEngine::start()
{
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
    _project.setDebuggerType(kCCRuntimeDebuggerCodeIDE);
#endif

    // set search path
    string path = FileUtils::getInstance()->fullPathForFilename(_project.getScriptFileRealPath().c_str());
    size_t pos;
    while ((pos = path.find_first_of("\\")) != std::string::npos)
    {
        path.replace(pos, 1, "/");
    }
    size_t p = path.find_last_of("/");
    string workdir;
    if (p != path.npos)
    {
        workdir = path.substr(0, p);
        FileUtils::getInstance()->addSearchPath(workdir);
    }

    // update search pathes
    FileUtils::getInstance()->addSearchPath(_project.getProjectDir());
    auto &customizedPathes = _project.getSearchPath();
    for (auto &path : customizedPathes)
    {
        FileUtils::getInstance()->addSearchPath(path);
    }

    //
    if (_project.getDebuggerType() == kCCRuntimeDebuggerNone)
    {
        setupRuntime();
        startScript("");
    }
    else
    {
        startNetwork();
    }
}
Example #8
0
int main(int argc, char *argv[])
{
    BD_MANAGER_t *deviceManager = malloc(sizeof(BD_MANAGER_t));
    printf("BD_MANAGER créé\n");
	int failed = 0;
	char cmd='0';

	// initialize jsMnager
    deviceManager->alManager = NULL;
    deviceManager->netManager = NULL;
    deviceManager->streamReader = NULL;
    deviceManager->rxThread = NULL;
    deviceManager->txThread = NULL;
    deviceManager->videoRxThread = NULL;
    deviceManager->videoTxThread = NULL;
    deviceManager->d2cPort = BD_D2C_PORT;
    deviceManager->c2dPort = BD_C2D_PORT; //deviceManager->c2dPort = 0; // Should be read from json	
    deviceManager->run = 1;

	failed = ardiscoveryConnect (deviceManager);   

	if(!failed)
	    failed = startNetwork(deviceManager);
	else
		printf("Erreur ardiscoveryConnect\n");

	if(!failed)
	{
		sendLanding(deviceManager);
		sleep(1);		
        }

	if(!failed)
		stopNetwork(deviceManager);
	else
		printf("Erreur de StartNetwork\n");

    return EXIT_SUCCESS; 
}
/* private slots */
void NetControlThread::run()
{
    Result result;
    switch (task.action) {
    case GET_ALL_ENTITY_STATE :
        result = getAllNetworkList();
        break;
    case CREATE_ENTITY :
        result = createNetwork();
        break;
    case DEFINE_ENTITY :
        result = defineNetwork();
        break;
    case START_ENTITY :
        result = startNetwork();
        break;
    case DESTROY_ENTITY :
        result = destroyNetwork();
        break;
    case UNDEFINE_ENTITY :
        result = undefineNetwork();
        break;
    case CHANGE_ENTITY_AUTOSTART :
        result = changeAutoStartNetwork();
        break;
    case GET_XML_DESCRIPTION :
        result = getVirtNetXMLDesc();
        break;
    default:
        break;
    };
    // task.srcConnPtr reference will closed in destructor as ptr_ConnPtr
    //virConnectClose(*task.srcConnPtr);
    result.type   = "network";
    result.number = number;
    result.action = task.action;
    emit resultData(result);
}
MarLpcWindow::MarLpcWindow()
{
	frequencyPole_ = 0;
	amplitudePole_ = .85;

	QWidget *w = new QWidget;
	setCentralWidget(w);

	createActions();
	createMenus();  

	QLabel  *breathinessLabel  = new QLabel("breathiness");
	breathinessSlider_ = new QSlider(Qt::Horizontal);

	QLabel  *cutOffLabel  = new QLabel("cutOff");
	QSlider *cutOffSlider = new QSlider(Qt::Horizontal);

	QLabel  *frequencyPoleLabel1  = new QLabel("frequencyPole");
	QLabel  *frequencyPoleLabel2  = new QLabel("frequencyPole");
	frequencyPoleSlider_ = new QSlider(Qt::Horizontal);

	QLabel  *amplitudePoleLabel1  = new QLabel("amplitudePole");
	QLabel  *amplitudePoleLabel2  = new QLabel("amplitudePole");
	amplitudePoleSlider_ = new QSlider(Qt::Horizontal);

	QLabel  *tiltLabel  = new QLabel("Tilt");
	tiltSlider_ = new QSlider(Qt::Horizontal);

	QLabel *posLabel = new QLabel("Pos");
	posSlider_ = new QSlider(Qt::Horizontal);

	breathinessLabel->setMinimumWidth(150);
	cutOffLabel->setMinimumWidth(150);

	frequencyPoleSlider_->setValue(50);
	amplitudePoleSlider_->setValue(50);
	tiltSlider_->setValue(50);

	createNetwork();

	QGridLayout *gridLayout = new QGridLayout;

	gridLayout->addWidget(breathinessLabel, 0, 0);
	gridLayout->addWidget(breathinessSlider_, 1, 0);

	gridLayout->addWidget(tiltLabel, 0, 1);
	gridLayout->addWidget(tiltSlider_, 1, 1);

	gridLayout->addWidget(frequencyPoleLabel1, 2, 0);
	gridLayout->addWidget(frequencyPoleSlider_, 3, 0);

	gridLayout->addWidget(amplitudePoleLabel1, 2, 1);
	gridLayout->addWidget(amplitudePoleSlider_, 3, 1);

	gridLayout->addWidget(posLabel, 5, 0);
	gridLayout->addWidget(posSlider_, 6, 0);
	gridLayout->addWidget(posControl_, 6, 1);

	gridLayout->addWidget(frequencyPoleControl_, 4, 0);
	gridLayout->addWidget(amplitudePoleControl_, 4, 1);

	connect(breathinessSlider_, SIGNAL(valueChanged(int)), this, SLOT(breathinessChanged(int)));
	connect(cutOffSlider, SIGNAL(valueChanged(int)), this, SLOT(cutOffChanged(int)));
	connect(frequencyPoleSlider_, SIGNAL(valueChanged(int)), this, SLOT(frequencyPoleChanged(int)));
	connect(amplitudePoleSlider_, SIGNAL(valueChanged(int)), this, SLOT(amplitudePoleChanged(int)));
	connect(tiltSlider_, SIGNAL(valueChanged(int)), this, SLOT(tiltChanged(int)));
	connect(posSlider_, SIGNAL(sliderReleased()), this, SLOT(posChanged()));

	connect(mwr_, SIGNAL(ctrlChanged(MarControlPtr)), this, SLOT(ctrlChanged(MarControlPtr)));

	w->setLayout(gridLayout);

	startNetwork();
}
Example #11
0
void loop() {
    // Though counter-intuitive, game creation cannot be in setup because of varying arduino boot times and boot gibberish
    if (!gameCreated) {
        drawGUI();
        while(!waitUntil(JOYSTICK_BUTTON_PIN, false));
        if (!startNetwork()) {
            tft.fillScreen(ST7735_BLACK); // we must clear all conflicting messages from screen
            tft.setCursor(0,0);
            dualPrint("Network connection failed!");
            dualPrint("Please ensure:");
            dualPrint("1) both arduinos are connected");
            dualPrint("2) both parties pressed the joystick");
            dualPrint("If both are true, consult someone who");
            dualPrint("looks like he knows what he's talking about");
            dualPrint("Reset both Arduinos to try again");
            while(1);
        }
        /* Extensibility Goal:
         * Enable colour selection here, time permissible
         */
        gameCreated = true;
    }
    if (!gameStarted) {
        setSpawns(&player1, &player2);
        setColour(&player1, &player2);
        tft.fillScreen(ST7735_BLACK);
        startCountdown();
        gameStarted = true;
    }
    winner = gameOver(&player1.currentPosition, &player2.currentPosition);
    if (winner) {
        tft.setCursor(0, 80);
        String message;
        switch (winner) {
        case -1:
            message = "YOU SUPER TIE";
            break;
        case 1:
            message = "YOU SUPER WIN";
            player1.score++;
            break;
        case 2:
            message = "YOU SUPER LOSE";
            player2.score++;
            break;
        }
        tft.println(message);
        tft.println("SCORES:");
        tft.print("You: ");
        tft.print(player1.score);
        tft.print(" | Him: ");
        tft.println(player2.score);
        tft.println("Again? <Press Joystick>");
        waitUntil(JOYSTICK_BUTTON_PIN, LOW);
        memset(&wallPositions, 0, 2560); // 2560 is a magic number because size_ts were acting unexpectedly
        gameStarted = false;
        tft.fillScreen(ST7735_BLACK);
    } else {
        // add a wall ad draw car at current position
        addWallPosition(player1.currentPosition);
        addWallPosition(player2.currentPosition);
        tft.fillRect(player1.currentPosition.x, player1.currentPosition.y, 2, 2, player1.colour);
        tft.fillRect(player2.currentPosition.x, player2.currentPosition.y, 2, 2, player2.colour);
        movement_t newDirection = getJoystickInput();
        if (validInput(newDirection, player1.direction)) player1.direction = newDirection;
        sendDeltas(&player1.direction);
        receiveDeltas(&player2.direction);
        player1.currentPosition.x += player1.direction.x;
        player1.currentPosition.y += player1.direction.y;
        player2.currentPosition.x += player2.direction.x;
        player2.currentPosition.y += player2.direction.y;
        delay(75); // this is how we control the game speed
        /* Extensibility Goal:
         * Find a more efficient and reliable way of controlling game speed.
         * Implement it, and allow it to be customized
         */
    }
}
Example #12
0
///配置运行环境信息
int CwxMqApp::initRunEnv() {
  ///设置系统的时钟间隔,最小刻度为1ms,此为0.1s。
  this->setClick(100); //0.1s
  ///设置工作目录
  this->setWorkDir(m_config.getCommon().m_strWorkDir.c_str());
  ///设置循环运行日志的数量
  this->setLogFileNum(LOG_FILE_NUM);
  ///设置每个日志文件的大小
  this->setLogFileSize(LOG_FILE_SIZE * 1024 * 1024);
  ///调用架构的initRunEnv,使以上设置的参数生效
  if (CwxAppFramework::initRunEnv() == -1) return -1;
  ///将加载的配置文件信息输出到日志文件中,以供查看检查
  m_config.outputConfig();
  ///block各种signal
  this->blockSignal(SIGTERM);
  this->blockSignal(SIGUSR1);
  this->blockSignal(SIGUSR2);
  this->blockSignal(SIGCHLD);
  this->blockSignal(SIGCLD);
  this->blockSignal(SIGHUP);
  this->blockSignal(SIGPIPE);
  this->blockSignal(SIGALRM);
  this->blockSignal(SIGCONT);
  this->blockSignal(SIGSTOP);
  this->blockSignal(SIGTSTP);
  this->blockSignal(SIGTTOU);

  //set version
  this->setAppVersion(CWX_MQ_VERSION);
  //set last modify date
  this->setLastModifyDatetime(CWX_MQ_MODIFY_DATE);
  //set compile date
  this->setLastCompileDatetime(CWX_COMPILE_DATE(_BUILD_DATE));
  ///设置启动时间
  CwxDate::getDateY4MDHMS2(time(NULL), m_strStartTime);

  //启动binlog管理器
  if (0 != startBinLogMgr()) return -1;
  if (m_config.getCommon().m_bMaster) {
    ///注册数据接收handler
    if (m_config.getRecv().m_recv.getHostName().length()) {
      m_recvHandler = new CwxMqRecvHandler(this);
      getCommander().regHandle(SVR_TYPE_RECV, m_recvHandler);
    }
  } else {
    ///注册slave的master数据接收handler
    m_masterHandler = new CwxMqMasterHandler(this);
    getCommander().regHandle(SVR_TYPE_MASTER, m_masterHandler);
  }

  ///启动网络连接与监听
  if (0 != startNetwork()) return -1;
  ///创建recv线程池对象,此线程池中线程的group-id为THREAD_GROUP_USER_START,
  ///线程池的线程数量为1。
  m_recvThreadPool = new CwxThreadPool(1, &getCommander());
  ///创建线程的tss对象
  CwxTss** pTss = new CwxTss*[1];
  pTss[0] = new CwxMqTss();
  ((CwxMqTss*) pTss[0])->init();
  ///启动线程
  if (0 != m_recvThreadPool->start(pTss)) {
    CWX_ERROR(("Failure to start recv thread pool"));
    return -1;
  }
  //创建分发线程池
  if (m_config.getDispatch().m_async.getHostName().length()) {
    m_dispChannel = new CwxAppChannel();
    m_dispThreadPool = new CwxThreadPool(1,
      &getCommander(),
      CwxMqApp::dispatchThreadMain,
      this);
    ///启动线程
    pTss = new CwxTss*[1];
    pTss[0] = new CwxMqTss();
    ((CwxMqTss*) pTss[0])->init();
    if (0 != m_dispThreadPool->start(pTss)) {
      CWX_ERROR(("Failure to start dispatch thread pool"));
      return -1;
    }
  }
  //创建mq线程池
  if (m_config.getMq().m_mq.getHostName().length()
    || m_config.getMq().m_mq.getUnixDomain().length())
  {
    m_mqChannel = new CwxAppChannel();
    m_mqThreadPool = new CwxThreadPool(1,
      &getCommander(),
      CwxMqApp::mqFetchThreadMain,
      this);
    ///启动线程
    pTss = new CwxTss*[1];
    pTss[0] = new CwxMqTss();
    ((CwxMqTss*) pTss[0])->init();
    if (0 != m_mqThreadPool->start(pTss)) {
      CWX_ERROR(("Failure to start mq thread pool"));
      return -1;
    }
  }
  return 0;
}