Beispiel #1
0
    void Well::addCompletionSet(size_t time_step, CompletionSet new_set ){
        if( getWellCompletionOrdering() == WellCompletion::TRACK) {
            const auto headI = this->m_headI[ time_step ];
            const auto headJ = this->m_headJ[ time_step ];
            new_set.orderCompletions( headI, headJ );
        }

        m_completions.update( time_step, std::move( new_set ) );
        addEvent( ScheduleEvents::COMPLETION_CHANGE , time_step );
    }
Beispiel #2
0
CWMPEventParser::CWMPEventParser(const QDomNode &eventNode) {
    QDomNode node = eventNode.firstChild();
    while(!node.isNull()) {
        QByteArray dbgA = node.localName().toLatin1();
        qDebug("%s, %d: Node's name is %s", __FUNCTION__, __LINE__, dbgA.constData());
        addEvent(node);

        node = node.nextSibling();
    }
}
Beispiel #3
0
    void Well::updateWellConnections(size_t time_step, WellConnections * new_set ){
        if( getWellConnectionOrdering() == WellCompletion::TRACK) {
            const auto headI = this->m_headI[ time_step ];
            const auto headJ = this->m_headJ[ time_step ];
            new_set->orderConnections( headI, headJ );
        }

        m_completions.update( time_step, std::shared_ptr<WellConnections>( new_set ));
        addEvent( ScheduleEvents::COMPLETION_CHANGE , time_step );
    }
Beispiel #4
0
/*************************************************************************
	Constructor
*************************************************************************/
Renderer::Renderer(void)
    : d_resourceProvider(0),
      d_identifierString("Unknown renderer (vendor did not set the ID string!)")
{
	// setup standard events available
	addEvent(EventDisplaySizeChanged);

	// default initialisation
	resetZValue();
}
Beispiel #5
0
void Manager::putBottom(Seat* s, const std::vector<Card>& cards)
{
    logDebug(__PRETTY_FUNCTION__, "Seat(%d) put bottom", s->id());
    auto f = std::bind(&Manager::handlePutBottom, this, std::placeholders::_1);
    PutBottomMsg m;
    m.set_seat(s->seat());
    m << cards;
    auto e = new ValueCallbackEvent<PutBottomMsg, decltype(f)>(m, f);
    addEvent(e);
}
Beispiel #6
0
	Animation::Animation() :
		m_ID(0xffffffff),
		//m_Name(""),
		m_TotalTime(0),
		m_CurrentTime(0),
		m_AnimationEnded(0),
		m_bIsInitialized(false),
		m_Loop(true)
	{
		addEvent(AnimationFinishedEvent::GetEventName());
	}
Beispiel #7
0
void MainWindow::makeConnections() {
    connect(&storage, SIGNAL(eventAdded(CalendarEvent)),
            calendar, SLOT(addEvent(CalendarEvent)));
    connect(&storage, SIGNAL(eventRemoved(CalendarEvent)),
            calendar, SLOT(removeEvent(CalendarEvent)));

    connect(calendar, SIGNAL(eventRemoved(CalendarEvent)),
            &storage, SLOT(removeEvent(CalendarEvent)));
    connect(calendar, SIGNAL(eventUpdated(CalendarEvent,CalendarEvent)),
            &storage, SLOT(updateEvent(CalendarEvent,CalendarEvent)));
}
Beispiel #8
0
    bool Well::setProductionProperties(size_t timeStep , const WellProductionProperties& newProperties) {
        if (isInjector(timeStep))
            switchToProducer( timeStep );

        m_isProducer.update(timeStep , true);
        bool update = m_productionProperties.update(timeStep, newProperties);
        if (update)
            addEvent( ScheduleEvents::PRODUCTION_UPDATE, timeStep );

        return update;
    }
Beispiel #9
0
    bool Well::setInjectionProperties(size_t timeStep , const WellInjectionProperties& newProperties) {
        if (isProducer(timeStep))
            switchToInjector( timeStep );

        m_isProducer.update(timeStep , false);
        bool update = m_injectionProperties.update(timeStep, newProperties);
        if (update)
            addEvent( ScheduleEvents::INJECTION_UPDATE, timeStep );

        return update;
    }
