Exemple #1
0
ChopperDrop* initializeChopperDrop()
{
	ChopperDrop* game = (ChopperDrop*) malloc(sizeof(ChopperDrop));

	// Subscribe devices
	game->IRQ_SET_KB = subscribeKeyboard();
	game->IRQ_SET_TIMER = subscribeTimer();
	game->IRQ_SET_MOUSE = subscribeMouse();
	game->IRQ_SET_RTC = subscribeRTC();

	game->done = 0;
	game->draw = 1;
	game->scancode = 0;
	game->timer = newTimer();
	game->date = newDate();

	game->currentState = MAIN_MENU_STATE;
	game->state = newMainMenuState();

    game->mouseCursor = loadBitmap("/home/images/cursor.bmp");

    // Load digits
    int i;
    for (i = 0; i < 10; i++)
    {
    	char filename[40];
    	sprintf(filename, "/home/images/digits/%d.bmp", i);
    	digits[i] = loadBitmap(filename);
    }

    slash = loadBitmap("/home/images/slash.bmp");
    colon = loadBitmap("/home/images/colon.bmp");

	return game;
}
Exemple #2
0
void test_timer_create() {
    t = newTimer(OCR, TimerResolution8);
    TEST_ASSERT_TRUE_MESSAGE(timerValid(t), "Timer not valid after creation");
    Pin p = getTimerOutputPin(t);
    TEST_ASSERT_FALSE_MESSAGE(IsValid(p), "Non-pwm timer has output-pin");
    TEST_ASSERT_FALSE_MESSAGE(isPwmTimer(t), "Timer should not be pwm timer");
}
Exemple #3
0
struct TTimer *AddTimer(
    struct timeval        tExpirationMoment,
    struct TStateMachine *ptStateMachine)
{
    BOOL               bFound;
    struct TTimerList *ptTimerWalker;
    struct TTimerList *ptNewTimer;

    ptNewTimer = newTimerList();
    ptNewTimer->ptThis = newTimer();

    ptNewTimer->ptThis->ptStateMachine = ptStateMachine;
    memcpy( &ptNewTimer->ptThis->tExpirationMoment,
            &tExpirationMoment,
            sizeof( struct timeval));

    /* New timer record is ready now. Now insert it in the right position in  */
    /* the timer list. (In such a way that the first record in the list expi- */
    /* res the first.                                                         */


    ptTimerWalker = _ptTimerList;

    bFound = FALSE;
    /* Go to the next timer in the list when
     * 1) the seconds of the timer in the list is less than the seconds of
     *    the new timer.
     * 2) The seconds of the two timers are equal and the microsecond value
     *    of the timer in the list is less than the microseconds of the new
     *    timer
     */
    while ( (ptTimerWalker->ptNext != NULL) && (bFound == FALSE) )
    {
        if ( (ptTimerWalker->ptNext->ptThis->tExpirationMoment.tv_sec <
                tExpirationMoment.tv_sec) ||
                ( (ptTimerWalker->ptNext->ptThis->tExpirationMoment.tv_sec ==
                   tExpirationMoment.tv_sec) &&
                  (ptTimerWalker->ptNext->ptThis->tExpirationMoment.tv_usec <
                   tExpirationMoment.tv_sec) ) )
        {
            ptTimerWalker = ptTimerWalker->ptNext;
        }
        else
        {
            bFound = TRUE;
        }
    }

    /* Found. The new record has to be added just after ptTimerWalker. We     */
    /* don't have to take care of the heading of the list: records will never */
    /* be added to the beginning of this list due to a dummy record over      */
    /* there.                                                                 */

    ptNewTimer->ptNext = ptTimerWalker->ptNext;
    ptTimerWalker->ptNext = ptNewTimer;

