Example #1
0
int main()
{
    osm_init();
    timeMeasurmentStructure osmTime = measureTimes(10000, 10000, 10000, 10000);
    printTimes(osmTime);
    osm_finalizer();
    return 0;
}
Example #2
0
void Field::printAll() {
    if (t > nextFrameTime) {
        nextFrameTime += algo::ftr().TMax() / algo::ftr().FramesCount();

        printConsole();
        printViews();
        printMatrix();
        printTimes();
    }
}
Example #3
0
//----------------------------------------------------------------------------
// figure out darkest hours & print to buffer
//
char* printDarkness( char* p, int i, const TimePair* const astTwi, const TimePair* const moonRSOrg )
{
    TimePair dark = { astTwi[i].TP_END, astTwi[i+1].TP_START };

    // first time in, create a local copy that we can munge
    static TimePair moonRS[DAYS];
    if ( 0 == i )
        memcpy( moonRS, moonRSOrg, sizeof(TimePair)*DAYS);

    // define day + time vars to deal with 'yesterday' and 'tomorrow'
    double darkStart = astTwi[i].TP_END + i;
    double darkEnd = astTwi[i+1].TP_START + (i+1);

    double moonRise;
    if ( moonRS[i].TP_RISE < 0. || moonRS[i].TP_SET > moonRS[i].TP_RISE) {
        moonRise = moonRS[i+1].TP_RISE + (i+1);
        moonRS[i].TP_RISE = moonRS[i+1].TP_RISE;
    }
    else
        moonRise = moonRS[i].TP_RISE + i;

    double moonSet;
    if ( moonRS[i].TP_SET < 0. || moonRS[i].TP_RISE > moonRS[i].TP_SET ) {
        moonSet = moonRS[i+1].TP_SET + (i+1);
        moonRS[i].TP_SET = moonRS[i+1].TP_SET;
    }
    else
        moonSet = moonRS[i].TP_SET + i;

    // check moon rise & set
    if (moonSet > darkStart && moonSet < darkEnd) {
        darkStart = moonSet;
        dark.TP_START = moonRS[i].TP_SET;
    }
    if (moonRise > darkStart && moonRise < darkEnd ) {
        darkEnd = moonRise;
        dark.TP_END = moonRS[i].TP_RISE;
    }

    bool noDarkness = (moonRise < darkStart && moonSet > darkEnd );

    // print out darkness range or 'none'
    if ( noDarkness ) {
        strcpy(p, " -- none -- " );
        p = nextColumn(p+12, 3);
    }
    else
        p = printTimes( p, dark );

    return p;
}
Example #4
0
int main (int argc, const char **argv) {
	std::vector< std::pair< std::string, int > > times;
	std::vector< std::string > arguments;
	FileMapper mapper;
	
	QTime timeTotal;
	timeTotal.start ();
	
	// Parse arguments
	const char *helpTitle = "Tria by the NuriaProject, built on " __DATE__ " " __TIME__;
	llvm::cl::ParseCommandLineOptions (argc, argv, helpTitle);
	initClangArguments (argv[0], arguments);
	std::string inputFile = addInputFiles (mapper);
	arguments.push_back (inputFile);
	
	// 
	QVector< GenConf > generators = generatorsFromArguments ();
	mapper.mapRecursive (QDir (":/headers/"), QStringLiteral("/builtins/"));
	
	// Create tool instance
	Definitions definitions (sourceFileList ());
	Compiler compiler (&definitions);
	if (!compiler.prepare (&mapper, arguments)) {
		return 1;
	}
	
	// Run it
	times.emplace_back ("init", timeTotal.elapsed ());
	if (!compiler.run ()) {
		return 2;
	}
	
	// Generate code
	definitions.parsingComplete ();
	times.emplace_back ("parse", timeTotal.elapsed ());
	
	// Run generators
	LuaGenerator luaGenerator (&definitions, &compiler);
	for (int i = 0; i < generators.length (); i++) {
		const GenConf &conf = generators.at (i);
		if (!luaGenerator.generate (conf)) {
			return 5;
		}
		
		times.emplace_back (conf.luaScript.toStdString (), timeTotal.elapsed ());
	}
	
	// 
	printTimes (timeTotal.elapsed (), times, definitions);
	return 0;
}
Example #5
0
void IBEDemo() {
  std::cout << "IBE" << std::endl;

  const size_t Q = size_t(1) << K;

  struct timeval t1, t2;
  std::string idString = "conner";

  // Make MSK and PK
  gettimeofday( &t1, 0 );
  gring::IBEMasterSecret<N,Q,K>* MSK = new gring::IBEMasterSecret<N,Q,K>{};
  gettimeofday( &t2, 0 );
  printTimes( "setup", t1, t2 );

  gring::IBEPublic<N,Q,K>* PK = MSK->publicKey();

  // Encrypt to ID
  gettimeofday( &t1, 0 );
  gring::IBECiphertext<N,Q,K>* ctxt = PK->encrypt( idString, "something much "
      "longer than 32 bytes so that maybe it gets cut off?" );
  gettimeofday( &t2, 0 );
  printTimes( "encryption", t1, t2 );

  // Invert Secret Key
  gettimeofday( &t1, 0 );
  gring::IBESecret<N,Q,K>* userSecret = MSK->secretKeyForID( idString );
  gettimeofday( &t2, 0 );
  printTimes( "inversion", t1, t2 );

  // Decrypt
  gettimeofday( &t1, 0 );
  std::string messagePrime = userSecret->decrypt( ctxt );
  gettimeofday( &t2, 0 );
  printTimes( "decryption", t1, t2 );

  std::cout << "messagePrime: " << messagePrime << std::endl;
}
Example #6
0
void dumpInterference( chart_t *msc ) {

   int i, k, len = msc->topoListLen;

//  int changed = 0;

  for( i = 0; i < len; i++ ) {
  printTimes(msc->topoList[i]);
  }

  // update interference graph
  for( i = 0; i < len; i++ ) {
    int ix = msc->topoList[i];
    for( k = 0; k <  len; k++ ) {
      int kx = msc->topoList[k];
     printf("%d ", interfere[ix][kx]);
    }
     printf("\n");
  }
}
Example #7
0
int main(int argc, char** argv) {
    
    /*File Pointers*/
        FILE *namef;
        FILE *entrantf;
        FILE *nodef;
        FILE *trackf;
        FILE *timef;
        FILE *coursef;
        FILE *logf;
    
    /*Filenames*/
    char namefile[30];
    char nodesfile[30];
    char tracksfile[30];
    char entrantsfile[30];
    char coursesfile[30];
    char cp_timesfile1[30];
    char logfile[30];
    
    /*These are the structures that will contain all the data read in*/
    NAME title[3];
    COURSE courses[26];
    ENTRANT *entrant_head = NULL;
    NODE *node_head = NULL;
    TRACK *track_head = NULL;
    TIME *time_head = NULL;

    char my_buffer[100];
    
    /*These variables are used when reading in files and calculating queries*/
    char name[100];
    int i, j, n1, n2, n3, h, m, timesanswer, answer, qh, qm, node;
    char t;

    i = 0;
    answer = 0;
    timesanswer = 0;
    
    
    /*This is where the user is asked to enter all the files that are needed to run the program They are entered sequentially
          to ensure that all files are read in and that none conflict with each other.*/
    
    printf("Please enter the name of the log file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", logfile);
    
    logf = fopen(logfile, "a");
    
    fprintf(logf, "Log File Opened\n");

    printf("Please enter the names file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", namefile);

    namef = fopen(namefile, "r");

    while (fgets(my_buffer, 80, namef) != NULL) {
        strcpy(title[i].line, my_buffer);
        i++;
    }

    fclose(namef);

    
    printf("Please enter the nodes file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", nodesfile);

    createLinkedNodes(&node_head, nodef, nodesfile);
     




    printf("Please enter the tracks file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", tracksfile);

    createLinkedTracks(&track_head, trackf, tracksfile);




    printf("Please enter the entrants file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", entrantsfile);

    createLinkedEntrants(&entrant_head, entrantf, entrantsfile);





    printf("Please enter the courses file: \n");
    scanf(" %[a-z,A-Z,.,_,0-9]", coursesfile);

    coursef = fopen(coursesfile, "r");


    while (!feof(coursef)) {
        i = 0;
        if (fscanf(coursef, "%c %d", &(courses[i].name),
                &(courses[i].amount)) == 2) {

            for (j = 0; j < courses[i].amount; j++) {
                while (fscanf(coursef, " %d", &(courses[i].nodes[j])) == 1);

            }
            fscanf(coursef, "\n");

            i++;
        } else {
            fprintf(stderr, "Error: file format wrong.\n");
            break;
        }
    }

    /*This prompts the user to choose how they will enter the first competitor's time. There is an
        option to add more later.*/

    printf(" Choose how times for competitors are entered.\n");
    printf(" 1. Enter a pre-prepared file of all competitors' times.\n");
    printf(" 2. Manually enter more times for competitors.\n");

    scanf("%d", &timesanswer);

    if (timesanswer == 1) {

        printf("Please enter the times file: \n");
        scanf(" %[a-z,A-Z,.,_,0-9]", cp_timesfile1);


        timef = fopen(cp_timesfile1, "r");

        while (fgets(my_buffer, 100, timef) != NULL) {
            sscanf(my_buffer, "%c %d %d %d:%d", &t, &n1, &n2, &h, &m);
            createLinkedTimes(&time_head, t, n1, n2, h, m);
        }

        fclose(timef);

    } else if (timesanswer == 2) {
        printf("How many times do you wish to enter? ");
        scanf(" %d", &i);
        int count = 0;
        while (count != i) {
            printf("Please enter the type of checkpoint :");
            scanf(" %[A-Z]", &t);
            printf("Please  enter the checkpoint node :");
            scanf(" %d", &n2);
            printf("Please enter the competitor number :");
            scanf(" %d", &n3);
            printf("Please enter the hours :");
            scanf(" %d", &h);
            printf("Please enter the minutes :");
            scanf(" %d", &m);

            createLinkedTimes(&time_head, t, n2, n3, h, m);

            count += 1;
        }
        printTimes(&time_head);
    }

    while (answer != 11) {

        for (i = 0; i < 3; i++) {
            printf("%s", title[i].line);
        }
        /*This prints out the last time entered into the linked list of times. This is assumed to be the current time.*/
        printf("Current Time : %02d:%02d\n", h, m);
        
        /*MENU*/
        printf("Please choose an option :\n");
        printf("1. Query the status and location of a competitor.\n");
        printf("2. Query how many competitors have not yet started.\n");
        printf("3. Query how many competitors are out on the course.\n");
        printf("4. Query how many competitors are finished.\n");
        printf("5. Add more times\n");
        printf("6. Results\n");
        printf("7. Query which competitors were excluded for going to an incorrect checkpoint\n");
        printf("8. Query which competitors were excluded for medical reasons\n");
        printf("9. Query when a competitor entered a medical checkpoint\n");
        printf("10. Query when a competitor left a medical checkpoint\n");
        printf("11. Quit\n");

        scanf("%d", &answer);
        
        /*Allows the user to query the location and status of one competitor*/
        if (answer == 1) {
            
            fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried location and status of a competitor\n", h, m, title[1].line);
            
            printf("Enter a time you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            if (compareTime(h, m, qh, qm) == 0) {
                printf("Time entered is after current time, please enter an appropriate time\n");
            } else {
                printf("Enter competitor's  number: \n");
                scanf("%d", &n1);

                findCompetitor(&entrant_head, n1, name);
                if ((strcmp(name, "Not Found")) != 0) {
                    printf("Name : %s\n", name);

                    node = 0;

                    node = findLocation(&time_head, n1, qh, qm);
                    if (node == 100) {
                        printf("Location : %d\n", node);
                        printf("Status : Finished\n");
                        printf("\n");
                    }
                    if (node == 0) {
                        printf("Status : Not Started\n");
                        printf("\n");
                    } else {
                        printf("Location : %d\n", node);
                        printf("Status : On Course\n");
                        printf("\n");
                    }

                }
                else {
                    printf("%s\n", name);
                }


            }
            
            /*Allows the user to query all the competitors that have not started*/
        } else if (answer == 2) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors had not started\n", h, m, title[1].line);

            printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryNotStarted(&time_head, &entrant_head, qh, qm);

              /*Allows the user to query all the competitors that are out on course*/
        } else if (answer == 3) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors are out on course\n", h, m, title[1].line);
            
            printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryOnCourse(&time_head, &entrant_head, qh, qm);
            
            
             /*Allows the user to query all the competitors that are finished*/
        }else if (answer == 4) {
            
            fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors are finished\n", h, m, title[1].line);
            
            printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryFinished(&time_head, &entrant_head, qh, qm);
            
            
            /*Allows the user to enter more times*/
        } else if (answer == 5) {
            
            printf(" Choose how times for competitors are entered.\n");
            printf(" 1. Enter a pre-prepared file of all competitors' times.\n");
            printf(" 2. Manually enter more times for competitors.\n");

            scanf("%d", &timesanswer);

            if (timesanswer == 1) {
                
                 fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Added more times from a file\n", h, m, title[1].line);

                printf("Please enter the times file: \n");
                scanf(" %[a-z,A-Z,.,_,0-9]", cp_timesfile1);


                timef = fopen(cp_timesfile1, "r");

                while (fgets(my_buffer, 100, timef) != NULL) {
                    sscanf(my_buffer, "%c %d %d %d:%d", &t, &n1, &n2, &h, &m);
                    createLinkedTimes(&time_head, t, n1, n2, h, m);
                }

                fclose(timef);

                printTimes(&time_head);

            } else if (timesanswer == 2) {
                
                 fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Manually entered more times\n", h, m, title[1].line);
                
                printf("How many times do you wish to enter? ");
                scanf(" %d", &i);
                int count = 0;
                while (count != i) {
                    printf("Please enter the type of checkpoint :");
                    scanf(" %[A-Z]", &t);
                    printf("Please  enter the checkpoint node :");
                    scanf(" %d", &n2);
                    printf("Please enter the competitor number :");
                    scanf(" %d", &n3);
                    printf("Please enter the hours :");
                    scanf(" %d", &h);
                    printf("Please enter the minutes :");
                    scanf(" %d", &m);

                    createLinkedTimes(&time_head, t, n2, n3, h, m);

                    count += 1;
                }
                printTimes(&time_head);
            }
        }
        /*Allows the user to print out the results*/
        else if (answer == 6) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Checked results\n", h, m, title[1].line);
            
            queryResults(&time_head, &entrant_head, h, m);
        }
        
        
        
        else if(answer == 7){
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors were excluded for incorrect checkpoints \n", h, m, title[1].line);
            
              printf("Enter a time for you wish to query for : \n");
              scanf("%d:%d", &qh, &qm);

            queryWrongExclusion(&time_head, &entrant_head, qh, qm);
        }
        
        
        
        else if(answer == 8){
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried which competitors were excluded for medical reasons \n", h, m, title[1].line);
            
              printf("Enter a time for you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            queryMedicalExclusion(&time_head, &entrant_head, qh, qm);
        }

        else if (answer == 9) {
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried a competitor's entry into a medical checkpoint \n", h, m, title[1].line);
            
            int compNum = 0;
            
            
            printf("Enter a time you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            if (compareTime(h, m, qh, qm) == 0) {
                printf("Time entered is after current time, please enter an appropriate time\n");
            } else {
                printf("Enter competitor's  number: \n");
                scanf("%d", &compNum);

                findCompetitor(&entrant_head, compNum, name);
                if ((strcmp(name, "Not Found")) != 0) {
                    printf("Name : %s\n", name);

                    char type;
                    
                    type = findType(&time_head, compNum, qh, qm);
                    
                    if(type == 'A'){
                        int h = findHourTime(&time_head, compNum, qh, qm);
                        int m = findMinutesTime(&time_head, compNum, qh, qm);
                        printf("Time : %d:%d", h, m);
                    }

                }
                else {
                    printf("%s\n", name);
                }
        }
        
        }
        
        else if(answer == 10){
            
             fprintf(logf, "Time :  %02d:%02d  Date : %s Activity : Queried a competitor's departure from a medical checkpoint \n", h, m, title[1].line);
            
            int compNum = 0;
            
            printf("Enter a time you wish to query for : \n");
            scanf("%d:%d", &qh, &qm);

            if (compareTime(h, m, qh, qm) == 0) {
                printf("Time entered is after current time, please enter an appropriate time\n");
            } else {
                printf("Enter competitor's  number: \n");
                scanf("%d", &compNum);

                findCompetitor(&entrant_head, compNum, name);
                if ((strcmp(name, "Not Found")) != 0) {
                    printf("Name : %s\n", name);

                    char type;
                    
                    type = findType(&time_head, compNum, qh, qm);
                    
                    if(type == 'D'){
                        int h = findHourTime(&time_head, compNum, qh, qm);
                        int m = findMinutesTime(&time_head, compNum, qh, qm);
                        printf("Time : %d:%d \n", h, m);
                    }

                }
                else {
                    printf("%s\n", name);
                }
            
        }
        
    }        
        
        }


    return (EXIT_SUCCESS);

}