void parseSequence(ModelInstance *comp) {
    fmi2String sequence = s(sequence_);
    int i = 0;
    if (sequence == NULL) {
        // This could happen if we are running fmusdk2 on this fmu.
        fprintf(stderr, "HybridSequenceCheck parseSequence(): sequence was null?\n");
        return;
    }
    char * pEnd;
    if (sizeof(*sequence) > 0) { 
        long t = strtol(sequence, &pEnd, 10);
        double v = strtod(pEnd, &pEnd);
        addEvent(v, t);
    }
    for (i = 1; i < strlen(s(sequence_)); i++) {
        long t = strtol(pEnd, &pEnd, 10);
        double v = strtod(pEnd, &pEnd);
        addEvent(v, t);
    }
}
void InspectorScriptProfilerAgent::didEvaluateScript(JSGlobalObject& globalObject, double startTime, ProfilingReason reason)
{
    m_activeEvaluateScript = false;

    if (m_enableLegacyProfiler)
        m_profiles.append(LegacyProfiler::profiler()->stopProfiling(globalObject.globalExec(), ASCIILiteral("ScriptProfiler")));

    double endTime = m_environment.executionStopwatch()->elapsedTime();

    addEvent(startTime, endTime, reason);
}
Beispiel #12
0
int main()
{
	int pipefd[2];
	int count = 15;
	if(pipe(pipefd) < 0) return -1;

	pid_t pid = fork();
	if(pid < 0) return -1;

	int pipeReadfd = pipefd[0];
	int pipeWritefd = pipefd[1];

	setFdNonblocking(pipeReadfd);

	if(0 == pid){
		int i = 0;
		int epfd = createEvent();

		if(addEvent(epfd, pipeReadfd, AE_READABLE) < -1) return -1;

		struct epoll_event *e = calloc(1024, sizeof(struct epoll_event));

		while(i++ < count){
			int ret = 0;
			if((ret = myRead(epfd, pipeReadfd, e)) < 0){
				//Here we do not check the situation that the "ret" less than 0
				//stracing or gdbing this process will trigger a siglarm which will cause "ret == -1"
			}
			//                              printf("ret val: %d\n", ret);
		}

		close(epfd);
		free(e);
		printf("child finished...\n");

	}else{
		int i = 0;

		while(i++ < count){
			usleep(100000);
			//                      char buf[1204];
			//                      memset(buf, 0x0, 1024);
			//                      fgets(buf, 10, stdin);
			write(pipeWritefd, "hello", 1024);
		}

		printf("parent finished...\n");
	}

	close(pipefd[0]);
	close(pipefd[1]);
	usleep(10000);
	return 0;
}
Beispiel #13
0
void Engine::process(const Event * event){
	if (timestamp == statsNextEvent){
		updateStats();
		statsNextEvent += statsPeriod;
		stats->printInterval(statsOut);
		statsOut << endl;
		currentInterval++;
		stats->startInterval();
	}
	if (timestamp == progressNextEvent){
		progressNextEvent += progressPeriod;
		uint64 eventsInPeriod = numEvents - lastNumEvents;
		struct timeval current;
		gettimeofday(&current, NULL);
		long seconds  = current.tv_sec  - last.tv_sec;
		long useconds = current.tv_usec - last.tv_usec;
		long mtime = seconds * 1000000 + useconds;
		double eventsPerSecond = 1000000 * (static_cast<double>(eventsInPeriod) / static_cast<double>(mtime));
		cout << "Between timestamps " << lastTimestamp << " and " << timestamp << " executed " << eventsInPeriod << " events (" << eventsPerSecond << " events per second)" << endl;
		lastTimestamp = timestamp;
		lastNumEvents = numEvents;
		last = current;
	}
	if (!currentEventsEmpty() || !events.empty()){
		if (statsNextEvent == 0){
			if (progressNextEvent != 0){
				addEvent(progressNextEvent - timestamp, this);
			}
		} else {
			if (progressNextEvent == 0){
				addEvent(statsNextEvent -timestamp, this);
			} else {
				if (statsNextEvent < progressNextEvent){
					addEvent(statsNextEvent -timestamp, this);
				} else {
					addEvent(progressNextEvent - timestamp, this);
				}
			}
		}
	}
}
void MessageCenter::process(AudioSampleBuffer& buffer, MidiBuffer& eventBuffer)
{
	softTimestamp = Time::getHighResolutionTicks() - lastTime;
    setTimestamp(eventBuffer,getTimestamp());
    if (needsToSendTimestampMessage)
    {
        String eventString = "Software time: " + String(getTimestamp(true)) + "@" + String(Time::getHighResolutionTicksPerSecond()) + "Hz";
        CharPointer_UTF8 data = eventString.toUTF8();

        addEvent(eventBuffer,
                 MESSAGE,
                 0,
                 0,
                 0,
                 data.length() + 1, //It doesn't hurt to send the end-string null and can help avoid issues
                 (uint8*)data.getAddress());

        needsToSendTimestampMessage = false;
    }

    if (newEventAvailable)
    {
        //int numBytes = 0;

        String eventString = messageCenterEditor->getLabelString();

        CharPointer_UTF8 data = eventString.toUTF8();

        addEvent(eventBuffer,
                 MESSAGE,
                 0,
                 0,
                 0,
                 data.length()+1, //It doesn't hurt to send the end-string null and can help avoid issues
                 (uint8*) data.getAddress());

        newEventAvailable = false;
    }


}
Beispiel #15
0
/*************************************************************************
	add events for the System object
*************************************************************************/
void System::addSystemEvents(void)
{
    addEvent(EventGUISheetChanged);
    addEvent(EventSingleClickTimeoutChanged);
    addEvent(EventMultiClickTimeoutChanged);
    addEvent(EventMultiClickAreaSizeChanged);
    addEvent(EventDefaultFontChanged);
    addEvent(EventDefaultMouseCursorChanged);
    addEvent(EventMouseMoveScalingChanged);
}
boolean RapifireMqttClient::addEvent(const char* name, const char* type, String value)
{
  String event = F("{\"n\":\"");
  event += name;
  event += F("\",\"");
  event += type;
  event += F("\":");
  event += value;
  event += F("}");

  return addEvent(event);
}
Beispiel #17
0
    bool Well::setStatus(size_t timeStep, WellCommon::StatusEnum status) {
        if ((WellCommon::StatusEnum::OPEN == status) && getConnections(timeStep).allConnectionsShut()) {
            OpmLog::note("When handling keyword for well " + name() + ": Cannot open a well where all completions are shut" );
            return false;
        } else {
            bool update = m_status.update( timeStep , status );
            if (update)
                addEvent( ScheduleEvents::WELL_STATUS_CHANGE , timeStep );

            return update;
        }
    }