    return ptNewTimer->ptThis;

}
Exemple #4
0
void test_timer_9_set_value() {
    t = newTimer(OCR, TimerResolution9);
    assert_write(10, 0, 1);
    assert_write(127, 0, 2);
    assert_write(128, 1, 3);
    assert_write(0, 0, 4);
    assert_write(3000, 3000 >> 7, 5);
    assert_write(10000, 10000 >> 7, 6);
}
Exemple #5
0
void test_timer_8_get_value() {
    t = newTimer(OCR, TimerResolution8);
    assert_read(0, 0, 1);
    assert_read(0xFF00, 0, 2);
    assert_read(0xC200, 0, 2);
    assert_read(0xFF01, 0x0100, 3);
    assert_read(0xABDD, 0xDD00, 4);
    assert_read(0x2020, 0x2000, 5);
}
Exemple #6
0
void test_timer_16_set_value() {
    t = newTimer(OCR, TimerResolution16);
    assert_write(10, 10, 1);
    assert_write(0, 0, 2);
    assert_write(255, 255, 3);
    assert_write(256, 256, 4);
    assert_write(3000, 3000, 5);
    assert_write(10000, 10000, 6);
}
Exemple #7
0
void test_timer_10_set_value() {
    t = newTimer(OCR, TimerResolution10);
    assert_write(10, 0, 1);
    assert_write(63, 0, 2);
    assert_write(64, 1, 3);
    assert_write(0, 0, 4);
    assert_write(3000, 3000 >> 6, 5);
    assert_write(10000, 10000 >> 6, 6);
}
Exemple #8
0
void test_timer_8_set_value() {
    t = newTimer(OCR, TimerResolution8);
    assert_write(10, 0, 1);
    assert_write(255, 0, 2);
    assert_write(256, 1, 3);
    assert_write(0, 0, 4);
    assert_write(3000, HIBYTE(3000), 5);
    assert_write(10000, HIBYTE(10000), 6);
}
Exemple #9
0
// now main program, as usual, with some options parsing, etc.
int main(int argc, char** argv){

	int i;
	pTimer T = newTimer(); startTimer(T); // let's measure execution time of the whole program.
	// options parsing, configuration and reporting variables
	parseOptions(argc,argv);
	printf("[i] vector size is:    %li\n",SIZE);
	printf("[i] threads requested: %i\n", PTHR);
	printf("[i] total mem for data: %1.2f MB\n",SIZE*sizeof(Data)/1024.0/1024.0);
	if(PTHR<=0){printf("Too few threads, exiting...\n");exit(0);}
	printf("\n");

	// preparing data for calculations
	pVector V = newVector(SIZE); setVector(V,1.0);

	// preparing barrier for all threads involved in calculations
	if(pthread_barrier_init( &barrier, NULL, PTHR)){
		fprintf(stderr,"[E] could not create barrier!\n");
		exit(-1);
	}

	// preparing threads for calculations
	Info threads[PTHR];
	for(i=0;i<PTHR;i++){
		threads[i].nr = i;
		threads[i].V = V;
		threads[i].sum = 0.0;
		threads[i].start = (i  )*SIZE/PTHR;
		threads[i].end   = (i+1)*SIZE/PTHR;
		int rc = pthread_create(&threads[i].id,NULL,reduceVector,(void*) &threads[i]);
		if(rc){
			fprintf(stderr,"[E] thread creation error, code returned: %i\n",rc);
			exit(-1);
		}
		else{
			if(LOUD) printf("[i] thread %i: start=%i, end=%i\n",i,threads[i].start,threads[i].end);
		}
	}

	for(i=0;i<PTHR;i++){
		if(pthread_join(threads[i].id,NULL)){
			fprintf(stderr,"[e] Can't join thread id=%li, nr=%i\n",threads[i].id,threads[i].nr);
			return -1;
		}
	}
	// at the end we have to collect all data from threads
	double sum = 0.0;
	double time = 0.0;
	for(i=0;i<PTHR;i++){
		sum += threads[i].sum;
		time+= threads[i].time;
	}
	stopTimer(T);
	printf("Main sum is %1.2f, avg thread time: %-1.12f s, TOTAL time: %1.12f\n",sum,time/PTHR,getTime(T));
	freeTimer(T);
}
Exemple #10
0
void test_timer_9_get_value() {
    t = newTimer(OCR, TimerResolution9);
    assert_read(0, 0, 1);
    assert_read(0xFE00, 0, 2);
    assert_read(0xAA00, 0, 3);
    assert_read(0xFE22, 0x22 << 7, 4);
    assert_read(0xFEAA, 0xAA << 7, 5);
    assert_read(0xFFAA, 0x1AA << 7, 6);
    assert_read(0xFF22, 0x122 << 7, 7);
}
Exemple #11
0
void test_timer_16_get_value() {
    t = newTimer(OCR, TimerResolution16);
    assert_read(0, 0, 1);
    assert_read(0xFF00, 0xFF00, 2);
    assert_read(0xC200, 0xC200, 2);
    assert_read(0xFF01, 0xFF01, 3);
    assert_read(0xABDD, 0xABDD, 4);
    assert_read(0x2020, 0x2020, 5);
    assert_read(0xFAAA, 0xFAAA, 6);
    assert_read(0xFA22, 0xFA22, 7);
    assert_read(0xAFAA, 0xAFAA, 8);
    assert_read(0xAF22, 0xAF22, 9);
}
Exemple #12
0
void test_timer_10_get_value() {
    t = newTimer(OCR, TimerResolution10);
    assert_read(0, 0, 1);
    assert_read(0xFC00, 0, 2);
    assert_read(0xA400, 0, 3);
    assert_read(0xFC22, 0x22 << 6, 4);
    assert_read(0xFCAA, 0xAA << 6, 5);
    assert_read(0xFDAA, 0x1AA << 6, 6);
    assert_read(0xFD22, 0x122 << 6, 7);
    assert_read(0xFAAA, 0x2AA << 6, 6);
    assert_read(0xFA22, 0x222 << 6, 7);
    assert_read(0xAFAA, 0x3AA << 6, 6);
    assert_read(0xAF22, 0x322 << 6, 7);
}
Exemple #13
0
int main(int argc, char **argv){	
  if (argc > 1) {
	int size;
	if (sscanf(argv[1], "%d", &size)) {
		printf("Macierz o rozmiarach: %dx%d\n", size,size);
		pTimer T = newTimer();
		int matrix[size][size];	
		int vector[size];
		int result[size];
		int i,j,k;
		
		for (i = 0; i < size; i++) {
			result[i] = 0;
		}

		for (i = 0; i < size; i++){
			for (j = 0; j < size; j++){
				matrix[i][j] = (int)(rand() % 10);	
			}
			vector[i] =  (int)(rand() % 10);	
		}

			startTimer(T);
			for (i = 0; i < size; i++){
				for (j = 0; j < size; j++){
				 result[i] += matrix[i][j] * vector[j];
				}
			}
		stopTimer(T);
			printf("Czas wykonania = %f\n", getTime(T));

		if (size <= 16) {
			for (i = 0; i < size; i++){
				for (j = 0; j < size; j++){
					printf("%d\t",matrix[i][j]);
				}
				printf("| %d\t|", vector[i]);
				printf("| %d\t|\n", result[i]);
			}
		}
		else { printf("Wyświetlanie macierzy powyżej 16x16 jest nie przejrzyste.\n"); }
	 } else {
		printf("Parametrem musi byc liczba\n");
	}
}	else {
	printf("Musisz podac rozmiar macierzy!\n");
}
	return 0;
}
Exemple #14
0
int16 InitTimer(
    void)
