PopulationParams::PopulationParams(nat id, nat numberOfGenerations, popSize_t initSize, const ProgramOptions &progOpt) : initSize(initSize) , correction(1) // , correction(progOpt.get<nat>("ploidy") - 1 ) , isNeutral(false) { vector<string> stringEvents; if(progOpt.hasOption("popEvent")) stringEvents = progOpt.get<vector<string> >("popEvent"); // parse rates recombinationRate = parseRate(progOpt.get<vector<string> >("recRate"),id); // geneConversionRate = parseRate(progOpt.get<vector<string> >("mutRate"), id); mutationRate = parseRate(progOpt.get<vector<string> >("mutRate"), id); if(NOT stringEvents.empty()) { parseEvents(stringEvents,id); nat lastPopSize = initSize; // for(auto event : events) for(auto eventI = events.begin(); eventI != events.end(); ++eventI) { (*eventI)->init(lastPopSize); if(eventI+1 != events.end()) { nat whenIsNext = (*(eventI+1))->getWhen(); lastPopSize = (*eventI)->getByTime(whenIsNext-1); } } } }
void PropertyManager::parseBlock(BlockProperties& properties) { parseMethods(properties); if (!properties.luaRef["perBlock"].isNil()) parsePerBlockProperties(properties); if (!properties.luaRef["events"].isNil()) parseEvents(properties); }
prvreader::PrvEvent* prvreader::PrvParser::parseLine() { string line; PrvEvent* prvEvent; if (prvStream){ if(getline(*prvStream,line)){ lineNumber++; if (lineNumber%10000==0){ Message::Debug(to_string(lineNumber)+ " lines processed"); } replace(line.begin(), line.end(), '\t', ' '); std::size_t found = line.find_first_of("("); if ((found!=std::string::npos)&&(found+1<line.length())){ found = line.find_first_of("a", found+1); } if ((found!=std::string::npos)&&(line[found+1]=='t')&&(found+5<line.length())&&(line[found+5]==PRV_HEADER_SEP_MAIN_CHAR)){ line[found+5]='*'; } replace(line.begin(), line.end(), PRV_HEADER_QUOTE_IN_CHAR, GENERIC_SEP_CHAR); replace(line.begin(), line.end(), PRV_HEADER_QUOTE_OUT_CHAR, GENERIC_SEP_CHAR); trim_all(line); if (!line.empty()){ escaped_list_separator<char> sep(GENERIC_ESCAPE_CHAR, PRV_HEADER_SEP_MAIN_CHAR, GENERIC_QUOTE_CHAR); tokenizer<escaped_list_separator<char> > *tokens = new tokenizer<escaped_list_separator<char> >(line, sep); tokenizer<escaped_list_separator<char> >::iterator tokensIterator=tokens->begin(); if (mode==Header){ prvEvent=parseHeader(tokens); mode=Body; }else{ string eventType=*tokensIterator; tokensIterator++; //communicator if (eventType.compare(PRV_BODY_COMMUNICATOR)==0){ prvEvent= new PrvOther(lineNumber, prveventtype::Skip); //communications }else if (eventType.compare(PRV_BODY_COMMUNICATION)==0){ prvEvent=parseCommunications(tokens, lineNumber); }else if (eventType.compare(PRV_BODY_EVENTS)==0){ prvEvent=parseEvents(tokens, lineNumber); }else if (eventType.compare(PRV_BODY_STATE)==0){ prvEvent=parseState(tokens, lineNumber); }else{ prvEvent= new PrvOther(lineNumber, prveventtype::Skip); } } delete tokens; } }else{ prvEvent=new PrvOther(lineNumber, prveventtype::End); } } return prvEvent; }
void Testsuite::execute() { // Main Loop for a testsuite uint count = 0; Common::Point pt = getDisplayRegionCoordinates(); pt.y += getLineSeparation(); int numEnabledTests = getNumTestsEnabled(); for (Common::Array<Test *>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) { if (!(*i)->enabled) { logPrintf("Info! Skipping Test: %s, Skipped by configuration.\n", ((*i)->featureName).c_str()); _numTestsSkipped++; continue; } if((*i)->isInteractive && !ConfParams.isSessionInteractive()) { logPrintf("Info! Skipping Test: %s, non-interactive environment is selected\n", ((*i)->featureName).c_str()); _numTestsSkipped++; continue; } logPrintf("Info! Executing Test: %s\n", ((*i)->featureName).c_str()); updateStats("Test", ((*i)->featureName).c_str(), count++, numEnabledTests, pt); // Run the test and capture exit status. TestExitStatus eStatus = (*i)->driver(); if (kTestPassed == eStatus) { logPrintf("Result: Passed\n"); _numTestsExecuted++; _numTestsPassed++; } else if (kTestSkipped == eStatus){ logPrintf("Result: Skipped\n"); _numTestsSkipped++; } else { _numTestsExecuted++; logPrintf("Result: Failed\n"); } updateStats("Test", ((*i)->featureName).c_str(), count, numEnabledTests, pt); // TODO: Display a screen here to user with details of upcoming test, he can skip it or Quit or RTL // Check if user wants to quit/RTL/Skip next test by parsing events. // Quit directly if explicitly requested if (Engine::shouldQuit()) { _toQuit = kEngineQuit; genReport(); return; } _toQuit = parseEvents(); } genReport(); }
int main(int argc, char ** argv) { if(argc != 2) { printf("Usage is midiParse <file>\n"); exit(1); } //now lets open it up FILE * mFile; mFile = fopen(argv[1], "r"); if(!mFile) { //printf("Opening file \"%s\" failed. Aborting.\n", argv[1]); exit(1); } //get the file size // obtain file size: fseek (mFile , 0 , SEEK_END); uint32_t lSize = ftell(mFile); rewind (mFile); printf("Size = %d\n", lSize); //read the first header fread(&hChunk, 14, 1, mFile); /*printf("Header is [ "); printf("%s %08X %04X %04X %04X]\n", &hChunk.type, hChunk.length, hChunk.format, hChunk.numtrk, hChunk.div );*/ //hChunk.type[4] = 0; //printf("Type is %s\n", &hChunk.type); //printf("Length is %d\n", endianSwap32(hChunk.length)); //printf("Format is %d\n", endianSwap16(hChunk.format)); //printf("Format is %d\n", endianSwap16(hChunk.numtrk)); //printf("Format is %d\n", endianSwap16(hChunk.div)); //TODO: allow for reading of any len > 5 headers if((endianSwap32(hChunk.length) != 6) || (endianSwap16(hChunk.format) == 2)) { printf("Length of header corrupt or format unknown! Aborting.\n"); exit(1); } fseek(mFile, 8 + endianSwap32(hChunk.length), SEEK_SET); //loop through the rest of the file while(ftell(mFile) < lSize) { char type[5]; type[4] = 0; struct t_chunk * chunk = (struct t_chunk *)malloc(sizeof(struct t_chunk)); printf("Reading chunk...\n"); fread(&type, 1, 4, mFile); fread(&((*chunk).size), 4, 1, mFile); (*chunk).size = endianSwap32((*chunk).size); (*chunk).data = (uint8_t *)malloc((*chunk).size); fread((*chunk).data, 1, (*chunk).size, mFile); printf("Type %s, Length = %d bytes\n", type, (*chunk).size); //link them up if(TCs) { //find the last one in the list struct t_chunk * tmpTC = TCs; while((*tmpTC).next) { tmpTC = (*tmpTC).next; numTCs++; } //add our latest node (*tmpTC).next = chunk; numTCs++; } else { TCs = chunk; numTCs++; } //break; printf("at pos %d\n", ftell(mFile)); } printf("Parsed %d Track Chunks.\n", numTCs); //parse events struct t_chunk * node = TCs; while(node) { parseEvents((*node).data, (*node).size); node = (*node).next; } return 0; }