Beispiel #18
0
SplitTextApp::SplitTextApp() 
{
	addModifier(new poCamera2D());
	
	std::string s = "In the late 1930s, Max Marcus ran a general merchandise auction house out of one of the basement storefronts at 97 Orchard Street. His entire life was shaped by doing business on the Lower East Side. By the late 1980s, Marcus was running a botanica at the nearby Essex Street indoor market.";
	
	t = new flyingText(s, 250, 400, 0, 1.f, 5.f);
	t->position.set(200,25,0);
	addChild(t);
	
	addEvent(PO_KEY_DOWN_EVENT, this);
}
static int8_t setHupEvent(dispatcher_t* disp, entity_context_t* ent_context) {

	int8_t ret = -1;
	if (ent_context->event_hup) {
		pthread_mutex_lock(&(disp->disp_state));
		ret = addEvent(disp, ent_context, EPOLLHUP);
		if (ret > 0)
			ent_context->event_flags |= EPOLLHUP;
		pthread_mutex_unlock(&(disp->disp_state));
	}
	return ret;	
}
/*************************************************************************
	Add multi-line edit box specific events	
*************************************************************************/
void MultiLineEditbox::addMultiLineEditboxEvents(bool bCommon)
{
    if ( bCommon == false )
    {
        addEvent(EventReadOnlyModeChanged);
        addEvent(EventWordWrapModeChanged);
        addEvent(EventMaximumTextLengthChanged);
        addEvent(EventCaratMoved);
        addEvent(EventTextSelectionChanged);
        addEvent(EventEditboxFull);
        addEvent(EventVertScrollbarModeChanged);
        addEvent(EventHorzScrollbarModeChanged);
    }
}
 void DragContainer::addDragContainerEvents(bool bCommon)
 {
     if ( bCommon == false )
     {
         addEvent(EventDragStarted);
         addEvent(EventDragEnded);
         addEvent(EventDragPositionChanged);
         addEvent(EventDragEnabledChanged);
         addEvent(EventDragAlphaChanged);
         addEvent(EventDragMouseCursorChanged);
         addEvent(EventDragThresholdChanged);
         addEvent(EventDragDropTargetChanged);
     }
 }
