AutoNavigator::AutoNavigator(GameObject& owner, PluginId pid) : Property::Concept(owner, "AutoNavigator", pid) { initvar(ID::PV_TriggerRadius); require("ThrustControl"); require("Physical"); requestEvent(ID::GOE_VALUE_UPDATED); requestEvent(ID::GOE_AUTONAVIGATE); assert(ownerHandle() == rootModule() && "AutoNavigator: This code may contain some out-dated assumptions."); }
WeaponRack::WeaponRack(GameObject& owner, PluginId pid) : Property::Concept(owner, "WeaponRack", pid), mRocketAmmo(ROCKET_AMMO_START_AMOUNT_FOR_TESTING), mTarget(NULL_HANDLE) { require("Physical"); requestEvent(ID::GOE_FIRE_ROCKET); requestEvent(ID::GOE_FIRE_LASER); requestEvent(ID::GOE_SET_WEAPON_TARGET); requestEvent(ID::GOE_REINITIALIZE); updateGuiAmmo(); }
int Request(int _first, struct Node* _t, struct Node* _l, struct Position* _p) { if (_first==true) { if (_l->owner == _t) { return -1; } requestEvent(_t, _l, _p); checkForCycles(_t); } if (!_p->inHist) { return -1; } grant(_p, _t); int i = 0; while (i < histSize) { if (contains(&history[i], _p)) { if (instance(&history[i], 0)) { yieldEvent(_t, &history[i]); ungrant(_p, _t); checkForCycles(_t); return i; } } i = i + 1; } grantEvent(_t, _l, _p); return -1; }
/*! @brief Starts a Checkpoint after the recovery. */ void CheckpointService::executeRecoveryCheckpoint( const Event::Source &eventSource) { if (lastMode_ == CP_SHUTDOWN) { return; } try { GS_TRACE_INFO( CHECKPOINT_SERVICE, GS_TRACE_CP_STATUS, "[RecoveryCheckpoint]"); Event requestEvent( eventSource, CP_REQUEST_CHECKPOINT, CP_HANDLER_PARTITION_ID); EventByteOutStream out = requestEvent.getOutStream(); int32_t mode = CP_AFTER_RECOVERY; uint32_t flag = 0; std::string backupPath; out << mode; out << flag; out << backupPath; ee_.add(requestEvent); } catch (std::exception &e) { clusterService_->setError(eventSource, &e); GS_RETHROW_SYSTEM_ERROR(e, "Recovery checkpoint failed. (reason=" << GS_EXCEPTION_MESSAGE(e) << ")"); } }
void ItemDocument::resizeCanvasToItems() { QRect bound = canvasBoundingRect(); m_viewList.remove((View*)0); const ViewList::iterator end = m_viewList.end(); for (ViewList::iterator it = m_viewList.begin(); it != end; ++it) { ItemView * iv = static_cast<ItemView*>((View*) * it); CVBEditor * cvbEditor = iv->cvbEditor(); QPoint topLeft = iv->mousePosToCanvasPos(QPoint(0, 0)); int width = int(cvbEditor->visibleWidth() / iv->zoomLevel()); int height = int(cvbEditor->visibleHeight() / iv->zoomLevel()); QRect r(topLeft, QSize(width, height)); bound |= r; // kdDebug() << "r="<<r<<endl; // kdDebug() << "bound="<<bound<<endl; } // Make it so that the rectangular offset is a multiple of 8 bound.setLeft(bound.left() - (bound.left() % 8)); bound.setTop(bound.top() - (bound.top() % 8)); m_pUpdateItemViewScrollbarsTimer->start(10, true); bool changedSize = canvas()->rect() != bound; if (changedSize) { canvas()->resize(bound); requestEvent(ItemDocumentEvent::ResizeCanvasToItems); } else if (ICNDocument * icnd = dynamic_cast<ICNDocument*>(this)) { icnd->createCellMap(); } }
/*! @brief Starts a Checkpoint for the Shutdown. */ void CheckpointService::requestShutdownCheckpoint( const Event::Source &eventSource) { if (lastMode_ == CP_SHUTDOWN) { return; } try { GS_TRACE_INFO( CHECKPOINT_SERVICE, GS_TRACE_CP_STATUS, "[ShutdownCP]requested."); Event requestEvent( eventSource, CP_REQUEST_CHECKPOINT, CP_HANDLER_PARTITION_ID); EventByteOutStream out = requestEvent.getOutStream(); int32_t mode = CP_SHUTDOWN; uint32_t flag = 0; std::string backupPath; out << mode; out << flag; out << backupPath; if (!requestedShutdownCheckpoint_) { requestedShutdownCheckpoint_ = true; chunkCopyIntervalMillis_ = 0; ee_.add(requestEvent); } } catch (std::exception &e) { clusterService_->setError(eventSource, &e); GS_RETHROW_SYSTEM_ERROR(e, "Request shutdowncheckpoint failed. (reason=" << GS_EXCEPTION_MESSAGE(e) << ")"); } }
/*! @brief Starts a checkpoint. */ void CheckpointService::requestNormalCheckpoint( const Event::Source &eventSource) { if (lastMode_ == CP_SHUTDOWN) { return; } try { if (requestedShutdownCheckpoint_) { GS_THROW_USER_ERROR(GS_ERROR_CP_CONTROLLER_ILLEAGAL_STATE, "Checkpoint cancelled: already requested shutdown (" "lastMode=" << checkpointModeToString(lastMode_) << ")"); } GS_TRACE_INFO( CHECKPOINT_SERVICE, GS_TRACE_CP_STATUS, "[NormalCP]requested."); Event requestEvent( eventSource, CP_REQUEST_CHECKPOINT, CP_HANDLER_PARTITION_ID); EventByteOutStream out = requestEvent.getOutStream(); int32_t mode = CP_REQUESTED; uint32_t flag = 0; std::string backupPath; out << mode; out << flag; out << backupPath; ee_.add(requestEvent); } catch (std::exception &e) { clusterService_->setError(eventSource, &e); GS_RETHROW_SYSTEM_ERROR(e, "Request normal checkpoint failed. (reason=" << GS_EXCEPTION_MESSAGE(e) << ")"); } }
/*! @brief Starts an event. */ void CheckpointService::start(const Event::Source &eventSource) { try { if (!initailized_) { GS_THROW_USER_ERROR(GS_ERROR_CP_SERVICE_NOT_INITIALIZED, ""); } ee_.start(); Event requestEvent( eventSource, CP_REQUEST_CHECKPOINT, CP_HANDLER_PARTITION_ID); EventByteOutStream out = requestEvent.getOutStream(); int32_t mode = CP_NORMAL; uint32_t flag = 0; std::string backupPath; out << mode; out << flag; out << backupPath; ee_.addTimer(requestEvent, changeTimeSecondToMilliSecond(cpInterval_)); if (logWriteMode_ > 0 && logWriteMode_ < INT32_MAX) { Event flushLogEvent( eventSource, CP_TIMER_LOG_FLUSH, CP_SERIALIZED_PARTITION_ID); ee_.addPeriodicTimer( flushLogEvent, changeTimeSecondToMilliSecond(logWriteMode_)); } } catch (std::exception &e) { clusterService_->setError(eventSource, &e); GS_RETHROW_SYSTEM_ERROR( e, "Start failed. (reason=" << GS_EXCEPTION_MESSAGE(e) << ")"); } }
bool ItemDocument::registerItem(QCanvasItem *qcanvasItem) { if (!qcanvasItem) return false; requestEvent(ItemDocument::ItemDocumentEvent::ResizeCanvasToItems); if (Item *item = dynamic_cast<Item*>(qcanvasItem)) { m_itemList[item->id()] = item; connect(item, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); itemAdded(item); return true; } return false; }
bool ItemDocument::openURL(const KURL &url) { ItemDocumentData data(type()); if (!data.loadData(url)) return false; // Why do we stop simulating while loading a document? // Crash possible when loading a circuit document, and the Qt event loop is // reentered (such as when a PIC component pops-up a message box), which // will then call the Simulator::step function, which might use components // that have not fully initialized themselves. m_bIsLoading = true; bool wasSimulating = Simulator::self()->isSimulating(); Simulator::self()->slotSetSimulating(false); data.restoreDocument(this); Simulator::self()->slotSetSimulating(wasSimulating); m_bIsLoading = false; setURL(url); clearHistory(); m_savedState = m_currentState; setModified(false); if (FlowCodeDocument *fcd = dynamic_cast<FlowCodeDocument*>(this)) { // We need to tell all pic-depedent components about what pic type is in use emit fcd->picTypeChanged(); } requestEvent(ItemDocument::ItemDocumentEvent::ResizeCanvasToItems); // Load Z-position info m_zOrder.clear(); ItemMap::iterator end = m_itemList.end(); for (ItemMap::iterator it = m_itemList.begin(); it != end; ++it) { if (!(it->second) || it->second->parentItem()) continue; assert(it->second->itemDocument() == this); m_zOrder[it->second->baseZ()] = it->second; } slotUpdateZOrdering(); return true; }
/*! @brief Starts a Checkpoint on a transaction thread. */ void CheckpointService::executeOnTransactionService(EventContext &ec, GSEventType eventType, int32_t mode, PartitionId pId, CheckpointId cpId, bool executeAndWait) { try { Event requestEvent(ec, eventType, pId); EventByteOutStream out = requestEvent.getOutStream(); out << mode; out << cpId; if (executeAndWait) { txnEE_->executeAndWait(ec, requestEvent); } else { txnEE_->add(requestEvent); } } catch (std::exception &e) { GS_RETHROW_SYSTEM_ERROR( e, "Execute handler on TransactionService failed. (reason=" << GS_EXCEPTION_MESSAGE(e) << ")"); } }
void CheckpointService::runCheckpoint( EventContext &ec, int32_t mode, uint32_t flag) { if ((lastMode_ == CP_UNDEF && mode != CP_AFTER_RECOVERY) || lastMode_ == CP_SHUTDOWN || (mode != CP_SHUTDOWN && requestedShutdownCheckpoint_) ) { GS_TRACE_WARNING(CHECKPOINT_SERVICE, GS_TRACE_CP_CHECKPOINT_CANCELLED, "Checkpoint cancelled by status (mode=" << checkpointModeToString(mode) << ", lastMode=" << checkpointModeToString(lastMode_) << ", shutdownRequested=" << requestedShutdownCheckpoint_ << ")"); return; } currentCpGrpId_ = 0; errorOccured_ = false; struct CheckpointDataCleaner { CheckpointDataCleaner(CheckpointService &service, ChunkManager &chunkManager, EventContext &ec) : service_(service), chunkManager_(chunkManager), ec_(ec), workerId_(ec.getWorkerId()) {} ~CheckpointDataCleaner() { if (workerId_ == 0) { for (PartitionGroupId pgId = 0; pgId < service_.pgConfig_.getPartitionGroupCount(); ++pgId) { const PartitionId startPId = service_.pgConfig_.getGroupBeginPartitionId(pgId); const CheckpointId cpId = 0; try { service_.executeOnTransactionService(ec_, CLEANUP_CP_DATA, CP_UNDEF, startPId, cpId, false); } catch (...) { } } try { service_.endTime_ = util::DateTime::now(false).getUnixTime(); service_.pendingPartitionCount_ = 0; } catch (...) { } } } CheckpointService &service_; ChunkManager &chunkManager_; EventContext &ec_; uint32_t workerId_; } cpDataCleaner(*this, *chunkManager_, ec); startTime_ = 0; endTime_ = 0; lastMode_ = mode; startTime_ = util::DateTime::now(false).getUnixTime(); pendingPartitionCount_ = pgConfig_.getPartitionCount(); GS_TRACE_INFO(CHECKPOINT_SERVICE, GS_TRACE_CP_STATUS, "[CP_START] mode=" << checkpointModeToString(mode)); if (parallelCheckpoint_) { groupCheckpointStatus_.assign( pgConfig_.getPartitionGroupCount(), GROUP_CP_COMPLETED); PartitionGroupId pgId = 1; try { for (; pgId < pgConfig_.getPartitionGroupCount(); ++pgId) { PartitionId topPId = pgConfig_.getGroupBeginPartitionId(pgId); Event requestEvent(ec, CP_REQUEST_GROUP_CHECKPOINT, topPId); EventByteOutStream out = requestEvent.getOutStream(); out << mode; out << flag; groupCheckpointStatus_[pgId] = GROUP_CP_RUNNING; ee_.add(requestEvent); } pgId = 0; groupCheckpointStatus_[pgId] = GROUP_CP_RUNNING; runGroupCheckpoint(pgId, ec, mode, flag); } catch (...) { groupCheckpointStatus_[pgId] = GROUP_CP_COMPLETED; waitAllGroupCheckpointEnd(); throw; } waitAllGroupCheckpointEnd(); } else { for (PartitionGroupId pgId = 0; pgId < pgConfig_.getPartitionGroupCount(); ++pgId) { runGroupCheckpoint(pgId, ec, mode, flag); } } if (mode == CP_AFTER_RECOVERY) { clusterService_->requestCompleteCheckpoint(ec, ec.getAllocator(), true); RecoveryManager::setProgressPercent(100); } if (mode == CP_SHUTDOWN) { clusterService_->requestCompleteCheckpoint( ec, ec.getAllocator(), false); } GS_TRACE_INFO(CHECKPOINT_SERVICE, GS_TRACE_CP_STATUS, "[CP_END] mode=" << checkpointModeToString(mode) << ", commandElapsedMillis=" << getLastDuration(util::DateTime::now(false))); pendingPartitionCount_ = 0; if (mode == CP_NORMAL) { totalNormalCpOperation_++; } else if (mode == CP_REQUESTED) { totalRequestedCpOperation_++; } }
Boolean TPZCrossbarFlowCTMux :: dispatchEvent(const TPZEvent& event) { if( ( event.type() == _CrossbarRequest_ ) || ( event.type() == _CrossbarPass_ ) ) { TPZCrossbar& crossbar = (TPZCrossbar&)(getComponent()); unsigned iPort = event.source(); unsigned oPort = getOutputForInput(iPort).left(); unsigned channel = getOutputForInput(iPort).right(); if(event.type() == _CrossbarRequest_) { oPort=event.destiny(); channel=event.channel(); } TPZMessage *msg; m_MessageReceivedTable->valueAt(iPort,&msg); if(!msg) return true; if(!channel) { if(_CrossbarRequest_) { EXIT_PROGRAM("Channel set to 0 in request Not allowed"); } else { EXIT_PROGRAM("Channel set to 0 in data Not allowed"); } } else if( ! iPort ) { TPZString err; err.sprintf( ERR_TPZCFLOC_001, (char*)getComponent().asString(), (char*)msg->asString() ); EXIT_PROGRAM(err); } else if(!oPort) { TPZString err; err.sprintf( ERR_TPZCFLOC_002, (char*)getComponent().asString(), (char*)msg->asString() ); EXIT_PROGRAM(err); } //Here's the difference with the normal version if( event.type() == _CrossbarRequest_) { for(int i=1; i<=crossbar.numberOfInputs(); i++) { uPAIR temp; m_PortAsignamentTable->valueAt(i,temp); if(i!=iPort && (temp.left()==oPort) ) { inputInterfaz(iPort)->sendStop(); uTIME delayTime = getOwnerRouter().getCurrentTime() + 1; getEventQueue().enqueue(event,delayTime); #ifndef NO_TRAZA TPZString time = getOwnerRouter().getCurrentTime(); TPZString texto = getComponent().asString() + " CONTENTION STOP TIME = "; texto += time + msg->asString() + " i=" + TPZString(iPort) + ", o=" + TPZString(oPort) + ", OPORT used by i=" + TPZString(i); TPZWRITE2LOG( texto ); #endif return true; } } if( (outputInterfaz(oPort)->isStopActive(channel))) { inputInterfaz(iPort)->sendStop(); uTIME delayTime = getOwnerRouter().getCurrentTime() + 1; getEventQueue().enqueue(event,delayTime); #ifndef NO_TRAZA TPZString time = getOwnerRouter().getCurrentTime(); TPZString texto = getComponent().asString() + " QUEUES STOP TIME = "; texto += time + msg->asString() + " i=" + TPZString(iPort) + ", o=" + TPZString(oPort); TPZWRITE2LOG( texto ); #endif return true; } establishConnection(iPort,oPort,channel); setStateForInput(iPort,Connect); } inputInterfaz(iPort)->clearStopRightNow(); outputInterfaz(oPort)->sendData(msg,channel); ((TPZNetwork*)(getOwnerRouter().getOwner()))->incrEventCount( TPZNetwork::SWTraversal); if (msg->getRoutingPort()!=_LocalNode_) ((TPZNetwork*)(getOwnerRouter().getOwner()))->incrEventCount( TPZNetwork::LinkTraversal); #ifndef NO_TRAZA TPZString time = getOwnerRouter().getCurrentTime(); TPZString texto = getComponent().asString() + " Flit Tx. TIME = "; texto += time + msg->asString() + " i=" + TPZString(iPort) + ", o=" + TPZString(oPort); TPZWRITE2LOG( texto ); #endif if( msg->isTail() ) { clearConnection(iPort); uPAIR temp; temp = getConnectionRequestForWith(oPort); iPort=temp.left(); channel=temp.right(); if( iPort != 0 ) { establishConnection(iPort,oPort,channel); TPZEvent requestEvent(_CrossbarRequest_,iPort,oPort,channel); uTIME delayTime = getOwnerRouter().getCurrentTime() + MAXIMO(1,getHeaderDelay()); if( ((TPZCrossbar&)getComponent()).isLocalNodeOutput(oPort) ) { if( getHeaderDelay() > 1 ) delayTime -= 1; } getEventQueue().enqueue(requestEvent,delayTime); } } } return true; }
void ItemDocument::itemAdded(Item *) { requestEvent(ItemDocument::ItemDocumentEvent::UpdateZOrdering); }
void ItemDocument::requestCanvasResize() { requestEvent(ItemDocumentEvent::ResizeCanvasToItems); }
void ItemDocument::handleNewView(View * view) { Document::handleNewView(view); requestEvent(ItemDocument::ItemDocumentEvent::ResizeCanvasToItems); }
void Btz_i2c::OnRequest() { requestEvent(); }
void ADServerConnection::run() { while(m_client->state() != QAbstractSocket::UnconnectedState) { QString readed; while(m_client->canReadLine()) { readed += m_client->readLine(); if ( readed.endsWith("%%\n") ) { break; } } if ( !readed.isEmpty() ) { readed.remove(readed.lastIndexOf("%%"), 2); dDebug() << "Readed:" << readed; QDomDocument doc; if ( doc.setContent(readed) ) { QString root = doc.documentElement().tagName(); dDebug() << root; if(root == "Event") { // dDebug() << "RECIBI EL EVENTO EN ADSERVERCONNECTION void ADServerConnection::run()"; ADEventFactory factory; ADEvent *request = factory.build( readed ); if ( request ) { emit requestEvent(this, request ); // delete request; } } } /* QXmlInputSource xmlsource; xmlsource.setData(readed+'\n'); dDebug() << "READED: " << readed; if ( m_reader.parse(&xmlsource) ) { QString root = m_parser->root(); QMap<QString, QString> values = m_parser->values(); if ( root == "Connection") { } // else if ( root == "Chat" ) // { // emit requestSendToAll( SChatPackage(m_login,values["Message"]).toString().remove('\n') ); // } else if ( root == "Insert" ) { QStringList fields_and_values = values["field"].split(ADS::FIELD_SEPARATOR); QStringList fieldsList, valuesList; foreach(QString field_and_value, fields_and_values ) { QStringList tmpFields = field_and_value.split("::"); if ( tmpFields.count() != 2 ) continue; fieldsList << tmpFields[0]; valuesList << tmpFields[1]; } QString table = values["table"]; ADInsert *insert = new ADInsert(table, fieldsList, valuesList); if ( !values["where"].isEmpty() ) { insert->setWhere( values["where"] ); } if ( !values["condition"].isEmpty() ) { insert->setCondition( values["condition"] ); } emit requestOperation( this, insert ); } else if ( root == "Update" ) { QStringList fields_and_values = values["field"].split(ADS::FIELD_SEPARATOR); QStringList fieldsList, valuesList; foreach(QString field_and_value, fields_and_values ) { QStringList tmpFields = field_and_value.split("::"); if ( tmpFields.count() != 2 ) continue; fieldsList << tmpFields[0]; valuesList << tmpFields[1]; } QString table = values["table"]; ADUpdate *update = new ADUpdate(table, fieldsList, valuesList); if ( !values["where"].isEmpty() ) { update->setWhere( values["where"] ); } if ( !values["condition"].isEmpty() ) { update->setCondition( values["condition"] ); } emit requestOperation( this, update ); } else if ( root == "Delete" ) { QString table = values["table"]; ADDelete *del = new ADDelete(table); if ( !values["where"].isEmpty() ) { del->setWhere( values["where"] ); } if ( !values["condition"].isEmpty() ) { del->setCondition( values["condition"] ); } emit requestOperation( this, del ); } else if ( root == "Select" ) { QString fields = values["field"]; QString tables = values["table"]; //remove the last (,) fields = fields.remove(fields.count()-1,1); tables = tables.remove(tables.count()-1,1); ADSelect *select = new ADSelect(QStringList() << fields, QStringList() << tables, values["distinct"].toInt() ); if ( values.contains( "where" ) ) select->setWhere( values["where"] ); if ( values.contains("condition") ) select->setCondition( values["condition"] ); emit requestOperation( this, select); } } else { m_parser->reset(); sendToClient( SErrorPackage(0, tr("Bad package ")+readed) ); if ( !readed.isEmpty() ) { close(); } }*/ } } // Finish connection emit requestRemoveConnection( this ); }
Boolean TPZCrossbarFlowCTMux :: onReadyUp(unsigned interfaz, unsigned cv) { unsigned i = interfaz; TPZMessage* msg; TPZMessage* lastMessage; inputInterfaz(i)->getData(&msg); m_MessageReceivedTable->valueAt(i,&lastMessage); if(lastMessage) if( *msg == *lastMessage ) return true; m_MessageReceivedTable->setValueAt(i,msg); uTIME delayTime = getOwnerRouter().getCurrentTime() ; #ifndef NO_TRAZA TPZString texto = getComponent().asString() + " Flit Rx. TIME = "; texto += TPZString(delayTime) + " # " + msg->asString(); TPZWRITE2LOG( texto ); #endif if( getOutputForInput(i).left() == 0 ) { // This is to run the TPZCrossbarFlowCTMux if(!msg->isHeader()) { return true; } // This from the head. unsigned outPort = extractOutputPortNumber(msg); unsigned outChannel = extractOutputChannel(msg); if( outChannel==0) { EXIT_PROGRAM("Message without output VC"); } TPZEvent requestEvent(_CrossbarRequest_,i,outPort,outChannel); setStateForInput(i,Waiting); if( isOutputPortFree(outPort,outChannel) ) { // You must assign an output delayTime += getHeaderDelay(); if( ((TPZCrossbar&)getComponent()).isLocalNodeOutput(outPort) ) { if( getHeaderDelay() > 1 ) delayTime -= 1; } getEventQueue().enqueue(requestEvent,delayTime); } else { // The output port is busy. A request is queued #ifndef NO_TRAZA TPZString texto = getComponent().asString() + " Esperando una SALIDA !"; texto += TPZString(delayTime) + " iport= " + TPZString(i); TPZWRITE2LOG( texto ); #endif addConnectionRequest(i,uPAIR(outPort,outChannel)); } #ifndef NO_TRAZA TPZString time = getOwnerRouter().getCurrentTime(); TPZString texto = getComponent().getName() + " Stop Tx. TIME = "; texto += time + " iport= " + TPZString(i); TPZWRITE2LOG( texto ); #endif inputInterfaz(i)->sendStopRightNow(); } else { delayTime += getDataDelay(); TPZEvent passEvent(_CrossbarPass_,i); getEventQueue().enqueue(passEvent,delayTime); } return true; }