/****************************************************************************/
/* Initialises the expirator module.                                        */
/****************************************************************************/
{
    /* Define a dummy record at the head of the timer list. Such a dummy      */
    /* records simplifies a lot of algorithms. This dummy record will never   */
    /* be deleted!                                                            */
    /* (It's expirationmoment is set to zero; which will be earlier than all  */
    /*  other expiration moments.)                                            */

    _ptTimerList = newTimerList();
    _ptTimerList->ptThis = newTimer();
    return 0;
}
static jlong
initialize(JNIEnv* env, jobject thiz, jint freq, jint stepsize, jint windowsize)
{
    Variables* inParam = (Variables*) malloc(sizeof(Variables));
    inParam->inMelfcc = (Melfcc*) malloc(sizeof(Melfcc));
    inParam->timer = newTimer();
    inParam->frequency = freq;
    inParam->stepSize = stepsize;
    inParam->windowSize = windowsize;
    inParam->overlap = windowsize-stepsize;
    //inParam->overlap = windowsize-stepsize;
    inParam->inputBuffer = (float*) calloc(windowsize,sizeof(float));
    //inParam->inputBuffer = (float*) calloc(windowsize,sizeof(float));
    //inParam->outputBuffer = (float*) malloc(stepsize*sizeof(float));
    inParam->outputBuffer = (float*) calloc(stepsize,sizeof(float));
    inParam->testBuffer = (float*) calloc(windowsize,sizeof(float));
    //-----------------------TVPhamVAD-----------------------------------------
    int winSize = inParam->stepSize;
	int Na = winSize/2;
	int Nf = inParam->frequency/winSize/2;

	inParam->Nf = (inParam->frequency/inParam->windowSize)/2;
	inParam->epsqb = 0.001;
	inParam->alpha = 0.975;
	inParam->aDs = 0.65;
	inParam->Na = (inParam->windowSize)/2;
	inParam->Dbuf = (float*) calloc(Nf,sizeof(float));
	inParam->Dbufsort = (float*) calloc(Nf,sizeof(float));
	inParam->DbufInd = 0;
	inParam->PreDs = 0;
	inParam->PreTqb = 0;
	inParam->Firstrunflag = 1;
	inParam->VADflag = 0;
	inParam->NoVoiceCount = 0;
	inParam->VadDec = 0;
	inParam->interVadDec = 0;
	//-----------------------VAD------------------------------------------------
	inParam->XL = (float*)malloc(sizeof(float)*stepsize);
	inParam->XH = (float*)malloc(sizeof(float)*stepsize);
    //initialTVPhamVAD(inParam);
	//-----------------------Monitor--------------------------------------------
	inParam->monitor = 0;
	//--------------------------------------------------------------------------
	melfcc_Initial(inParam->inMelfcc,inParam->frequency);

    return (jlong)inParam;
}
Exemple #16
0
  bool CPVRGUIActions::AddTimer(const CFileItemPtr &item, bool bCreateRule, bool bShowTimerSettings) const
  {
    const CPVRChannelPtr channel(CPVRItem(item).GetChannel());
    if (!channel)
    {
      CLog::Log(LOGERROR, "CPVRGUIActions - %s - no channel!", __FUNCTION__);
      return false;
    }

    if (!g_PVRManager.CheckParentalLock(channel))
      return false;

    const CEpgInfoTagPtr epgTag(CPVRItem(item).GetEpgInfoTag());
    if (!epgTag && bCreateRule)
    {
      CLog::Log(LOGERROR, "CPVRGUIActions - %s - no epg tag!", __FUNCTION__);
      return false;
    }

    CPVRTimerInfoTagPtr timer(bCreateRule || !epgTag ? nullptr : epgTag->Timer());
    CPVRTimerInfoTagPtr rule (bCreateRule ? g_PVRTimers->GetTimerRule(timer) : nullptr);
    if (timer || rule)
    {
      CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19034}); // "Information", "There is already a timer set for this event"
      return false;
    }

    CPVRTimerInfoTagPtr newTimer(epgTag ? CPVRTimerInfoTag::CreateFromEpg(epgTag, bCreateRule) : CPVRTimerInfoTag::CreateInstantTimerTag(channel));
    if (!newTimer)
    {
      CGUIDialogOK::ShowAndGetInput(CVariant{19033},
                                    bCreateRule
                                      ? CVariant{19095} // "Information", "Timer rule creation failed. The PVR add-on does not support a suitable timer rule type."
                                      : CVariant{19094}); // "Information", "Timer creation failed. The PVR add-on does not support a suitable timer type."
      return false;
    }

    if (bShowTimerSettings)
    {
      if (!ShowTimerSettings(newTimer))
        return false;
    }

    return g_PVRTimers->AddTimer(newTimer);
  }
