Exemple #1
0
TestResult xUnitTest::Run()
{
    for (auto &recorder : testEventRecorders)
    {
        recorder->Tie([&](TestEvent &&evt) { AddEvent(std::move(evt)); });
    }

    testStart = Time::Clock::now();

    try
    {
        test();
    }
    catch (const xUnitAssert &assert)
    {
        AddEvent(TestEvent(EventLevel::Assert, assert));
    }
    catch (const std::exception &e)
    {
        AddEvent(TestEvent(e));
    }
    catch (...)
    {
        AddEvent(TestEvent(EventLevel::Fatal, "Unknown exception caught: test has crashed."));
    }

    testStop = Time::Clock::now();

    return failureEventLogged ? TestResult::Failure : TestResult::Success;
}
Exemple #2
0
int CEventQueue::Restore( IRestore &restore )
{
	// clear the event queue
	Clear();

	// rebuild the event queue by restoring all the queue items
	EventQueuePrioritizedEvent_t tmpEvent;

	// load the number of items saved
	if ( !restore.ReadFields( "EventQueue", this, NULL, m_DataMap.dataDesc, m_DataMap.dataNumFields ) )
		return 0;
	
	for ( int i = 0; i < m_iListCount; i++ )
	{
		if ( !restore.ReadFields( "PEvent", &tmpEvent, NULL, tmpEvent.m_DataMap.dataDesc, tmpEvent.m_DataMap.dataNumFields ) )
			return 0;

		// add the restored event into the list
		if ( tmpEvent.m_pEntTarget )
		{
			AddEvent( tmpEvent.m_pEntTarget, STRING(tmpEvent.m_iTargetInput), tmpEvent.m_VariantValue, tmpEvent.m_flFireTime - gpGlobals->curtime, tmpEvent.m_pActivator, tmpEvent.m_pCaller, tmpEvent.m_iOutputID );
		}
		else
		{
			AddEvent( STRING(tmpEvent.m_iTarget), STRING(tmpEvent.m_iTargetInput), tmpEvent.m_VariantValue, tmpEvent.m_flFireTime - gpGlobals->curtime, tmpEvent.m_pActivator, tmpEvent.m_pCaller, tmpEvent.m_iOutputID );
		}
	}

	return 1;
}
BOOL COSMCtrlMapOperationsDlg::DeleteCachedTilesHelper()
{
  //What will be the return value from this function (assume the best)
  BOOL bSuccess = TRUE;

  //Accumulate how many tiles we have deleted and not deleted
  int nTilesDeleted = 0;
  int nTilesNotDeleted = 0;

  //Work thro all the tiles
  CString sCacheDirectory(m_pOSMCtrl->GetCacheDirectory());
  for (std::vector<COSMCtrlMapOperationsDlgTile>::size_type i=0; (i<m_Tiles.size()) && bSuccess; i++)
  {
    //Pull out the tile we are working on
    const COSMCtrlMapOperationsDlgTile& tile = m_Tiles[i];

    //Do the deletion of the tile        
    CString sTile(m_pOSMCtrl->GetTileCachePath(sCacheDirectory, tile.m_nZoom, tile.m_nTileX, tile.m_nTileY, FALSE));
    COSMCtrlMapOperationsDlgEvent dlgEvent;
    if (GetFileAttributes(sTile) != INVALID_FILE_ATTRIBUTES) //Don't bother doing anything if the tile does not already exist
    {
      if (DeleteFile(sTile))
      {
        //Update the stats
        ++nTilesDeleted;
        
        dlgEvent.m_bSuccess = true;
      }
      else
      {
        //Update the stats
        ++nTilesNotDeleted;
        
        dlgEvent.m_bSuccess = false;
      }
    }

    //Update the UI          
    dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
    dlgEvent.m_sString = sTile;
    dlgEvent.m_nItemData = i + 1;
    AddEvent(dlgEvent);
    
    //Check if we have been cancelled before we loop around
    bSuccess = (WaitForSingleObject(m_WorkerTerminateEvent, 0) == WAIT_TIMEOUT);
  }
  
  //Finally add a event about how many items have been deleted
  COSMCtrlMapOperationsDlgEvent dlgEvent;
  dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus;
  CString sTilesDeleted;
  sTilesDeleted.Format(_T("%d"), nTilesDeleted);
  CString sTilesNotDeleted;
  sTilesNotDeleted.Format(_T("%d"), nTilesNotDeleted);
  AfxFormatString2(dlgEvent.m_sString, IDS_OSMCTRL_DELETE_FILES_STATS, sTilesDeleted, sTilesNotDeleted);
  AddEvent(dlgEvent);
  
  return bSuccess;
}
Exemple #4
0
void Extension::SaveReceivedBinaryToFile(int Position, int Size, char * Filename)
{
    if (Position < 0)
        CreateError("Cannot save received binary; Position less than 0.");
    else if (Size <= 0)
        CreateError("Cannot save received binary; Size equal or less than 0.");
    else if (!Filename || Filename[0] == '\0')
        CreateError("Cannot save received binary; filename is invalid.");
    else if (ThreadData.ReceivedMsg.Size - Size <= 0)
        CreateError("Cannot save received binary; Message is too small.");
    else
    {
        FILE * File = NULL;
        if (fopen_s(&File, Filename, "wb") || !File)
        {
            char errorval[20];
            SaveExtInfo &S = AddEvent(0);
            std::string Error = "Cannot save received binary to file, error ";
            if (_itoa_s(*_errno(), &errorval[0], 20, 10))
            {
                Error += " with opening the file, and with converting error number.";
            }
            else
            {
                Error += "number [";
                Error += &errorval[0];
                Error += "] occured with opening the file.";
            }
            Error += "\r\nThe message has not been modified.";
            S.Error.Text = _strdup(Error.c_str());
            return;
        }
        // Jump to end
        fseek(File, 0, SEEK_END);
        // Read current position as file size
        long long filesize = _ftelli64(File);
        // Go back to start
        fseek(File, 0, SEEK_SET);
        long l;
        if ((l = fwrite(ThreadData.ReceivedMsg.Content + Position, 1, Size, File)) != Size)
        {
            char sizeastext[20];
            SaveExtInfo &S = AddEvent(0);
            std::string Error = "Couldn't save the received binary to file, ";
            if (_itoa_s(errno, &sizeastext[0], 20, 10))
            {
                Error += " and error copying size.";
            }
            else
            {
                Error += &sizeastext[0];
                Error += " bytes managed to be written.";
            }
            S.Error.Text = _strdup(Error.c_str());
        }
        fclose(File);
    }
}
CUAC_Thread::CUAC_Thread(int processId)
{
	m_processId = processId;

	AddEvent(UAC_PASTE, StrF(_T("Global\\UAC_PASTE_%d"), m_processId));
	AddEvent(UAC_COPY, StrF(_T("Global\\UAC_COPY_%d"), m_processId));
	AddEvent(UAC_CUT, StrF(_T("Global\\UAC_CUT_%d"), m_processId));

	AddEvent(UAC_EXIT, StrF(_T("Global\\UAC_EXIT_%d"), m_processId));

	m_waitTimeout = 30000;
}
Exemple #6
0
void CInputJoystick::StartUp(void)
{

	AddEvent(EVENT_TYPE_SDL, SDL_JOYAXISMOTION);
	AddEvent(EVENT_TYPE_SDL, SDL_JOYBALLMOTION);
	AddEvent(EVENT_TYPE_SDL, SDL_JOYHATMOTION);
	AddEvent(EVENT_TYPE_SDL, SDL_JOYBUTTONDOWN);
	AddEvent(EVENT_TYPE_SDL, SDL_JOYBUTTONUP);
	RegisterEventManager();

	LoadJoysticks();
}
Exemple #7
0
void Extension::AppendReceivedBinaryToFile(int Position, int Size, char * Filename)
{
    if (Position < 0)
        CreateError("Cannot append received binary; Position less than 0.");
    else if (Size <= 0)
        CreateError("Cannot append received binary; Size equal or less than 0.");
    else if (!Filename || Filename[0] == '\0')
        CreateError("Cannot append received binary; filename is invalid.");
    else if (ThreadData.ReceivedMsg.Size - Size <= 0)
        CreateError("Cannot append received binary; Message is too small.");
    else
    {
        // Open while denying write of other programs
        FILE * File = _fsopen(Filename, "ab", SH_DENYWR);
        if (!File)
        {
            char errorval[20];
            SaveExtInfo &S = AddEvent(0);
            std::string Error = "Cannot append received binary to file, error ";
            if (_itoa_s(*_errno(), &errorval[0], 20, 10))
            {
                Error += " with opening the file, and with converting error number.";
            }
            else
            {
                Error += "number [";
                Error += &errorval[0];
                Error += "] occured with opening the file.";
            }
            Error += "\r\nThe message has not been modified.";
            S.Error.Text = _strdup(Error.c_str());
            return;
        }
        long l;
        if ((l = fwrite(ThreadData.ReceivedMsg.Content + Position, 1, Size, File)) != Size)
        {
            char sizeastext[20];
            SaveExtInfo &S = AddEvent(0);
            std::string Error = "Couldn't append the received binary to file, ";
            if (_itoa_s(errno, &sizeastext[0], 20, 10))
            {
                Error += " and error copying size.";
            }
            else
            {
                Error += &sizeastext[0];
                Error += " bytes managed to be append.";
            }
            S.Error.Text = _strdup(Error.c_str());
        }
        fclose(File);
    }
}
Exemple #8
0
 void OnEvent(int id) {
   if (id == m_event_open)
   {
     if (connected < antal)
     {
       TestSocket *p = new TestSocket(static_cast<EventHandler&>(Handler()));
       p -> SetDeleteByHandler();
       p -> Open(host, port);
       Handler().Add(p);
     }
     else
     {
       printf("Finished connecting. %d connected / %d failed / %d lost\n", connected, failed, lost);
     }
     m_event_open = AddEvent(interval / 1000, (interval % 1000) * 1000);
   }
   else
   if (id == m_event_request)
   {
     if (m_req_index < full_request.size())
     {
       if (full_request[m_req_index] == '\r')
       {
         printf("<CR>");
         fflush(stdout);
       }
       if (full_request[m_req_index] == '\n')
       {
         printf("<LF>");
         fflush(stdout);
       }
       SendBuf( &full_request[m_req_index], 1 );
       m_req_index++;
       m_event_request = AddEvent(delay / 1000, (delay % 1000) * 1000);
     }
     else
     {
       m_event_restart = AddEvent(3, 0);
     }
   }
   else
   if (id == m_event_restart)
   {
     m_req_index = 0;
     m_event_request = AddEvent(delay / 1000, (delay % 1000) * 1000);
   }
   else
   {
     fprintf(stderr, "%9lu %5u Unknown event id\n", UniqueIdentifier(), GetSockPort());
     SetCloseAndDelete();
   }
 }
