void externalTransition( const vle::devs::ExternalEventList& events, const vle::devs::Time& time) { vle::devs::ExternalEventList::const_iterator it = events.begin(); while (it != events.end()) { if ((*it)->onPort("start")) { if (mPhase == INIT) { mActivities.starting(time); if (mActivities.startingActivities().empty()) { mPhase = WAIT; } else { mPhase = SEND; } } } else if ((*it)->onPort("done")) { Activity* a = Activity::build(Activity::get(*it)); TraceModel(vle::fmt(" [%1%:%2%] at %3% -> %4% DONE") % getModel().getParentName() % getModelName() % time % a->name()); mDoneActivities.push_back(a); } ++it; } if (mSigma > 0) { mSigma -= (time - mLastTime); mLastTime = time; } }
/** * Method: GenerateGradeFile(QString _activityID) * * Description: * Obtains the grades for all students in a course that is tied to the _activityID, obtains the grades for those * students for that activity, and then stores each student grade file line in the returned QList<QString> * (formatted for writing to a file using the CSVProcessor). * * Attributes: * QString _activityID - the id of the activity to get grades for * * Author: Joshua Campbell * * Version: 1 */ QList<QString> RubricItemGrade::GenerateGradeFile(QString _activityID) { Activity activityModel; QMap<QString, QString> activityMap = activityModel.GetActivityByID(_activityID); activityModel.SetParameters(activityMap); QList<QMap<QString, QString> > rubricMapList = activityModel.getRubric(); QListIterator<QMap<QString, QString> > rubricMapListIterator(rubricMapList); Student s; QList<QString> studentList = s.getEnrolledStudentIDs(activityMap["courseID"]); QList<QString> gradeOutput; for (size_t i = 0; i < studentList.count(); i++) { std::ostringstream oss; oss << studentList[i].toStdString(); while(rubricMapListIterator.hasNext()) { QMap<QString, QString> tempMap = rubricMapListIterator.next(); QList<QMap<QString, QString> > itemGrades = GetGradesByItemID(tempMap["rubricItemID"]); QListIterator<QMap<QString, QString> > itemGradesIterator(itemGrades); while (itemGradesIterator.hasNext()) { QMap<QString, QString> tempItemGrade = itemGradesIterator.next(); if (tempItemGrade["studentID"] == studentList[i]) { oss << "," << tempItemGrade["mark"].toStdString(); } } } oss << "\n"; gradeOutput.push_back(oss.str().c_str()); } return gradeOutput; }
NoRubricActivitySelectionScreen::NoRubricActivitySelectionScreen(QWidget *parent) : QWidget(parent), ui(new Ui::NoRubricActivitySelectionScreen) { ui->setupUi(this); //QString currentCourseID = session->getCourseID(); //DBAccess dba; Activity activityModel; rubriclessActivities = activityModel.getRubriclessByCourseID(session->getCourseID()); //my ugly sql query to get activities without rubrics //QString sqlString = "SELECT DISTINCT activityID FROM Activity A, Rubric R WHERE R.courseID ='"; //sqlString.append(currentCourseID); //sqlString.append("' AND A.activityID NOT IN(SELECT DISTINCT activityID FROM Rubric WHERE courseID = '"); //sqlString.append(currentCourseID); //sqlString.append("')"); //DEBUG(DEBUG_INFO, sqlString); //dba.__query(sqlString); //QSqlQuery rubriclessResults(sqlString); //DEBUG(DEBUG_INFO, rubriclessResults.value(0).toString()); //add to the widget list the results int count = rubriclessActivities.count(); for(int k=0; k<count; k++){ ui->RubriclessActivityListWidget->addItem(rubriclessActivities[k]["activityName"]); } }
/** * Attach an activity to an interpreter instance * * @param instance The interpreter instance involved. * * @return Either an existing activity, or a new activity created for * this thread. */ Activity *ActivityManager::attachThread() { // it's possible we already have an activity active for this thread. That // most likely occurs in nested RexxStart() calls. Activity *oldActivity = findActivity(); // we have an activity created for this thread already. The interpreter instance // should already have handled the case of an attach for an already attached thread. // so we're going to have a new activity to create, and potentially an existing one to // suspend // we need to lock the kernel to have access to the memory manager to // create this activity. lockKernel(); Activity *activityObject = createCurrentActivity(); // Do we have a nested interpreter call occurring on the same thread? We need to // mark the old activity as suspended, and chain this to the new activity. if (oldActivity != OREF_NULL) { oldActivity->setSuspended(true); // this pushes this down the stack. activityObject->setNestedActivity(oldActivity); } unlockKernel(); /* release kernel semaphore */ // now we need to have this activity become the kernel owner. activityObject->requestAccess(); // this will help ensure that the code after the request access call // is only executed after access acquired. sentinel = true; // belt-and-braces. Make sure the current activity is explicitly set to // this activity before leaving. currentActivity = activityObject; return activityObject; }
void ActivityManager::RunActivity(Activity& act) { MojLogTrace(s_log); MojLogInfo(s_log, _T("Running [Activity %llu]"), act.GetId()); m_resourceManager->Associate(act.shared_from_this()); act.RunActivity(); }
/** * Clone off an activity from an existing activity. Used for * message start() are early reply operations. * * @param parent The currently running activity. The activity-specific settings are * inherited from the parent. * * @return A new activity. */ Activity *ActivityManager::createNewActivity(Activity *parent) { // create a new activity with the same priority as the parent Activity *activity = createNewActivity(); // copy any needed settings from the parent activity->inheritSettings(parent); return activity; }
/** * Signal an activation to yield control */ void ActivityManager::yieldCurrentActivity() { ResourceSection lock; Activity *activity = ActivityManager::currentActivity; if (activity != OREF_NULL) { activity->yield(); } }
/** * Clear the activty pool of pooled activities. */ void ActivityManager::clearActivityPool() { Activity *activity = (Activity *)availableActivities->pull(); while (activity != OREF_NULL) { // terminate this thread activity->terminatePoolActivity(); activity = (Activity *)availableActivities->pull(); } }
void ActivityTableModel::durationChanged() { Activity *activity = static_cast<Activity *>(QObject::sender()); int row = indexOfActivityId(activity->id()); if (row >= 0) { QModelIndex modelIndex = index(row, 6); emit dataChanged(modelIndex, modelIndex); } }
void PromotionActivityGetResponse::parseNormalResponse() { parseError(); if (responseParser->hasName("activitys")) { QList<Parser *> listParser = responseParser->getListObjectParser("activitys"); Parser *parser; foreach (parser, listParser) { Activity tmp; tmp.setParser(parser); tmp.parseResponse(); activitys.append(tmp); }
/** * Flip on external trace for a thread. * * @param thread_id The target thread id. * @param on_or_off The trace setting. * * @return true if this worked, false otherwise. */ bool ActivityManager::setActivityTrace(thread_id_t thread_id, bool on_or_off ) { ResourceSection lock; // locate the activity associated with this thread_id. If not found, return // a failure. Activity *activity = findActivity(thread_id); if (activity != OREF_NULL) { return activity->setTrace(on_or_off); } return false; // this was a failure }
/** * Raise a halt condition on an activity. * * @param thread_id The target thread identifier. * @param description * The description of the halt. * * @return Returns the halt result. Returns false if a halt * condition is already pending or the target activity * is not found. */ bool ActivityManager::haltActivity(thread_id_t thread_id, RexxString * description ) { ResourceSection lock; // locate the activity associated with this thread_id. If not found, return // a failure. Activity *activity = findActivity(thread_id); if (activity != OREF_NULL) { return activity->halt(description); } return false; // this was a failure }
void MainWindow::startActivityLike(QSharedPointer<Activity> activity) { Activity *newActivity = Activity::startLike(activity.data()); if (newActivity != NULL) { stopCurrentActivities(); newActivity->save(); QSharedPointer<Activity> ptr = m_recordManager->addRecord(newActivity); emit activityCreated(ptr); refreshCompleterModels(); } }
bool ActivityManager::ActivityNameComp::operator()( const Activity& act1, const Activity& act2) const { const std::string& act1Name = act1.GetName(); const std::string& act2Name = act2.GetName(); if (act1Name != act2Name) { return act1Name < act2Name; } else { return act1.GetCreator() < act2.GetCreator(); } }
BOOL CCommonApp::InitActivity( LPCWSTR param1 ) { //throw std::exception("The method or operation is not implemented."); BOOL ret = FALSE; wstring path; AfxGetWorkPath(path); path += param1; TiXmlDocument xmlDoc; ret = xmlDoc.LoadFile(StrHelp::WStringToString(path).c_str()); if (!ret) { OutputDebugString(L"LoadFile error! \r\n"); return FALSE; } TiXmlElement *root = xmlDoc.RootElement(); if (strcmp(root->Value(), "manifest") != 0) { return FALSE; } TiXmlElement * element = root->FirstChildElement(); string startAction; string startActiviy; while(element) { if (strcmp(element->Value(), "activity") != 0) { return FALSE; } TiXmlElement * action = element->FirstChildElement(); if (action) { startAction = action->Attribute("name"); startActiviy = element->Attribute("name"); break; } element = element->NextSiblingElement(); } if (startAction == "MAIN") { Activity * pAct = GXCreateControl::CreateAcitviyByType(startActiviy.c_str()); AfxSetActiviy(pAct); pAct->onCreate(); return TRUE; } return ret=FALSE; }
void MainWindow::on_goToActivity_activated(const QString &arg1) { MyRect * r = MyRect::m_selectedRect; if(!ui->goToActivity->currentIndex()) { cout << "Setting MyRect with " << r->id() << " 0" << endl; r->setId(0); r->setGameType(GameType::NONE); ui->actPieceWidg->setHidden(true); r->setActPieceFilepath(QString("None")); if(!ui->graphicsView->actsAreInScene()) ui->chooseRewardBadge->setEnabled(false); return; } QString actType = ui->goToActivity->currentText().section(QChar('-'), 0, 0); actType = actType.remove(QChar(' ')); QString str = ui->goToActivity->currentText().section(QChar('-'), 1, 1); if(ui->graphicsView->rewardBadgeId()) ui->actPieceWidg->setHidden(false); if(!r->id()) { r->setActPieceFilepath(m_fileManager.errorImgFilepath()); ui->actPieceImg->setPixmap(QPixmap(r->actPieceFilepath()).scaled(50, 50, Qt::KeepAspectRatioByExpanding, Qt::FastTransformation)); } if(actType == QString("Pairing")) { r->setId(m_pairActs->id(str.remove(0, 1))); r->setGameType(GameType::PAIR); } else if(actType == QString("Matching")) { r->setId(m_matchActs->id(str.remove(0, 1))); r->setGameType(GameType::MATCHING); cout << "set matching" << endl; } if(r->id()) { string actFileName = MyRect::m_selectedRect->actFileName().toStdString(); Activity *act = new Activity(actFileName, NULL); act->load(); ui->actPieceImg->setPixmap(QPixmap(QString::fromStdWString(act->m_badge_piece.m_image)).scaled(50, 50, Qt::KeepAspectRatioByExpanding, Qt::FastTransformation)); r->setActPieceFilepath(QString::fromStdWString(act->m_badge_piece.m_image)); } if(ui->graphicsView->actsAreInScene()) ui->chooseRewardBadge->setEnabled(true); }
bool Frontend::Tune( Activity &act ) { Port *port = act.GetPort( ); if( !port ) return false; Transponder *transponder = act.GetTransponder( ); if( !transponder ) return false; act.SetFrontend( this ); if( !SetPort( port->GetKey( ))) return false; if( !Tune( *transponder )) return false; return true; }
void completeActivity(std::string id, bool complete) { Pdb db; Activity act = db.getActivity(id); if(act.getId() == 0) { //No activity found std::cerr << "No activity found for id: " << id << std::endl; exit(1); } act.complete(complete); act.persist(); }
void list_all_activities() { Pdb db; std::vector<Activity> activities = db.getAllActivities(); printf("%-5s\t%-50s\t%-20s\t%-2s\t%-2s\n", "ID", "TITLE", "DATE", "E", "C"); printf("=====\t=================================================\t====================\t==\t==\n\n"); for(int i = 0; i < activities.size(); i++) { Activity act = activities.at(i); printf("%5i\t%-50s\t%20s\t%-2i\t%-2i\n", act.getId(), act.getTitle().c_str(), act.getDateAsText().c_str(), act.getExpectedPomodoros(), act.getPomodoros()); //std::cout << activities.at(i).toString() << std::endl; } }
/** * Get an already existing activity for the current thread and * give it kernel access before returning. This will fail if * the thread has not been properly attached. * * @return The activity for this thread. */ Activity *ActivityManager::getActivity() { // it's possible we already have an activity active for this thread. That // most likely occurs in nested RexxStart() calls. Activity *activityObject = findActivity(); // we generally should have something. Somehow we have an improperly // attached thread. Just return a failure indicator. if (activityObject == OREF_NULL) { return OREF_NULL; } // go acquire the kernel lock and take care of nesting activityObject->enterCurrentThread(); return activityObject; // Return the activity for thread }
void CActivity::read(const Activity& activity) { this->iActId = activity.actid(); this->iType = activity.type(); this->sName = activity.name(); this->iStatus = activity.status(); this->sIconFile = activity.icon(); this->sInfoFile = activity.pic(); this->iExtraParam = activity.param(); this->exlist = activity.exchange(); this->bTips = activity.tips(); }
void ActivityManager::RunReadyBackgroundActivity(Activity& act) { MojLogTrace(s_log); MojLogInfo(s_log, _T("Running background [Activity %llu]"), act.GetId()); if (act.m_runQueueItem.is_linked()) { act.m_runQueueItem.unlink(); } else { MojLogWarning(s_log, _T("[Activity %llu] was not queued attempting to " "run background Activity"), act.GetId()); } m_runQueue[RunQueueBackground].push_back(act); RunActivity(act); }
// Handles screen rendering on current view void ArduinOS::render(bool forceRender){ if(forceRender){ if(GUI) GUI->render(forceRender); if(STAGE) STAGE->render(forceRender); } Activity* act = ActivityManager::getCurrentActivity(); // Is there a activity running, or is it NULL? if(act){ act->_rel = ArduinOS::_rel; act->render(forceRender); } requestRender = false; }
QVariant TestList::data(const QModelIndex &index, int role) const { int row = index.row(); if(row < 0 || row >= m_data.count()) { return QVariant(); } Activity* activity = m_data.at(row); switch(role) { case NameRole: // return activity's name as a string (model.name) return activity->name(); case DisciplineRole: // return activity's discipline (model.discipline) return activity->discipline(); case DateRole: // return activity's submission date return activity->date(); case GradeRole: return activity->grade(); case AchievedGradeRole: return activity->achievedGrade(); case ActivityTypeRole: return activity->activityType(); } return QVariant(); }
/** * Return an activity to the activity pool. * * @param activityObject * The released activity. */ void ActivityManager::returnActivity(Activity *activityObject) { // START OF CRITICAL SECTION { ResourceSection lock; // remove this from the activte list allActivities->removeItem(activityObject); // if we ended up pushing an old activity down when we attached this // thread, then we need to restore the old thread to active state. Activity *oldActivity = activityObject->getNestedActivity(); if (oldActivity != OREF_NULL) { oldActivity->setSuspended(false); } // cleanup any system resources this activity might own activityObject->cleanupActivityResources(); } }
bool Port::Scan( Activity &act ) { if( !source ) return false; act.SetPort( this ); if( !source->GetTransponderForScanning( act )) return false; return true; }
/** * Locate the activity associated with a thread * * @param threadId The target thread id * * @return The activity, or OREF_NULL if this is not currently in use. */ Activity *ActivityManager::findActivity(thread_id_t threadId) { // this is a critical section ResourceSection lock; // NB: New activities are pushed on to the end, so it's prudent to search // from the list end toward the front of the list. Also, this ensures we // will find the toplevel activity nested on a given thread first. for (size_t listIndex = allActivities->lastIndex(); listIndex > 0; listIndex--) { Activity *activity = (Activity *)allActivities->get(listIndex); // this should never happen, but we never return suspended threads if (activity->isThread(threadId) && !activity->isSuspended()) { return activity; } } return OREF_NULL; }
//@Override ECode BaseChromiumApplication::InnerActivityLifecycleCallbacks::OnActivityDestroyed( /* [in] */ Activity activity) { AutoPtr<IWindow> window; activity->GetWindow((IWindow**)&window); AutoPtr<IWindowCallback> callback; window->GetCallback((IWindowCallback**)&callback); assert(callback->Probe(EIID_WindowCallbackWrapper)); return NOERROR; }
/** * notify all waiting activities that a variable has been updated. */ void RexxVariable::notify() { // if we have a dependents table, iterate through the table tapping // the waiting activities if (dependents != OREF_NULL) { // use an iterator to traverse the table HashContents::TableIterator iterator = dependents->iterator(); for (; iterator.isAvailable(); iterator.next()) { // copy these methods over any of our own. Activity *activity = (Activity *)iterator.index(); activity->guardPost(); } // yield control and allow the waiting guard(s) to run too Activity *activity = ActivityManager::currentActivity; activity->yieldControl(); } }
void LoadBitmaps(JavaVM* vm, JNIEnv* env, jobject objActivity) { vm->AttachCurrentThread(&env, NULL); BitmapFactory::Options options = BitmapFactory::Options(); options.set_inScaled(false); // No pre-scaling Activity activity = Activity(objActivity); Context context = activity.getApplicationContext(); AssetManager assetManager = context.getAssets(); String path = String(""); std::vector<std::string> files = assetManager.list(path); for (int index = 0; index < files.size(); ++index) { __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, files[index].c_str()); } glGenTextures(TEXTURE_COUNT, &textures[0]); int textureId = 0; g_controller = LoadTexture(env, assetManager, options, "controller.png", textureId); g_buttonA = LoadTexture(env, assetManager, options, "a.png", ++textureId); g_dpadDown = LoadTexture(env, assetManager, options, "dpad_down.png", ++textureId); g_dpadLeft = LoadTexture(env, assetManager, options, "dpad_left.png", ++textureId); g_dpadRight = LoadTexture(env, assetManager, options, "dpad_right.png", ++textureId); g_dpadUp = LoadTexture(env, assetManager, options, "dpad_up.png", ++textureId); g_leftBumper = LoadTexture(env, assetManager, options, "lb.png", ++textureId); g_leftTrigger = LoadTexture(env, assetManager, options, "lt.png", ++textureId); g_leftStickInactive = LoadTexture(env, assetManager, options, "l_stick.png", ++textureId); g_buttonO = LoadTexture(env, assetManager, options, "o.png", ++textureId); g_rightBumper = LoadTexture(env, assetManager, options, "rb.png", ++textureId); g_rightTrigger = LoadTexture(env, assetManager, options, "rt.png", ++textureId); g_rightStickInactive = LoadTexture(env, assetManager, options, "r_stick.png", ++textureId); g_leftStickActive = LoadTexture(env, assetManager, options, "thumbl.png", ++textureId); g_rightStickActive = LoadTexture(env, assetManager, options, "thumbr.png", ++textureId); g_buttonU = LoadTexture(env, assetManager, options, "u.png", ++textureId); g_buttonY = LoadTexture(env, assetManager, options, "y.png", ++textureId); __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "Loaded %d textures", textureId + 1); }