コード例 #1
0
ファイル: kcategorydrawer.cpp プロジェクト: fluxer/kdelibs
void KCategoryDrawer::drawCategory(const QModelIndex &index,
                                   int /*sortRole*/,
                                   const QStyleOption &option,
                                   QPainter *painter) const
{
    painter->setRenderHint(QPainter::Antialiasing);

    const QString category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
    const QRect optRect = option.rect;
    QFont font(QApplication::font());
    font.setBold(true);
    const QFontMetrics fontMetrics = QFontMetrics(font);

    QColor outlineColor = option.palette.text().color();
    outlineColor.setAlphaF(0.35);

    //BEGIN: top left corner
    {
        painter->save();
        painter->setPen(outlineColor);
        const QPointF topLeft(optRect.topLeft());
        QRectF arc(topLeft, QSizeF(4, 4));
        arc.translate(0.5, 0.5);
        painter->drawArc(arc, 1440, 1440);
        painter->restore();
    }
    //END: top left corner

    //BEGIN: left vertical line
    {
        QPoint start(optRect.topLeft());
        start.ry() += 3;
        QPoint verticalGradBottom(optRect.topLeft());
        verticalGradBottom.ry() += fontMetrics.height() + 5;
        QLinearGradient gradient(start, verticalGradBottom);
        gradient.setColorAt(0, outlineColor);
        gradient.setColorAt(1, Qt::transparent);
        painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient);
    }
    //END: left vertical line

    //BEGIN: horizontal line
    {
        QPoint start(optRect.topLeft());
        start.rx() += 3;
        QPoint horizontalGradTop(optRect.topLeft());
        horizontalGradTop.rx() += optRect.width() - 6;
        painter->fillRect(QRect(start, QSize(optRect.width() - 6, 1)), outlineColor);
    }
    //END: horizontal line

    //BEGIN: top right corner
    {
        painter->save();
        painter->setPen(outlineColor);
        QPointF topRight(optRect.topRight());
        topRight.rx() -= 4;
        QRectF arc(topRight, QSizeF(4, 4));
        arc.translate(0.5, 0.5);
        painter->drawArc(arc, 0, 1440);
        painter->restore();
    }
    //END: top right corner

    //BEGIN: right vertical line
    {
        QPoint start(optRect.topRight());
        start.ry() += 3;
        QPoint verticalGradBottom(optRect.topRight());
        verticalGradBottom.ry() += fontMetrics.height() + 5;
        QLinearGradient gradient(start, verticalGradBottom);
        gradient.setColorAt(0, outlineColor);
        gradient.setColorAt(1, Qt::transparent);
        painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient);
    }
    //END: right vertical line

    //BEGIN: text
    {
        QRect textRect(option.rect);
        textRect.setTop(textRect.top() + 7);
        textRect.setLeft(textRect.left() + 7);
        textRect.setHeight(fontMetrics.height());
        textRect.setRight(textRect.right() - 7);

        painter->save();
        painter->setFont(font);
        QColor penColor(option.palette.text().color());
        penColor.setAlphaF(0.6);
        painter->setPen(penColor);
        painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, category);
        painter->restore();
    }
    //END: text
}
コード例 #2
0
ファイル: ServiceCoreMain.cpp プロジェクト: boskee/Desurium-1
	Server() : IPC::PipeServer("ServiceCore", 1, true)
	{
		start();
	}
コード例 #3
0
bool RegionDesc::Block::contains(SrcKey sk) const {
  return sk >= start() && sk <= last();
}
コード例 #4
0
 void stop()
 {
     jack_Log ("jack stop \n");
     start (nullptr);
     client.deactivate();
 }
