Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally I've always found based on the code generators that I've written that code generators are best avoided as they tend to be fiddly, hard to implement and an artificial limitation. In effect a code generator will grow beyond original intentions.</p> <p>It is wise to realise that unless you really want to design and implement a new language specifically tailored to your domain you are best off finding a solution using pre-existing technologies.</p> <p>I know it seems that a code generator will make things easier, save typing and generally be wonderful, but realistically this is too optimistic.</p> <p>If I were doing this in C++ I would firstly spend some time designing a coherent object model, possibly using the approach taken with <a href="http://jsbsim.sourceforge.net/" rel="nofollow noreferrer">JSBSim</a> of having the model contained within an XML file.</p> <p>So following your edit I would say that it is probably best to invest the time in building a clean model, some good documented examples and some training.</p> <p>The following is a rough prototype model for illustration. It may not be relevant given your edit, but as I've just spent a while putting it together I figured I might as well post it.</p> <pre><code>#include &lt;string&gt; using namespace std; // // Fundamental element of simulation - an ExecModule is a concise unit of simulation work. It will // be called by the main real time executive at the frequency specified by the getExecRate() method. // Communication between modules is either via datapool, or by using BusMessages. class ExecModule { public: virtual bool initialise(long time_ms) = 0; virtual long run(long ms) = 0; virtual long getExecRate() = 0; virtual string getModuleDescription() = 0; } class GeoCoordinate { public: GeoCoordinate(double lat, double lon, double alt); }; class Model { public: virtual void DifferentialEquations() = 0; virtual void AlgebraicEquations() = 0; }; class State { public: Value Prime(); Prime(Value &amp;v); State operator *(State c); } class AircraftModel : public ExecModule, public Model { private: State x1, x2; State x3; InputDouble u; InputBool flag1, flag2; AlgebraicDouble x1x2; Model tw1, tw2; // engine Model gear; Model isa; TrimRoutine HorizontalFight; TrimRoutine OnGround, General; ConstantDouble c1, c2; ConstantInt : ci1; public: AircraftModel() { } public: virtual void DifferentialEquations() { x1.Prime(2.0*x2); x2.Prime(x1x2); } virtual void AlgebraicEquations() { x1x2 = x1 * x2 + x1.Prime(); } public: // Required for ExecModule string getModuleDescription() { return "Aircraft Model"; } long getExecRate() { return 33L;//ms (30hz) } long run(long ms) { return 0L; } bool initialise(long time_ms) { // called by the Exec (in sequence) when initialisation is required. } }; class SimLoad { public: // exec modules to load class Model *aircraft_model; class Model *engine_model; class Model *aerodynamics_model; class GPSSimulator *gps; class FeaturesDataProvider *runways; class ArincDB *arincDB; class ExecSystem *execSystem; SimLoad() { engine_model = new EngineModel(); aerodynamics_model = new AeroDynamicsModel(); aircraft_model = new AircraftModel(); arincDB = new ArincDB(); gps = new GPSSimulator(); // ensure that the simulated systems are loaded in the correct // sequence. Notice that the exec system provides two schedulers which // we select manually to allow for threading. Each thread within the exec is // synchronised at the start of each frame (iteration) however within each frame // each thread is free running so care needs to be taken when scheduling dependant // modules across different threads. execSystem.scheduler.addModule(engine_model); execSystem.scheduler.addModule(aerodynamics_model); execSystem.scheduler.addModule(aircraft_model); execSystem.scheduler1.addModule(gps); runways = new ArincRunwayProvider(arincDB); execSystem.start(); // } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload