コード例 #1
0
ファイル: xmlparser.cpp プロジェクト: cg8530/WorkSplace
void Parser::parse_property( std::string const& tag )
{
    std::vector<Property> propertys;
    std::string::size_type pos = tag.find( ' ' );
    if( pos == std::string::npos )
    {
        on_start( tag, propertys );
        return;
    }
    std::string tag_name = tag.substr( 0, pos );

    std::string::size_type  p1 = tag.find( '=', pos + 1 );
    while( p1 != std::string::npos 
        && pos != std::string::npos )
    {
        std::string name = property_name( tag, pos, p1 );
        std::string::size_type p2 = tag.find( '\x22', p1 );//find "
        if( p2 != std::string::npos )
        {
            std::string::size_type p3 = tag.find( '\x22', p2 + 1 );
            if( p3 != std::string::npos )
            {
                std::string value( tag.substr( p2 + 1, p3 - p2 - 1 ) );
                propertys.push_back( Property( name, value ) );
                pos = tag.find( ' ', p3 );
            }
            else
                pos = tag.find( ' ', p2 );
        }
        else if( ( p2 = tag.find( '\x27', p1 ) ) != std::string::npos )//find '
        {
            std::string::size_type p3 = tag.find( '\x27', p2 + 1 );
            if( p3 != std::string::npos )
            {
                std::string value( tag.substr( p2 + 1, p3 - p2 - 1 ) );
                propertys.push_back( Property( name, value ) );
                pos = tag.find( ' ', p3 );
            }
            else
                pos = tag.find( ' ', p2 );
        }
        else
        {
           pos = tag.find( ' ', p1 );
        }
        p1 = tag.find( '=', pos + 1 );
    }
    on_start( tag_name, propertys );
}
コード例 #2
0
  ExplorationWorkerWrapper(
      OnSuccess_t&& success,
      DeviceExplorerWidget& widg,
      Device::DeviceInterface& dev)
      : worker{new ExplorationWorker{dev}}
      , m_widget{widg}
      , m_success{std::move(success)}
  {
    QObject::connect(
        thread,
        &QThread::started,
        worker,
        [&]() { on_start(); }, // so that it runs on thread.
        Qt::QueuedConnection);

    QObject::connect(
        worker,
        &ExplorationWorker::finished,
        this,
        &ExplorationWorkerWrapper::on_finish,
        Qt::QueuedConnection);

    QObject::connect(
        worker,
        &ExplorationWorker::failed,
        this,
        &ExplorationWorkerWrapper::on_fail,
        Qt::QueuedConnection);
  }
