예제 #1
0
static void
update_IrPoints( irInfo* irs)
{
  int cnt;
  Point rpos;
  float rrot;

  float distanceToObstacle = ROB_RADIUS + IR_THRESHOLD_DIST;
  
  updateActualPosition( &rpos, &rrot, DONT_CONSIDER_DIRECTION);

  for ( cnt = 0; cnt < irs->numberOfActivatedIrs; cnt++) {
    
    float angle = rrot + irs->angle[cnt];
    
    Ir_Obstacle_Points.points[cnt].x =
      rpos.x + (fcos( angle) * distanceToObstacle);
    Ir_Obstacle_Points.points[cnt].y =
      rpos.y + (fsin( angle) * distanceToObstacle);
  }

  if ( irs->numberOfActivatedIrs > 0)
    setStartTime( IR_TIMER);
  
  Ir_Obstacle_Points.no_of_points = irs->numberOfActivatedIrs;
}
std::unique_ptr<Path> DirectTargetPathPlanner::run(PlanRequest& planRequest) {
    const MotionInstant& startInstant = planRequest.start;
    const auto& motionConstraints = planRequest.constraints.mot;
    const Geometry2d::ShapeSet& obstacles = planRequest.obstacles;
    std::unique_ptr<Path>& prevPath = planRequest.prevPath;

    const Planning::DirectPathTargetCommand& command =
        dynamic_cast<const Planning::DirectPathTargetCommand&>(
            *planRequest.motionCommand);

    if (shouldReplan(planRequest)) {
        Geometry2d::Point endTarget = command.pathGoal.pos;
        const auto direction = (endTarget - startInstant.pos).normalized();

        float endSpeed = command.pathGoal.vel.mag();
        auto path = std::make_unique<TrapezoidalPath>(
            startInstant.pos, vectorInDirection(startInstant.vel, direction),
            endTarget, vectorInDirection(command.pathGoal.vel, direction),
            motionConstraints);
        path->setStartTime(RJ::now());
        return std::move(path);
    } else {
        return std::move(prevPath);
    }
}
예제 #3
0
bool ShowFunction::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLShowFunction)
    {
        qWarning() << Q_FUNC_INFO << "ShowFunction node not found";
        return false;
    }

    QXmlStreamAttributes attrs = root.attributes();

    if (attrs.hasAttribute(KXMLShowFunctionID))
        setFunctionID(attrs.value(KXMLShowFunctionID).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionStartTime))
        setStartTime(attrs.value(KXMLShowFunctionStartTime).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionDuration))
        setDuration(attrs.value(KXMLShowFunctionDuration).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionColor))
        setColor(QColor(attrs.value(KXMLShowFunctionColor).toString()));
    if (attrs.hasAttribute(KXMLShowFunctionLocked))
        setLocked(true);

    root.skipCurrentElement();

    return true;
}
예제 #4
0
int64_t FPS_Manager::resetTime(const long long& time)
{
	//LOG("Warning, FPS timer reset!");
	setStartTime(time);
	m_frameCount = 0;
	return 0;
}
예제 #5
0
파일: term.c 프로젝트: gto76/race
int main(void) {
	setEnvironment();
	setOutput();
	setScoreboard();

	while(1) {
		setRaceMode();
		PLAYER ppp[numOfPlayers];
		setPlayer(&ppp, 0, STARTING_POSITION_X, 18, '1', 65, 66, 67, 68);
		setPlayer(&ppp, 1, STARTING_POSITION_X, 20, '2', 119, 115, 100, 97);
		players = &ppp;

		redrawScreen();
		splashScreen();
		countdown();

		setStartTime(&ppp); 
		char c;
		while (!weHaveAWinner(&ppp)) { 
			c = getc(stdin);
			checkMove(c, &ppp);
		}
		printWins();
		checkeredFlag();
		waitForEnter();
	}

	return EXIT_SUCCESS;
}	
예제 #6
0
EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
{
    m_rulerWidget = new EPGRuler( this );
    m_epgView = new EPGView( this );
    m_channelsWidget = new EPGChannels( this, m_epgView );

    m_channelsWidget->setMinimumWidth( 100 );

    m_epgView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    setZoom( 1 );

    QGridLayout* layout = new QGridLayout( this );
    layout->addWidget( m_rulerWidget, 0, 1 );
    layout->addWidget( m_channelsWidget, 1, 0 );
    layout->addWidget( m_epgView, 1, 1 );
    layout->setSpacing( 0 );
    setLayout( layout );

    connect( m_epgView, SIGNAL( startTimeChanged(QDateTime) ),
             m_rulerWidget, SLOT( setStartTime(QDateTime) ) );
    connect( m_epgView, SIGNAL( durationChanged(int) ),
             m_rulerWidget, SLOT( setDuration(int) ) );
    connect( m_epgView->horizontalScrollBar(), SIGNAL( valueChanged(int) ),
             m_rulerWidget, SLOT( setOffset(int) ) );
    connect( m_epgView->verticalScrollBar(), SIGNAL( valueChanged(int) ),
             m_channelsWidget, SLOT( setOffset(int) ) );
    connect( m_epgView, SIGNAL( eventFocusedChanged(EPGEvent*)),
             this, SIGNAL(itemSelectionChanged(EPGEvent*)) );
}
예제 #7
0
// root search
void SimplePVSearch::search(Board board) {
	prepareToSearch();
	setStartTime(getTickCount());
	setTimeToStop();
	searchScore = idSearch(board);
	time = getTickCount()-getStartTime();
}
void QmlProfilerModelManager::load()
{
    QString filename = d->fileName;

    QFile file(filename);

    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        emit error(tr("Could not open %1 for reading.").arg(filename));
        return;
    }

    // erase current
    clear();

    setState(QmlProfilerDataState::AcquiringData);

    QmlProfilerFileReader reader;
    connect(&reader, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
    connect(&reader, SIGNAL(rangedEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
                                        qint64, qint64, qint64, qint64, qint64)),
            this, SLOT(addQmlEvent(int,int,qint64,qint64,QStringList,QmlDebug::QmlEventLocation,
                             qint64, qint64, qint64, qint64, qint64)));
    connect(&reader, SIGNAL(traceStartTime(qint64)), traceTime(), SLOT(setStartTime(qint64)));
    connect(&reader, SIGNAL(traceEndTime(qint64)), traceTime(), SLOT(setEndTime(qint64)));
    reader.setV8DataModel(d->v8Model);
    reader.load(&file);

    complete();
}
예제 #9
0
QList<EventDay *> *TablesWizard::getSchedule()
{
    QList<EventDay*>* result = new QList<EventDay*>();

    int day = ui->m_dayCount->value();

    for(auto key : m_editors.keys())
    {
        auto value = m_editors.value(key);

        auto time = key->time();
        value->setData(Qt::DisplayRole,time);
    }

    for(int i = 0; i < day ; ++i)
    {
        auto itemStart = ui->tableWidget->item(i,0);
        auto itemEnd = ui->tableWidget->item(i,1);

        auto event = new EventDay();
        event->setId(i);
        QTime time1 = itemStart->data(Qt::DisplayRole).toTime();
        int time1Min = time1.minute()+time1.hour()*60;
        event->setStartTime(time1Min);

        QTime time2 = itemEnd->data(Qt::DisplayRole).toTime();
        int time2Min = time2.minute()+time2.hour()*60;
        event->setEndTime(time2Min);

        result->append(event);
    }


    return result;
}
예제 #10
0
DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
	ui.setupUi(this);
	ui.dateEdit->setDisplayFormat(getDateFormat());
	ui.tableWidget->setTitle(tr("Dive planner points"));
	ui.tableWidget->setModel(DivePlannerPointsModel::instance());
	DivePlannerPointsModel::instance()->setRecalc(true);
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
	ui.cylinderTableWidget->setTitle(tr("Available gases"));
	ui.cylinderTableWidget->setModel(CylindersModel::instance());
	QTableView *view = ui.cylinderTableWidget->view();
	view->setColumnHidden(CylindersModel::START, true);
	view->setColumnHidden(CylindersModel::END, true);
	view->setColumnHidden(CylindersModel::DEPTH, false);
	view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
	connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addCylinder_clicked()));
	connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));

	connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
		GasSelectionModel::instance(), SLOT(repopulate()));
	connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)),
		GasSelectionModel::instance(), SLOT(repopulate()));
	connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
		GasSelectionModel::instance(), SLOT(repopulate()));
	connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
		plannerModel, SIGNAL(cylinderModelEdited()));
	connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)),
		plannerModel, SIGNAL(cylinderModelEdited()));
	connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)),
		plannerModel, SIGNAL(cylinderModelEdited()));

	ui.tableWidget->setBtnToolTip(tr("Add dive data point"));
	connect(ui.startTime, SIGNAL(timeChanged(QTime)), plannerModel, SLOT(setStartTime(QTime)));
	connect(ui.dateEdit, SIGNAL(dateChanged(QDate)), plannerModel, SLOT(setStartDate(QDate)));
	connect(ui.ATMPressure, SIGNAL(valueChanged(int)), this, SLOT(atmPressureChanged(int)));
	connect(ui.atmHeight, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int)));
	connect(ui.salinity, SIGNAL(valueChanged(double)), this, SLOT(salinityChanged(double)));
	connect(DivePlannerPointsModel::instance(), SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime)));

	// Creating (and canceling) the plan
	replanButton = ui.buttonBox->addButton(tr("Save new"), QDialogButtonBox::ActionRole);
	connect(replanButton, SIGNAL(clicked()), plannerModel, SLOT(saveDuplicatePlan()));
	connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(savePlan()));
	connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
	QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
	connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan()));

	// This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth.
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, 1, this));
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, 1, this));
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, 1, this));
	ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.1, this));

	/* set defaults. */
	ui.ATMPressure->setValue(1013);
	ui.atmHeight->setValue(0);

	setMinimumWidth(0);
	setMinimumHeight(0);
}
예제 #11
0
void LogVariablesWidget::setLogVariableChecked( int pIndex, bool pChecked )
{
	mHeaderView->setChecked(pIndex, pChecked);	
	if ( pChecked )
	{
		Qt::ItemFlags flags = Qt::ItemIsEditable|Qt::ItemIsSelectable
			|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled;

		ui->logVariableTable->item(pIndex, 0)->setFlags(Qt::ItemIsEnabled);
		ui->logVariableTable->item(pIndex, 1)->setFlags(flags);		
		ui->logVariableTable->item(pIndex, 2)->setFlags(flags);		
		ui->logVariableTable->item(pIndex, 3)->setFlags(flags);		
	}
	else
	{
		ui->logVariableTable->item(pIndex, 0)->setFlags(Qt::NoItemFlags);
		ui->logVariableTable->item(pIndex, 1)->setFlags(Qt::NoItemFlags);
		ui->logVariableTable->item(pIndex, 2)->setFlags(Qt::NoItemFlags);
		ui->logVariableTable->item(pIndex, 3)->setFlags(Qt::NoItemFlags);

		setFrequency(pIndex, DataRepository::instance()->frequency());
		setStartTime(pIndex, 0);
		setDuration(pIndex, DataRepository::instance()->duration());
	}

	QFont font = ui->logVariableTable->item(pIndex, 0)->font();
	font.setBold(pChecked);
	ui->logVariableTable->item(pIndex, 0)->setFont(font);
	ui->logVariableTable->item(pIndex, 1)->setFont(font);
	ui->logVariableTable->item(pIndex, 2)->setFont(font);
	ui->logVariableTable->item(pIndex, 3)->setFont(font);
}
예제 #12
0
bool LedCycle::loadEepromDatas()
{
  uint8_t tempValue;
  time_t tempTime;
  uint8_t readValues[8];

  for (int i = 0; i < 8; i++) {
    tempValue = EEPROM.read(eepromAddress + i);
    if (tempValue > 60) {
      applyDefaultTime();
      return false;
    }
    readValues[i] = tempValue;
  }

  setStartTime(hoursToTime_t(readValues[0]) + 
               minutesToTime_t(readValues[1]));
  setFadeInTime(hoursToTime_t(readValues[2]) + 
               minutesToTime_t(readValues[3]));
  setStopTime(hoursToTime_t(readValues[4]) + 
               minutesToTime_t(readValues[5]));
  setFadeOutTime(hoursToTime_t(readValues[6]) + 
               minutesToTime_t(readValues[7]));
  return true;
}
std::unique_ptr<Path> EscapeObstaclesPathPlanner::run(
    SinglePlanRequest& planRequest) {
    const MotionInstant& startInstant = planRequest.startInstant;
    const auto& motionConstraints = planRequest.robotConstraints.mot;
    const Geometry2d::ShapeSet& obstacles = planRequest.obstacles;
    std::unique_ptr<Path>& prevPath = planRequest.prevPath;

    boost::optional<Point> optPrevPt;
    if (prevPath) optPrevPt = prevPath->end().motion.pos;
    const Point unblocked =
        findNonBlockedGoal(startInstant.pos, optPrevPt, obstacles);

    // reuse path if there's not a significantly better spot to target
    if (prevPath && unblocked == prevPath->end().motion.pos) {
        return std::move(prevPath);
    }

    // TODO(justbuchanan): build a bezier path instead of a trapezoidal one.  As
    // is, the path isn't dynamically feasible if the robot has any initial
    // velocity.  We could potentially even use a kinodynamic RRT in
    // findNonBlockedGoal() so it takes initial velocity into account

    auto path = std::unique_ptr<Path>(
        new TrapezoidalPath(startInstant.pos, motionConstraints.maxSpeed,
                            unblocked, 0, motionConstraints));
    path->setStartTime(RJ::timestamp());
    return std::move(path);
}
예제 #14
0
void ExecData::setStartTime(string startTime) {
	stringstream ss;
	long val = -1;
	ss << startTime;
	ss >> val;
	setStartTime(val);
}
예제 #15
0
void KDGanttViewEventItem::setLeadTime( const QDateTime& leadTimeStart )
{
  if (!myLeadTime) myLeadTime = new QDateTime;
  *myLeadTime =  leadTimeStart;
  if ( startTime() < leadTime() )
      setStartTime( leadTimeStart );
  else {
    updateCanvasItems();
  }

}
예제 #16
0
파일: VTTCue.cpp 프로젝트: aosm/WebCore
VTTCue::VTTCue(ScriptExecutionContext& context, const WebVTTCueData& cueData)
    : TextTrackCue(context, 0, 0)
{
    initialize(context);
    setText(cueData.content());
    setStartTime(cueData.startTime(), IGNORE_EXCEPTION);
    setEndTime(cueData.endTime(), IGNORE_EXCEPTION);
    setId(cueData.id());
    setCueSettings(cueData.settings());
    m_originalStartTime = cueData.originalStartTime();
}
void UIActionFrame::initWithDictionary(cs::CSJsonDictionary *dic)
{
    setFrameId(DICTOOL->getIntValue_json(dic, "frameid"));
    setStartTime(DICTOOL->getFloatValue_json(dic, "starttime"));
    setPosition(ccp(DICTOOL->getFloatValue_json(dic, "positionx"), DICTOOL->getFloatValue_json(dic, "positiony")));
    setScaleX(DICTOOL->getFloatValue_json(dic, "scalex"));
    setScaleY(DICTOOL->getFloatValue_json(dic, "scaley"));
    setRotation(DICTOOL->getFloatValue_json(dic, "rotation"));
    setOpacity(DICTOOL->getIntValue_json(dic, "opacity"));
    setColor(ccc3(DICTOOL->getIntValue_json(dic, "colorr"), DICTOOL->getIntValue_json(dic, "colorg"), DICTOOL->getIntValue_json(dic, "colorb")));
}
int EventEditor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 11)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 11;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = subject(); break;
        case 1: *reinterpret_cast< QString*>(_v) = location(); break;
        case 2: *reinterpret_cast< QDateTime*>(_v) = startTime(); break;
        case 3: *reinterpret_cast< QDateTime*>(_v) = endTime(); break;
        case 4: *reinterpret_cast< int*>(_v) = folderId(); break;
        case 5: *reinterpret_cast< int*>(_v) = accountId(); break;
        case 6: *reinterpret_cast< Mode*>(_v) = mode(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setSubject(*reinterpret_cast< QString*>(_v)); break;
        case 1: setLocation(*reinterpret_cast< QString*>(_v)); break;
        case 2: setStartTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 3: setEndTime(*reinterpret_cast< QDateTime*>(_v)); break;
        case 4: setFolderId(*reinterpret_cast< int*>(_v)); break;
        case 5: setAccountId(*reinterpret_cast< int*>(_v)); break;
        case 6: setMode(*reinterpret_cast< Mode*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
예제 #19
0
bool Video::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::Video))
    {
        qWarning() << Q_FUNC_INFO << root.attribute(KXMLQLCFunctionType)
                   << "is not Video";
        return false;
    }

    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();
        if (tag.tagName() == KXMLQLCVideoSource)
        {
            if (tag.hasAttribute(KXMLQLCVideoStartTime))
                setStartTime(tag.attribute(KXMLQLCVideoStartTime).toUInt());
            if (tag.hasAttribute(KXMLQLCVideoColor))
                setColor(QColor(tag.attribute(KXMLQLCVideoColor)));
            if (tag.hasAttribute(KXMLQLCVideoLocked))
                setLocked(true);
            if (tag.hasAttribute(KXMLQLCVideoScreen))
                setScreen(tag.attribute(KXMLQLCVideoScreen).toInt());
            if (tag.hasAttribute(KXMLQLCVideoFullscreen))
            {
                if (tag.attribute(KXMLQLCVideoFullscreen) == "1")
                    setFullscreen(true);
                else
                    setFullscreen(false);
            }
            if (tag.text().contains("://") == true)
                setSourceUrl(tag.text());
            else
                setSourceUrl(m_doc->denormalizeComponentPath(tag.text()));
        }
        else if (tag.tagName() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(tag);
        }
        node = node.nextSibling();
    }

    return true;
}
예제 #20
0
void TextTrackCue::setStartTime(double value, ExceptionCode& ec)
{
    // NaN, Infinity and -Infinity values should trigger a TypeError.
    if (std::isinf(value) || std::isnan(value)) {
        ec = TypeError;
        return;
    }

    // TODO(93143): Add spec-compliant behavior for negative time values.
    if (m_startTime.toDouble() == value || value < 0)
        return;

    setStartTime(MediaTime::createWithDouble(value));
}
예제 #21
0
/*!
  Specifies the middle time of this summary item. The parameter must be valid
  and non-null. If the parameter is invalid or null, no value is set.

  \param dateTime the middle time
  \sa middleTime()
*/
void KDGanttViewSummaryItem::setMiddleTime( const QDateTime& dateTime )
{
 if (! dateTime.isValid() ) {
    qDebug("KDGanttViewSummaryItem::setMiddleTime():Invalid parameter-no time set");
    return;
  }
  if (!myMiddleTime) myMiddleTime = new QDateTime;
  *myMiddleTime = dateTime;
  if ( myEndTime < middleTime() )
      setEndTime( middleTime() );
  if ( myStartTime > middleTime() )
      setStartTime( middleTime() );
  updateCanvasItems();
}
예제 #22
0
void LogVariablesWidget::on_logVariableTable_itemChanged(QTableWidgetItem *item)
{
	if ( item->column() == 1 )      // Frequency
	{
		setFrequency(item->row(), item->text().toDouble());
	}
	else if ( item->column() == 2 ) // Start Time
	{
		setStartTime(item->row(), item->text().toDouble());
	}
	else if ( item->column() == 3 ) // Duration
	{
        setDuration(item->row(), item->text().toDouble());
    }
}
예제 #23
0
void startupInit()
{
    usbdataEnable();

	gdispSetBacklight(50);
	gdispSetContrast(50);

	geventListenerInit(&gl);
	gwinAttachListener(&gl);

	// Setup UI objects and show splash
	guiCreate();
	gwinProgressbarSetResolution(ghProgbarLoad, 10);
	gwinProgressbarStart(ghProgbarLoad, 300);
	graphInit();

	// Setup INA219 I2C Current Sensor
	ina219Init();

	sduObjectInit(USB_SERIAL_DRIVER);
	sduStart(USB_SERIAL_DRIVER, &serusbcfg);

	/*
	 * Activates the USB driver and then the USB bus pull-up on D+.
	 * Note, a delay is inserted in order to not have to disconnect the cable
	 * after a reset.
	 */
	usbDisconnectBus(serusbcfg.usbp);
	chThdSleepMilliseconds(1000);
	usbStart(serusbcfg.usbp, &usbcfg);
	usbConnectBus(serusbcfg.usbp);

	setStartTime();

	chThdCreateStatic(ledThread, sizeof(ledThread), LOWPRIO, ThreadLED, NULL);
	chThdCreateStatic(inaThread, sizeof(inaThread), HIGHPRIO, ThreadINA, NULL);
	chThdCreateStatic(gfxvalThread, sizeof(gfxvalThread), NORMALPRIO, ThreadGFXVal, NULL);
	chThdCreateStatic(timeThread, sizeof(timeThread), NORMALPRIO, ThreadTIME, NULL);
	chThdCreateStatic(gfxEventThread, sizeof(gfxEventThread), NORMALPRIO, ThreadGFXEvent, NULL);

	chThdSleepMilliseconds(2000);

	chThdCreateStatic(graphThread, sizeof(graphThread), NORMALPRIO+5, ThreadGRAPH, NULL);
	// Destroy splay screen and show main page
	gwinDestroy(ghContainerPageSplash);
	guiShowPage(1);
}
예제 #24
0
파일: audio.cpp 프로젝트: hfanieng/qlcplus
bool Audio::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attributes().value(KXMLQLCFunctionType).toString() != typeToString(Function::Audio))
    {
        qWarning() << Q_FUNC_INFO << root.attributes().value(KXMLQLCFunctionType).toString()
                   << "is not Audio";
        return false;
    }

    QString fname = name();

    while (root.readNextStartElement())
    {
        if (root.name() == KXMLQLCAudioSource)
        {
            QXmlStreamAttributes attrs = root.attributes();
            if (attrs.hasAttribute(KXMLQLCAudioDevice))
                setAudioDevice(attrs.value(KXMLQLCAudioDevice).toString());
            if (attrs.hasAttribute(KXMLQLCAudioStartTime))
                setStartTime(attrs.value(KXMLQLCAudioStartTime).toString().toUInt());
            if (attrs.hasAttribute(KXMLQLCAudioColor))
                setColor(QColor(attrs.value(KXMLQLCAudioColor).toString()));
            if (attrs.hasAttribute(KXMLQLCAudioLocked))
                setLocked(true);
            setSourceFileName(m_doc->denormalizeComponentPath(root.readElementText()));
        }
        else if (root.name() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(root);
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown Audio tag:" << root.name();
            root.skipCurrentElement();
        }
    }

    setName(fname);

    return true;
}
void FrameHandler::frame(Time frameTime)
{
    if(_mfUninitializedFrameTasks.size() != 0)
    {
        this->init();
    }

    setCurrTime(frameTime);

    if(osgAbs(_sfStartTime.getValue()) < 0.00001)
    {
        setStartTime(_sfCurrTime.getValue());

        setLastTime(0.f);
    }

    _sfCurrTime.getValue() -= _sfStartTime.getValue();

    if(_sfPaused.getValue() == false)
    {
        SFTime *pSFTimeStamp = editSFTimeStamp();

        if(_sfConstantTime.getValue() == true)
        {
            pSFTimeStamp->getValue() += _sfConstantTimeStep.getValue();

            if(pSFTimeStamp->getValue() < 0.)
                pSFTimeStamp->setValue(0.0);
        }
        else
        {
            pSFTimeStamp->getValue() +=
                (_sfCurrTime.getValue() - _sfLastTime.getValue()) *
                _sfTimeScale.getValue();

            if(pSFTimeStamp->getValue() < 0.)
                pSFTimeStamp->setValue(0.0);
        }
    }

    setLastTime(_sfCurrTime.getValue());

    ++(editSFFrameCount()->getValue());

    callTasks();
}
예제 #26
0
파일: EPGWidget.cpp 프로젝트: qdk0901/vlc
EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
{
    b_input_type_known = false;
    m_rulerWidget = new EPGRuler( this );
    m_epgView = new EPGView( this );
    m_channelsWidget = new EPGChannels( this, m_epgView );

    m_channelsWidget->setMinimumWidth( 100 );

    m_epgView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    setZoom( 1 );

    rootWidget = new QStackedWidget( this );

    QWidget *containerWidget = new QWidget( this );
    QGridLayout* layout = new QGridLayout( this );
    layout->addWidget( m_rulerWidget, 0, 1 );
    layout->addWidget( m_channelsWidget, 1, 0 );
    layout->addWidget( m_epgView, 1, 1 );
    layout->setSpacing( 0 );
    containerWidget->setLayout( layout );
    rootWidget->insertWidget( EPGVIEW_WIDGET, containerWidget );

    QLabel *noepgLabel = new QLabel( qtr("No EPG Data Available"), this );
    noepgLabel->setAlignment( Qt::AlignCenter );
    rootWidget->insertWidget( NOEPG_WIDGET, noepgLabel );

    rootWidget->setCurrentIndex( 1 );
    layout = new QGridLayout( this );
    layout->addWidget( rootWidget );
    setLayout( layout );

    CONNECT( m_epgView, startTimeChanged(QDateTime),
             m_rulerWidget, setStartTime(QDateTime) );
    CONNECT( m_epgView, durationChanged(int),
             m_rulerWidget, setDuration(int) );
    CONNECT( m_epgView->horizontalScrollBar(), valueChanged(int),
             m_rulerWidget, setOffset(int) );
    CONNECT( m_epgView->verticalScrollBar(), valueChanged(int),
             m_channelsWidget, setOffset(int) );
    connect( m_epgView, SIGNAL( itemFocused(EPGItem*)),
             this, SIGNAL(itemSelectionChanged(EPGItem*)) );
    CONNECT( m_epgView, channelAdded(QString), m_channelsWidget, addChannel(QString) );
    CONNECT( m_epgView, channelRemoved(QString), m_channelsWidget, removeChannel(QString) );
}
예제 #27
0
/**
 * @brief Initializes an ISIS cube converting it into a SPICE segment
 *
 * This method is called to extract the perinent contents of an ISIS cube file
 * and accumulate generic information that is used to create the output SPICE
 * kernel segment.  Other specific kernel types can use this class as its base
 * class and add to it additional elements to complete the needed content for
 * the NAIF kernel.
 *
 * @param cube ISIS cube file to accumulate information from
 */