コード例 #5
0
ファイル: ciFlyCap.cpp プロジェクト: afrancois/BanTheRewind
// Set pixel format
bool ciFlyCap::Obj::setPixelFormat(const PixelFormat & value) 
{

	// Return false if not changing value or no camera
	if (mRawImage.GetPixelFormat() == value)
		return false;

	// Store values in case we need to restore them
	SurfaceChannelOrder mPrevSurfaceChannelOrder = mSurfaceChannelOrder;
	int32_t mPrevChannelCount = mChannelCount;
	mChannelCount = -1;

	// Key on pixel format
	switch (value)
	{
	case PixelFormat::PIXEL_FORMAT_411YUV8:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_422YUV8:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_444YUV8:
		mSurfaceChannelOrder = SurfaceChannelOrder::BGR;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_BGR:
		mSurfaceChannelOrder = SurfaceChannelOrder::BGR;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_BGRU:
		mSurfaceChannelOrder = SurfaceChannelOrder::BGRA;
		mChannelCount = 4;
		break;
	case PixelFormat::PIXEL_FORMAT_MONO12:
		mSurfaceChannelOrder = SurfaceChannelOrder::CHAN_RED;
		mChannelCount = 1;
		break;
	case PixelFormat::PIXEL_FORMAT_MONO16:
		mSurfaceChannelOrder = SurfaceChannelOrder::CHAN_RED;
		mChannelCount = 1;
		break;
	case PixelFormat::PIXEL_FORMAT_MONO8:
		mSurfaceChannelOrder = SurfaceChannelOrder::CHAN_RED;
		mChannelCount = 1;
		break;
	case PixelFormat::PIXEL_FORMAT_RAW12:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_RAW16:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_RAW8:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_RGB16:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_RGB8:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_RGBU:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGBA;
		mChannelCount = 3;
		break;
	case PixelFormat::PIXEL_FORMAT_S_MONO16:
		mSurfaceChannelOrder = SurfaceChannelOrder::CHAN_RED;
		mChannelCount = 1;
		break;
	case PixelFormat::PIXEL_FORMAT_S_RGB16:
		mSurfaceChannelOrder = SurfaceChannelOrder::RGB;
		mChannelCount = 3;
		break;
	case PixelFormat::UNSPECIFIED_PIXEL_FORMAT:
		mSurfaceChannelOrder = SurfaceChannelOrder::UNSPECIFIED;
		mChannelCount = -1;
		break;
	}

	// If input value format is unspecifed, restore values and bail
	if (mChannelCount < 0)
	{
		mChannelCount = mPrevChannelCount;
		mSurfaceChannelOrder = mPrevSurfaceChannelOrder;
		return false;
	}

	// Update dimensions
	mErr = mRawImage.SetDimensions(mRawImage.GetRows(), mRawImage.GetCols(), mRawImage.GetStride(), value, mRawImage.GetBayerTileFormat());
	if (mErr != PGRERROR_OK)
	{
		showError();
		return false;
	}

	// Re-start input if we're previously capturing
	if (mCapturing)
	{
		stop();
		return start();
	}

	// Just return if we weren't already capturing
	return true;

}
コード例 #6
0
ファイル: Timer.cpp プロジェクト: SaintDubious/DubiousEngine
Timer::Timer()
{
    start();
}
コード例 #7
0
ファイル: sf0x.cpp プロジェクト: JW-CHOI/Firmware
void
SF0X::cycle()
{
	/* fds initialized? */
	if (_fd < 0) {
		/* open fd */
		_fd = ::open(_port, O_RDWR | O_NOCTTY | O_NONBLOCK);
	}

	/* collection phase? */
	if (_collect_phase) {

		/* perform collection */
		int collect_ret = collect();

		if (collect_ret == -EAGAIN) {
			/* reschedule to grab the missing bits, time to transmit 8 bytes @ 9600 bps */
			work_queue(HPWORK,
				   &_work,
				   (worker_t)&SF0X::cycle_trampoline,
				   this,
				   USEC2TICK(1042 * 8));
			return;
		}

		if (OK != collect_ret) {

			/* we know the sensor needs about four seconds to initialize */
			if (hrt_absolute_time() > 5 * 1000 * 1000LL && _consecutive_fail_count < 5) {
				DEVICE_LOG("collection error #%u", _consecutive_fail_count);
			}
			_consecutive_fail_count++;

			/* restart the measurement state machine */
			start();
			return;
		} else {
			/* apparently success */
			_consecutive_fail_count = 0;
		}

		/* next phase is measurement */
		_collect_phase = false;

		/*
		 * Is there a collect->measure gap?
		 */
		if (_measure_ticks > USEC2TICK(SF0X_CONVERSION_INTERVAL)) {

			/* schedule a fresh cycle call when we are ready to measure again */
			work_queue(HPWORK,
				   &_work,
				   (worker_t)&SF0X::cycle_trampoline,
				   this,
				   _measure_ticks - USEC2TICK(SF0X_CONVERSION_INTERVAL));

			return;
		}
	}

	/* measurement phase */
	if (OK != measure()) {
		DEVICE_LOG("measure error");
	}

	/* next phase is collection */
	_collect_phase = true;

	/* schedule a fresh cycle call when the measurement is done */
	work_queue(HPWORK,
		   &_work,
		   (worker_t)&SF0X::cycle_trampoline,
		   this,
		   USEC2TICK(SF0X_CONVERSION_INTERVAL));
}
コード例 #8
0
ファイル: gridwidget.cpp プロジェクト: docsteer/sacnview
void GridWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter(this);

    qreal wantedHeight = CELL_HEIGHT * (ROW_COUNT + 1);
    qreal wantedWidth = FIRST_COL_WIDTH + CELL_WIDTH * COL_COUNT;

    qreal scaleWidth = width()/wantedWidth;
    qreal scaleHeight = height()/ wantedHeight;
    qreal minScale = qMin(scaleWidth, scaleHeight);

    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.translate((width()-minScale*wantedWidth) /2,0);
    painter.scale(minScale,minScale);

    painter.fillRect(QRectF(0,0, wantedWidth, wantedHeight), QBrush(QColor("#FFF")));

    painter.setPen(textColor);
    painter.setFont(QFont("Segoe UI", 8));
    for(int row=1; row<ROW_COUNT+1; row++)
    {
        QRect textRect(0, row*CELL_HEIGHT, FIRST_COL_WIDTH, CELL_HEIGHT);
        QString rowLabel = QString("%1 - %2")
                .arg(1+(row-1)*32)
                .arg((row)*32);
        painter.drawText(textRect, rowLabel, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
    }
    for(int col=0; col<COL_COUNT; col++)
    {
        QRect textRect(FIRST_COL_WIDTH + col*CELL_WIDTH, 0, CELL_WIDTH, CELL_HEIGHT);
        QString rowLabel = QString("%1")
                .arg(col+1);
        painter.drawText(textRect, rowLabel, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
    }
    for(int row=0; row<ROW_COUNT; row++)
        for(int col=0; col<COL_COUNT; col++)
        {
            int address = row*COL_COUNT + col;
            QRect textRect(FIRST_COL_WIDTH + col*CELL_WIDTH, (row+1)*CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT);
            QString value = m_values[address];

            if(!value.isEmpty())
            {
                QColor fillColor = m_colors[address];

                QString rowLabel = value;
                painter.fillRect(textRect, fillColor);
                painter.drawText(textRect, rowLabel, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
            }

        }

    painter.setPen(gridLineColor);

    for(int row=0; row<ROW_COUNT + 1; row++)
    {
        QPoint start(0, row*CELL_HEIGHT);
        QPoint end(wantedWidth, row*CELL_HEIGHT);
        painter.drawLine(start, end);
    }
    for(int col=0; col<COL_COUNT + 1; col++)
    {
        QPoint start(FIRST_COL_WIDTH + col*CELL_WIDTH, 0);
        QPoint end(FIRST_COL_WIDTH + col*CELL_WIDTH, wantedHeight);
        painter.drawLine(start, end);
    }

    // Draw the highlight for the selected one
    if(m_selectedAddress>-1)
    {
        int col = m_selectedAddress % 32;
        int row = m_selectedAddress / 32;
        QRect textRect(FIRST_COL_WIDTH + col*CELL_WIDTH, (row+1)*CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT);
        painter.setPen(QColor(Qt::black));
        painter.drawRect(textRect);
    }
}
コード例 #9
0
ファイル: dummymain.c プロジェクト: ForrestWeston/cs483-pa4
int main(int argc, char* argv[])
{
	int rank, p;
	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &p);

	if (argc != 6) {
		printf("ERROR: Incorrect number of args\n");
		printf("A = Constant\n");
		printf("B = Constant\n");
		printf("P = Prime Constant\n");
		printf("seed = seed for generation (x)\n");
		printf("itt = number of itterations\n");
		return -1;
	}

	struct context* ctx = malloc(sizeof(struct context));
	struct timer tParallel;
	struct timer tSerial;

	ctx->rank = rank;
	ctx->numprocs = p;

	ctx->A = atoi(argv[1]);
	ctx->B = atoi(argv[2]);
	ctx->P = atoi(argv[3]);
	ctx->seed = atoi(argv[4]);
	ctx->itt = atoi(argv[5]);
	ctx->size = ctx->itt/ctx->numprocs;
	//printf("ctx->size: %" PRIu64 "\n", ctx->size);

	if(rank == 0) {
		printf("Number procs: %d\n", ctx->numprocs);
	}

	int n = (int)log2(ctx->numprocs);
	if (1 << n != ctx->numprocs) {
		printf("number of procs must be power of 2\n");
		exit(1);
	}

	uint64_t* parallelresults = malloc(sizeof(uint64_t*)* ctx->itt);
	uint64_t* serialresults = malloc(sizeof(uint64_t*)* ctx->itt);


	if (rank == 0) {
		start(&tSerial);
		serialresults = SerialGen(ctx);
		stop(&tSerial);
	}

	start(&tParallel);
	parallelresults = ParallelGen(ctx);
	stop(&tParallel);

	if (rank == 0) {
		int pass = memcmp(parallelresults, serialresults, sizeof(parallelresults));
		printf("PASS: %d\n", pass);
		printf("Parallel Time: %dms\n", get_ms(&tParallel));
		printf("Serial Time: %dms\n",get_ms(&tSerial));
	}


	MPI_Finalize();
	return 0;
}
コード例 #10
0
int
BMI055_gyro::ioctl(struct file *filp, int cmd, unsigned long arg)
{
	switch (cmd) {

	case SENSORIOCSPOLLRATE: {
			switch (arg) {

			/* switching to manual polling */
			case SENSOR_POLLRATE_MANUAL:
				stop();
				_call_interval = 0;
				return OK;

			/* external signalling not supported */
			case SENSOR_POLLRATE_EXTERNAL:

			/* zero would be bad */
			case 0:
				return -EINVAL;

			/* set default/max polling rate */
			case SENSOR_POLLRATE_MAX:
				return ioctl(filp, SENSORIOCSPOLLRATE, BMI055_GYRO_MAX_RATE);

			case SENSOR_POLLRATE_DEFAULT:
				return ioctl(filp, SENSORIOCSPOLLRATE, BMI055_GYRO_DEFAULT_RATE);

			/* adjust to a legal polling interval in Hz */
			default: {
					/* do we need to start internal polling? */
					bool want_start = (_call_interval == 0);

					/* convert hz to hrt interval via microseconds */
					unsigned ticks = 1000000 / arg;

					/* check against maximum rate */
					if (ticks < 1000) {
						return -EINVAL;
					}

					float cutoff_freq_hz_gyro = _gyro_filter_x.get_cutoff_freq();
					float sample_rate = 1.0e6f / ticks;
					_gyro_filter_x.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
					_gyro_filter_y.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);
					_gyro_filter_z.set_cutoff_frequency(sample_rate, cutoff_freq_hz_gyro);

					/* update interval for next measurement */
					_call_interval = ticks;

					/*
					  set call interval faster than the sample time. We
					  then detect when we have duplicate samples and reject
					  them. This prevents aliasing due to a beat between the
					  stm32 clock and the bmi055 clock
					 */
					_call.period = _call_interval - BMI055_TIMER_REDUCTION;

					/* if we need to start the poll state machine, do it */
					if (want_start) {
						start();
					}

					return OK;
				}
			}
		}

	case SENSORIOCGPOLLRATE:
		if (_call_interval == 0) {
			return SENSOR_POLLRATE_MANUAL;
		}

		return 1000000 / _call_interval;

	case SENSORIOCRESET:
		return reset();

	case SENSORIOCSQUEUEDEPTH: {
			/* lower bound is mandatory, upper bound is a sanity check */
			if ((arg < 1) || (arg > 100)) {
				return -EINVAL;
			}

			irqstate_t flags = px4_enter_critical_section();

			if (!_gyro_reports->resize(arg)) {
				px4_leave_critical_section(flags);
				return -ENOMEM;
			}

			px4_leave_critical_section(flags);

			return OK;
		}

	case GYROIOCGSAMPLERATE:
		return _gyro_sample_rate;

	case GYROIOCSSAMPLERATE:
		return gyro_set_sample_rate(arg);

	case GYROIOCSSCALE:
		/* copy scale in */
		memcpy(&_gyro_scale, (struct gyro_calibration_s *) arg, sizeof(_gyro_scale));
		return OK;

	case GYROIOCGSCALE:
		/* copy scale out */
		memcpy((struct gyro_calibration_s *) arg, &_gyro_scale, sizeof(_gyro_scale));
		return OK;

	case GYROIOCSRANGE:
		return set_gyro_range(arg);

	case GYROIOCGRANGE:
		return (unsigned long)(_gyro_range_rad_s * 180.0f / M_PI_F + 0.5f);

	case GYROIOCSELFTEST:
		return gyro_self_test();

	default:
		/* give it to the superclass */
		return SPI::ioctl(filp, cmd, arg);
	}
}
コード例 #11
0
ファイル: history.c プロジェクト: saeedSarpas/mytools
int main(int argc, char *argv[])
{
  if(argc != 2){
    printf("[Error] You should specify path to the configuration file.\n");
    printf("        ./triplematches /path/to/the/configuration/file\n");
    exit(EXIT_FAILURE);
  }

  mh_history_params *p = load_params(argv[1]);

  // Loading Cross Runs Matching Halos
  clock_t _l_m_h_ = start("Loading cross runs matching halos");
  avltree *matches_512_256 = load_mh(p->matches_512_256);
  avltree *matches_1024_512 = load_mh(p->matches_1024_512);
  done(_l_m_h_);

  // Loading Internal Matching halos
  clock_t _l_i_m_ = start("Loading internal matches");
  avltree **matches_256 = allocate(p->num_match_files, sizeof(avltree*));
  avltree **matches_512 = allocate(p->num_match_files, sizeof(avltree*));
  avltree **matches_1024 = allocate(p->num_match_files, sizeof(avltree*));

  int i;
  for(i = 0; i < p->num_match_files; i++){
    matches_256[i] = load_mh(p->matches_256[i]);
    matches_512[i] = load_mh(p->matches_512[i]);
    matches_1024[i] = load_mh(p->matches_1024[i]);
  }
  done(_l_i_m_);

  // Loading halo files
  clock_t _l_h_ = start("Loading halo files\n");
  halofinder **rockstar[3];

  for(i = 0; i < 3; i++)
    rockstar[i] = allocate(p->num_halo_files, sizeof(*rockstar[i]));

  int progress = -1;
  for(i = 0; i < p->num_halo_files; i ++){
    rockstar[0][i] = load_rockstar_bin(p->halos_256[i]);
    rockstar[1][i] = load_rockstar_bin(p->halos_512[i]);
    rockstar[2][i] = load_rockstar_bin(p->halos_1024[i]);
    progress = simple_loading(progress, i, p->num_halo_files - 1);
  }
  done(_l_h_);

  // Generating triple cascade
  clock_t _g_t_c_ = start("Generating triple cascade of matching halos");
  vector **cascades = triplecascade(matches_512_256,
                                    matches_1024_512,
                                    rockstar[0][p->num_halo_files - 1]->header->num_halos,
                                    matches_256,
                                    matches_512,
                                    matches_1024,
                                    p->num_match_files);
  done(_g_t_c_);

  // Add modules here to study the evolution of the halo properties along the
  // history of the simulations
  clock_t _a_h_ = start("Generating accretion history");
  accretion_history(rockstar, cascades, p);
  done(_a_h_);

  // Cleaning up...
  clock_t _c_u_ = start("Cleaning Up...");

  dispose_triplecascade(&cascades);

  for(i = 0; i < p->num_halo_files; i++){
    dispose_halofinder(&rockstar[0][i]);
    dispose_halofinder(&rockstar[1][i]);
    dispose_halofinder(&rockstar[2][i]);
  }

  free(rockstar[0]);
  free(rockstar[1]);
  free(rockstar[2]);

  for(i = 0; i < p->num_match_files; i++){
    dispose_avltree(&matches_256[i]);
    dispose_avltree(&matches_512[i]);
    dispose_avltree(&matches_1024[i]);
  }

  free(matches_256);
  free(matches_512);
  free(matches_1024);

  dispose_avltree(&matches_512_256);
  dispose_avltree(&matches_1024_512);

  dispose_params(&p);
  done(_c_u_);

  return 0;
}
コード例 #12
0
ファイル: coll_base_alltoall.c プロジェクト: jsharpe/ompi
int ompi_coll_base_alltoall_intra_basic_linear(const void *sbuf, int scount,
                                               struct ompi_datatype_t *sdtype,
                                               void* rbuf, int rcount,
                                               struct ompi_datatype_t *rdtype,
                                               struct ompi_communicator_t *comm,
                                               mca_coll_base_module_t *module)
{
    int i, rank, size, err, nreqs, line;
    char *psnd, *prcv;
    MPI_Aint lb, sndinc, rcvinc;
    ompi_request_t **req, **sreq, **rreq;
    mca_coll_base_module_t *base_module = (mca_coll_base_module_t*) module;
    mca_coll_base_comm_t *data = base_module->base_data;

    if (MPI_IN_PLACE == sbuf) {
        return mca_coll_base_alltoall_intra_basic_inplace (rbuf, rcount, rdtype,
                                                            comm, module);
    }

    /* Initialize. */

    size = ompi_comm_size(comm);
    rank = ompi_comm_rank(comm);

    OPAL_OUTPUT((ompi_coll_base_framework.framework_output,
                 "ompi_coll_base_alltoall_intra_basic_linear rank %d", rank));

    err = ompi_datatype_get_extent(sdtype, &lb, &sndinc);
    if (OMPI_SUCCESS != err) {
        return err;
    }
    sndinc *= scount;

    err = ompi_datatype_get_extent(rdtype, &lb, &rcvinc);
    if (OMPI_SUCCESS != err) {
        return err;
    }
    rcvinc *= rcount;

    /* simple optimization */

    psnd = ((char *) sbuf) + (ptrdiff_t)rank * sndinc;
    prcv = ((char *) rbuf) + (ptrdiff_t)rank * rcvinc;

    err = ompi_datatype_sndrcv(psnd, scount, sdtype, prcv, rcount, rdtype);
    if (MPI_SUCCESS != err) {
        return err;
    }

    /* If only one process, we're done. */

    if (1 == size) {
        return MPI_SUCCESS;
    }

    /* Initiate all send/recv to/from others. */

    req = rreq = coll_base_comm_get_reqs(data, (size - 1) * 2);

    prcv = (char *) rbuf;
    psnd = (char *) sbuf;

    /* Post all receives first -- a simple optimization */

    for (nreqs = 0, i = (rank + 1) % size; i != rank;
         i = (i + 1) % size, ++rreq, ++nreqs) {
        err = MCA_PML_CALL(irecv_init
                           (prcv + (ptrdiff_t)i * rcvinc, rcount, rdtype, i,
                           MCA_COLL_BASE_TAG_ALLTOALL, comm, rreq));
        if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
    }

    /* Now post all sends in reverse order
       - We would like to minimize the search time through message queue
         when messages actually arrive in the order in which they were posted.
     */
    sreq = rreq;
    for (i = (rank + size - 1) % size; i != rank;
         i = (i + size - 1) % size, ++sreq, ++nreqs) {
        err = MCA_PML_CALL(isend_init
                           (psnd + (ptrdiff_t)i * sndinc, scount, sdtype, i,
                           MCA_COLL_BASE_TAG_ALLTOALL,
                           MCA_PML_BASE_SEND_STANDARD, comm, sreq));
        if (MPI_SUCCESS != err) { line = __LINE__; goto err_hndl; }
    }

    /* Start your engines.  This will never return an error. */

    MCA_PML_CALL(start(nreqs, req));

    /* Wait for them all.  If there's an error, note that we don't
     * care what the error was -- just that there *was* an error.  The
     * PML will finish all requests, even if one or more of them fail.
     * i.e., by the end of this call, all the requests are free-able.
     * So free them anyway -- even if there was an error, and return
     * the error after we free everything. */

    err = ompi_request_wait_all(nreqs, req, MPI_STATUSES_IGNORE);

 err_hndl:
    if( MPI_SUCCESS != err ) {
        OPAL_OUTPUT( (ompi_coll_base_framework.framework_output,"%s:%4d\tError occurred %d, rank %2d",
                      __FILE__, line, err, rank) );
    }
    /* Free the reqs in all cases as they are persistent requests */
    ompi_coll_base_free_reqs(req, nreqs);

    /* All done */
    return err;
}
コード例 #13
0
ファイル: gui.cpp プロジェクト: Jellofishi/Desktop
void AutoMateUi::applySelected() {
	emit start();
}
コード例 #14
0
ファイル: lis3mdl.cpp プロジェクト: LiYuanxing/Firmware
int
LIS3MDL::ioctl(struct file *file_pointer, int cmd, unsigned long arg)
{
	unsigned dummy = 0;

	switch (cmd) {
	case SENSORIOCSPOLLRATE: {
			switch (arg) {

			/* zero would be bad */
			case 0:
				return -EINVAL;

			case SENSOR_POLLRATE_DEFAULT: {
					/* do we need to start internal polling? */
					bool not_started = (_measure_ticks == 0);

					/* set interval for next measurement to minimum legal value */
					_measure_ticks = USEC2TICK(LIS3MDL_CONVERSION_INTERVAL);

					/* if we need to start the poll state machine, do it */
					if (not_started) {
						start();
					}

					return PX4_OK;
				}

			/* Uses arg (hz) for a custom poll rate */
			default: {
					/* do we need to start internal polling? */
					bool not_started = (_measure_ticks == 0);

					/* convert hz to tick interval via microseconds */
					unsigned ticks = USEC2TICK(1000000 / arg);

					/* update interval for next measurement */
					_measure_ticks = ticks;

					/* if we need to start the poll state machine, do it */
					if (not_started) {
						start();
					}

					return PX4_OK;
				}
			}
		}

	case SENSORIOCRESET:
		return reset();

	case MAGIOCSRANGE:
		return set_range(arg);

	case MAGIOCSSCALE:
		/* set new scale factors */
		memcpy(&_scale, (struct mag_calibration_s *)arg, sizeof(_scale));
		return 0;

	case MAGIOCGSCALE:
		/* copy out scale factors */
		memcpy((struct mag_calibration_s *)arg, &_scale, sizeof(_scale));
		return 0;

	case MAGIOCCALIBRATE:
		return calibrate(file_pointer, arg);

	case MAGIOCEXSTRAP:
		return set_excitement(arg);

	case MAGIOCGEXTERNAL:
		DEVICE_DEBUG("MAGIOCGEXTERNAL in main driver");
		return _interface->ioctl(cmd, dummy);

	case DEVIOCGDEVICEID:
		return _interface->ioctl(cmd, dummy);

	default:
		/* give it to the superclass */
		return CDev::ioctl(file_pointer, cmd, arg);
	}
}
コード例 #15
0
ファイル: mainwindow.cpp プロジェクト: danielmux/sgdr_tsim
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *      MainWindow Class Constructor                                                                                           *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Main window layout including creation / allocation of data viewers                                                     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    reorderBufferViewer = new ReorderBufferViewer;
    reservationStationViewer = new ReservationStationsViewer;
    registerFileViewer = new RegisterFileViewer;
    memoryViewer = new MemoryViewer;

    setCentralWidget(reorderBufferViewer);              // ROB Viewer is the central table

    QDockWidget *rsvWidget = new QDockWidget;
    rsvWidget->setWidget(reservationStationViewer);     // Reservation stations viewer is a docking table
    rsvWidget->setWindowTitle(QString("Reservation Stations"));

    QDockWidget *rfvWidget = new QDockWidget;
    rfvWidget->setWidget(registerFileViewer);           // Register array viewer is a docking table
    rfvWidget->setWindowTitle(QString("Register File"));
    rfvWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum);

    QDockWidget *mvWidget = new QDockWidget;
    mvWidget->setWidget(memoryViewer);                  // Memory viewer is a docking table
    mvWidget->setWindowTitle(QString("Memory"));

    addDockWidget(Qt::BottomDockWidgetArea, rsvWidget); // Reservation stations monitor is at the bottom
    addDockWidget(Qt::LeftDockWidgetArea, rfvWidget);   // Register array monitor is at the left
    addDockWidget(Qt::RightDockWidgetArea, mvWidget);   // Memory monitor is at the right

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Main menu description                                                                                                  *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    openAction = new QAction(tr("&Open"), this);            // Option not implemented yet: intended to open assembler code
                                                            //  text and run parser
    startAction = new QAction(tr("&Start"), this);          // Start processing: it basically enables the timer
    stopAction = new QAction(tr("&Stop"), this);            // Stop processing: disables the timer

    fileMenu = menuBar()->addMenu(tr("&File"));             // File menu only contains the Open command so far
    fileMenu->addAction(openAction);

    processingMenu = menuBar()->addMenu(tr("&Processing")); // Processing menu contains Start and Stop commands
    processingMenu->addAction(startAction);
    processingMenu->addAction(stopAction);

    mainTimer = new QTimer;                                 // Timer instantiation for 1-Hz operation
    mainTimer->setInterval(1000);
    mainTimer->setSingleShot(false);

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Signal-slot bindings                                                                                                   *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));       // Open commands shows Open File dialog

    connect(startAction, SIGNAL(triggered()), mainTimer, SLOT(start()));    // Start command triggers timer operation
    connect(stopAction, SIGNAL(triggered()), mainTimer, SLOT(stop()));      // Stop command stops timer

    connect(mainTimer, SIGNAL(timeout()), this, SLOT(cycleProcess()));      // Timer periodically triggers cycleProcess method

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *  Database initialization example                                                                                        *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    memoryData = (MemoryData *)malloc(10000);                           // Memory data structure
    registerFileData = (RegisterFileData *)malloc(10000);               // Register array data structure
    reorderBufferData = (ReorderBufferData *)malloc(10000);             // ROB data structure
    reservationStationsData = (ReservationStationsData *)malloc(10000); // Reservation stations data structure

    srand(time(NULL));  // Random generator initializer for databse management example below
}
コード例 #16
0
/**
* Constructor.
* @see SyncImageHandler
*/
SyncImageRig::SyncImageRig() :
  SyncImageTransportHandler() // don't forget to call base constructor first
{
  if (!start())
    _nh.shutdown();
}
コード例 #17
0
ファイル: Timer.cpp プロジェクト: SaintDubious/DubiousEngine
int64_t Timer::restart()
{
    int64_t milli = elapsed();
    start();
    return milli;
}
コード例 #18
0
ファイル: MobileSimulator.cpp プロジェクト: MrSnowman/angel2d
void MobileSimulator::MouseUpEvent(Vec2i screenCoordinates, MouseButtonInput button)
{
	_multiGestureOngoing = false;
	_gestureType = NONE;
	_mouseDown = false;

	TouchList* tl = &TouchListener::GetTouchList();
	
	if (theInput.IsKeyDown(ANGEL_KEY_LEFTCONTROL) || theInput.IsKeyDown(ANGEL_KEY_RIGHTCONTROL))
	{
		TouchList::iterator it = tl->begin();
		while (it != tl->end())
		{
			SendTouchNotifiers((*it), TOUCH_END);
			delete (*it);
			it = tl->erase(it);
		}
	}
	else
	{
		// just a single touch, but we'll iterate anyway
		TouchList::iterator it = tl->begin();
		while (it != tl->end())
		{
			if ( (theWorld.GetCurrentTimeSeconds() - (*it)->MotionStartTime) < SWIPE_MAX_DURATION)
			{
				Vector2 start((*it)->StartingPoint);
				Vector2 end((*it)->CurrentPoint);
				Vector2 motion = end - start;
				if (motion.LengthSquared() >= (SWIPE_MIN_DISTANCE * SWIPE_MIN_DISTANCE))
				{
					float angle = MathUtil::ToDegrees(acos(Vector2::Dot(Vector2::UnitX, Vector2::Normalize(motion))));
					if (motion.Y > 0.0f)
					{
						angle = 360.0f - angle;
					}

					if      ( (angle > 45.0f) && (angle <= 135.0f) )
					{
						// swipe up
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeUp"));
					}
					else if ( (angle > 135.0f) && (angle <= 225.0f) )
					{
						// swipe left
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeLeft"));
					}
					else if ( (angle > 225.0f) && (angle <= 315.0f) )
					{
						// swipe down
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeDown"));
					}
					else
					{
						// swipe right
						theSwitchboard.Broadcast(new Message("MultiTouchSwipeRight"));
					}
				}
			}
			SendTouchNotifiers((*it), TOUCH_END);
			delete (*it);
			it = tl->erase(it);
		}
	}
}
コード例 #19
0
ファイル: sf0x.cpp プロジェクト: JW-CHOI/Firmware
int
SF0X::ioctl(struct file *filp, int cmd, unsigned long arg)
{
	switch (cmd) {

	case SENSORIOCSPOLLRATE: {
			switch (arg) {

			/* switching to manual polling */
			case SENSOR_POLLRATE_MANUAL:
				stop();
				_measure_ticks = 0;
				return OK;

			/* external signalling (DRDY) not supported */
			case SENSOR_POLLRATE_EXTERNAL:

			/* zero would be bad */
			case 0:
				return -EINVAL;

			/* set default/max polling rate */
			case SENSOR_POLLRATE_MAX:
			case SENSOR_POLLRATE_DEFAULT: {
					/* do we need to start internal polling? */
					bool want_start = (_measure_ticks == 0);

					/* set interval for next measurement to minimum legal value */
					_measure_ticks = USEC2TICK(SF0X_CONVERSION_INTERVAL);

					/* if we need to start the poll state machine, do it */
					if (want_start) {
						start();
					}

					return OK;
				}

			/* adjust to a legal polling interval in Hz */
			default: {

					/* do we need to start internal polling? */
					bool want_start = (_measure_ticks == 0);

					/* convert hz to tick interval via microseconds */
					unsigned ticks = USEC2TICK(1000000 / arg);

					/* check against maximum rate */
					if (ticks < USEC2TICK(SF0X_CONVERSION_INTERVAL)) {
						return -EINVAL;
					}

					/* update interval for next measurement */
					_measure_ticks = ticks;

					/* if we need to start the poll state machine, do it */
					if (want_start) {
						start();
					}

					return OK;
				}
			}
		}

	case SENSORIOCGPOLLRATE:
		if (_measure_ticks == 0) {
			return SENSOR_POLLRATE_MANUAL;
		}

		return (1000 / _measure_ticks);

	case SENSORIOCSQUEUEDEPTH: {
			/* lower bound is mandatory, upper bound is a sanity check */
			if ((arg < 1) || (arg > 100)) {
				return -EINVAL;
			}

			irqstate_t flags = irqsave();

			if (!_reports->resize(arg)) {
				irqrestore(flags);
				return -ENOMEM;
			}

			irqrestore(flags);

			return OK;
		}

	case SENSORIOCGQUEUEDEPTH:
		return _reports->size();

	case SENSORIOCRESET:
		/* XXX implement this */
		return -EINVAL;

	case RANGEFINDERIOCSETMINIUMDISTANCE: {
			set_minimum_distance(*(float *)arg);
			return 0;
		}
		break;

	case RANGEFINDERIOCSETMAXIUMDISTANCE: {
			set_maximum_distance(*(float *)arg);
			return 0;
		}
		break;

	default:
		/* give it to the superclass */
		return CDev::ioctl(filp, cmd, arg);
	}
}
コード例 #20
0
ファイル: print.cpp プロジェクト: andrewDDC/hhvm
void print(std::ostream& os, const Block* block,
           const RegAllocInfo* regs, const AsmInfo* asmInfo,
           const GuardConstraints* guards, BCMarker* markerPtr) {
  BCMarker dummy;
  BCMarker& curMarker = markerPtr ? *markerPtr : dummy;

  TcaRange blockRange = asmInfo ? asmInfo->asmRanges[block] :
    TcaRange(nullptr, nullptr);

  os << '\n' << std::string(kIndent - 3, ' ');
  printLabel(os, block);
  os << punc(":");
  auto& preds = block->preds();
  if (!preds.empty()) {
    os << " (preds";
    for (auto const& edge : preds) {
      os << " B" << edge.inst()->block()->id();
    }
    os << ')';
  }
  os << "\n";

  if (block->empty()) {
    os << std::string(kIndent, ' ') << "empty block\n";
    return;
  }

  const char* markerEndl = "";
  for (auto it = block->begin(); it != block->end();) {
    auto& inst = *it; ++it;

    if (inst.marker() != curMarker) {
      std::ostringstream mStr;
      auto const& newMarker = inst.marker();
      if (!newMarker.hasFunc()) {
        os << color(ANSI_COLOR_BLUE)
           << std::string(kIndent, ' ')
           << "--- invalid marker"
           << color(ANSI_COLOR_END)
           << '\n';
      } else {
        auto func = newMarker.func();
        if (!curMarker.hasFunc() || func != curMarker.func()) {
          func->prettyPrint(mStr, Func::PrintOpts().noFpi());
        }
        mStr << std::string(kIndent, ' ')
             << newMarker.show()
             << '\n';

        auto bcOffset = newMarker.bcOff();
        func->unit()->prettyPrint(
          mStr, Unit::PrintOpts()
          .range(bcOffset, bcOffset+1)
          .noLineNumbers()
          .noFuncs()
          .indent(0));
        std::vector<std::string> vec;
        folly::split('\n', mStr.str(), vec);
        os << markerEndl;
        markerEndl = "\n";
        for (auto& s : vec) {
          if (s.empty()) continue;
          os << color(ANSI_COLOR_BLUE) << s << color(ANSI_COLOR_END) << '\n';
        }
      }

      curMarker = newMarker;
    }

    if (inst.op() == DefLabel) {
      // print phi pseudo-instructions
      for (unsigned i = 0, n = inst.numDsts(); i < n; ++i) {
        os << std::string(kIndent +
                          folly::format("({}) ", inst.id()).str().size(),
                          ' ');
        auto dst = inst.dst(i);
        JIT::print(os, dst, dstLoc(regs, &inst, i));
        os << punc(" = ") << color(ANSI_COLOR_CYAN) << "phi "
           << color(ANSI_COLOR_END);
        bool first = true;
        inst.block()->forEachSrc(i, [&](IRInstruction* jmp, SSATmp*) {
            if (!first) os << punc(", ");
            first = false;
            printSrc(os, jmp, i, regs);
            os << punc("@");
            printLabel(os, jmp->block());
          });
        os << '\n';
      }
    }

    os << std::string(kIndent, ' ');
    JIT::print(os, &inst, regs, guards);
    os << '\n';

    if (asmInfo) {
      TcaRange instRange = asmInfo->instRanges[inst];
      if (!instRange.empty()) {
        disasmRange(os, instRange.begin(), instRange.end());
        os << '\n';
        assert(instRange.end() >= blockRange.start() &&
               instRange.end() <= blockRange.end());
        blockRange = TcaRange(instRange.end(), blockRange.end());
      }
    }
  }

  if (asmInfo) {
    // print code associated with this block that isn't tied to any
    // instruction.  This includes code after the last isntruction (e.g.
    // jmp to next block), and ACold or AFrozen code.
    if (!blockRange.empty()) {
      os << std::string(kIndent, ' ') << punc("A:") << "\n";
      disasmRange(os, blockRange.start(), blockRange.end());
    }
    auto acoldRange = asmInfo->acoldRanges[block];
    if (!acoldRange.empty()) {
      os << std::string(kIndent, ' ') << punc("ACold:") << "\n";
      disasmRange(os, acoldRange.start(), acoldRange.end());
    }
    auto afrozenRange = asmInfo->afrozenRanges[block];
    if (!afrozenRange.empty()) {
      os << std::string(kIndent, ' ') << punc("AFrozen:") << "\n";
      disasmRange(os, afrozenRange.start(), afrozenRange.end());
    }
    if (!blockRange.empty() || !acoldRange.empty() || !afrozenRange.empty()) {
      os << '\n';
    }
  }

  os << std::string(kIndent - 2, ' ');
  auto next = block->empty() ? nullptr : block->next();
  if (next) {
    os << punc("-> ");
    printLabel(os, next);
    os << '\n';
  } else {
    os << "no fallthrough\n";
  }
}
コード例 #21
0
ファイル: repeater.cpp プロジェクト: Pepe74/panstamp
/**
 * init
 *
 * Initialize repeater
 *
 * 'maxHop': maximum hop count
 */
