Boolean TPZFifoMemoryFlow :: outputWriting() { outputInterfaz()->clearData(); if( ! outputInterfaz()->isStopActive() ) { uTIME timeStamp; if( getEventQueue().firstElementTimeStamp(timeStamp) ) { if( timeStamp <= getOwnerRouter().getCurrentTime() ) { TPZEvent event; getEventQueue().dequeue(event); dispatchEvent(event); } } } if(m_SendStop) { inputInterfaz()->sendStopRightNow(); #ifndef NO_TRAZA uTIME time = getOwnerRouter().getCurrentTime(); TPZString texto = getComponent().asString() + ": Full Buffer->Stop "; texto += TPZString(time); TPZWRITE2LOG(texto); #endif } else { inputInterfaz()->clearStop(); } return true; }
void CKeyState::sendKeyEvent( void* target, bool press, bool isAutoRepeat, KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button) { if (m_keyMap.isHalfDuplex(key, button)) { if (isAutoRepeat) { // ignore auto-repeat on half-duplex keys } else { getEventQueue().addEvent(CEvent(getKeyDownEvent(), target, CKeyInfo::alloc(key, mask, button, 1))); getEventQueue().addEvent(CEvent(getKeyUpEvent(), target, CKeyInfo::alloc(key, mask, button, 1))); } } else { if (isAutoRepeat) { getEventQueue().addEvent(CEvent(getKeyRepeatEvent(), target, CKeyInfo::alloc(key, mask, button, count))); } else if (press) { getEventQueue().addEvent(CEvent(getKeyDownEvent(), target, CKeyInfo::alloc(key, mask, button, 1))); } else { getEventQueue().addEvent(CEvent(getKeyUpEvent(), target, CKeyInfo::alloc(key, mask, button, 1))); } } }
void CMSWindowsKeyState::disable() { if (m_fixTimer != NULL) { getEventQueue().removeHandler(CEvent::kTimer, m_fixTimer); getEventQueue().deleteTimer(m_fixTimer); m_fixTimer = NULL; } m_lastDown = 0; }
virtual void checkEvents() { if ((fabs(_currentMouseX - _targetMouseY) > 0.1f) || (fabs(_currentMouseY - _targetMouseY) > 0.1)) { static const float scalar = 0.2f; _currentMouseX = (1.0f - scalar) * _currentMouseX + scalar * _targetMouseX; _currentMouseY = (1.0f - scalar) * _currentMouseY + scalar * _targetMouseY; getEventQueue()->mouseMotion(_currentMouseX, _currentMouseY, getEventQueue()->getTime()); } }
virtual bool checkEvents() { if (_targetMouseChanged && (fabs(_currentMouseX - _targetMouseY) > 0.1f) || (fabs(_currentMouseY - _targetMouseY) > 0.1)) { static const float scalar = 0.2f; _currentMouseX = (1.0f - scalar) * _currentMouseX + scalar * _targetMouseX; _currentMouseY = (1.0f - scalar) * _currentMouseY + scalar * _targetMouseY; getEventQueue()->mouseMotion(_currentMouseX, _currentMouseY, getEventQueue()->getTime()); } return !(getEventQueue()->empty()); }
void Simulator::printStatistic() { cout<<"\n================================================================\n"; unsigned long long transmittedBytesCount = getTransmittedBytesCount(); cout<<"Передано успешно "<< transmittedBytesCount <<" байт\n"; unsigned long long etalon = lround(getEventQueue()->getCurrentTime()*kTransmitVelocity/1000000); cout<<"Теоритически максимальная передача составляет "<< etalon <<" байт\n"; float C = (float)transmittedBytesCount/etalon*100; cout<<"Пропусная способность за время симуляции "<< getEventQueue()->getSimulationTime()/1000000 <<" c равна "<< C <<"%\n\n"; ofstream fout; fout.open("name.txt",ios::app); // open file for appending fout<<C<<endl; //send to file fout.close(); //close file }
long GraphicsWindowFOX::onKeyRelease(FXObject *sender, FXSelector sel, void* ptr) { int key = ((FXEvent*)ptr)->code; getEventQueue()->keyRelease(key); return FXGLCanvas::onKeyRelease(sender, sel, ptr); }
long GraphicsWindowFOX::onMotion(FXObject *sender, FXSelector sel, void* ptr) { FXEvent* event=(FXEvent*)ptr; getEventQueue()->mouseMotion(event->win_x, event->win_y); return FXGLCanvas::onMotion(sender, sel, ptr); }
long GraphicsWindowFOX::onRightBtnRelease(FXObject *sender, FXSelector sel, void* ptr) { FXEvent* event=(FXEvent*)ptr; getEventQueue()->mouseButtonRelease(event->click_x, event->click_y, 3); return FXGLCanvas::onRightBtnRelease(sender, sel, ptr); }
void GraphicsWindowSDL2::init() { if(mValid) return; if(!_traits.valid()) return; WindowData *inheritedWindowData = dynamic_cast<WindowData*>(_traits->inheritedWindowData.get()); mWindow = inheritedWindowData ? inheritedWindowData->mWindow : NULL; mOwnsWindow = (mWindow == 0); if(mOwnsWindow) { OSG_FATAL<<"Error: No SDL window provided."<<std::endl; return; } // SDL will change the current context when it creates a new one, so we // have to get the current one to be able to restore it afterward. SDL_Window *oldWin = SDL_GL_GetCurrentWindow(); SDL_GLContext oldCtx = SDL_GL_GetCurrentContext(); #ifdef OPENGL_ES SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); #endif mContext = SDL_GL_CreateContext(mWindow); if(!mContext) { OSG_FATAL<< "Error: Unable to create OpenGL graphics context: "<<SDL_GetError() <<std::endl; return; } SDL_GL_SetSwapInterval(_traits->vsync ? 1 : 0); SDL_GL_MakeCurrent(oldWin, oldCtx); mValid = true; #if OSG_VERSION_GREATER_OR_EQUAL(3,3,4) getEventQueue()->syncWindowRectangleWithGraphicsContext(); #else getEventQueue()->syncWindowRectangleWithGraphcisContext(); #endif }
virtual bool checkEvents() { osgGA::EventQueue* queue = getEventQueue(); for(std::vector<RequestHandler*>::iterator i = _handleOnCheckEvents.begin(); i != _handleOnCheckEvents.end(); ++i) { (*i)->operator()(queue); } return osgGA::Device::checkEvents(); }
long GraphicsWindowFOX::onConfigure(FXObject *sender, FXSelector sel, void* ptr) { // set GL viewport (not called by FXGLCanvas::onConfigure on all platforms...) // update the window dimensions, in case the window has been resized. getEventQueue()->windowResize(0, 0, getWidth(), getHeight()); resized(0, 0, getWidth(), getHeight()); return FXGLCanvas::onConfigure(sender, sel, ptr); }
long GraphicsWindowFOX::onRightBtnPress(FXObject *sender, FXSelector sel, void* ptr) { handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); FXEvent* event=(FXEvent*)ptr; getEventQueue()->mouseButtonPress(event->click_x, event->click_y, 3); return FXGLCanvas::onRightBtnPress(sender, sel, ptr); }
OSGGTKDrawingArea::OSGGTKDrawingArea(): _widget (gtk_drawing_area_new()), _glconfig (0), _context (0), _drawable (0), _state (0), _queue (*getEventQueue()) { setCameraManipulator(new osgGA::TrackballManipulator()); setLightingMode(osg::View::HEADLIGHT); }
double getLocalTime(double time_stamp) { if (_firstEventRemoteTimeStamp < 0) { _firstEventLocalTimeStamp = getEventQueue()->getTime(); _firstEventRemoteTimeStamp = time_stamp; } double local_time = _firstEventLocalTimeStamp + (time_stamp - _firstEventRemoteTimeStamp); // std::cout << "ts: "<< time_stamp << " -> " << local_time << std::endl; return local_time; }
bool Device::checkEvents() { OSG_DEBUG_FP<<"PointerEventDevice::checkEvents"<<std::endl; if (frame_.id() != lastFrame_.id()) { // Create new 'USER' event of class osgLeap::Event and push it to the queue osg::ref_ptr<Event> e = new Event(); e->setFrame(frame_); _eventQueue->addEvent(e); lastFrame_ = frame_; } return _eventQueue.valid() ? !(getEventQueue()->empty()) : false; }
int SnortEventqAdd( uint32_t gid, uint32_t sid, uint32_t rev, uint32_t classification, uint32_t priority, const char * msg, void * rule_info ) { EventNode *en; OptTreeNode *otn = (OptTreeNode *) rule_info; if (!otn) otn = GetApplicableOtn(gid, sid, rev, classification, priority, msg); else if (!getRtnFromOtn(otn, getApplicableRuntimePolicy(gid))) otn = NULL; if (otn) { en = (EventNode *) sfeventq_event_alloc(getEventQueue()); if (!en) return -1; en->gid = gid; en->sid = sid; en->rev = rev; en->classification = classification; en->priority = priority; en->msg = msg; en->rule_info = rule_info; if (sfeventq_add(getEventQueue(), (void *) en) != 0) return -1; s_events++; } return 0; }
//************************************************************************* //: // f: virtual Boolean onReadyUp (unsigned interface, unsigned cv) // // d: //: //************************************************************************* Boolean TPZCrossbarFlowVC::onReadyUp(unsigned interfaz, unsigned cv) { unsigned i = interfaz; TPZMessage* msg; TPZMessage* lastMessage; inputInterfaz(i)->getData(&msg); m_MessageReceivedTable->setValueAt(i, msg); uTIME delayTime = getOwnerRouter().getCurrentTime() ; #ifndef NO_TRAZA TPZString texto = getComponent().asString() + " Flit Rx. TIME = "; texto += TPZString(delayTime) + " # " + msg->asString(); texto += TPZString(" Interfaz=") + TPZString(interfaz); TPZWRITE2LOG(texto); #endif if (msg->isHeader() || msg->isHeadTail()) { // It is a header flit, routing must be performed TPZEvent routingEvent(_RoutingVC_, i); getEventQueue().enqueue(routingEvent, delayTime); } else { //data or tail going directly to arbitration Switch unsigned outPort; unsigned outVirtualChannel; m_InOutPortTable->valueAt(i, outPort); m_InOutVCTable->valueAt(i, outVirtualChannel); TPZEvent xbarAllocEvent(_SwitchAllocator_, i, outPort, outVirtualChannel, msg); getEventQueue().enqueue(xbarAllocEvent, delayTime); } inputInterfaz(i)->sendStopRightNow(); return true; }
bool GraphicsWindowSDL2::realizeImplementation() { if(mRealized) { OSG_NOTICE<< "GraphicsWindowSDL2::realizeImplementation() Already realized" <<std::endl; return true; } if(!mValid) init(); if(!mValid) return false; SDL_ShowWindow(mWindow); #if OSG_VERSION_GREATER_OR_EQUAL(3,3,4) getEventQueue()->syncWindowRectangleWithGraphicsContext(); #else getEventQueue()->syncWindowRectangleWithGraphcisContext(); #endif mRealized = true; return true; }
static inline int EventqAdd(uint32_t gid, uint32_t sid, uint32_t rev, uint32_t classification, uint32_t priority, const char *msg, OptTreeNode *rule_info) { EventNode *en = (EventNode *) sfeventq_event_alloc(getEventQueue()); if (!en) return -1; en->gid = gid; en->sid = sid; en->rev = rev; en->classification = classification; en->priority = priority; en->msg = msg; en->rule_info = rule_info; if (sfeventq_add(getEventQueue(), (void *) en) != 0) return -1; s_events++; return 0; }
//************************************************************************* //: // f: virtual Boolean onReadyUp (unsigned interface, unsigned cv) // // d: //: //************************************************************************* Boolean TPZCrossbarFlowWH :: onReadyUp(unsigned interfaz, unsigned cv) { unsigned i = interfaz; TPZMessage* msg; TPZMessage* lastMessage; inputInterfaz(i)->getData(&msg); 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( msg->isHeader() || msg->isHeadTail() ) { // It is a header flit, routing must be performed TPZEvent routingEvent(_RoutingVC_, i); getEventQueue().enqueue(routingEvent, delayTime); } else { //data or tail flits move directly to SWarbitration stage unsigned outPort; m_InOutPortTable->valueAt(i, outPort); TPZEvent SWTravEvent(_SwitchTraversal_, i, outPort, 1, msg); getEventQueue().enqueue(SWTravEvent, delayTime+1); } inputInterfaz(i)->sendStopRightNow(); return true; }
bool GraphicsWindowSDL2::realizeImplementation() { if(mRealized) { OSG_NOTICE<< "GraphicsWindowSDL2::realizeImplementation() Already realized" <<std::endl; return true; } if(!mValid) init(); if(!mValid) return false; SDL_ShowWindow(mWindow); getEventQueue()->syncWindowRectangleWithGraphicsContext(); mRealized = true; return true; }
const osg::Camera* ossimPlanetViewer::forceAdjustToMasterCamera(float x, float y, float& local_x, float& local_y) const { const osg::Camera* result = _camera.get(); // get and use the master camera if(!result) return 0; const osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState(); const osgViewer::GraphicsWindow* gw = dynamic_cast<const osgViewer::GraphicsWindow*>(eventState->getGraphicsContext()); bool view_invert_y = eventState->getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS; double epsilon = 0.5; if (_camera->getGraphicsContext() && (!gw || _camera->getGraphicsContext()==gw) && _camera->getViewport()) { const osg::Viewport* viewport = _camera->getViewport(); double new_x = x; double new_y = y; if (!gw) { new_x = static_cast<double>(_camera->getGraphicsContext()->getTraits()->width) * (x - eventState->getXmin())/(eventState->getXmax()-eventState->getXmin()); new_y = view_invert_y ? static_cast<double>(_camera->getGraphicsContext()->getTraits()->height) * (1.0 - (y- eventState->getYmin())/(eventState->getYmax()-eventState->getYmin())) : static_cast<double>(_camera->getGraphicsContext()->getTraits()->height) * (y - eventState->getYmin())/(eventState->getYmax()-eventState->getXmin()); } // lets still allow for valid camera positioning even if outside the frustum if no camera is found if (viewport) { local_x = new_x; local_y = new_y; result = _camera.get(); } } return result; }
void OSGGraphicsWindowQt::checkEvents() { if (mCloseRequested) getEventQueue()->closeWindow(); }
void SnortEventqReset(void) { sfeventq_reset(getEventQueue()); reset_counts(); }
virtual bool checkEvents() { _autoDiscovery->update(); return !(getEventQueue()->empty()); }
//************************************************************************* //: // f: virtual Boolean onReadyUp (unsigned interface, unsigned cv) // // d: //: //************************************************************************* Boolean TPZCrossbarFlowVCMuxOpt::onReadyUp(unsigned interfaz, unsigned cv) { unsigned i = interfaz; TPZMessage* msg; TPZMessage* lastMessage; inputInterfaz(i)->getData(&msg); 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 (msg->isHeader() || msg->isHeadTail()) { // It is a header flit, routing must be performed // Here is the point where we optimize pipeline. // If certain conditions are met, the header can move // directly to Switch Traversal Stage. if ( checkPipelineForMessageAt(i)==true) { unsigned outPort; unsigned outVirtualChannel; m_InOutPortTable->valueAt(i, outPort); m_InOutVCTable->valueAt(i, outVirtualChannel); #ifndef NO_TRAZA TPZString texto2 = getComponent().asString() + " Flit BYPASS. TIME = "; texto2 += TPZString(delayTime) + " # " ; texto2 += TPZString(" InPort=") + TPZString(i) + " OutPort=" + TPZString(outPort); texto2 += TPZString(" OutVC=") + TPZString(outVirtualChannel); TPZWRITE2LOG(texto2); #endif ((TPZNetwork*)(getOwnerRouter().getOwner()))->incrEventCount( TPZNetwork::RouterBypass); TPZEvent SWTravEvent(_SwitchTraversal_, i, outPort, outVirtualChannel, msg); getEventQueue().enqueue(SWTravEvent, delayTime+1); } else { TPZEvent routingEvent(_RoutingVC_, i); getEventQueue().enqueue(routingEvent, delayTime); } } else { //data or tail going directly to arbitration Switch unsigned outPort; unsigned outVirtualChannel; m_InOutPortTable->valueAt(i, outPort); m_InOutVCTable->valueAt(i, outVirtualChannel); TPZEvent xbarAllocEvent(_SwitchAllocator_, i, outPort, outVirtualChannel, msg); getEventQueue().enqueue(xbarAllocEvent, delayTime); } inputInterfaz(i)->sendStopRightNow(); return true; }
unsigned bufferElements() const { return getEventQueue().numberOfElements(); }
Boolean TPZFifoMemoryFlowWH::inputReading() { TPZMessage* msg; inputInterfaz()->getData(&msg); if (!inputInterfaz()->isReadyActive() && m_tail==false) { uTIME delayTime = getOwnerRouter().getCurrentTime() ; TPZString err= "A tail flit was expected but transmission has been interrupted"; err=err+msg->asString()+ "Time crash=" + TPZString(delayTime); EXIT_PROGRAM(err); } if (inputInterfaz()->isReadyActive() ) { msg->incDistance(); ((TPZNetwork*)(getOwnerRouter().getOwner()))->incrEventCount( TPZNetwork::BufferWrite); if (msg->isTail() || msg->isHeadTail()) { m_tail=true; setControlTail(true); } if (msg->isHeader() || msg->isHeadTail()) { getOwnerRouter().incrContadorTotal(); } if (msg->isHeader() && m_tail==false) { uTIME delayTime = getOwnerRouter().getCurrentTime() ; TPZString err= "A head flit arrives before previous tail flit"; err=err+msg->asString()+ "Time crash=" + TPZString(delayTime); EXIT_PROGRAM(err); } if ( !bufferHoles()) { uTIME delayTime = getOwnerRouter().getCurrentTime() ; TPZString err; err.sprintf(ERR_TPZFFLOW_001, (char*)getComponent().asString()); err=err+msg->asString()+ "Time crash=" + TPZString(delayTime); EXIT_PROGRAM(err); } uTIME delay = getOwnerRouter().getCurrentTime() + getDataDelay(); TPZEvent event(_BufferData_, msg); getEventQueue().enqueue(event, delay); #ifndef NO_TRAZA uTIME delayTime = getOwnerRouter().getCurrentTime() ; TPZString texto = getComponent().asString() + " Flit Rx on Time" + TPZString(delayTime) + " # " + msg->asString() + ") holes= " + TPZString(bufferHoles()); TPZWRITE2LOG(texto); #endif stateChange(); if (m_SendStop) { inputInterfaz()->sendStopRightNow(); #ifndef NO_TRAZA uTIME time = getOwnerRouter().getCurrentTime(); TPZString texto = getComponent().asString() + ": Full Buffer->Stop "; texto += TPZString(time); TPZWRITE2LOG(texto); #endif } else { inputInterfaz()->clearStopRightNow(); } return true; } return false; }
void StreamEventHandler::handleStreamLine(string line, bool complete) { // string::iterator it = line.end(); size_t last_sensible = line.find_last_not_of("\r\n"); if (last_sensible != string::npos) { line = line.substr(0, last_sensible+1); } else if (line.find_first_of("\r\n") != string::npos) { /** * Hvis forrige søk ikke gav noen treff på noe annet en \r\n, og vi får treff på en \r\n nå, * så må vel det bety at linja er tom? */ line = ""; } // cerr << "line " << line.length()<<" [" << line << "]" << endl; if (!line.length()) { /** * If event is not empty, then we're done with it, so ship it off */ if (working_event && !working_event->isEmpty()) { getEventQueue()->queue(working_event, base_ident); /** * Allocate new event for next round */ working_event = NULL; } return; } if (!working_event) { working_event = new Event(); } vector<string> line_parts; try { Tokenize(line, line_parts, ":", 2); } catch(std::out_of_range &ex) { // void cerr << "Exception under parsing av event-linje" << endl; } if (line_parts.size() == 2) { /** * Linja e rett formatert */ // cout << "Setter parametre [" << line_parts[0] << "]:[" << line_parts[1] << "]" <<endl; string key = string_trim(line_parts[0]); string value = string_trim(line_parts[1]); working_event->setParameter(key, value); } else { /** * Linja e skeivt formatert. What to do? */ cerr << "Bad event line: [" << line << "]" << endl; } if (complete) { if (!working_event->isEmpty()) { getEventQueue()->queue(working_event, base_ident); } working_event = NULL; } }