コード例 #3
0
static RET_CODE blind_scan_msg_proc(void *p_data, os_msg_t *p_msg)
{
  bl_scan_priv_t *p_priv = (bl_scan_priv_t *)p_data;
  RET_CODE ret = SUCCESS;
  
  switch(p_msg->content)
  {
    case NC_EVT_LOCKED:
      ret = on_locked(p_priv, (nc_channel_info_t *)p_msg->para1);      
      break;
    case NC_EVT_UNLOCKED:
      ret = on_unlocked(p_priv);     
      break;
    case DVB_NIT_FOUND:
      ret = on_nit(p_priv);
      break;
    case SCAN_CMD_START_SCAN:
      ret = on_start(p_priv, p_msg);
      break;
    default:
      break;
  }
  
  return ret;
}
コード例 #4
0
ファイル: daemon.c プロジェクト: ptulpen/test1234
void no_daemon_start(char * path, int nbCoreFiles, const char *name, void (*on_start) (void),
        void (*on_stop) (void), void (*on_hup) (void)) {
    int pid;
    DEBUG_FUNCTION;

    sprintf(pid_file, "%s%s", DAEMON_PID_DIRECTORY, name);

    // check if running
    if (read_pid(name, &pid) == 0 && kill(pid, 0) == 0) {
        fprintf(stderr, "%s already running as pid: %d\n", pid_file, pid);
        return;
    }
    
    rozofs_signals_declare (path,nbCoreFiles); 

    if (write_pid(name) != 0) {
        fatal("write_pid failed: %s", strerror(errno));
        return;
    }    
    rozofs_attach_crash_cbk(remove_pid_file);
          
    if (on_stop) rozofs_attach_crash_cbk((rozofs_attach_crash_cbk_t)on_stop);
    if (on_hup)  rozofs_attach_hgup_cbk((rozofs_attach_crash_cbk_t)on_hup);
    
    on_start();
}
コード例 #5
0
void BaseElement::run() {
	if (initial_tick) {
		on_start();
		initial_tick = false;
	}
	else {
		on_tick();
	}
}
コード例 #6
0
ファイル: game.cpp プロジェクト: inksmallfrog/backup
void Game::onGame(){
    while(true){
        switch (state) {
        case GameState_Start:
            on_start();
            break;

        case GameState_Deal:
           on_deal();
            break;

        case GameState_WaitingForSpecial:
            on_waiting_for_special();
            break;

        case GameState_Give:
            on_give();
            break;

        case GameState_Back:
            on_back();
            break;

        case GameState_GetBottom:
            on_getbottom();
            break;

        case GameState_HoldUp:
            on_holdup();
            break;

        case GameState_Play:
            on_play();
            break;

        case GameState_Follow:
            on_follow();
            break;

        case GameState_CircleFinished:
            on_circlefinished();
            break;

        case GameState_NewTurn:
            on_newturn();
            break;

        case GameState_Wait:
            break;

        default:
            break;
        }
        Game::msleep(33);
    }
}
コード例 #7
0
ファイル: interface.cpp プロジェクト: adarwawan/WerewolfPaxos
interface::interface(QObject *parent) : QObject(parent)
{
    connect(&connection, SIGNAL(on_start()), this, SLOT(do_login()));
    /* Creating the user interface */
    w_login = new login;
    w_gameplay = new gameplay;
    connect(&connection, SIGNAL(on_login()), w_login, SLOT(do_wait_ready()));
    connect(&connection, SIGNAL(on_ready()), w_login, SLOT(do_wait()));
    w_login->show();
}
コード例 #8
0
ファイル: quest.c プロジェクト: vaLinBSD/nethack
void
onquest()
{
	if(u.uevent.qcompleted || Not_firsttime) return;
	if(!Is_special(&u.uz)) return;

	if(Is_qstart(&u.uz)) on_start();
	else if(Is_qlocate(&u.uz) && u.uz.dlevel > u.uz0.dlevel) on_locate();
	else if(Is_nemesis(&u.uz)) on_goal();
	return;
}
コード例 #9
0
ファイル: basic_parser.cpp プロジェクト: CFQuantum/CFQuantumd
int
basic_parser::do_message_start ()
{
    complete_ = false;
    url_.clear();
    status_.clear();
    field_.clear();
    value_.clear();
    on_start();
    return 0;
}
コード例 #10
0
void NativeEngine::handle_cmd(int32_t cmd){
	switch (cmd) {
		case APP_CMD_INPUT_CHANGED:
			on_input_changed();
			break;
		case APP_CMD_INIT_WINDOW:
			on_init_window();
			break;
		case APP_CMD_TERM_WINDOW:
			on_term_window();
			break;
		case APP_CMD_WINDOW_RESIZED:
			on_window_resized();
			break;
		case APP_CMD_WINDOW_REDRAW_NEEDED:
			on_window_redraw_needed();
			break;
		case APP_CMD_CONTENT_RECT_CHANGED:
			on_content_rect_changed();
			break;
		case APP_CMD_GAINED_FOCUS:
			on_gained_focus();
			break;
		case APP_CMD_LOST_FOCUS:
			on_lost_focus();
			break;
		case APP_CMD_CONFIG_CHANGED:
			on_config_changed();
			break;
		case APP_CMD_LOW_MEMORY:
			on_low_memory();
			break;
		case APP_CMD_START:
			on_start();
			break;
		case APP_CMD_RESUME:
			on_resume();
			break;
		case APP_CMD_SAVE_STATE:
			on_save_state();
			break;
		case APP_CMD_PAUSE:
			on_pause();
			break;
		case APP_CMD_STOP:
			on_stop();
			break;
		case APP_CMD_DESTROY:
			on_destroy();
			break;
	}
}
コード例 #11
0
ファイル: loop.c プロジェクト: Ken2713/sigram
int loop (void) {
  on_start ();
  if (binlog_enabled) {
    double t = get_double_time ();
    logprintf ("replay log start\n");
    replay_log ();
    logprintf ("replay log end in %lf seconds\n", get_double_time () - t);
    write_binlog ();
    #ifdef USE_LUA
      lua_binlog_end ();
    #endif
  } else {
    read_auth_file ();
  }
  update_prompt ();

  assert (DC_list[dc_working_num]);
  if (!DC_working || !DC_working->auth_key_id) {
//  if (auth_state == 0) {
    DC_working = DC_list[dc_working_num];
    assert (!DC_working->auth_key_id);
    dc_authorize (DC_working);
    assert (DC_working->auth_key_id);
    auth_state = 100;
    write_auth_file ();
  }
  
  if (verbosity) {
    logprintf ("Requesting info about DC...\n");
  }
  do_help_get_config ();
  net_loop (0, mcs);
  if (verbosity) {
    logprintf ("DC_info: %d new DC got\n", new_dc_num);
  }
  int i;
  for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->auth_key_id) {
    dc_authorize (DC_list[i]);
    assert (DC_list[i]->auth_key_id);
    write_auth_file ();
  }

  if (auth_state == 100 || !(DC_working->has_auth)) {
      registeringStarted();
      start_registering();
  }

  registeringFinished();
  return connect_to_server();
}
コード例 #12
0
ファイル: oni_stream.hpp プロジェクト: gaocan1992/astra
        astra_status_t start()
        {
            if (isStarted_)
                return astra_status_t::ASTRA_STATUS_SUCCESS;

            auto rc = on_start();

            if (rc == astra_status_t::ASTRA_STATUS_SUCCESS)
            {
                isStarted_ = true;
                listener_.on_started(this);
            }

            return rc;
        }
