int main( int argc, char** argv ) { bool doUnitTests = 0; bool doRegressionTests = 0; unsigned int benchmark = 0; // This reorders the OpFunc to Fid mapping to ensure it is node and // compiler independent. Id shellId = init( argc, argv, doUnitTests, doRegressionTests, benchmark ); // Note that the main loop remains the parser loop, though it may // spawn a lot of other stuff. Element* shelle = shellId.element(); Shell* s = reinterpret_cast< Shell* >( shelle->data( 0 ) ); if ( doUnitTests ) nonMpiTests( s ); // These tests do not need the process loop. if ( Shell::myNode() == 0 ) { if ( Shell::numNodes() > 1 ) { // Use the last clock for the postmaster, so that it is called // after everything else has been processed and all messages // are ready to send out. s->doUseClock( "/postmaster", "process", 9 ); s->doSetClock( 9, 1.0 ); // Use a sensible default. } #ifdef DO_UNIT_TESTS if ( doUnitTests ) { mpiTests(); processTests( s ); } // if ( doRegressionTests ) regressionTests(); #endif // These are outside unit tests because they happen in optimized // mode, using a command-line argument. As soon as they are done // the system quits, in order to estimate timing. if ( benchmark != 0 ) { mooseBenchmarks( benchmark ); s->doQuit(); } else { // Here we set off a little event loop to poll user input. // It deals with the doQuit call too. if(! quitFlag) Shell::launchParser(); } } else { PostMaster* p = reinterpret_cast< PostMaster* >( ObjId( 3 ).data()); while ( Shell::keepLooping() ) { p->clearPending(); } } Msg::clearAllMsgs(); Id::clearAllElements(); #ifdef USE_MPI MPI_Finalize(); #endif return 0; }
void SbmlReader::getRules() { unsigned int nr = model_->getNumRules(); //if (nr > 0) // cout << "\n ##### Need to populate funcpool and sumtotal which is pending due to equations \n"; Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); for ( unsigned int r = 0; r < nr; r++ ) { Rule * rule = model_->getRule(r); bool assignRule = rule->isAssignment(); if ( assignRule ) { string rule_variable = rule->getVariable(); map< string,Id >::iterator v_iter; map< string,Id >::iterator m_iter; v_iter = molSidMIdMap_.find( rule_variable ); if (v_iter != molSidMIdMap_.end()) { Id rVariable = molSidMIdMap_.find(rule_variable)->second; string rstring =molSidMIdMap_.find(rule_variable)->first; Id sumId = shell->doCreate( "SumFunc", rVariable, "func", 1 ); rVariable.element()->zombieSwap( FuncPool::initCinfo() ); ObjId ret = shell->doAddMsg( "single", ObjId( sumId, 0 ), "output", ObjId( rVariable, 0 ), "input" ); assert( ret != ObjId() ); const ASTNode * ast = rule->getMath(); vector< string > ruleMembers; ruleMembers.clear(); printMembers( ast,ruleMembers ); for ( unsigned int rm = 0; rm < ruleMembers.size(); rm++ ) { m_iter = molSidMIdMap_.find( ruleMembers[rm] ); if ( m_iter != molSidMIdMap_.end() ) { Id rMember = molSidMIdMap_.find(ruleMembers[rm])->second; ObjId ret = shell->doAddMsg( "single", ObjId( rMember, 0 ), "nOut", ObjId( sumId, 0 ), "input" ); string test = molSidMIdMap_.find(ruleMembers[rm])->first; } else { cerr << "SbmlReader::getRules: Assignment rule member is not a species" << endl; // In assignment rule there are constants instead of molecule which is yet to deal in moose. errorFlag_ = true; } } } } bool rateRule = rule->isRate(); if ( rateRule ) { cout << "warning : for now Rate Rule is not handled " << endl; errorFlag_ = true; } bool algebRule = rule->isAlgebraic(); if ( algebRule ) { cout << "warning: for now Algebraic Rule is not handled" << endl; errorFlag_ = true; } } }
void setup(){ Serial.begin(9600); shell.setPrompt("$\n"); shell.begin(Serial); pinMode(3, OUTPUT); digitalWrite(3, LOW); ShellCommand(line, "draw a line", cmd_line); ShellCommand(origin, "move pen to origin", cmd_origin); }
int main() { TEvent init; init.what = evCommand; init.message.command = cmAbout; // make a cmAbout command event Shell shell; shell.putEvent(init); // put it in the queue to pop up shell.run(); // About box when program starts return 0; }
int main(int argc, char* argv[]) { char *input; char *str; char *tokv[5]; int tokc; char *expansion; int result; printf("Press Ctrl-D or enter \"exit\" to end session.\n" "Enter \"help\" to display a command list.\n"); using_history(); try { Shell shell; while (!shell.exitFlag()) { input = readline("bossa> "); if (!input) { printf("\n"); break; } for (str = input; *str && isspace(*str); str++); if (*str) { result = history_expand(input, &expansion); if (result >= 0 && result != 2) { add_history(expansion); tokc = split(expansion, tokv, ARRAY_SIZE(tokv)); shell.invoke(tokv, tokc); } free(expansion); } free(input); } } catch(...) { printf("\nUnhandled exception\n"); return 1; } return 0; }
Particle(unsigned int energy_limit){ shell.set_max(energy_limit); target = 10; shell.give(random(energy_limit)); mass = 20; acceleration = PVector(0, 0); velocity = PVector(0, 0); location = PVector(0, 0); maxspeed = 50-mass; maxforce = 50; }
void testRunKsolve() { double simDt = 0.1; // double plotDt = 0.1; Shell* s = reinterpret_cast< Shell* >( Id().eref().data() ); Id kin = makeReacTest(); Id ksolve = s->doCreate( "Ksolve", kin, "ksolve", 1 ); Id stoich = s->doCreate( "Stoich", ksolve, "stoich", 1 ); Field< Id >::set( stoich, "compartment", kin ); Field< Id >::set( stoich, "ksolve", ksolve ); Field< string >::set( stoich, "path", "/kinetics/##" ); s->doUseClock( "/kinetics/ksolve", "process", 4 ); s->doSetClock( 4, simDt ); s->doReinit(); s->doStart( 20.0 ); Id plots( "/kinetics/plots" ); for ( unsigned int i = 0; i < 7; ++i ) { stringstream ss; ss << "plot." << i; SetGet2< string, string >::set( ObjId( plots, i ), "xplot", "tsr2.plot", ss.str() ); } s->doDelete( kin ); cout << "." << flush; }
// Static func void Shell::cleanSimulation() { Eref sheller = Id().eref(); Shell* s = reinterpret_cast< Shell* >( sheller.data() ); vector< Id > kids; Neutral::children( sheller, kids ); for ( vector< Id >::iterator i = kids.begin(); i != kids.end(); ++i ) { if ( i->value() > 4 ) { cout << "Shell::cleanSimulation: deleted cruft at " << i->value() << ": " << i->path() << endl; s->doDelete( *i ); } } }
void testReadKkit() { ReadKkit rk; // rk.read( "test.g", "dend", 0 ); Id base = rk.read( "foo.g", "dend", Id() ); assert( base != Id() ); // Id kinetics = s->doFind( "/kinetics" ); Shell* s = reinterpret_cast< Shell* >( Id().eref().data() ); rk.run(); rk.dumpPlots( "dend.plot" ); s->doDelete( base ); cout << "." << flush; }
void testTaperingCylDiffn() { Shell* s = reinterpret_cast< Shell* >( Id().eref().data() ); double len = 25e-6; double r0 = 2e-6; double r1 = 1e-6; double diffLength = 1e-6; // 1e-6 is the highest dx for which error is OK double runtime = 10.0; double dt = 0.1; // 0.2 is the highest dt for which the error is in bounds double diffConst = 1.0e-12; // Should set explicitly, currently during creation of DiffPoolVec //double diffConst = 1.0e-12; Id model = s->doCreate( "Neutral", Id(), "model", 1 ); Id cyl = s->doCreate( "CylMesh", model, "cyl", 1 ); Field< double >::set( cyl, "r0", r0 ); Field< double >::set( cyl, "r1", r1 ); Field< double >::set( cyl, "x0", 0 ); Field< double >::set( cyl, "x1", len ); Field< double >::set( cyl, "diffLength", diffLength ); unsigned int ndc = Field< unsigned int >::get( cyl, "numMesh" ); assert( ndc == static_cast< unsigned int >( round( len / diffLength ))); Id pool = s->doCreate( "Pool", cyl, "pool", 1 ); Field< double >::set( pool, "diffConst", diffConst ); Id dsolve = s->doCreate( "Dsolve", model, "dsolve", 1 ); Field< Id >::set( dsolve, "compartment", cyl ); s->doUseClock( "/model/dsolve", "process", 1 ); s->doSetClock( 1, dt ); // Next: build by setting the path of the dsolve. Field< string >::set( dsolve, "path", "/model/cyl/pool" ); // Then find a way to test it. assert( pool.element()->numData() == ndc ); Field< double >::set( ObjId( pool, 0 ), "nInit", 1.0 ); s->doReinit(); s->doStart( runtime ); double myTot = 0.0; vector< double > poolVec; Field< double >::getVec( pool, "n", poolVec ); for ( unsigned int i = 0; i < poolVec.size(); ++i ) { myTot += poolVec[i]; } assert( doubleEq( myTot, 1.0 ) ); s->doDelete( model ); cout << "." << flush; }
void testPoolVolumeScaling() { Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); Id comptId = shell->doCreate( "CylMesh", Id(), "cyl", 1 ); Id meshId( comptId.value() + 1 ); Id poolId = shell->doCreate( "Pool", comptId, "pool", 1 ); ObjId mid = shell->doAddMsg( "OneToOne", ObjId( poolId, 0 ), "requestVolume", ObjId( meshId, 0 ), "get_volume" ); assert( mid != ObjId() ); vector< double > coords( 9, 0.0 ); double x1 = 100e-6; double r0 = 10e-6; double r1 = 5e-6; double lambda = x1; coords[3] = x1; coords[6] = r0; coords[7] = r1; coords[8] = lambda; Field< vector< double > >::set( comptId, "coords", coords ); double volume = Field< double >::get( poolId, "volume" ); assert( doubleEq( volume, PI * x1 * (r0+r1) * (r0+r1) / 4.0 ) ); Field< double >::set( poolId, "n", 400 ); double volscale = 1 / ( NA * volume ); double conc = Field< double >::get( poolId, "conc" ); assert( doubleEq( conc, 400 * volscale ) ); Field< double >::set( poolId, "conc", 500 * volscale ); double n = Field< double >::get( poolId, "n" ); assert( doubleEq( n, 500 ) ); Field< double >::set( poolId, "nInit", 650 ); double concInit = Field< double >::get( poolId, "concInit" ); assert( doubleEq( concInit, 650 * volscale ) ); Field< double >::set( poolId, "concInit", 10 * volscale ); n = Field< double >::get( poolId, "nInit" ); assert( doubleEq( n, 10 ) ); shell->doDelete( comptId ); cout << "." << flush; }
/** * Launches Parser. Blocking when the parser blocks. */ void Shell::launchParser() { Id shellId; Shell* s = reinterpret_cast< Shell* >( shellId.eref().data() ); bool quit = 0; cout << "moose : " << flush; while ( !quit ) { string temp; cin >> temp; if ( temp == "quit" || temp == "q" ) { s->doQuit(); quit = 1; } } cout << "\nQuitting Moose\n" << flush; }
void testSpikeGen() { Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); Id sid = shell->doCreate( "SpikeGen", Id(), "spike", 1, MooseGlobal ); SpikeGen& sg = *( reinterpret_cast< SpikeGen* >( sid.eref().data() ) ); Eref er( sid.eref() ); ProcInfo p; p.dt = 0.001; p.currTime = 0.0; sg.setThreshold( 1.0 ); sg.setRefractT( 0.005 ); sg.reinit( er, &p ); sg.handleVm( 0.5 ); sg.process( er, &p ); assert( !sg.getFired() ); p.currTime += p.dt; sg.handleVm( 0.999 ); sg.process( er, &p ); assert( !sg.getFired() ); p.currTime += p.dt; sg.handleVm( 1.001 ); sg.process( er, &p ); assert( sg.getFired() ); p.currTime += p.dt; sg.handleVm( 0.999 ); sg.process( er, &p ); assert( !sg.getFired() ); p.currTime += p.dt; sg.handleVm( 2.0 ); // Too soon, refractory sg.process( er, &p ); assert( !sg.getFired() ); p.currTime += 0.005; // Now post-refractory sg.handleVm( 2.0 ); // Now not refractory sg.process( er, &p ); assert( sg.getFired() ); sid.destroy(); cout << "." << flush; }
/* set up Michalies Menten reaction */ void SbmlReader::setupMMEnzymeReaction( Reaction * reac,string rid,string rname,const map< string, Id > &molSidcmptMIdMap ) { string::size_type loc = rid.find( "_MM_Reaction_" ); if( loc != string::npos ) { int strlen = rid.length(); rid.erase( loc,strlen-loc ); } unsigned int num_modifr = reac->getNumModifiers(); for ( unsigned int m = 0; m < num_modifr; m++ ) { const ModifierSpeciesReference* modifr=reac->getModifier( m ); std::string sp = modifr->getSpecies(); Id enzyme_; Id E = molSidMIdMap_.find(sp)->second; Id comptRef = molSidcmptMIdMap.find(sp)->second; //gives compartment of sp Id meshEntry = Neutral::child( comptRef.eref(), "mesh" ); Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); enzyme_ = shell->doCreate("MMenz",E,rname,1); //shell->doAddMsg( "Single", meshEntry, "remeshReacs", enzyme_, "remesh"); shell->doAddMsg("Single",E,"nOut",enzyme_,"enzDest"); KineticLaw * klaw=reac->getKineticLaw(); vector< double > rate; rate.clear(); getKLaw( klaw,true,rate ); if ( errorFlag_ ) return; else if ( !errorFlag_ ) { for ( unsigned int rt = 0; rt < reac->getNumReactants(); rt++ ) { const SpeciesReference* rct = reac->getReactant( rt ); sp=rct->getSpecies(); Id S = molSidMIdMap_.find(sp)->second; shell->doAddMsg( "OneToOne", enzyme_, "sub" ,S , "reac" ); } for ( unsigned int pt = 0; pt < reac->getNumProducts(); pt++ ) { const SpeciesReference* pdt = reac->getProduct(pt); sp = pdt->getSpecies(); Id P = molSidMIdMap_.find(sp)->second; shell->doAddMsg( "OneToOne", enzyme_, "prd" ,P, "reac" ); } Field < double > :: set( enzyme_, "kcat", rate[0] ); Field < double > :: set( enzyme_, "numKm", rate[1] ); } } }
////////////////////////////////////////////////////////////////// // The read functions. ////////////////////////////////////////////////////////////////// Id makeStandardElements( Id pa, const string& modelname ) { Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); //cout << " kkit read " << pa << " " << modelname << " "<< MooseGlobal; string modelPath = pa.path() + "/" + modelname; if ( pa == Id() ) modelPath = "/" + modelname; Id mgr( modelPath ); if ( mgr == Id() ) mgr = shell->doCreate( "Neutral", pa, modelname, 1, MooseGlobal ); Id kinetics( modelPath + "/kinetics" ); if ( kinetics == Id() ) { kinetics = shell->doCreate( "CubeMesh", mgr, "kinetics", 1, MooseGlobal ); SetGet2< double, unsigned int >::set( kinetics, "buildDefaultMesh", 1e-15, 1 ); } assert( kinetics != Id() ); Id graphs = shell->doCreate( "Neutral", mgr, "graphs", 1, MooseGlobal); assert( graphs != Id() ); Id moregraphs = shell->doCreate( "Neutral", mgr, "moregraphs", 1, MooseGlobal ); Id geometry = shell->doCreate( "Neutral", mgr, "geometry", 1, MooseGlobal ); assert( geometry != Id() ); Id groups = shell->doCreate( "Neutral", mgr, "groups", 1, MooseGlobal ); assert( groups != Id() ); return mgr; }
/* Enzymatic Reaction */ void SbmlReader::setupEnzymaticReaction( const EnzymeInfo & einfo,string enzname, const map< string, Id > &molSidcmptMIdMap,string name1) { string enzPool = einfo.enzyme; Id comptRef = molSidcmptMIdMap.find(enzPool)->second; //gives compartment of sp Id meshEntry = Neutral::child( comptRef.eref(), "mesh" ); Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); //Creating enz pool to enzyme site Id enzPoolId = molSidMIdMap_.find(enzPool)->second; Id enzyme_ = shell->doCreate("Enz", enzPoolId, name1, 1); //shell->doAddMsg( "Single", meshEntry, "remeshReacs", enzyme_, "remesh"); Id complex = einfo.complex; //Moving enzyme site under enzyme shell->doMove(complex,enzyme_); shell->doAddMsg("OneToAll",enzyme_,"cplx",complex,"reac"); shell->doAddMsg("OneToOne",enzyme_,"enz",enzPoolId,"reac"); vector< Id >::const_iterator sub_itr; for ( sub_itr = einfo.substrates.begin(); sub_itr != einfo.substrates.end(); sub_itr++ ) { Id S = (*sub_itr); Id b = shell->doAddMsg( "OneToOne", enzyme_, "sub" ,S , "reac" ); } vector< Id >::const_iterator prd_itr; for ( prd_itr = einfo.products.begin(); prd_itr != einfo.products.end(); prd_itr++ ) { Id P = (*prd_itr); shell->doAddMsg ("OneToOne",enzyme_,"prd", P,"reac"); } // populate k3,k2,k1 in this order only. Field < double > :: set( enzyme_, "k3", einfo.k3 ); Field < double > :: set( enzyme_, "k2", einfo.k2 ); Field < double > :: set( enzyme_, "k1", einfo.k1 ); }
/** * The readcell function implements the old GENESIS cellreader * functionality. Although it is really a parser operation, I * put it here in Kinetics because the cell format is independent * of parser and is likely to remain a legacy for a while. */ Id ReadKkit::read( const string& filename, const string& modelname, Id pa, const string& methodArg ) { string method = methodArg; ifstream fin( filename.c_str() ); if (!fin){ cerr << "ReadKkit::read: could not open file " << filename << endl; return Id(); } if ( method.substr(0, 4) == "old_" ) { moveOntoCompartment_ = false; method = method.substr( 4 ); } Shell* s = reinterpret_cast< Shell* >( ObjId().data() ); Id mgr = makeStandardElements( pa, modelname ); assert( mgr != Id() ); baseId_ = mgr; basePath_ = mgr.path(); enzCplxMols_.resize( 0 ); innerRead( fin ); assignPoolCompartments(); assignReacCompartments(); assignEnzCompartments(); assignMMenzCompartments(); convertParametersToConcUnits(); s->doSetClock( 8, plotdt_ ); string plotpath = basePath_ + "/graphs/##[TYPE=Table]," + basePath_ + "/moregraphs/##[TYPE=Table]"; s->doUseClock( plotpath, "process", 8 ); setMethod( s, mgr, simdt_, plotdt_, method ); s->doReinit(); return mgr; }
void Smoke::attach_shell(Shell &sh) { Game::attach_shell(sh); const Shell::Context &ctx = sh.context(); physical_dev_ = ctx.physical_dev; dev_ = ctx.dev; queue_ = ctx.game_queue; queue_family_ = ctx.game_queue_family; format_ = ctx.format.format; vk::GetPhysicalDeviceProperties(physical_dev_, &physical_dev_props_); if (use_push_constants_ && sizeof(ShaderParamBlock) > physical_dev_props_.limits.maxPushConstantsSize) { shell_->log(Shell::LOG_WARN, "cannot enable push constants"); use_push_constants_ = false; } VkPhysicalDeviceMemoryProperties mem_props; vk::GetPhysicalDeviceMemoryProperties(physical_dev_, &mem_props); mem_flags_.reserve(mem_props.memoryTypeCount); for (uint32_t i = 0; i < mem_props.memoryTypeCount; i++) mem_flags_.push_back(mem_props.memoryTypes[i].propertyFlags); meshes_ = new Meshes(dev_, mem_flags_); create_render_pass(); create_shader_modules(); create_descriptor_set_layout(); create_pipeline_layout(); create_pipeline(); create_frame_data(2); render_pass_begin_info_.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; render_pass_begin_info_.renderPass = render_pass_; render_pass_begin_info_.clearValueCount = 1; render_pass_begin_info_.pClearValues = &render_pass_clear_value_; primary_cmd_begin_info_.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; primary_cmd_begin_info_.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; // we will render to the swapchain images primary_cmd_submit_wait_stages_ = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; primary_cmd_submit_info_.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; primary_cmd_submit_info_.waitSemaphoreCount = 1; primary_cmd_submit_info_.pWaitDstStageMask = &primary_cmd_submit_wait_stages_; primary_cmd_submit_info_.commandBufferCount = 1; primary_cmd_submit_info_.signalSemaphoreCount = 1; if (multithread_) { for (auto &worker : workers_) worker->start(); } }
Shell* Shell::create() { Shell* pSprite = new Shell(); if (pSprite->initWithFile("Shell.png")) { pSprite->autorelease(); pSprite->initOptions(); pSprite->addEvents(); return pSprite; } CC_SAFE_DELETE(pSprite); return NULL; }
void testSetupReac() { Shell* s = reinterpret_cast< Shell* >( Id().eref().data() ); Id kin = makeReacTest(); s->doReinit(); s->doStart( 20.0 ); Id plots( "/kinetics/plots" ); /* for ( unsigned int i = 0; i < 7; ++i ) { stringstream ss; ss << "plot." << i; SetGet2< string, string >::set( ObjId( plots, i ), "xplot", "tsr.plot", ss.str() ); } */ s->doDelete( kin ); cout << "." << flush; }
static Id makeCompt( Id parent, const SwcSegment& seg, const SwcSegment& pa, double RM, double RA, double CM, unsigned int i, unsigned int j ) { Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); double len = seg.radius() * 2.0; string name = "soma"; Id compt; double x0, y0, z0; if ( seg.parent() != ~0U ) { len = seg.distance( pa ); stringstream ss; ss << SwcSegment::typeName[ seg.type() ] << "_" << i << "_" << j; name = ss.str(); x0 = pa.vec().a0(); y0 = pa.vec().a1(); z0 = pa.vec().a2(); } else { x0 = seg.vec().a0() - len; y0 = seg.vec().a1(); z0 = seg.vec().a2(); } assert( len > 0.0 ); compt = shell->doCreate( "Compartment", parent, name, 1 ); Eref er = compt.eref(); moose::CompartmentBase *cptr = reinterpret_cast< moose::CompartmentBase* >( compt.eref().data() ); double xa = seg.radius() * seg.radius() * PI * 1e-12; len *= 1e-6; double dia = seg.radius() * 2.0e-6; cptr->setRm( er, RM / ( len * dia * PI ) ); cptr->setRa( er, RA * len / xa ); cptr->setCm( er, CM * ( len * dia * PI ) ); cptr->setDiameter( dia ); cptr->setLength( len ); cptr->setX0( x0 * 1e-6 ); cptr->setY0( y0 * 1e-6 ); cptr->setZ0( z0 * 1e-6 ); cptr->setX( seg.vec().a0() * 1e-6 ); cptr->setY( seg.vec().a1() * 1e-6 ); cptr->setZ( seg.vec().a2() * 1e-6 ); return compt; }
int main() { Thread * thread; pc.baud(115200); pc.printf("\r\nStarting Mbed ...\r\n"); //Initialize the LCD pc.printf("Initializing LCD ...\r\n"); init_LCD(); printf("Initializing USB Mass Storage ...\r\n"); printf("Inititalizing ethernet ....\r\n"); eth.init(); // Use DHCP eth.connect(); printf("IP Address is %s\n", eth.getIPAddress()); // After initializing the ethernet interface // run it in its own thread printf("Starting blinker thread ...\r\n"); thread = new Thread(led1_thread); // Start the shell printf("Starting debug shell ...\r\n"); shell.addCommand("ls", cmd_ls); shell.addCommand("load", cmd_load); shell.addCommand("mem", cmd_mem); shell.addCommand("sensor", cmd_sensor); shell.start(osPriorityNormal, SHELL_STACK_SIZ, shellStack); printf("Shell now running!\r\n"); printf("Available Memory : %d\r\n", get_mem()); // Do something logical here // other than looping while(1) { printf("Temperature : %d °C\r\n", htu21d.sample_ctemp()); printf("Humitdity : %d%%\r\n", htu21d.sample_humid()); wait(10); } thread->terminate(); delete thread; }
int main () { printf ("Results of mathlib_performance test:\n"); try { Environment env; Shell shell ("lua", env); xtl::com_ptr<IInterpreter> script (shell.Interpreter ()); env.Library ("global").Register ("typename", make_invoker (&get_typename)); env.BindLibraries ("Math"); load_script (*script, SCRIPT_FILE_NAME); printf ("Test c++ performance:\n"); size_t start_time = common::milliseconds (); float test_result = test (); printf ("Duration = %u ms, result = %f\n", common::milliseconds () - start_time, test_result); printf ("Test lua performance:\n"); start_time = common::milliseconds (); test_result = invoke<float> (*script, "test"); printf ("Duration = %u ms, result = %f\n", common::milliseconds () - start_time, test_result); } catch (xtl::bad_any_cast& exception) { printf ("%s: %s -> %s\n", exception.what (), exception.source_type ().name (), exception.target_type ().name ()); } catch (std::exception& exception) { printf ("exception: %s\n", exception.what ()); } return 0; }
void testMMenz() { Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); Id mmid = shell->doCreate( "MMenz", Id(), "mm", 1 ); // mmenz MMenz m; ProcInfo p; m.vSetKm( mmid.eref(), 5.0 ); m.vSetKcat( mmid.eref(), 4.0 ); m.vReinit( mmid.eref(), &p ); m.vSub( 2 ); m.vEnz( 3 ); assert( doubleEq( m.vGetKm( mmid.eref() ), 5.0 ) ); assert( doubleEq( m.vGetKcat( mmid.eref() ), 4.0 ) ); m.vProcess( mmid.eref(), &p ); shell->doDelete( mmid ); cout << "." << flush; }
void FaceMesh::Render() { Shell * pShell = Shell::GetShell(); int w,h; pShell->GetScreenSize(w,h); mAppearance.mCompositingMode.mEnableDepth = false; mAppearance.Apply(); Shader * pShader = mAppearance.GetShader(); pShader->SetOrthographic(); mVertices->Apply(pShader); mIndices->Apply(); ERR( glDrawElements(GL_TRIANGLE_STRIP, mIndices->mCount, GL_UNSIGNED_SHORT, 0) ); }
int main(int argc, char *argv[]) { KAboutData aboutData("bookmanager", "bookmanager", ki18n("Book Manager"), "0.04", ki18n("An Ebook library manager."), KAboutData::License_GPL, ki18n("Copyright (c) 2010 Brian Korbein"), KLocalizedString(), "https://projects.kde.org/projects/playground/graphics/bookmanager" ); aboutData.addAuthor(ki18n("Brian Korbein"), ki18n("Creator & Developer"), "*****@*****.**"); aboutData.addAuthor(ki18n("Riccardo Bellini"), ki18n("Developer"), "*****@*****.**"); KCmdLineArgs::init(argc, argv, &aboutData); KApplication app; Shell* shell = new Shell(); shell->show(); return app.exec(); }
Vector_s& ShellBuilder::createShells(size_t shellNO, int spaceDimension) { Vector_s * shells = new Vector_s(); // The shellIdx is only a candidate shell index based on Fermat's theorem on sum of two squares // and Legendre's three-square theorem int shellIdx = 1; while (shells->size() < shellNO) { Shell * currentShell = new Shell(); Vector_t currentIntTuples = backtrackingMethod.decomposeByBacktracking(shellIdx, spaceDimension); if (currentIntTuples.size() != 0) { currentShell->setIntTuplesWithSwapsAndSignChange(currentIntTuples); shells->push_back(currentShell); } shellIdx++; } return *shells; }
void cmd_line(Shell &shell, int argc, const ShellArguments &argv){ if(argc != 5){ return; } long start[] = {atol(argv[1]), atol(argv[2])}; long end[] = {atol(argv[3]), atol(argv[4])}; artist.line(start, end); shell.write('x'); }
// See what Element::getNeighbors does with 2 sub <----> prd. void testTwoReacGetNeighbors() { Shell* shell = reinterpret_cast< Shell* >( Id().eref().data() ); Id comptId = shell->doCreate( "CubeMesh", Id(), "cube", 1 ); Id meshId( comptId.value() + 1 ); Id subId = shell->doCreate( "Pool", comptId, "sub", 1 ); Id prdId = shell->doCreate( "Pool", comptId, "prd", 1 ); Id reacId = shell->doCreate( "Reac", comptId, "reac", 1 ); ObjId mid = shell->doAddMsg( "OneToOne", subId, "requestVolume", meshId, "get_volume" ); assert( mid != ObjId() ); mid = shell->doAddMsg( "OneToOne", prdId, "requestVolume", meshId, "get_volume" ); assert( mid != ObjId() ); ObjId ret = shell->doAddMsg( "Single", reacId, "sub", subId, "reac" ); assert( ret != ObjId() ); ret = shell->doAddMsg( "Single", reacId, "sub", subId, "reac" ); assert( ret != ObjId() ); ret = shell->doAddMsg( "Single", reacId, "prd", prdId, "reac" ); assert( ret != ObjId() ); vector< Id > pools; unsigned int num = reacId.element()->getNeighbors( pools, Reac::initCinfo()->findFinfo( "toSub" ) ); assert( num == 2 ); assert( pools[0] == subId ); assert( pools[1] == subId ); pools.clear(); num = reacId.element()->getNeighbors( pools, Reac::initCinfo()->findFinfo( "sub" ) ); assert( num == 2 ); assert( pools[0] == subId ); assert( pools[1] == subId ); shell->doDelete( comptId ); cout << "." << flush; }
void DomainObject::initNewDomain(DomainObject *parentDomain) { Shell *core = (Shell*) this->core(); Domain* baseDomain; if (parentDomain) { baseDomain = parentDomain->domainEnv->domain(); } else { baseDomain = core->builtinDomain; } Domain* domain = new (core->GetGC()) Domain(core, baseDomain); if (parentDomain) { domainToplevel = parentDomain->domainToplevel; } else { domainToplevel = core->initShellBuiltins(); } domainEnv = new (core->GetGC()) DomainEnv(core, domain, domainToplevel->domainEnv()); }