Exemple #17
0
int main(int argc,char **argv){
	int i,j;
	int sum = 0;
	int N;
	#pragma omp parallel 
	N = 100*omp_get_num_threads(); // numery wątków
	printf("N: %d\n", N);	

	int matrix[N][N];	
	pTimer T = newTimer();
	startTimer(T);
	srand(time(0));

	
	for(i=0;i<N;i++){
	  for(j=0;j<N;j++){
	  	matrix[i][j] = rand() % 10;
		printf("%d\t ",matrix[i][j]);
	  }
	  printf("\n");	
	}
	
	
	for(i=0;i<N;i++){
	#pragma omp parallel for  \
	   reduction(+ : sum)
	  for(j=0;j<N;j++){
		sum += matrix[i][j];
		//printf("sum: %d, id: %d\n",sum,omp_get_thread_num());
	  }
	}	
	
	stopTimer(T);
	printf("\nsum: %d\n",sum);
	printf("Czas obliczen: %f\n", getTime(T));
	return 0;
}
Exemple #18
0
int main(int argc, char **argv){	
	long int n = 10000000;
	long int in_circle = 0;
	double gotowe_time;
	double pi,x,y;
	int i; 
	pTimer T = newTimer();     // we will measure time in each thread now
	
	if (argc > 1) {
		if (!sscanf(argv[1], "%ld", &n)) {
			printf("Zły paramter! Musi być liczbą całkowitą\n");		
		}
	}		
	
	srand(time(0));
	startTimer(T);           // start timer!
	for (i = 0; i < n; i++) {           
         x = ((double)rand() / (RAND_MAX))*2 - 1; //losowanie pozycji x z zakresu od -1 do 1
         y = ((double)rand() / (RAND_MAX))*2 - 1; //losowanie pozycji y z zakresu od -1 do 1
         
         if(x*x + y*y <= 1) {
             in_circle++;
         }
  	}
		
	pi = 	4 * (double)in_circle / n;
	stopTimer(T);            // store time
	gotowe_time = getTime(T);

	printf("Dla liczby punktów w kole: %ld \n", n);
	printf("Z math.h \tPI = %.40lf\n", M_PI);
	printf("Wyliczone\tPI = %.40lf\n", pi);
	printf("Czas obliczeń = %f\n", gotowe_time);
	

	return 0;
}
Exemple #19
0
void Timer_test()
{
	size_t i;
	const struct timespec* rTime;
	Timer* t = newTimer(1, 0);
	if(!t)
	{
		printf("Error occurred allocating memory for the timer.\n");
		return;
	}

	Timer_begin(t);
	rTime = Timer_get_run_time(t);
	usleep(NANOS_TO_MICROS(rTime->tv_nsec) + SECONDS_TO_MICROS(rTime->tv_sec));
	for(i = 0; !Timer_check(t); ++i);
	printf("Timer check %lu times.\n", i);

	Timer_begin(t);
	for(i = 0; !Timer_check(t); ++i)
		usleep((NANOS_TO_MICROS(rTime->tv_nsec) + SECONDS_TO_MICROS(rTime->tv_sec)) / 10);
	printf("Timer check %lu times.\n", i);

	delTimer(&t);
}
Exemple #20
0
// this function is our reduction function, it will be executed in parallel by threading
// as a multiple threads sharing the same vector, and adding diffrent regions from it
// data here is a pointer to struct Info with all necessary fields, like vector itself,
// start and end of region to calculate and sum. There are also some other less important things.
void* reduceVector(void* data){
	int i;
	pTimer T = newTimer();     // we will measure time in each thread now
	pInfo info = (pInfo) data; // copy data structure
	info->time = 0.0;          // time is zero at start
	if(info->V){               // if we have anything
		startTimer(T);           // start timer!
		for(i=info->start; i<info->end; i++){
			(info->sum) += (info->V->data[i]);      // add all values to the sum
		}
		stopTimer(T);            // store time
		info->time = getTime(T); // get time as a double precision value
		if(LOUD) printf("[i] thread %i, sum=%f, time=%1.4e\n",info->nr,info->sum,info->time);
	}
	freeTimer(T);

	// wait for all other threads to finish.
	int rc = pthread_barrier_wait(&barrier);
	if(rc != 0 && rc != PTHREAD_BARRIER_SERIAL_THREAD){
		fprintf(stderr,"[E] Could not wait on barrier for some reason, code=%i\n",rc);
		exit(-1);
	}
	pthread_exit(NULL); // exit nicely
}
Exemple #21
0
int CTimerList::show()
{
	neutrino_msg_t      msg;
	neutrino_msg_data_t data;

	int res = menu_return::RETURN_REPAINT;

	uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);

	bool loop=true;
	bool update=true;

	COSDFader fader(g_settings.menu_Content_alpha);
	fader.StartFadeIn();

	while (loop)
	{
		if (update)
		{
			hide();
			updateEvents();
			update=false;
			paint();
		}
		g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
		
		//ignore numeric keys
		if (g_RCInput->isNumeric(msg)){
			msg = CRCInput::RC_nokey;
		}
			
		if ( msg <= CRCInput::RC_MaxRC )
			timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings
							      ::TIMING_MENU]);

		if((msg == NeutrinoMessages::EVT_TIMER) && (data == fader.GetTimer())) {
			if(fader.Fade())
				loop = false;
		}
		else if ( ( msg == CRCInput::RC_timeout ) ||
				( msg == CRCInput::RC_home)  || (msg == CRCInput::RC_left) ||
				(( msg == CRCInput::RC_ok) && (timerlist.empty())) )
		{	//Exit after timeout or cancel key
			if(fader.StartFadeOut()) {
				timeoutEnd = CRCInput::calcTimeoutEnd( 1 );
				msg = 0;
			} else
				loop=false;

		}
		else if ((msg == CRCInput::RC_up || msg == (unsigned int)g_settings.key_channelList_pageup) && !(timerlist.empty()))
		{
			int step = 0;
			int prev_selected = selected;

			step = (msg == (unsigned int)g_settings.key_channelList_pageup) ? listmaxshow : 1;  // browse or step 1
			selected -= step;
			if((prev_selected-step) < 0)		// because of uint
				selected = timerlist.size() - 1;

			paintItem(prev_selected - liststart);
			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}

			paintFoot();
		}
		else if ((msg == CRCInput::RC_down || msg == (unsigned int)g_settings.key_channelList_pagedown) && !(timerlist.empty()))
		{
			unsigned int step = 0;
			int prev_selected = selected;

			step = (msg == (unsigned int)g_settings.key_channelList_pagedown) ? listmaxshow : 1;  // browse or step 1
			selected += step;

			if(selected >= timerlist.size())
			{
				if (((timerlist.size() / listmaxshow) + 1) * listmaxshow == timerlist.size() + listmaxshow) // last page has full entries
					selected = 0;
				else
					selected = ((step == listmaxshow) && (selected < (((timerlist.size() / listmaxshow) + 1) * listmaxshow))) ? (timerlist.size() - 1) : 0;
			}
			paintItem(prev_selected - liststart);

			unsigned int oldliststart = liststart;
			liststart = (selected/listmaxshow)*listmaxshow;
			if (oldliststart!=liststart)
			{
				paint();
			}
			else
			{
				paintItem(selected - liststart);
			}

			paintFoot();
		}
		else if ((msg == CRCInput::RC_right || msg == CRCInput::RC_ok || msg==CRCInput::RC_blue) && !(timerlist.empty()))
		{
			if (modifyTimer()==menu_return::RETURN_EXIT_ALL)
			{
				res=menu_return::RETURN_EXIT_ALL;
				loop=false;
			}
			else
				update=true;
		}
		else if ((msg == CRCInput::RC_red) && !(timerlist.empty()))
		{
			bool killTimer = true;
			if (CRecordManager::getInstance()->RecordingStatus(timerlist[selected].channel_id)) {
				CTimerd::RecordingStopInfo recinfo;
				recinfo.channel_id = timerlist[selected].channel_id;
				recinfo.eventID = timerlist[selected].eventID;
				if (CRecordManager::getInstance()->IsRecording(&recinfo)) {
					std::string title = "";
					char buf1[1024];
					CEPGData epgdata;
					CEitManager::getInstance()->getEPGid(timerlist[selected].epgID, timerlist[selected].epg_starttime, &epgdata);
					memset(buf1, '\0', sizeof(buf1));
					if (epgdata.title != "")
						title = "(" + epgdata.title + ")\n";
					snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_TIMERLIST_ASK_TO_DELETE), title.c_str());
					if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1,
							CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) {
						killTimer = false;
						update = false;
					}
				}
			}
			if (killTimer) {
				Timer->removeTimerEvent(timerlist[selected].eventID);
				skipEventID=timerlist[selected].eventID;
				update = true;
			}
		}
		else if (msg==CRCInput::RC_green)
		{
			if (newTimer()==menu_return::RETURN_EXIT_ALL)
			{
				res=menu_return::RETURN_EXIT_ALL;
				loop=false;
			}
			else
				update=true;
		}
		else if (msg==CRCInput::RC_yellow)
		{
			update=true;
		}