void REPEATER::init(byte maxHop)
{
  maxHopCount = maxHop;
  start();
}
コード例 #22
0
void PlayActionEffectComboInstance::restart()
{
	destroy(false);
	start();
}
コード例 #23
0
	~TaskThread() { mStopping = true; start(); }
コード例 #24
0
ファイル: main.cpp プロジェクト: gaocan1992/astra
int main(int argc, char** argv)
{
    astra::initialize();

    set_key_handler();

#ifdef _WIN32
    auto fullscreenStyle = sf::Style::None;
#else
    auto fullscreenStyle = sf::Style::Fullscreen;
#endif

    const sf::VideoMode fullScreenMode = sf::VideoMode::getFullscreenModes()[0];
    const sf::VideoMode windowedMode(1800, 1350);

    bool isFullScreen = false;
    sf::RenderWindow window(windowedMode, "Multi Sensor Viewer");

    astra::StreamSet streamSet1("device/sensor0");
    astra::StreamSet streamSet2("device/sensor1");
    astra::StreamReader reader1 = streamSet1.create_reader();
    astra::StreamReader reader2 = streamSet2.create_reader();

    reader1.stream<astra::PointStream>().start();
    reader2.stream<astra::PointStream>().start();

    auto depthStream1 = configure_depth(reader1);
    depthStream1.start();

    auto colorStream1 = configure_color(reader1);
    colorStream1.start();

    auto irStream1 = configure_ir(reader1, false);

    auto depthStream2 = configure_depth(reader2);
    depthStream2.start();

    auto colorStream2 = configure_color(reader2);
    colorStream2.start();

    auto irStream2 = configure_ir(reader2, false);

    MultiFrameListener listener1;
    listener1.set_mode(MODE_COLOR);

    MultiFrameListener listener2;
    listener2.set_mode(MODE_COLOR);

    reader1.add_listener(listener1);
    reader2.add_listener(listener2);

    while (window.isOpen())
    {
        astra_temp_update();

        sf::Event event;
        while (window.pollEvent(event))
        {
            switch (event.type)
            {
            case sf::Event::Closed:
                window.close();
                break;
            case sf::Event::KeyPressed:
                {
                    switch (event.key.code)
                    {
                    case sf::Keyboard::Escape:
                        window.close();
                        break;
                    case sf::Keyboard::F:
                        if (isFullScreen)
                        {
                            isFullScreen = false;
                            window.create(windowedMode, "Multi Sensor Viewer", sf::Style::Default);
                        }
                        else
                        {
                            isFullScreen = true;
                            window.create(fullScreenMode, "Multi Sensor Viewer", fullscreenStyle);
                        }
                        break;
                    case sf::Keyboard::R:
                        depthStream1.enable_registration(!depthStream1.registration_enabled());
                        depthStream2.enable_registration(!depthStream2.registration_enabled());
                        break;
                    case sf::Keyboard::M:
                        {
                            const bool newMirroring1 = !depthStream1.mirroring_enabled();
                            depthStream1.enable_mirroring(newMirroring1);
                            colorStream1.enable_mirroring(newMirroring1);
                            irStream1.enable_mirroring(newMirroring1);

                            const bool newMirroring2 = !depthStream2.mirroring_enabled();
                            depthStream2.enable_mirroring(newMirroring2);
                            colorStream2.enable_mirroring(newMirroring2);
                            irStream2.enable_mirroring(newMirroring2);
                        }
                        break;
                    case sf::Keyboard::G:
                        colorStream1.stop();
                        configure_ir(reader1, false);
                        listener1.set_mode(MODE_IR_16);
                        irStream1.start();

                        colorStream2.stop();
                        configure_ir(reader2, false);
                        listener2.set_mode(MODE_IR_16);
                        irStream2.start();
                        break;
                    case sf::Keyboard::I:
                        colorStream1.stop();
                        configure_ir(reader1, true);
                        listener1.set_mode(MODE_IR_RGB);
                        irStream1.start();

                        colorStream2.stop();
                        configure_ir(reader2, true);
                        listener2.set_mode(MODE_IR_RGB);
                        irStream2.start();
                        break;
                    case sf::Keyboard::O:
                        listener1.toggle_depth_overlay();
                        if (listener1.get_overlay_depth())
                        {
                            depthStream1.enable_registration(true);
                        }
                        listener2.toggle_depth_overlay();
                        if (listener2.get_overlay_depth())
                        {
                            depthStream2.enable_registration(true);
                        }
                        break;
                    case sf::Keyboard::P:
                        listener1.toggle_paused();
                        listener2.toggle_paused();
                        break;
                    case sf::Keyboard::C:
                        if (event.key.control)
                        {
                            window.close();
                        }
                        else
                        {
                            irStream1.stop();
                            listener1.set_mode(MODE_COLOR);
                            colorStream1.start();

                            irStream2.stop();
                            listener2.set_mode(MODE_COLOR);
                            colorStream2.start();
                        }
                        break;
                    default:
                        break;
                    }
                    break;
                }
            default:
                break;
            }
        }

        // clear the window with black color
        window.clear(sf::Color::Black);

        listener1.draw_to(window, sf::Vector2f(0.0f, 0.0f), sf::Vector2f(window.getSize().x, window.getSize().y / 2.0f));
        listener2.draw_to(window, sf::Vector2f(0.0f, 0.5f), sf::Vector2f(window.getSize().x, window.getSize().y / 2.0f));
        window.display();

        if (!shouldContinue)
        {
            window.close();
        }
    }

    astra::terminate();

    return 0;
}
コード例 #25
0
ファイル: main.cpp プロジェクト: muromec/qtopia-ezx
 void play(const QString& file)
 {
     filename = file;
     start();
 }
