Example #1
0
task autonomous() {
	//start flywheel
	initializeTasks();
	setFlywheelRange(2);

	wait1Msec(1000);
	startTask(fire);
	//wait until first set of preloads are fired
	waitUntilNotFiring(15000);
	while (firing) { EndTimeSlice(); }
	stopTask(fire);

	turn(120); //turn toward stack
	motor[feedMe] = 127;
	driveStraight(150, 1, 1, 60); //move to second stack
	turn(-30);
	driveStraight(3200, 1, 1, 60); //drive across field
	autonProgress = 1;
	turn(-83); // turn toward net
	autonProgress = 2;

	//fire remaining balls
	startTask(fire);
	while (true) { EndTimeSlice(); }
}
Example #2
0
task autonomous() {
	initializeTasks();
	stopTask(seymoreControl);

	//startTask(skillPointAuto);
	//startTask(stationaryAuto);
	//startTask(hoardingAuto);
	//startTask(classicAuto);
	//startTask(skillz);

	if (SensorValue[ternaryPot] < 1187) {
		if (SensorValue[binaryPot] < 1217) {
			startTask(stationaryAuto);
		}
		else {
			startTask(skillPointAuto);
		}
	}
	else if (SensorValue[ternaryPot] < 2577) {
		if (SensorValue[binaryPot] < 1217) {
			startTask(classicAuto);
		}
		else {
			startTask(hoardingAuto);
		}
	}
	else {
		startTask(skillz);
	}

	while(true) { EndTimeSlice(); }
}
Example #3
0
void emergencyStop() {
	stopTask(flywheel);
	stopTask(flywheelStabilization);
	stopTask(seymoreControl);
	stopTask(liftSwitcher);

	initializeTasks();
}
Example #4
0
task usercontrol() {
	initializeTasks();
	setFlywheelRange(0);

	while (true)
	{
		while (vexRT[emergencyStopBtn] == 0)
		{
			setDrivePower(sgn(vexRT[Ch2]) * vexRT[Ch2] * vexRT[Ch2] / 127, sgn(vexRT[Ch3]) * vexRT[Ch3] * vexRT[Ch3] / 127); //drive
			motor[feedMe] = 127*vexRT[feedInBtn] - 127*vexRT[feedOutBtn];
			feedMePower = motor[feedMe];
			EndTimeSlice();
		}

		emergencyStop(); //reassign emstop button
	}
}
Example #5
0
task usercontrol() {
	initializeTasks();
	setFlywheelRange(0);

	while (true)
	{
		while (vexRT[emergencyStopBtn] == 0)
		{
			setDrivePower(sgn(vexRT[Ch2]) * vexRT[Ch2] * vexRT[Ch2] / 127, sgn(vexRT[Ch3]) * vexRT[Ch3] * vexRT[Ch3] / 127); //drive
			motor[seymore] = abs(targetVelocity - flywheelVelocity) < firingErrorMargin * targetVelocity ? 127*vexRT[fireBtn] - 127*vexRT[seymoreOutBtn] : 0;
			motor[feedMe] = 127*vexRT[feedInBtn] - 127*vexRT[feedOutBtn];
			EndTimeSlice();
		}

		emergencyStop(); //reassign emstop button
	}
}
Example #6
0
task autonomous() {
	//start flywheel
	initializeTasks();
	setFlywheelRange(0);

	wait1Msec(1000);
	motor[seymore] = 127; //start feed
	//wait until first set of preloads are fired
	waitUntilNotFiring(2000);
	while (firing) { EndTimeSlice(); }
	motor[seymore] = 0;

	turn(93); //turn toward other starting tile
	driveStraight(8000, 1, 1, 60); //drive across field
	autonProgress = 1;
	turn(-95); // turn toward net
	autonProgress = 2;

	//fire remaining balls
	motor[seymore] = 127;
	while (true) { EndTimeSlice(); }
}
Example #7
0
void emergencyStop() {
	stopTask(flywheel);
	stopTask(flywheelStabilization);

	initializeTasks();
}
Example #8
0
void FileAnalyzer::run()
{
	m_bSuccess = false;

	m_tasksCounterNext = 0;
	m_tasksCounterDone = 0;
	m_completedCounter = 0;

	m_completedFiles.clear();
	m_completedTaskIds.clear();
	m_runningTaskIds.clear();

	m_filesAccepted = 0;
	m_filesRejected = 0;
	m_filesDenied = 0;
	m_filesDummyCDDA = 0;
	m_filesCueSheet = 0;

	m_timer->invalidate();

	//Create MediaInfo template file
	if(!m_templateFile)
	{
		if(!createTemplate())
		{
			qWarning("Failed to create template file!");
			return;
		}
	}

	//Sort files
	MUtils::natural_string_sort(m_inputFiles, true);

	//Handle playlist files first!
	handlePlaylistFiles();

	const unsigned int nFiles = m_inputFiles.count();
	if(nFiles < 1)
	{
		qWarning("File list is empty, nothing to do!");
		return;
	}

	//Update progress
	emit progressMaxChanged(nFiles);
	emit progressValChanged(0);

	//Create thread pool
	if(!m_pool) m_pool = new QThreadPool();
	const int idealThreadCount = QThread::idealThreadCount();
	if(idealThreadCount > 0)
	{
		m_pool->setMaxThreadCount(qBound(2, ((idealThreadCount * 3) / 2), 12));
	}

	//Start first N threads
	QTimer::singleShot(0, this, SLOT(initializeTasks()));

	//Start event processing
	this->exec();

	//Wait for pending tasks to complete
	m_pool->waitForDone();

	//Was opertaion aborted?
	if(m_bAborted)
	{
		qWarning("Operation cancelled by user!");
		return;
	}
	
	//Update progress
	emit progressValChanged(nFiles);

	//Emit pending files (this should not be required though!)
	if(!m_completedFiles.isEmpty())
	{
		qWarning("FileAnalyzer: Pending file information found after last thread terminated!");
		QList<unsigned int> keys = m_completedFiles.keys(); qSort(keys);
		while(!keys.isEmpty())
		{
			emit fileAnalyzed(m_completedFiles.take(keys.takeFirst()));
		}
	}

	qDebug("All files added.\n");
	m_bSuccess = true;

	QThread::msleep(333);
}
Example #9
0
Organisateur::Organisateur(QWidget *parent = 0) : QDialog(parent)
{
	setWindowTitle("Multiuso - Organisteur");
	setWindowIcon(QIcon(":/icones/actions/actionOrganisteur.png"));
	resize(Multiuso::screenWidth() / 2, (Multiuso::screenHeight() / 2) + 20);

	m_sortBy = new QComboBox;
		m_sortBy->addItems(QStringList() << "Tout" << "Priorité très élevée" << "Priorité élevée"
				<< "Priorité normale" << "Priorité faible" << "Priorité très faible");
		connect(m_sortBy, SIGNAL(currentIndexChanged(QString)), this, SLOT(initializeTasks(QString)));

	QPushButton *addTask = new QPushButton("Ajouter une tâche");
		connect(addTask, SIGNAL(clicked()), this, SLOT(slotAddTask()));

	QStringList headerLabels;
		headerLabels << "#" << "-" << "Titre" << "Contenu" << "Priorité";

	mainTable = new QTableWidget(0, headerLabels.size());
		mainTable->setShowGrid(false);
		mainTable->setHorizontalHeaderLabels(headerLabels);
		mainTable->verticalHeader()->hide();
		mainTable->setSelectionBehavior(QAbstractItemView::SelectRows);
		mainTable->setSelectionMode(QAbstractItemView::SingleSelection);
		mainTable->resizeColumnsToContents();
		mainTable->horizontalHeader()->setStretchLastSection(true);
		connect(mainTable, SIGNAL(itemDoubleClicked(QTableWidgetItem *)), this, SLOT(slotShowTask(QTableWidgetItem *)));

	QGridLayout *mainLayout = new QGridLayout;
		mainLayout->addWidget(new QLabel("Double-cliquez sur une tâche pour l'afficher"), 0, 0, 1, 2);
		mainLayout->addWidget(m_sortBy, 0, 2, 1, 1);
		mainLayout->addWidget(addTask, 0, 3, 1, 1);
		mainLayout->addWidget(mainTable, 1, 0, 1, 4);
		mainLayout->addWidget(Multiuso::closeButton(this), 2, 3, 1, 1);

	QWidget *centralWidget = new QWidget;
		centralWidget->setLayout(mainLayout);

	QMainWindow *mainWindow = new QMainWindow;
		mainWindow->setCentralWidget(centralWidget);

	QVBoxLayout *centralLayout = new QVBoxLayout(this);
		centralLayout->addWidget(mainWindow);
		centralLayout->setContentsMargins(0, 0, 0, 0);
	
	QToolBar *toolBar = mainWindow->addToolBar("Options");
		toolBar->setMovable(false);
		toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

		QAction *actionPut = new QAction("Sauvegarder", this);
			actionPut->setIcon(QIcon(":/icones/organisateur/put.png"));
			connect(actionPut, SIGNAL(triggered()), this, SLOT(putSafeguard()));
				toolBar->addAction(actionPut);

		QAction *actionGet = new QAction("Rétablir à la dernière sauvegarde", this);
			actionGet->setIcon(QIcon(":/icones/organisateur/get.png"));
			connect(actionGet, SIGNAL(triggered()), this, SLOT(getSafeguard()));
				toolBar->addAction(actionGet);

	m_sortBy->setCurrentIndex(m_sortBy->findText("Tout"));
	initializeTasks();
}