#if 0
		else if ((msg==CRCInput::RC_blue)||
				(CRCInput::isNumeric(msg)) )
		{
			//pushback key if...
			g_RCInput->postMsg( msg, data );
			loop=false;
		}
#endif
		else if (msg==CRCInput::RC_setup)
		{
			res=menu_return::RETURN_EXIT_ALL;
			loop=false;
		}
		else if ( msg == CRCInput::RC_help || msg == CRCInput::RC_info)
		{
			CTimerd::responseGetTimer* timer=&timerlist[selected];
			if (timer!=NULL)
			{
				if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_ZAPTO)
				{
					hide();
					if (timer->epgID != 0)
						res = g_EpgData->show(timer->channel_id, timer->epgID, &timer->epg_starttime);
					else
						ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NOTFOUND);
					if (res==menu_return::RETURN_EXIT_ALL)
						loop=false;
					else
						paint();
				}
			}
			// help key
		}
		else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) {
			g_RCInput->postMsg (msg, 0);
			loop = false;
			res = menu_return::RETURN_EXIT_ALL;
		}
		else
		{
			if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all )
			{
				loop = false;
				res = menu_return::RETURN_EXIT_ALL;
			}
		}
	}
	hide();
	fader.Stop();

	return(res);
}
void CVNSITimers::Action()
{
#if VDRVERSNUM >= 20301
  bool modified;
  cStateKey timerState;

  // set thread priority (nice level)
  SetPriority(1);

  while (Running())
  {
    if (!m_doScan)
    {
      usleep(1000*1000);
      continue;
    }
    m_doScan = false;

    std::vector<CVNSITimer> timers;
    {
      cMutexLock lock(&m_timerLock);
      timers = m_timers;
    }

    cTimers *Timers = cTimers::GetTimersWrite(timerState);
    if (!Timers)
      continue;

    Timers->SetExplicitModify();
    modified = false;
    cStateKey SchedulesStateKey(true);
    const cSchedules *schedules = cSchedules::GetSchedulesRead(SchedulesStateKey);
    if (schedules)
    {
      for (const cSchedule *schedule = schedules->First(); schedule; schedule = schedules->Next(schedule))
      {
        for (auto &searchTimer : timers)
        {
          if (!searchTimer.m_enabled)
            continue;

          if (!(searchTimer.m_channelID == schedule->ChannelID()))
            continue;

          for (const cEvent *event = schedule->Events()->First(); event; event = schedule->Events()->Next(event))
          {
            std::string title(event->Title());
            std::smatch m;
            std::regex e(Convert(searchTimer.m_search));

            if (std::regex_search(title, m, e,  std::regex_constants::match_not_null))
            {
              bool duplicate = false;
              LOCK_RECORDINGS_READ;
              for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording))
              {
                if (recording->Info() != nullptr)
                {
                  if (strcmp(recording->Info()->Title(), event->Title()) == 0)
                  {
                    if (recording->Info()->ShortText() != nullptr && event->ShortText() != nullptr &&
                        strcmp(recording->Info()->ShortText(), event->ShortText()) == 0)
                    {
                      duplicate = true;
                      break;
                    }
                  }
                }
                if (abs(difftime(event->StartTime(), recording->Start())) < 300)
                {
                  duplicate = true;
                  break;
                }
              }
              if (duplicate)
                continue;

              if (IsDuplicateEvent(Timers, event))
                continue;

              std::unique_ptr<cTimer> newTimer(new cTimer(event));
              Timers->Add(newTimer.release());
              modified = true;
            }
          }
        }
      }
    }
    if (modified)
      Timers->SetModified();
    timerState.Remove(modified);
    SchedulesStateKey.Remove(modified);
  }