コード例 #13
0
ファイル: main.cpp プロジェクト: gitter-badger/SObjectizer
int
main()
{
	try
	{
		run_with_time_limit(
			[]()
			{
				so_5::wrapped_env_t env{
					[]( so_5::environment_t & env ) {
						env.introduce_coop( []( so_5::coop_t & coop ) {
							struct hello_sig : public so_5::signal_t {};

							auto a = coop.define_agent();
							a.on_start( [a] {
									so_5::send_delayed< hello_sig >( a,
											std::chrono::milliseconds( 25 ) );
								} );
							a.event< hello_sig >( a, [a] {
									std::cout << "Hello for agent" << std::endl;
									so_5::send_delayed< hello_sig >( a,
											std::chrono::milliseconds( 100 ) );
								} );
						} );
					}
				};

				std::this_thread::sleep_for( std::chrono::milliseconds(250) );

				env.stop();

				std::cout << "Stop signal is sent" << std::endl;

				env.join();

				std::cout << "Joined" << std::endl;
			},
			4,
			"test for stopping wrapped_env_t" );
	}
	catch( const std::exception & ex )
	{
		std::cerr << "Error: " << ex.what() << std::endl;
		return 1;
	}

	return 0;
}
コード例 #14
0
ファイル: quest.c プロジェクト: FredrIQ/nhfourk
void
onquest(const d_level * orig_lev)
{
    if (u.uevent.qcompleted || on_level(orig_lev, &u.uz))
        return;
    if (!Is_special(&u.uz))
        return;

    if (Is_qstart(&u.uz))
        on_start(orig_lev);
    else if (Is_qlocate(&u.uz))
        on_locate(orig_lev);
    else if (Is_nemesis(&u.uz))
        on_goal();
    return;
}
コード例 #15
0
static RET_CODE blind_scan_msg_proc(void *p_data, os_msg_t *p_msg)
{
  bl_scan_priv_t *p_priv = (bl_scan_priv_t *)p_data;
  RET_CODE ret = SUCCESS;
  switch(p_msg->content)
  {
    case BLIND_SCAN_EVT_LOCKED:
      ret = on_locked_evt(p_priv, (nim_channel_info_t *)p_msg->para1);
      if(ret == ERR_FAILURE)
        BS_UNLOCK();
      break;
    case BLIND_SCAN_EVT_UNLOCKED:
      ret = on_unlocked_evt(p_priv, (nim_channel_info_t *)p_msg->para1);
      break;
    case BLIND_SCAN_EVT_FINISHED:
      ret = on_finished_evt(p_priv);
    case DVB_NIT_FOUND:
      ret = on_nit(p_priv);
      break;
    case DVB_CAT_FOUND:
      ret = p_priv->hook.process_cat((void *)(p_msg->para1));
      break;
    case SCAN_CMD_START_SCAN:
      ret = on_start(p_priv, p_msg);
      break;
    case SCAN_CMD_PAUSE_SCAN:
      pause_flag = TRUE;
      break;
    case SCAN_CMD_RESUME_SCAN:
      pause_flag = FALSE;
      BS_UNLOCK_PAUSE();
      break;
    default:
      break;
  }

  return ret;
}
コード例 #16
0
ファイル: loop.c プロジェクト: tkosgrabar/tg
int loop (void) {
  on_start ();
  read_auth_file ();
  readline_active = 1;
  rl_set_prompt ("");

  assert (DC_list[dc_working_num]);
  if (auth_state == 0) {
    DC_working = DC_list[dc_working_num];
    assert (!DC_working->auth_key_id);
    dc_authorize (DC_working);
    assert (DC_working->auth_key_id);
    auth_state = 100;
    write_auth_file ();
  }
  
  if (verbosity) {
    logprintf ("Requesting info about DC...\n");
  }
  do_help_get_config ();
  net_loop (0, mcs);
  if (verbosity) {
    logprintf ("DC_info: %d new DC got\n", new_dc_num);
  }
  int i;
  for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->auth_key_id) {
    dc_authorize (DC_list[i]);
    assert (DC_list[i]->auth_key_id);
    write_auth_file ();
  }

  if (auth_state == 100) {
    if (!default_username) {
      size_t size = 0;
      char *user = 0;

      if (!user) {
        printf ("Telephone number (with '+' sign): ");         
        if (net_getline (&user, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        set_default_username (user);
      }
    }
    int res = do_auth_check_phone (default_username);
    assert (res >= 0);
    logprintf ("%s\n", res > 0 ? "phone registered" : "phone not registered");
    if (res > 0) {
      do_send_code (default_username);
      char *code = 0;
      size_t size = 0;
      printf ("Code from sms: ");
      while (1) {
        if (net_getline (&code, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        if (do_send_code_result (code) >= 0) {
          break;
        }
        printf ("Invalid code. Try again: ");
        free (code);
      }
      auth_state = 300;
    } else {
      printf ("User is not registered. Do you want to register? [Y/n] ");
      char *code;
      size_t size;
      if (net_getline (&code, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }
      if (!*code || *code == 'y') {
        printf ("Ok, starting registartion.\n");
      } else {
        printf ("Then try again\n");
        exit (EXIT_SUCCESS);
      }
      char *first_name;
      printf ("Name: ");
      if (net_getline (&first_name, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }
      char *last_name;
      printf ("Name: ");
      if (net_getline (&last_name, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }

      int dc_num = do_get_nearest_dc ();
      assert (dc_num >= 0 && dc_num <= MAX_DC_NUM && DC_list[dc_num]);
      dc_working_num = dc_num;
      DC_working = DC_list[dc_working_num];
      
      do_send_code (default_username);
      printf ("Code from sms: ");
      while (1) {
        if (net_getline (&code, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        if (do_send_code_result_auth (code, first_name, last_name) >= 0) {
          break;
        }
        printf ("Invalid code. Try again: ");
        free (code);
      }
      auth_state = 300;
    }
  }

  for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->has_auth) {
    do_export_auth (i);
    do_import_auth (i);
    DC_list[i]->has_auth = 1;
    write_auth_file ();
  }
  write_auth_file ();

  fflush (stdin);
  fflush (stdout);
  fflush (stderr);

  rl_callback_handler_install (get_default_prompt (), interpreter);
  rl_attempted_completion_function = (CPPFunction *) complete_text;
  rl_completion_entry_function = complete_none;

  do_get_dialog_list ();

  return main_loop ();
}
コード例 #17
0
ファイル: loop.c プロジェクト: AndrewShmig/tg
int loop (void) {
  on_start ();
  if (binlog_enabled) {
    replay_log ();
    write_binlog ();
  } else {
    read_auth_file ();
  }
  update_prompt ();

  assert (DC_list[dc_working_num]);
  if (!DC_working || !DC_working->auth_key_id) {
//  if (auth_state == 0) {
    DC_working = DC_list[dc_working_num];
    assert (!DC_working->auth_key_id);
    dc_authorize (DC_working);
    assert (DC_working->auth_key_id);
    auth_state = 100;
    write_auth_file ();
  }
  
  if (verbosity) {
    logprintf ("Requesting info about DC...\n");
  }
  do_help_get_config ();
  net_loop (0, mcs);
  if (verbosity) {
    logprintf ("DC_info: %d new DC got\n", new_dc_num);
  }
  int i;
  for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->auth_key_id) {
    dc_authorize (DC_list[i]);
    assert (DC_list[i]->auth_key_id);
    write_auth_file ();
  }

  if (auth_state == 100 || !(DC_working->has_auth)) {
    if (!default_username) {
      size_t size = 0;
      char *user = 0;

      if (!user) {
        printf ("Telephone number (with '+' sign): ");         
        if (net_getline (&user, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        set_default_username (user);
      }
    }
    int res = do_auth_check_phone (default_username);
    assert (res >= 0);
    logprintf ("%s\n", res > 0 ? "phone registered" : "phone not registered");
    if (res > 0) {
      do_send_code (default_username);
      char *code = 0;
      size_t size = 0;
      printf ("Code from sms: ");
      while (1) {
        if (net_getline (&code, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        if (do_send_code_result (code) >= 0) {
          break;
        }
        printf ("Invalid code. Try again: ");
        free (code);
      }
      auth_state = 300;
    } else {
      printf ("User is not registered. Do you want to register? [Y/n] ");
      char *code;
      size_t size;
      if (net_getline (&code, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }
      if (!*code || *code == 'y' || *code == 'Y') {
        printf ("Ok, starting registartion.\n");
      } else {
        printf ("Then try again\n");
        exit (EXIT_SUCCESS);
      }
      char *first_name;
      printf ("Name: ");
      if (net_getline (&first_name, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }
      char *last_name;
      printf ("Name: ");
      if (net_getline (&last_name, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }

      int dc_num = do_get_nearest_dc ();
      assert (dc_num >= 0 && dc_num <= MAX_DC_NUM && DC_list[dc_num]);
      dc_working_num = dc_num;
      DC_working = DC_list[dc_working_num];
      
      do_send_code (default_username);
      printf ("Code from sms: ");
      while (1) {
        if (net_getline (&code, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        if (do_send_code_result_auth (code, first_name, last_name) >= 0) {
          break;
        }
        printf ("Invalid code. Try again: ");
        free (code);
      }
      auth_state = 300;
    }
  }

  for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->has_auth) {
    do_export_auth (i);
    do_import_auth (i);
    DC_list[i]->has_auth = 1;
    if (binlog_enabled) {
      int *ev = alloc_log_event (8);
      ev[0] = LOG_DC_SIGNED;
      ev[1] = i;
      add_log_event (ev, 8);
    }
    write_auth_file ();
  }
  write_auth_file ();

  fflush (stdin);
  fflush (stdout);
  fflush (stderr);

  read_state_file ();
  read_secret_chat_file ();

  set_interface_callbacks ();

  do_get_difference ();
  net_loop (0, dgot);
  do_get_dialog_list ();

  return main_loop ();
}
コード例 #18
0
ファイル: mainwindow.cpp プロジェクト: mjlsuccess/SDK
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->starttime->setText("0");
    ui->simurate->setText("1");

    ///create node
    //STM32 MCU
    Simulator* stm32comm = new Simulator(library, "Sensor_stm32comm", "stm32comm", config, QTime(),1);
    stm32comm->setOutputNodesName(QList<QString>()<<"stm32comm_viewer;stm32comm_storage;doordetection;simplecollect;planner");


    VisualizationMono* stm32comm_viewer = new VisualizationMono(library, "Sensor_stm32comm", "stm32comm_viewer", config);
    stm32comm_viewer->setInputNodesName(QList<QString>()<<"stm32comm");
    stm32comm_viewer->connectExternalTrigger(0, DRAINSLOT);

    //LCamera
    Simulator* l_camera = new Simulator(library, "Sensor_Camera", "l_camera", config, QTime(),1);
    l_camera->setOutputNodesName(QList<QString>()<<"l_camera_viewer;l_camera_storage;cameralasercalib");

    VisualizationMono* l_camera_viewer = new VisualizationMono(library, "Sensor_Camera", "l_camera_viewer", config);
    l_camera_viewer->setInputNodesName(QList<QString>()<<"l_camera");
    l_camera_viewer->connectExternalTrigger(0, DRAINSLOT);


    //RCamera
    Simulator* r_camera = new Simulator(library, "Sensor_Camera", "r_camera",config, QTime(),1);
    r_camera->setOutputNodesName(QList<QString>()<<"r_camera_viewer");

    VisualizationMono*r_camera_viewer = new VisualizationMono(library, "Sensor_Camera", "r_camera_viewer", config);
    r_camera_viewer->setInputNodesName(QList<QString>()<<"r_camera");
    r_camera_viewer->connectExternalTrigger(0, DRAINSLOT);


    //Laser
    Simulator* laser = new Simulator(library, "Sensor_Laser", "laser", config, QTime(),1);
    laser->setOutputNodesName(QList<QString>()<<"laser_viewer;doordetection;simplecollect;calib;cameralasercalib");

    VisualizationMono* laser_viewer = new VisualizationMono(library, "Sensor_Laser", "laser_viewer", config);
    laser_viewer->setInputNodesName(QList<QString>()<<"laser");
    laser_viewer->connectExternalTrigger(0, DRAINSLOT);

    //camera laser calib
    ProcessorMulti* cameralasercalib = new ProcessorMulti(library, "Processor_CameraLaser", "cameralasercalib", config);
    cameralasercalib->setInputNodesName(QList<QString>()<<"l_camera"<<"laser");
    cameralasercalib->setOutputNodesName(QList<QString>()<<"cameralasercalib_viewer");
    cameralasercalib->connectExternalTrigger(1,PROCESSORSLOT);

    VisualizationMono *cameralasercalib_viewer = new VisualizationMono(library, "Processor_CameraLaser", "cameralasercalib_viewer", config);
    cameralasercalib_viewer->setInputNodesName(QList<QString>()<<"cameralasercalib");
    cameralasercalib_viewer->connectExternalTrigger(0, DRAINSLOT);

    //calibration
    VisualizationMono *laserCalib = new VisualizationMono(library, "Calibration_Laser", "calib", config);
    laserCalib->setInputNodesName(QList<QString>()<<"laser");
    laserCalib->connectExternalTrigger(0, DRAINSLOT);

    //Path
    ProcessorMono* pathPlanner = new ProcessorMono(library, "Processor_PathGenerator", "planner", config);
    pathPlanner->setInputNodesName(QList<QString>() << "stm32comm");
    pathPlanner->setOutputNodesName(QList<QString>() << "plannerViewer");
    pathPlanner->connectExternalTrigger(0, PROCESSORSLOT);

    VisualizationMono* pathPlannerViewer = new VisualizationMono(library, "Processor_PathGenerator", "plannerViewer", config);
    pathPlannerViewer->setInputNodesName(QList<QString>() << "planner");
    pathPlannerViewer->connectExternalTrigger(0, DRAINSLOT);


    //doordetection
    ProcessorMulti* doordetection = new ProcessorMulti(library,"Processor_doordetection", "doordetection",config);
    doordetection->setInputNodesName(QList<QString>()<<"laser"<<"stm32comm");
    doordetection->setOutputNodesName(QList<QString>()<<"doordetection_viewer;simplecollect");
    doordetection->connectExternalTrigger(1, PROCESSORSLOT);

    VisualizationMono* doordetection_viewer = new VisualizationMono(library,"Processor_doordetection", "doordetection_viewer", config);
    doordetection_viewer->setInputNodesName(QList<QString>()<<"doordetection");
    doordetection_viewer->connectExternalTrigger(0,DRAINSLOT);

    //simple collect
    ProcessorMulti* simplecollect = new ProcessorMulti(library,"Processor_SimpleCollect", "simplecollect", config);
    simplecollect->setInputNodesName(QList<QString>()<<"joystick"<<"laser"<<"stm32comm"<<"doordetection");
    simplecollect->setOutputNodesName(QList<QString>()<<"simplecollect_viewer");
    simplecollect->connectExternalTrigger(2, PROCESSORSLOT);

    VisualizationMono* simplecollect_viewer = new VisualizationMono(library,"Processor_SimpleCollect", "simplecollect_viewer",config);
    simplecollect_viewer->setInputNodesName(QList<QString>()<<"simplecollect");
    simplecollect_viewer->connectExternalTrigger(0,DRAINSLOT);

    ///add node
    edge.addNode(stm32comm, 1, MONITOR);
    edge.addNode(stm32comm_viewer, 0, 0);


    edge.addNode(l_camera, 1, MONITOR);
    edge.addNode(l_camera_viewer, 0, 0);

    edge.addNode(r_camera, 1, MONITOR);
    edge.addNode(r_camera_viewer, 0, 0);


    edge.addNode(laser, 1, MONITOR);
    edge.addNode(laser_viewer, 0, 0);

    edge.addNode(pathPlanner, 1, MONITOR);
    edge.addNode(pathPlannerViewer, 0, 0);


    edge.addNode(doordetection, 1, MONITOR);
    edge.addNode(doordetection_viewer, 0, 0);

    edge.addNode(cameralasercalib, 1, MONITOR);
    edge.addNode(cameralasercalib_viewer, 0, 0);

//    edge.addNode(simplecollect, 1, MONITOR);
//    edge.addNode(simplecollect_viewer, 0, 0);

    edge.addNode(laserCalib, 0, 0);

    edge.connectAll();

    connect(ui->open, SIGNAL(clicked()), &edge, SLOT(openAllNodesSlot()));
    connect(ui->close, SIGNAL(clicked()), &edge, SLOT(closeAllNodesSlot()));

    connect(ui->setvale, SIGNAL(clicked()), this, SLOT(on_setvalue()));
    connect(this, SIGNAL(sig_setstarttime(QTime)), stm32comm, SLOT(setStartTimeSlot(QTime)));
    connect(this,SIGNAL(sig_setsimurate(double)), stm32comm, SLOT(setSimulateRateSlot(double)));
    connect(this, SIGNAL(sig_setstarttime(QTime)), l_camera, SLOT(setStartTimeSlot(QTime)));
    connect(this,SIGNAL(sig_setsimurate(double)), l_camera, SLOT(setSimulateRateSlot(double)));
    connect(this, SIGNAL(sig_setstarttime(QTime)), r_camera, SLOT(setStartTimeSlot(QTime)));
    connect(this,SIGNAL(sig_setsimurate(double)), r_camera, SLOT(setSimulateRateSlot(double)));
    connect(this, SIGNAL(sig_setstarttime(QTime)), laser, SLOT(setStartTimeSlot(QTime)));
    connect(this,SIGNAL(sig_setsimurate(double)), laser, SLOT(setSimulateRateSlot(double)));

    connect(ui->sync, SIGNAL(clicked()), this, SLOT(on_sync()));
    connect(this, SIGNAL(sig_sync()), stm32comm, SLOT(syncTimeTrackSlot()));
    connect(this, SIGNAL(sig_sync()), l_camera, SLOT(syncTimeTrackSlot()));
    connect(this, SIGNAL(sig_sync()), r_camera, SLOT(syncTimeTrackSlot()));
    connect(this, SIGNAL(sig_sync()), laser, SLOT(syncTimeTrackSlot()));

    connect(ui->start, SIGNAL(clicked()), this, SLOT(on_start()));
    connect(this, SIGNAL(sig_start()), stm32comm, SLOT(startSimulatorSlot()));
    connect(this, SIGNAL(sig_start()), l_camera, SLOT(startSimulatorSlot()));
    connect(this, SIGNAL(sig_start()), r_camera, SLOT(startSimulatorSlot()));
    connect(this, SIGNAL(sig_start()), laser, SLOT(startSimulatorSlot()));

    connect(ui->stop, SIGNAL(clicked()), this, SLOT(on_stop()));
    connect(this, SIGNAL(sig_stop()), stm32comm, SLOT(stopSimulatorSlot()));
    connect(this, SIGNAL(sig_stop()), l_camera, SLOT(stopSimulatorSlot()));
    connect(this, SIGNAL(sig_stop()), r_camera, SLOT(stopSimulatorSlot()));
    connect(this, SIGNAL(sig_stop()), laser, SLOT(stopSimulatorSlot()));

    connect(ui->reset, SIGNAL(clicked()), this, SLOT(on_reset()));
    connect(this, SIGNAL(sig_sync()), stm32comm, SLOT(resetTimeTrackSlot()));
    connect(this, SIGNAL(sig_sync()), l_camera, SLOT(resetTimeTrackSlot()));
    connect(this, SIGNAL(sig_sync()), r_camera, SLOT(resetTimeTrackSlot()));
    connect(this, SIGNAL(sig_sync()), laser, SLOT(resetTimeTrackSlot()));

    ///visualazition
    QList<QWidget *> widgets;

    widgets = stm32comm_viewer->getVisualizationWidgets();
    ui->scrollArea->setWidget(widgets.front());

    widgets = laser_viewer->getVisualizationWidgets();
    ui->scrollArea_2->setWidget(widgets.front());

 //   widgets = laserCalib->getVisualizationWidgets();
 //   ui->scrollArea_3->setWidget(widgets.front());
    widgets =cameralasercalib_viewer->getVisualizationWidgets();
    ui->scrollArea_3->setWidget(widgets.front());

    widgets = l_camera_viewer->getVisualizationWidgets();
    ui->scrollArea_4->setWidget(widgets.front());

    widgets = r_camera_viewer->getVisualizationWidgets();
    ui->scrollArea_5->setWidget(widgets.front());

    widgets = doordetection_viewer->getVisualizationWidgets();
    ui->scrollArea_6->setWidget(widgets.front());

    widgets = pathPlannerViewer->getVisualizationWidgets();
    ui->scrollArea_7->setWidget(widgets.front());

//    widgets = simplecollect_viewer->getVisualizationWidgets();
//    ui->scrollArea_8->setWidget(widgets.front());

    if(MONITOR)
        ui->tabWidget->addTab(&edge, "Monitor");

}
コード例 #19
0
ファイル: loop.c プロジェクト: BUSHA/tg
int loop (void) {
  on_start ();
  if (binlog_enabled) {
    double t = get_double_time ();
    logprintf ("replay log start\n");
    replay_log ();
    logprintf ("replay log end in %lf seconds\n", get_double_time () - t);
    write_binlog ();
    #ifdef USE_LUA
      lua_binlog_end ();
    #endif
  } else {
    read_auth_file ();
  }
  update_prompt ();

  assert (DC_list[dc_working_num]);
  if (!DC_working || !DC_working->auth_key_id) {
//  if (auth_state == 0) {
    DC_working = DC_list[dc_working_num];
    assert (!DC_working->auth_key_id);
    dc_authorize (DC_working);
    assert (DC_working->auth_key_id);
    auth_state = 100;
    write_auth_file ();
  }
  
  if (verbosity) {
    logprintf ("Requesting info about DC...\n");
  }
  do_help_get_config ();
  net_loop (0, mcs);
  if (verbosity) {
    logprintf ("DC_info: %d new DC got\n", new_dc_num);
  }
  int i;
  for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->auth_key_id) {
    dc_authorize (DC_list[i]);
    assert (DC_list[i]->auth_key_id);
    write_auth_file ();
  }

  if (auth_state == 100 || !(DC_working->has_auth)) {
    if (!default_username) {
      size_t size = 0;
      char *user = 0;

      if (!user) {
        printf ("Telephone number (with '+' sign): ");         
        if (net_getline (&user, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        set_default_username (user);
      }
    }
    int res = do_auth_check_phone (default_username);
    assert (res >= 0);
    logprintf ("%s\n", res > 0 ? "phone registered" : "phone not registered");
    if (res > 0 && !register_mode) {
      do_send_code (default_username);
      char *code = 0;
      size_t size = 0;
      printf ("Code from sms (if you did not receive an SMS and want to be called, type \"call\"): ");
      while (1) {
        if (net_getline (&code, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        if (!strcmp (code, "call")) {
          printf ("You typed \"call\", switching to phone system.\n");
          do_phone_call (default_username);
          printf ("Calling you! Code: ");
          continue;
        }
        if (do_send_code_result (code) >= 0) {
          break;
        }
        printf ("Invalid code. Try again: ");
        tfree_str (code);
      }
      auth_state = 300;
    } else {
      printf ("User is not registered. Do you want to register? [Y/n] ");
      char *code;
      size_t size;
      if (net_getline (&code, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }
      if (!*code || *code == 'y' || *code == 'Y') {
        printf ("Ok, starting registartion.\n");
      } else {
        printf ("Then try again\n");
        exit (EXIT_SUCCESS);
      }
      char *first_name;
      printf ("First name: ");
      if (net_getline (&first_name, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }
      char *last_name;
      printf ("Last name: ");
      if (net_getline (&last_name, &size) == -1) {
        perror ("getline()");
        exit (EXIT_FAILURE);
      }

      int dc_num = do_get_nearest_dc ();
      assert (dc_num >= 0 && dc_num <= MAX_DC_NUM && DC_list[dc_num]);
      dc_working_num = dc_num;
      DC_working = DC_list[dc_working_num];
      
      do_send_code (default_username);
      printf ("Code from sms (if you did not receive an SMS and want to be called, type \"call\"): ");
      while (1) {
        if (net_getline (&code, &size) == -1) {
          perror ("getline()");
          exit (EXIT_FAILURE);
        }
        if (!strcmp (code, "call")) {
          printf ("You typed \"call\", switching to phone system.\n");
          do_phone_call (default_username);
          printf ("Calling you! Code: ");
          continue;
        }
        if (do_send_code_result_auth (code, first_name, last_name) >= 0) {
          break;
        }
        printf ("Invalid code. Try again: ");
        tfree_str (code);
      }
      auth_state = 300;
    }
  }

  for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->has_auth) {
    do_export_auth (i);
    do_import_auth (i);
    bl_do_dc_signed (i);
    write_auth_file ();
  }
  write_auth_file ();

  fflush (stdout);
  fflush (stderr);

  read_state_file ();
  read_secret_chat_file ();

  set_interface_callbacks ();

  do_get_difference ();
  net_loop (0, dgot);
  #ifdef USE_LUA
    lua_diff_end ();
  #endif
  send_all_unsent ();


  do_get_dialog_list ();
  if (wait_dialog_list) {
    dialog_list_got = 0;
    net_loop (0, dlgot);
  }

  return main_loop ();
}
コード例 #20
0
ファイル: chapter.cpp プロジェクト: Kazade/K4X
void Chapter::start() {
    on_start();
}
コード例 #21
0
void component::trigger_on_start()
{
  on_start();
}