void SpiceSegment::init(Cube &cube) {

  _kernels.UnLoad();  // Unload all active, owned kernels
  init();            // Init local variables

  _fname = cube.fileName();

  //  Extract ISIS CK blob and transform to CK 3 content
  NaifStatus::CheckErrors();
  try {

    // Order is somewhat important here.  The call to initialize Kernels
    // object checks the NAIF pool for existance.  It logs their NAIF
    // status as loaded which may cause trouble from here on...
    Pvl *label = cube.label();
    _kernels.Init(*label);
    Camera *camera = cube.camera();

    //  Determine segment ID from product ID if it exists, otherwise basename
    if ( _name.isEmpty() ) {
      _name = getKeyValue(*label, "ProductId");
      if (_name.isEmpty() ) {
        _name = FileName(_fname).baseName();
      }
    }

    // Get instrument and target ids
    QString value("");
    value = getKeyValue(*label, "InstrumentId");
    if (!value.isEmpty()) { _instId = value; }
    value = getKeyValue(*label, "TargetName");
    if (!value.isEmpty()) { _target = value; }

    // Get default times for sorting purposes
    setStartTime(camera->cacheStartTime().Et());
    setEndTime(camera->cacheEndTime().Et());

  } catch ( IException &ie  ) {
    ostringstream mess;
    mess << "Failed to construct Spice Segment basics from ISIS file " << _fname;
    throw IException(ie, IException::User, mess.str(), _FILEINFO_);
  }

  return;
}
예제 #28
0
void Scheduler::scheduleOneOffInFreeSpace(std::shared_ptr<std::vector<std::shared_ptr<Event>>> & scheduledEvents, const std::shared_ptr<const Task> & currentTask)
{
    unsigned int remainingDuration = currentTask->getDuration();
    unsigned int nextStartTime = currentTask->getEarliestStartTime();
    
    while(remainingDuration > 0)
    {
        auto newEvent = std::make_shared<Event>();
        unsigned int freeStartTime = 0;
        unsigned int freeDuration = 0;
        
        newEvent->setParent(currentTask);
        
        auto spaceIsAvailable = findFreeSpaceBetween(
                                                     nextStartTime,
                                                     currentTask->getLatestEndTime(),
                                                     freeStartTime,freeDuration);
        
        if(!spaceIsAvailable)
        {
            freeDuration = remainingDuration;
        }
        
        if(freeDuration > remainingDuration)
        {
            newEvent->setDuration(remainingDuration);
        }
        else
        {
            newEvent->setDuration(freeDuration);
        }
        
        newEvent->setStartTime(freeStartTime);
        
        scheduledEvents->push_back(newEvent);
        
        remainingDuration -= newEvent->getDuration();
        nextStartTime = newEvent->getEndTime();
    }
    
}
예제 #29
0
void LogVariablesWidget::loadSettings(QSettings &pSettings)
{
    pSettings.beginGroup("logVariablesWidget");
    restoreGeometry( pSettings.value("geometry").toByteArray() );
    setVisible( pSettings.value("visible").toBool() );

    for ( int i = 0; i < ui->logVariableTable->rowCount(); ++i )
    {
        if ( pSettings.childGroups().contains(ui->logVariableTable->item(i, 0)->text()) )
        {
            pSettings.beginGroup(ui->logVariableTable->item(i, 0)->text());
			setLogVariableChecked( i, true );
			setFrequency(i, pSettings.value("frequency", DataRepository::instance()->frequency()).toDouble());
			setStartTime(i, pSettings.value("startTime", 0).toDouble());
			setDuration(i, pSettings.value("duration", DataRepository::instance()->duration()).toDouble());
            pSettings.endGroup();
        }
    }

    pSettings.endGroup();
}
예제 #30
0
파일: PerfGraph.C 프로젝트: FHilty/moose
void
PerfGraph::push(const PerfID id)
{
  if (!_active)
    return;

  auto new_node = _stack[_current_position]->getChild(id);

  // Set the start time
  new_node->setStartTime(std::chrono::steady_clock::now());

  // Increment the number of calls
  new_node->incrementNumCalls();

  _current_position++;

  if (_current_position >= MAX_STACK_SIZE)
    mooseError("PerfGraph is out of stack space!");

  _stack[_current_position] = new_node;
}