#endif
}
Exemple #23
0
int main(int argc, char **argv) {
	int np, rank;
	int size = atoi(argv[1]);
	int matrix[size][size]; //[wiersz][kolumna]
	int vector[size];
	
	int result[size];

	MPI_Init(&argc, &argv);
	MPI_Status status;
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &np);
	int partition = size / np;
	int subresult[partition];
	int submatrix[size*partition];
	pTimer T = newTimer(); //deklaruje czas T
	double gotowe_time; //zmienna pod która bedę podstawiał czas do wyświetlenia

	int i, j;
	
	/* Walidacja równego podziału na macierzy na procesy */
	if ((size <= 0) || ((size % np) != 0)){
	   if (rank == 0){
	      printf("Nie mogę tego równo podzielić! Koniec.\n");
	   }
	   MPI_Finalize();
	   return 0;
	}
	
	if(rank == 0) {
		srand(time(0));
		for(i = 0; i < size; i++) {
			for(j = 0; j < size; j++) {
				matrix[i][j] = (int)(rand() % 10);
			}
		}
		for(i = 0; i < size; i++){
		   vector[i] = (int)(rand() % 10);
		} 
	}
	
	/*
		czyszczenie wszystkich zmiennych żeby nie było cudów
	*/
		for(i = 0; i < size; i++) {
		   result[i] = 0;
		}
		for(i=0; i < size*partition; i++) {
		   submatrix[i]=0;
		}
		for(i=0; i < partition; i++) {
		  subresult[i]=0;
		}
		
	startTimer(T);           // czas start
	
	/*
	   	Dziel na wiersze i wysyłam do procesów
	*/
	
	MPI_Scatter(matrix, size*partition, MPI_INT, submatrix, size*partition, MPI_INT, 0, MPI_COMM_WORLD);
		
	/*
		Broadcast wysyłam vektor do każdego procesu
	*/
	MPI_Bcast(vector, size, MPI_INT, 0, MPI_COMM_WORLD);

	/*     
		Każdy proces liczy swój wiersz
	*/
	for(i=0; i<partition; i++){
	   for(j=0; j<size; j++){
	      subresult[i]+= submatrix[j+size*i] * vector[j]; //size*i żeby przeskoczył do następnego wiersza jeśli otrzyma ich kilka
	   }
	}
	
	/*
		Proces zbiera wyniki i skleja je do result
	*/
	MPI_Gather(subresult, partition, MPI_INT, result, partition, MPI_INT, 0, MPI_COMM_WORLD);
	
	if(rank == 0) {
	     stopTimer(T);  // czas stop
	     gotowe_time = getTime(T); //podstawiam czas
	     printf("Koniec obliczeń, czas obliczeń = %f\n", gotowe_time);
	     if(size<8){
		     for(i = 0; i < size; i++) {
			   for(j=0; j < size; j++){
			     printf("%d\t",matrix[i][j]);
			   }
			   printf("|%d\t| %d\t\n", vector[i],result[i]);
		     }
	    }
	    else {
	         printf("Nie wyświetle w terminalu poprawnie tak dużej macierzy\n");
	    }
	}
	
	MPI_Finalize();
	
	return 0;
}
Exemple #24
0
    connect(_playlistTab->playlist(), SIGNAL(scheduleRequested(Channel *)), _scheduleTab, SLOT(channel(Channel *)));

    connect(_mediaPlayer, SIGNAL(stateChanged(Vlc::State)), this, SLOT(setState(Vlc::State)));
    connect(_mediaPlayer, SIGNAL(vout(int)), this, SLOT(showVideo(int)));
    connect(_mediaPlayer, SIGNAL(sessionChannel(int)), _playlistTab->playlist(), SLOT(channelSelected(int)));

    connect(ui->actionRecorder, SIGNAL(triggered(bool)), this, SLOT(showRecorder()));
    connect(ui->actionRecordNow, SIGNAL(toggled(bool)), this, SLOT(recordNow(bool)));
    connect(ui->actionSnapshot, SIGNAL(triggered()), _mediaPlayer, SLOT(takeSnapshot()));

    connect(_showInfoTab, SIGNAL(requestRecord(QString)), _xmltv, SLOT(requestProgrammeRecord(QString)));
    connect(_scheduleTab, SIGNAL(requestRecord(QString)), _xmltv, SLOT(requestProgrammeRecord(QString)));
    connect(_xmltv, SIGNAL(programmeRecord(XmltvProgramme *)), this, SLOT(recordProgramme(XmltvProgramme *)));

    connect(ui->actionRecordQuick, SIGNAL(triggered()), _recorder, SLOT(quickRecord()));
    connect(ui->actionRecordTimer, SIGNAL(triggered()), _recorder, SLOT(newTimer()));
    connect(_recorder, SIGNAL(play(Timer *)), this, SLOT(playRecording(Timer *)));

    connect(_mouseTimer, SIGNAL(timeout()), this, SLOT(toggleMouse()));

    qDebug() << "Initialised: Event connections";
}