Exemple #9
0
void CastleScene::Initialize(void) {
	boost::optional<boost::shared_ptr<Error> > error;
	if(error = AddEvent(EVENT_TYPE_NEXT_STEP)) {
		error.get()->Abort();
		BOOST_ASSERT(false);
	}
	if(error = AddEvent(EVENT_TYPE_INPUT_STRING)) {
		error.get()->Abort();
		BOOST_ASSERT(false);
	}
	if(error = AddEvent(EVENT_TYPE_ON_SELECT)) {
		error.get()->Abort();
		BOOST_ASSERT(false);
	}
}
	//! Take the existing events and put them in bins
	void Bin(int no_bins, T min, T max) {
		typename std::map<T,int>::iterator f;
		if (events.empty()) return;
		EventCounter binned_cntr;

		T delta = (max - min) / no_bins;
		std::cout << "Delta is " << delta << std::endl;
		for (f = events.begin(); f != events.end(); ++f) {
			T value = (*f).first;
			int bin_id = 0;
			if (value >= min) bin_id = (value - min) / delta;
			if (value > max) bin_id = no_bins;
			T bin_value = min + delta * bin_id;
//			std::cout << "Bin id is " << bin_id << "(" << value << "-" << min << ") /" << no_bins << " and bin value thus: " << bin_value << std::endl;
			binned_cntr.AddEvent(bin_value, (*f).second);
		}
		int size = events.size();
		events.clear();
		for (f = binned_cntr.getEvents().begin(); f != binned_cntr.getEvents().end(); ++f) {
			AddEvent(f->first, f->second);
		}
		std::cerr << "Goes from size " << size << " to " << events.size() << std::endl;
		if (events.size() < 10) {
			std::cerr << "Maybe use more than " << no_bins << " bins" << std::endl;
		}

		// add e.g. assert on nr of events (should be the same)
	}
