int main(int argc, char *argv[]) { string mission_file; bool lancer_tests = false; string run_command = argv[0]; for(int i = 1; i < argc ; i++) { string argi = argv[i]; if((argi=="-v") || (argi=="--version") || (argi=="-version")) showReleaseInfoAndExit(); else if((argi=="-e") || (argi=="--example") || (argi=="-example")) showExampleConfigAndExit(); else if((argi == "-h") || (argi == "--help") || (argi=="-help")) showHelpAndExit(); else if((argi == "-i") || (argi == "--interface")) showInterfaceAndExit(); else if((argi == "-tests")) lancer_tests = true; else if(strEnds(argi, ".moos") || strEnds(argi, ".moos++")) mission_file = argv[i]; else if(strBegins(argi, "--alias=")) run_command = argi.substr(8); else if(i==2) run_command = argi; } if(mission_file == "") showHelpAndExit(); if(lancer_tests) launchTestsAndExitIfOk(); else { cout << termColor("green"); cout << "Lancement de " << run_command << endl; cout << termColor() << endl; Logs Logs; Logs.Run(run_command.c_str(), mission_file.c_str()); } return(0); }
int main (int ac, char *ag[]) { int addr; int len; int index; CArray result; LowLevelDriverInterface *iface = 0; memset (&arg, 0, sizeof (arg)); argp_parse (&argp, ac, ag, 0, &index, &arg); if (index > ac - 3) die ("more parameter expected"); if (index < ac - 3) die ("unexpected parameter"); signal (SIGPIPE, SIG_IGN); pth_init (); Logs t; t.setTraceLevel (arg.tracelevel); iface = Create (ag[index], &t); if (!iface) die ("initialisation failed"); if (!iface->init ()) die ("initialisation failed"); addr = readHex (ag[index + 1]); len = atoi (ag[index + 2]); int res = readEMIMem (iface, addr, len, result); if (!res) { printf ("Read failed"); } else { for (int i = 0; i < result (); i++) printf ("%02x ", result[i]); printf ("\n"); } delete iface; if (Cleanup) Cleanup (); pth_exit (0); return 0; }
ConsensusImp::ConsensusImp ( FeeVote::Setup const& voteSetup, Logs& logs) : journal_ (logs.journal("Consensus")) , feeVote_ (make_FeeVote (voteSetup, logs.journal("FeeVote"))) , proposing_ (false) , validating_ (false) , lastCloseProposers_ (0) , lastCloseConvergeTook_ (LEDGER_IDLE_INTERVAL) , lastValidationTimestamp_ (0s) , lastCloseTime_ (0s) { }
bool takeLogs( Logs& aLogs ) { { std::lock_guard<std::mutex> lg( mLogMutex ); std::swap( mLogs, aLogs ); } return mHasNew.exchange( false, std::memory_order_relaxed ) || !aLogs.empty(); }
SDL_Surface* EntityViewData::getEntityImage() { if (this->openImage == NULL) { SDL_Surface* loadedImageTmp = IMG_Load(this->entityImage.c_str()); if (loadedImageTmp == NULL) { printf("Unable to load Entity Image. %s\n", SDL_GetError()); unlog.logErrorMessage( string("Unable to load Entity Image.") + string(SDL_GetError())); return NULL; } SDL_Surface* loadedImageRot = rotozoomSurfaceXY(loadedImageTmp, 0, this->scaleWidth, this->scaleHeight, 0); SDL_FreeSurface(loadedImageTmp); SDL_Surface* loadedImage = SDL_DisplayFormatAlpha(loadedImageRot); SDL_FreeSurface(loadedImageRot); this->openImage = loadedImage; } return this->openImage; }
bool OfferStream::step (Logs& l) { // Modifying the order or logic of these // operations causes a protocol breaking change. auto viewJ = l.journal ("View"); for(;;) { // BookTip::step deletes the current offer from the view before // advancing to the next (unless the ledger entry is missing). if (! tip_.step(l)) return false; std::shared_ptr<SLE> entry = tip_.entry(); // If we exceed the maximum number of allowed steps, we're done. if (!counter_.step ()) return false; // Remove if missing if (! entry) { erase (view_); erase (cancelView_); continue; } // Remove if expired using d = NetClock::duration; using tp = NetClock::time_point; if (entry->isFieldPresent (sfExpiration) && tp{d{(*entry)[sfExpiration]}} <= expire_) { JLOG(j_.trace) << "Removing expired offer " << entry->getIndex(); offerDelete (cancelView_, cancelView_.peek(keylet::offer(entry->key())), viewJ); continue; } offer_ = Offer (entry, tip_.quality()); Amounts const amount (offer_.amount()); // Remove if either amount is zero if (amount.empty()) { JLOG(j_.warning) << "Removing bad offer " << entry->getIndex(); offerDelete (cancelView_, cancelView_.peek(keylet::offer(entry->key())), viewJ); offer_ = Offer{}; continue; } // Calculate owner funds auto const owner_funds = accountFunds(view_, offer_.owner(), amount.out, fhZERO_IF_FROZEN, viewJ); // Check for unfunded offer if (owner_funds <= zero) { // If the owner's balance in the pristine view is the same, // we haven't modified the balance and therefore the // offer is "found unfunded" versus "became unfunded" auto const original_funds = accountFunds(cancelView_, offer_.owner(), amount.out, fhZERO_IF_FROZEN, viewJ); if (original_funds == owner_funds) { offerDelete (cancelView_, cancelView_.peek( keylet::offer(entry->key())), viewJ); JLOG(j_.trace) << "Removing unfunded offer " << entry->getIndex(); } else { JLOG(j_.trace) << "Removing became unfunded offer " << entry->getIndex(); } offer_ = Offer{}; continue; } break; } return true; }
void NobracketString::Multip(string Anumb,string Atype, string Bnumb, string Btype){ isReturnOneNumb = false; if(Atype==Btype){ //if they are the same type; if(Atype == "frac") { Fraction* fra = new Fraction(Anumb); Fraction* frb = new Fraction(Bnumb); fra->Multiplication(*frb); opAnswer = fra->getAnswer(); isReturnOneNumb = true; // here may need to delete the object. } else if(Atype == "int") { Integers* intnumbA = new Integers(Anumb); Integers* intnumbB = new Integers(Bnumb); intnumbA->Multiply(*intnumbB); opAnswer = intnumbA->getAnswer(); //// //delete[] intnumb; isReturnOneNumb = true; } else if(Atype=="log") { Logs* lgA = new Logs(Anumb); Logs* lgB = new Logs(Bnumb); lgA->Multip(*lgB); opAnswer = lgA->getAnswer(); //delete[] lg; if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false; else isReturnOneNumb = true; } else if(Atype=="root") { nthRoot* nthNumb = new nthRoot(Anumb); nthRoot* B = new nthRoot(Bnumb); nthNumb->multiply(*B); opAnswer = nthNumb->getAns(); if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false; else isReturnOneNumb = true; }//it is handled in the calculating() else if(Atype=="pi"){ // Pi* p = new Pi(Anumb); // p->Multiply(*p); // opAnswer = p->getAnswer(); isReturnOneNumb = true; } else if(Atype=="e"){ Exponential* p = new Exponential(Anumb); p->Multiply(*p); opAnswer = p->getAnswer(); isReturnOneNumb = true; }else if(Atype=="exp"){ Exponent* power = new Exponent(Anumb); Exponent* b = new Exponent(Bnumb); power->multiply(*b); opAnswer = power->getAnswer(); if(opAnswer.find("-")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false; else isReturnOneNumb = true; } } else{ if((Atype=="frac"&&Btype=="int")||(Btype=="frac"&&Atype=="int")){ //if not the same type Fraction* fra = new Fraction(Anumb); Fraction* frb = new Fraction(Bnumb); fra->Multiplication(*frb); opAnswer = fra->getAnswer(); isReturnOneNumb = true; }else if((Atype=="int"&&Btype=="root")||(Btype=="int"&&Atype=="root")){ nthRoot* nthNumb = new nthRoot(Anumb); nthRoot* B = new nthRoot(Bnumb); nthNumb->multiply(*B); opAnswer = nthNumb->getAns(); // if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression // isReturnOneNumb = true; // else isReturnOneNumb = true; } else{ isReturnOneNumb=false; } } }
void NobracketString::divide(string Anumb,string Atype, string Bnumb, string Btype){ //need to handle different types calculation, basicly differen type just return as it is. isReturnOneNumb = false; if(Atype==Btype){ //if they are the same type; if(Atype == "frac") { Fraction* fra = new Fraction(Anumb); Fraction* frb = new Fraction(Bnumb); fra->Division(*frb); opAnswer = fra->getAnswer(); isReturnOneNumb = true; // here may need to delete the object. } else if(Atype == "int") { Integers* intnumbA = new Integers(Anumb); Integers* intnumbB = new Integers(Bnumb); intnumbA->Divide(*intnumbB); opAnswer = intnumbA->getAnswer(); //!!!!!here type has to be a "frac"!!!!! //// //delete[] intnumb; // if(opAnswer.find("/")<100) // isReturnOneNumb = false; // else isReturnOneNumb = true; } else if(Atype=="log") { Logs* lgA = new Logs(Anumb); Logs* lgB = new Logs(Bnumb); lgA->divide(*lgB); opAnswer = lgA->getAnswer(); //delete[] lg; if(opAnswer.find("/")<100){ //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false;} else isReturnOneNumb = true; } else if(Atype=="root") { nthRoot* nthNumb = new nthRoot(Anumb); nthRoot* B = new nthRoot(Bnumb); nthNumb->divide(*B); opAnswer = nthNumb->getAns(); if(opAnswer.find("/")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false; else isReturnOneNumb = true; }//it is handled in the calculating() else if(Atype=="pi"){ // Pi* p = new Pi(Anumb); // p->Divide(*p); // opAnswer = p->getAnswer(); isReturnOneNumb = true; } else if(Atype=="e"){ Exponential* p = new Exponential(Anumb); Exponential* b = new Exponential(Bnumb); p->Divide(*b); opAnswer = p->getAnswer(); isReturnOneNumb = true; }else if(Atype=="exp"){ Exponent* power = new Exponent(Anumb); Exponent* b = new Exponent(Bnumb); power->divide(*b); opAnswer = power->getAnswer(); if(opAnswer.find("-")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false; else isReturnOneNumb = true; } }else{ //if not the same type } }
void NobracketString::add(string Anumb, string Atype, string Bnumb, string Btype){ //does not need to handle differen type here only handel same type or (fraction and integer) if(Atype==Btype){ //if they are the same type; if(Atype == "frac") { Fraction* fra = new Fraction(Anumb); Fraction* frb = new Fraction(Bnumb); fra->Addition(*frb); opAnswer = fra->getAnswer(); isReturnOneNumb = true; //same type fraction should always return one numb //delete[] fra; // here may need to delete the object. } else if(Atype == "int") { Integers* intnumbA = new Integers(Anumb); Integers* intnumbB = new Integers(Bnumb); intnumbA->Add(*intnumbB); opAnswer = intnumbA->getAnswer(); //// //delete[] intnumb; isReturnOneNumb = true; } else if(Atype=="log") { Logs* lgA = new Logs(Anumb); Logs* lgB = new Logs(Bnumb); lgA->add(*lgB); opAnswer = lgA->getAnswer(); //delete[] lg; if(opAnswer.find("+")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false; else isReturnOneNumb = true; } else if(Atype=="root") { nthRoot* nthNumb = new nthRoot(Anumb); nthRoot* B = new nthRoot(Bnumb); nthNumb->add(*B); opAnswer = nthNumb->getAns(); if(opAnswer.find("+")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = false; else isReturnOneNumb = true; }//it is handled in the calculating() else if(Atype=="pi"){ // isReturnOneNumb = true; } else if(Atype=="e"){ Exponential* p = new Exponential(Anumb); p->Add(*p); opAnswer = p->getAnswer(); isReturnOneNumb = true; }else if(Atype=="exp"){ } }else{ //if not the same type if((Atype=="root"&&Btype=="int")||(Btype=="int"&&Atype=="root")){ nthRoot* nthNumb = new nthRoot(Anumb); nthRoot* B = new nthRoot(Bnumb); nthNumb->add(*B); opAnswer = nthNumb->getAns(); if(opAnswer.find("*")<100) //if the opanswer string contains "+", means it return a complex expression isReturnOneNumb = true; else isReturnOneNumb = true; } } }
void NobracketString::simplifynumbers(){ //maybe need to delete the object I create here. for(int i = 0; i<somenumbs.size();i++){ string tempnumb = somenumbs[i]; if(tempnumb.find("^")<100 && tempnumb.find("log")>100){ /////this lines needs to go into Exponent* power = new Exponent(somenumbs[i]); somenumbs[i]=power->getAnswer(); if(power->canSimplifyToInt()){ type.push_back("int"); }else if(power->canSimplifyToFrac()){ type.push_back("frac"); }else{ type.push_back("exp"); } } else if(tempnumb.find("rt")<100){ nthRoot* power = new nthRoot(somenumbs[i]); //will do the simplification in constructor. somenumbs[i]=power->getSimp(); //get a string type if(power->canSimplifytoInt()){ type.push_back("int"); } else if(power->canSimpifytoFrac()){ type.push_back("frac"); }else{ type.push_back("root"); } } else if(tempnumb.find("/")<100 && tempnumb.find("p")>100){ //im each value, if it contains /, Fraction* fra = new Fraction(somenumbs[i]); somenumbs[i]=fra->getAnswer(); //change the vector number to the simplify number. tempnumb = fra->getAnswer(); if(fra->canSimplifytoInteger()) { //if it simplifies to int type.push_back("int"); } // put "int" in the vector type; else{ type.push_back("frac"); } } else if(tempnumb.find("log")<100){ Logs* lg = new Logs(somenumbs[i]); somenumbs[i]=lg->getSimplify(); if(somenumbs[i]==expression){ //if user enter a log only and it cannot be simplify // expression = lg->FinalSplit(); //try split it; if(somenumbs[i]==expression){ //if the log cannot be split, do nothing. }else{ somenumbs.erase(somenumbs.begin()); type.clear(); separateString(); simplifynumbers(); } } if(lg->canSimplifytoInt()){ //check if it can be simplified type.push_back("int"); //if it simplifies to int, put "int" to vector type; } else if(lg->canSimplifytoFra()){ type.push_back("frac"); //else if it simplifies to fraction, put "fra" to vector type; }else{ type.push_back("log"); ////cout<<"in the log to log here"<<endl; } } else if(tempnumb.find("Pi")<100||tempnumb.find("pi")<100){ type.push_back("pi"); } else if(tempnumb.find("e")<100){ type.push_back("e"); }else{ type.push_back("int"); } } }