Beispiel #22
0
StarShapeApp::StarShapeApp() {
	addModifier(new poCamera2D(poColor::black));
    
    addEvent(PO_KEY_DOWN_EVENT, this);
    
    numPoints = 5;
    radius = 100;
    depth = 40; 
    
    s = new poStarShape(radius, numPoints, depth); 
    s->position = poPoint(300,150);
    addChild(s);
}
Beispiel #23
0
/////////////////////////////////////////////////////////////////////////////
// CDuiScrollBar
CDuiScrollBar::CDuiScrollBar()
    : m_pSkin(NULL)
    , m_bDrag(FALSE)
    , m_uClicked(-1)
    , m_bNotify(FALSE)
    , m_uHtPrev(-1)
    , m_uAllowSize(-1)
    , m_bVertical(TRUE)
{
    memset(&m_si,0,sizeof(SCROLLINFO));
    m_si.nTrackPos=-1;
	addEvent(DUINM_SCROLL);
}
Beispiel #24
0
/*
================
idCameraDef::addTarget
================
*/
void idCameraDef::addTarget(const char *name, idCameraPosition::positionType type) {
	const char *text = (name == NULL) ? va("target0%d", numTargets()+1) : name;
	idCameraPosition *pos = newFromType(type);
	if (pos) {
		pos->setName(name);
		targetPositions.Append(pos);
		activeTarget = numTargets()-1;
		if (activeTarget == 0) {
			// first one
			addEvent(idCameraEvent::EVENT_TARGET, name, 0);
		}
	}
}
void l1menu::TriggerRatePlot::addEvent( const l1menu::IEvent& event )
{
	const l1menu::ISample& sample=event.sample();
	float weightPerEvent=sample.eventRate()/sample.sumOfWeights();

	// For some implementations of ISample, it is significantly faster to
	// create ICachedTriggers and then loop over those. The addEvent overload
	// I'm about to delegate to loops over the histogram bins, so even for
	// one event this trigger can be called multiple times.
	std::unique_ptr<l1menu::ICachedTrigger> pCachedTrigger=sample.createCachedTrigger( *pTrigger_ );

	addEvent( event, pCachedTrigger, weightPerEvent );
}
static int8_t registerEntity(dispatcher_t* disp,
		entity_context_t* ent_context) {

	pthread_mutex_lock(&(disp->disp_state));
	int32_t ret = 0;
	if (ent_context->fd >= disp->fd_lk->max_fds) {
		ret = -1;
		goto disp_unlock;
	}
	if (disp->fd_flag[ent_context->fd] == -1) {
		int8_t found_event = 0;
		int8_t found_timeout = 0;
		disp->fd_flag[ent_context->fd] = 1;
		disp->con_ptr[ent_context->fd] = ent_context;
		if ((ent_context->fd >= 0) && (ent_context->event_flags)) {
			if (addEvent(disp, ent_context, 
						ent_context->event_flags) < 0) {
				ret = -2;
				goto reg_error;
			}
			found_event = 1;
			setNonBlocking(ent_context->fd);
		}
		if ((ent_context->to_be_scheduled.tv_sec != 0) &&
				(ent_context->to_be_scheduled.tv_usec != 0)) {
			if (scheduleTimeoutEventLockHeld(disp,
						ent_context) < 0) {
				if (found_event == 1)
					delEvent(disp, ent_context, 
							ent_context->event_flags);
				ret = -2;
				goto reg_error;
			}
			found_timeout = 1;
		}
		if ((found_event == 1) || (found_timeout == 1)) {
			DBG_DISPLOG(DISP_MOD_NAME, DISP_MSG, disp_log_id, "Register success");
			ret = 1;
			goto disp_unlock;
		}
		ret = -3;
		goto reg_error;
	}
	ret = -4;
reg_error:
	disp->fd_flag[ent_context->fd] = -1;
	disp->con_ptr[ent_context->fd] = NULL;
disp_unlock:
	pthread_mutex_unlock(&(disp->disp_state));
	return ret;
}
Beispiel #27
0
bool ListenSocket::listen(uint32 ip, int port)
{
	if (!createSocket(SOCK_STREAM))
		return false;

	if (!bindAddress(ip, port)) {
		ICQ_LOG("Can not bind on port %d\n", port);
		return false;
	}

	::listen(sockfd, 5);
	addEvent(SOCKET_READ);
	return true;
}
Beispiel #28
0
Event* addFileEvent(EventLoop *loop, int sfd, void (*callback)(EventLoop*, void*), void *data, int op)
{
	Event *evt=getNextEvent(loop);
	PRINT("add file event %p", evt);
	assert(evt!=NULL);

	evt->fd=sfd;
	evt->callback=callback;
	evt->type=FILE_EVT;
	evt->data=data;

	addEvent(loop, evt, op);
	return evt;
}
	/*************************************************************************
		Overridden subscribeEvent (with group) which always succeeds.
	*************************************************************************/
	Event::Connection GlobalEventSet::subscribeEvent(const String& name, Event::Group group, Event::Subscriber subscriber)
	{
		EventMap::iterator pos = d_events.find(name);

		// if event did not exist, add it and then find it.
		if (pos == d_events.end())
		{
			addEvent(name);
			pos = d_events.find(name);
		}

		// do subscription with group
		return pos->second->subscribe(group, subscriber);
	}
void l1menu::TriggerRatePlot::addSample( const l1menu::ISample& sample )
{
	float weightPerEvent=sample.eventRate()/sample.sumOfWeights();

	// Create a cached trigger, which depending on the concrete type of the ISample
	// may or may not significantly increase the speed at which this next loop happens.
	std::unique_ptr<l1menu::ICachedTrigger> pCachedTrigger=sample.createCachedTrigger( *pTrigger_ );

	for( size_t eventNumber=0; eventNumber<sample.numberOfEvents(); ++eventNumber )
	{
		addEvent( sample.getEvent(eventNumber), pCachedTrigger, weightPerEvent );
	} // end of loop over events

}