Exemple #11
0
VSCPanel::VSCPanel(QWidget *parent, Qt::WindowFlags flags)
    : QWidget(parent, flags)
{
	ui.setupUi(this);
	setAcceptDrops(true);
	setMouseTracking(true);
	ui.scrollArea->setBackgroundRole(QPalette::Light);

	/* Setup connection */
	connect(ui.pbView, SIGNAL(clicked()), this, SIGNAL(AddSurveillance()));
	connect(ui.pbSearch, SIGNAL(clicked()), this, SIGNAL(Search()));
	connect(ui.pbMining, SIGNAL(clicked()), this, SIGNAL(AddDmining()));
	connect(ui.pbEmap, SIGNAL(clicked()), this, SIGNAL(AddEmap()));
	connect(ui.pbRecordPlan, SIGNAL(clicked()), this, SIGNAL(AddRecordPlan())); 

	connect(ui.pbRecorder, SIGNAL(clicked()), this, SIGNAL(AddRecorder()));
	connect(ui.pbCamera, SIGNAL(clicked()), this, SIGNAL(AddCamera()));

	connect(ui.pbSetting, SIGNAL(clicked()), this, SIGNAL(Setting()));
	connect(ui.pbAlarm, SIGNAL(clicked()), this, SIGNAL(AddEvent()));
	connect(ui.pbVIPC, SIGNAL(clicked()), this, SIGNAL(AddVIPC()));

	connect(ui.pbTasklist, SIGNAL(clicked()), this, SLOT(UpdateTaskList()));


	UpdateTaskList();
}
Exemple #12
0
bool WrappedOpenGL::Serialise_glDebugMessageInsert(SerialiserType &ser, GLenum source, GLenum type,
                                                   GLuint id, GLenum severity, GLsizei length,
                                                   const GLchar *buf)
{
  std::string name = buf ? std::string(buf, buf + (length > 0 ? length : strlen(buf))) : "";

  // unused, just for the user's benefit
  SERIALISE_ELEMENT(source);
  SERIALISE_ELEMENT(type);
  SERIALISE_ELEMENT(id);
  SERIALISE_ELEMENT(severity);
  SERIALISE_ELEMENT(name);

  SERIALISE_CHECK_READ_ERRORS();

  if(IsReplayingAndReading())
  {
    GLMarkerRegion::Set(name);

    if(IsLoading(m_State))
    {
      DrawcallDescription draw;
      draw.name = name;
      draw.flags |= DrawFlags::SetMarker;

      AddEvent();
      AddDrawcall(draw, false);
    }
  }

  return true;
}
Exemple #13
0
bool WrappedOpenGL::Serialise_glInsertEventMarkerEXT(SerialiserType &ser, GLsizei length,
                                                     const GLchar *marker_)
{
  std::string marker =
      marker_ ? std::string(marker_, marker_ + (length > 0 ? length : strlen(marker_))) : "";

  SERIALISE_ELEMENT(marker);

  SERIALISE_CHECK_READ_ERRORS();

  if(IsReplayingAndReading())
  {
    GLMarkerRegion::Set(marker);

    if(IsLoading(m_State))
    {
      DrawcallDescription draw;
      draw.name = marker;
      draw.flags |= DrawFlags::SetMarker;

      AddEvent();
      AddDrawcall(draw, false);
    }
  }

  return true;
}
Exemple #14
0
bool WrappedOpenGL::Serialise_glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
{
	SERIALISE_ELEMENT(GLenum, buf, buffer);
	SERIALISE_ELEMENT(int32_t, draw, drawbuffer);
	SERIALISE_ELEMENT(float, d, depth);
	SERIALISE_ELEMENT(int32_t, s, stencil);
	
	if(m_State <= EXECUTING)
		m_Real.glClearBufferfi(buf, draw, d, s);
	
	const string desc = m_pSerialiser->GetDebugStr();

	if(m_State == READING)
	{
		AddEvent(CLEARBUFFERFI, desc);
		string name = "glClearBufferfi(" +
						ToStr::Get(buf) + ", " +
						ToStr::Get(draw) + ")";

		FetchDrawcall draw;
		draw.name = widen(name);
		draw.flags |= eDraw_Clear;

		AddDrawcall(draw, true);
	}

	return true;
}
Exemple #15
0
void ElunaEventProcessor::Update(uint32 diff, Eluna* E, WorldObject* obj)
{
    m_time += diff;
    for (EventList::iterator it = eventList.begin(); it != eventList.end() && it->first <= m_time; it = eventList.begin())
    {
        LuaEvent* luaEvent = it->second;
        eventList.erase(it);

        if (!luaEvent->abort)
        {
            bool remove = luaEvent->repeats == 1;
            if (!remove)
                AddEvent(*luaEvent, true); // Reschedule before calling incase RemoveEvents used

            // Call the timed event
            E->OnTimedEvent(luaEvent->funcRef, luaEvent->delay, luaEvent->repeats ? luaEvent->repeats-- : luaEvent->repeats, obj);

            if (!remove)
                continue;
        }

        // Event should be deleted (executed last time or set to be aborted)
        luaL_unref(E->L, LUA_REGISTRYINDEX, luaEvent->funcRef);
        eventMap.erase(luaEvent->funcRef);
    }
}
IOEventRef IOEventLoop::AddWriteEvent(int fd,
                                      const std::function<bool()>& callback) {
  if (!MakeFdNonBlocking(fd)) {
    return nullptr;
  }
  return AddEvent(fd, EV_WRITE | EV_PERSIST, nullptr, callback);
}
Exemple #17
0
CMainFrmThread::CMainFrmThread(void)
{
    for(int eventEnum = 0; eventEnum < ECMAINFRMTHREADEVENTS_COUNT; eventEnum++)
    {
        AddEvent(eventEnum);
    }
}
Exemple #18
0
void EventMgr::EventLoop()
{
	ThreadPool pool(5,true);
	pool.PoolStart();

	while(true)
	{
		struct epoll_event events[MAX_EVENTS];
		int nfds = epoll_wait(m_epfd,events,MAX_EVENTS,-1);
		for (int i = 0; i < nfds; ++i)
		{
			if (events[i].data.fd == listenfd){
				struct sockaddr_in peer_addr;
				socklen_t addr_len = 0;
				memset(&peer_addr,0,sizeof(peer_addr));
				int connfd;
				if((connfd = accept(listenfd,(struct sockaddr*)&peer_addr,&addr_len)) == -1){
					perror("accept error\n");
				}
				fprintf(stdout,"get a connection from %s:%d\n",inet_ntoa(peer_addr.sin_addr),ntohs(peer_addr.sin_port));
				AddEvent(connfd,EPOLLIN);
			}else if(events[i].events & EPOLLIN){
				int connfd = events[i].data.fd;
				PoolTask *pTask = new PoolTask();
				pTask->SetCallbackFun((callback_t)handle_connection);
				pTask->SetCallbackData((void*)connfd);
				pool.PushTask(pTask);
				RemoveEvent(connfd);
			}else{
				continue;
			}
		}
	}
}
Exemple #19
0
bool WrappedOpenGL::Serialise_glPushDebugGroup(SerialiserType &ser, GLenum source, GLuint id,
                                               GLsizei length, const GLchar *message)
{
  std::string name =
      message ? std::string(message, message + (length > 0 ? length : strlen(message))) : "";

  // unused, just for the user's benefit
  SERIALISE_ELEMENT(source);
  SERIALISE_ELEMENT(id);
  SERIALISE_ELEMENT(name);

  SERIALISE_CHECK_READ_ERRORS();

  if(IsReplayingAndReading())
  {
    GLMarkerRegion::Begin(name, source, id);
    m_ReplayEventCount++;

    if(IsLoading(m_State))
    {
      DrawcallDescription draw;
      draw.name = name;
      draw.flags |= DrawFlags::PushMarker;

      AddEvent();
      AddDrawcall(draw, false);
    }
  }

  return true;
}
Exemple #20
0
	void Animation2D::Read(const tinyxml2::XMLElement& el_ )
	{
		Animation::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		//float totalTime = 0.0f;

		while (pElemFrame != nullptr)
		{
			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->Read(const_cast<tinyxml2::XMLElement *>(pElemFrame));
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();

			/*unsigned int spriteID;
			pElemFrame->QueryUnsignedAttribute("spriteID", &spriteID);
			float time;
			pElemFrame->QueryFloatAttribute("time", &time);

			std::ostringstream str;
			str << spriteID;

			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->FrameID(str.str().c_str());
			pFrameEvent->Time(time + totalTime);
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();
			totalTime += time;*/
		}
	}