コード例 #26
0
void Horus::Commons::Network::StreamServer::start(const QString &address)
{
    if (m_running) return;
    setAddress(address);
    start();
}
コード例 #27
0
ファイル: main.c プロジェクト: pombredanne/anacrolix
int main(int argc, char *argv[])
{
	start();
	return EXIT_SUCCESS;
}
コード例 #28
0
void Horus::Commons::Network::StreamServer::start(const QString &address, const QString &port)
{
    if (m_running) return;
    setPort(port);
    start(address);
}
コード例 #29
0
ファイル: serialport.cpp プロジェクト: 1ee7/bldc-logger
int SerialPort::openPort(
        const QString& port,
        int baudrate,
        SerialDataBits dataBits,
        SerialStopBits stopBits,
        SerialParity parity)
{
    if (mIsOpen) {
        closePort();
    }

    mFd = open(port.toLocal8Bit().data(), O_RDWR | O_NOCTTY | O_NDELAY);
    if (mFd == -1) {
        qCritical() << "Opening serial port failed.";
        return -1;
    }
    
    mIsOpen = true;
    
    // No-blocking reads
    fcntl(mFd, F_SETFL, FNDELAY);
    
    struct termios options;
    if (0 != tcgetattr(mFd, &options)) {
        qCritical() << "Reading serial port options failed.";
        return -2;
    }
    
    // Enable the receiver and set local mode...
    options.c_cflag |= CLOCAL | CREAD;
    
    // Raw input
    options.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG);
    
    // Disable flow control
    options.c_cflag &= ~CRTSCTS;
    options.c_iflag &= ~(IXON|IXOFF|IXANY);
    
    // ???
    /*set up other port settings*/
    options.c_cflag |= CREAD|CLOCAL;
    options.c_lflag &= (~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
    options.c_iflag &= (~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
    options.c_oflag &= (~OPOST);
    options.c_cc[VMIN] = 0;
#ifdef _POSIX_VDISABLE  // Is a disable character available on this system?
    // Some systems allow for per-device disable-characters, so get the
    //  proper value for the configured device
    const long vdisable = ::fpathconf(mFd, _PC_VDISABLE);
    options.c_cc[VINTR] = vdisable;
    options.c_cc[VQUIT] = vdisable;
    options.c_cc[VSTART] = vdisable;
    options.c_cc[VSTOP] = vdisable;
    options.c_cc[VSUSP] = vdisable;
#endif //_POSIX_VDISABLE
    
    //Set the new options for the port...
    if (0 != tcsetattr(mFd, TCSANOW, &options)) {
        qCritical() << "Writing serial port options failed.";
        closePort();
        return -3;
    }
    
    if (false == setDataBits(dataBits)) {
        qCritical() << "Setting data bits failed.";
        closePort();
        return -4;
    }

    if (false == setStopBits(stopBits)) {
        qCritical() << "Setting stopbits failed.";
        closePort();
        return -5;
    }

    if (false == setParity(parity)) {
        qCritical() << "Setting parity faield.";
        closePort();
        return -6;
    }

    if (false == setBaudrate(baudrate)) {
        qCritical() << "Setting baudrate failed.";
        closePort();
        return -7;
    }
    
    mAbort = false;
    start(LowPriority);
    return 0;
}
コード例 #30
0
void StopWatch::restart()
{
    reset();
    start();
}