void MainWindow::createMenus()
{
    _rightMenu = new QMenu();
    _rightMenu->addAction(ui->actionPlay);
    _rightMenu->addAction(ui->actionStop);
    _rightMenu->addAction(ui->actionBack);
    _rightMenu->addAction(ui->actionNext);
    _rightMenu->addSeparator();
Exemple #25
0
TimerManager::TimerManager(Stack* documents, QWidget* parent)
	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
	m_documents(documents)
{
	setWindowTitle(tr("Timers"));

	// Set up interaction with timer display
	m_display = new TimerDisplay(m_timers, this);
	m_display->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(m_display, SIGNAL(clicked()), this, SLOT(toggleVisibility()));
	connect(m_display, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(recentTimerMenuRequested(const QPoint&)));

	// Create clock
	m_clock_label = new QLabel(this);
	m_clock_label->setAlignment(Qt::AlignCenter);

	m_clock_timer = new QTimer(this);
	m_clock_timer->setInterval(1000);
	connect(m_clock_timer, SIGNAL(timeout()), this, SLOT(updateClock()));
	startClock();

	// Create timers layout
	QWidget* timers_widget = new QWidget(this);

	m_timers_layout = new QVBoxLayout(timers_widget);
	m_timers_layout->addStretch();
	m_timers_layout->setSizeConstraint(QLayout::SetMinAndMaxSize);

	m_timers_area = new QScrollArea(this);
	m_timers_area->setWidget(timers_widget);
	m_timers_area->setWidgetResizable(true);

	// Create action buttons
	QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
	connect(buttons, SIGNAL(rejected()), this, SLOT(close()));

	m_new_button = buttons->addButton(tr("New"), QDialogButtonBox::ActionRole);
	m_new_button->setDefault(true);
	connect(m_new_button, SIGNAL(clicked()), this, SLOT(newTimer()));

	m_recent_timers = new QMenu(this);
	m_recent_button = buttons->addButton(tr("Recent"), QDialogButtonBox::ActionRole);
	m_recent_button->setMenu(m_recent_timers);
	setupRecentMenu();
	connect(m_recent_timers, SIGNAL(triggered(QAction*)), this, SLOT(recentTimer(QAction*)));

	// Lay out window
	QVBoxLayout* layout = new QVBoxLayout(this);
	layout->addWidget(m_clock_label);
	layout->addWidget(m_timers_area, 1);
	layout->addWidget(buttons);
	setMinimumHeight(sizeHint().width());

	QSettings settings;
	settings.beginGroup("Timers");
	resize(settings.value("DialogSize").toSize());

	// Load currently running timers
	QStringList ids = settings.childKeys();
	foreach (const QString& id, ids) {
		int i = id.mid(5).toInt();
		if (!id.startsWith("Timer") || i == 0) {
			continue;
		}
		Timer* timer = new Timer(id, m_documents, this);
		addTimer(timer);
		timerChanged(timer);
	}
Exemple #26
0
int main(int argc, char **argv){	
  if (argc > 1) {
	int size; // deklarujemy wielkość Macierzy
	int np, rank; // np - ilość nodów
	pTimer T = newTimer();		
		
	MPI_Status status;
	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &np);	
	if (sscanf(argv[1], "%d", &size)) {
	  if (size % np == 0) { 
	int podzial = (int)size/np;
	int matrix[size][size]; 
	int vector[size];
	int result[size];
	int res_result[podzial]; // każdy proces podstawi wynik do indexu res_result ktory bedzie numerem jego procesu
	int i,j,k;
	int res_matrix[size][podzial]; // [kolumna, wiersz]
	  if(rank == 0){
		printf("podzial: %d\n", podzial);
	  }	srand(time(0));
				
	// wektor rozwiązania
	  for (i =0; i < podzial; i++) {
		res_result[i] = 0;
	  }	

	  if (rank == ROOT) {
		for (i = 0; i < size; i++){
			for (j = 0; j < size; j++){
				matrix[i][j] = (int)(rand() % 10);	
			}
	           vector[i] =  (int)(rand() % 10);	
		}
	}
	
	if (rank == ROOT) {
	startTimer(T);
	}	
	/* Wysłanie części macierzy do procesów */
					
	for (k =0; k< size; k++ ){
/*(void *sendbuf, int sendcnt, MPI_Datatype sendtype, 
   void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, 
               MPI_Comm comm)*/
	MPI_Scatter(matrix[k], podzial, MPI_INT, &res_matrix[k], podzial, 			MPI_INT, ROOT, MPI_COMM_WORLD); 
	}
/*    (void *buffer, int count, MPI_Datatype datatype, int root,MPI_Comm comm )*/
	MPI_Bcast( vector, size, MPI_INT, 0,  MPI_COMM_WORLD);	
			
//Mnoży swoje czesci Matrixa przez wektor = res_result
	for (i = 0; i < podzial; i++){
		for (j = 0; j < size; j++){
			res_result[i] += res_matrix[j][i] * vector[j];
				
		} // j - kolumna, i - wiersz
	}
// cześciowe rozwiązanie - res_result
// odbierany bufor - result

/*(void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm)*/
	MPI_Gather(&res_result, podzial, MPI_INT, result, podzial, MPI_INT, ROOT, 			MPI_COMM_WORLD);	
			
			
	if (rank == ROOT) {
		stopTimer(T);
		if (size <= 16) {
		  for (i = 0; i < size; i++){
		    for (j = 0; j < size; j++){
		      printf("%d\t",matrix[j][i]);
		    }
		   printf("| %d\t|", vector[i]);
		   printf("| %d\t|\n", result[i]);
		  }
					
		}
	printf("Czas obliczen = %f\n", getTime(T));
		}
	} else {
	  if (rank == ROOT) {	printf("Źle dobrane parametry wielkość macierzy musi być podzielna przez liczbe procesów.\n"); }
		}
	} else {
	  if (rank == ROOT) { printf("Zly paramter wywoałania programu! Musi to być liczba.\n"); }
		}
	} else {
	   printf("Musisz podac parametr.\n");
	}
	
	MPI_Finalize();
	
	return 0;
}