Exemple #21
0
void VSCMainWindows::SetupConnections()
{
    connect(m_pMainArea, SIGNAL(tabCloseRequested(int)), this, SLOT(MainCloseTab(int)));
    connect(m_pDeviceList, SIGNAL(SurveillanceClicked()), this, SLOT(AddSurveillance()));
    connect(m_pDeviceList, SIGNAL(CameraAddClicked()), this, SLOT(AddCamera()));
    connect(m_pDeviceList, SIGNAL(PlaybackClicked()), this, SLOT(AddPlayback()));
    connect(m_pDeviceList, SIGNAL(SearchClicked()), this, SLOT(Search()));
    connect(m_pDeviceList, SIGNAL(RecorderClicked()), this, SLOT(AddRecorder()));
    connect(m_pDeviceList, SIGNAL(SiteAddClicked()), this, SLOT(AddSite()));

    
    connect(m_pDeviceList, SIGNAL(CameraEditClicked(int)), this, SLOT(EditCamera(int)));
    connect(m_pDeviceList, SIGNAL(CameraDeleteClicked(int)), this, SLOT(DeleteCamera(int)));

    connect(m_pDeviceList, SIGNAL(SiteEditClicked(int)), this, SLOT(EditSite(int)));
    connect(m_pDeviceList, SIGNAL(SiteDeleteClicked(int)), this, SLOT(DeleteSite(int)));


    /* Disk edit */
    connect(m_pDeviceList, SIGNAL(DiskEditClicked()), this, SLOT(EditDisk()));
	

    //connect(this, SIGNAL(CameraDeleted()), m_pDeviceList, SLOT(CameraTreeUpdated()));
    connect(m_pToolBar->ui.pbFullScreen, SIGNAL(clicked()), this, SLOT(SetFullScreen()));
    connect(m_pToolBar->ui.pbAbout, SIGNAL(clicked()), this, SLOT(about()));
    connect(m_pToolBar->ui.pbAlarm, SIGNAL(clicked()), this, SLOT(AddEvent()));
    connect(m_pToolBar->ui.pbSetting, SIGNAL(clicked()), this, SLOT(Setting()));
    connect(m_pEventThread, SIGNAL(EventNotifyNoParam()), m_pToolBar, SLOT(NewAlarm()));

}
Exemple #22
0
bool WrappedOpenGL::Serialise_glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
{
	SERIALISE_ELEMENT(GLenum, buf, buffer);
	SERIALISE_ELEMENT(int32_t, draw, drawbuffer);
	
	{
		uint32_t v[4];
		if(value) memcpy(v, value, sizeof(v));

		m_pSerialiser->Serialise<4>("value", v);
		
		if(m_State <= EXECUTING)
			m_Real.glClearBufferuiv(buf, draw, v);
	}
	
	const string desc = m_pSerialiser->GetDebugStr();

	if(m_State == READING)
	{
		AddEvent(CLEARBUFFERUI, desc);
		string name = "glClearBufferuiv(" +
						ToStr::Get(buf) + ", " +
						ToStr::Get(draw) + ")";

		FetchDrawcall draw;
		draw.name = widen(name);
		draw.flags |= eDraw_Clear;

		AddDrawcall(draw, true);
	}

	return true;
}
WorkoutWindow::WorkoutWindow(RunnerDatabase * databasePointer, RunningProfile selectedProfile,QDate selectedDate,
                             QList< QList<RunningEvent> > athleteEvents)
{
    setupUi(this);

    TheDatabase = databasePointer;
    CurrentProfile = selectedProfile;
    WorkoutDate = selectedDate;
    LoadedEvents = athleteEvents;

    //Update label to show current profile name
    ProfileNameLabel->setText(selectedProfile.returnName());
    //Update label to show current date
    WorkoutDateLabel->setText(selectedDate.toString(RunnerDatabase::DATE_FORMAT));

    //Find the model workout to be displayed
    findModelWorkout();
    UpdateWorkoutList();

    //Set the default button to be the Add Event Button
    AddButton->setFocus();

    //Form connections
    connect(AddButton,SIGNAL(clicked()),this,SLOT(AddEvent()));
    connect(buttonBox,SIGNAL(accepted()),this,SLOT(SaveChangesToDatabase()));
    connect(buttonBox,SIGNAL(rejected()),this,SLOT(close()));
    //Up and Down buttons
    connect(UpButton,SIGNAL(clicked(bool)),this,SLOT(ShiftListUp()));
    connect(DownButton,SIGNAL(clicked(bool)),this,SLOT(ShiftListDown()));
    //Delete Button
    connect(DeleteButton,SIGNAL(clicked(bool)),this,SLOT(DeleteEvent()));
    connect(EventNameLineEdit,SIGNAL(editingFinished()),AddButton,SLOT(setFocus()));
}
Exemple #24
0
void ElunaEventProcessor::Update(uint32 diff)
{
    m_time += diff;
    for (EventList::iterator it = eventList.begin(); it != eventList.end() && it->first <= m_time; it = eventList.begin())
    {
        LuaEvent* luaEvent = it->second;
        eventList.erase(it);

        if (luaEvent->state != LUAEVENT_STATE_ERASE)
            eventMap.erase(luaEvent->funcRef);

        if (luaEvent->state == LUAEVENT_STATE_RUN)
        {
            bool remove = luaEvent->repeats == 1;
            if (!remove)
                AddEvent(luaEvent); // Reschedule before calling incase RemoveEvents used

            // Call the timed event
            (*E)->OnTimedEvent(luaEvent->funcRef, luaEvent->delay, luaEvent->repeats ? luaEvent->repeats-- : luaEvent->repeats, obj);

            if (!remove)
                continue;
        }

        // Event should be deleted (executed last time or set to be aborted)
        RemoveEvent(luaEvent);
    }
}
void ElunaEventProcessor::Update(uint32 diff)
{
    m_time += diff;
    for (EventList::iterator it = eventList.begin(); it != eventList.end() && it->first <= m_time; it = eventList.begin())
    {
        LuaEvent* event = it->second;
        eventList.erase(it);
        eventMap.erase(event->funcRef);

        if (event->to_Abort)
        {
            delete event;
            continue;
        }

        bool remove = event->calls == 1;
        if (!remove)
            AddEvent(event); // Reschedule before calling incase RemoveEvents used

        event->Execute();

        if (remove)
            delete event;
    }
}
Exemple #26
0
void SocketManager::SecurityCheck(ConnectionID connectionID)
{
    SecurityEvent event;
    event.sock = connectionID.sock;
    event.counter = connectionID.counter;
    AddEvent(event);
}
Exemple #27
0
void SocketManager::Close(ConnectionID connectionID)
{
    CloseEvent event;
    event.sock = connectionID.sock;
    event.counter = connectionID.counter;
    AddEvent(event);
}
// -----------------------------------------------------------------------------
// MCCEConferenceCallObserver ErrorOccurred
// -----------------------------------------------------------------------------
void CCCEObserverAsynchroniser::ErrorOccurred( TCCPConferenceCallError aError  )
    {
    CCELOGSTRING( "CCCEObserverAsynchroniser::ErrorOccurred");
    TEventStorage event;
    event.iEventType = EErrorOccurred;
    event.iInt1 = aError;
    AddEvent(event);
    }
// -----------------------------------------------------------------------------
// MCCEConferenceCallObserver CallDurationChanged
// -----------------------------------------------------------------------------
void CCCEObserverAsynchroniser::CallDurationChanged( const TTimeIntervalSeconds aDuration )
    {
    CCELOGSTRING( "CCCEObserverAsynchroniser::CallDurationChanged");
    TEventStorage event;
    event.iEventType = ECallDurationChanged;
    event.iDuration = aDuration;
    AddEvent(event);
    }
Exemple #30
0
	void OnConnect() {
		if (!m_id)
		{
			m_id = AddEvent(0, TIME_US);
		}
		printf(".");
		fflush(stdout);
	}