private void UpdateCurrentStroke()
        {
            if (piston.angle_of_current_stroke >= 180)
            {
                //Either now in intake or power stroke

                if (current_stroke == StrokeCycle.Intake)
                {
                    current_stroke = StrokeCycle.Compression;
                }
                else if (current_stroke == StrokeCycle.Compression)
                {
                    current_stroke = StrokeCycle.Combustion;
                }
                else if (current_stroke == StrokeCycle.Combustion)
                {
                    current_stroke = StrokeCycle.Exhaust;
                }
                else if (current_stroke == StrokeCycle.Exhaust)
                {
                    current_stroke = StrokeCycle.Intake;
                }

                piston.angle_of_current_stroke -= 180.0;
            }
        }
 public Cylinder(EngineSpecs es, Crankshaft crankshaft, double initial_crank_angle, StrokeCycle initial_stroke)
 {
     this.es             = es;
     piston              = new Piston(es, crankshaft, initial_crank_angle);
     bore                = es.bore;
     stroke              = es.stroke;
     this.current_stroke = initial_stroke;
 }
Exemple #3
0
        public Engine(EngineSpecs es)
        {
            this.es = es;

            cylinders = new Cylinder[es.num_of_cylinders];

            crankshaft = new Crankshaft(this, es);

            num_of_cylinders = es.num_of_cylinders;
            efficiency       = es.efficiency;

            for (int i = 0; i < es.num_of_cylinders; i++)
            {
                double      initial_piston_angle = 0;
                StrokeCycle initial_stroke       = StrokeCycle.Intake;


                switch (i)
                {
                case 0:
                {
                    initial_piston_angle = 0;
                    initial_stroke       = StrokeCycle.Intake;
                    break;
                }

                case 1:
                {
                    initial_piston_angle = 180;
                    initial_stroke       = StrokeCycle.Compression;
                    break;
                }

                case 2:
                {
                    initial_piston_angle = 180;
                    initial_stroke       = StrokeCycle.Exhaust;
                    break;
                }

                case 3:
                {
                    initial_piston_angle = 0;
                    initial_stroke       = StrokeCycle.Combustion;
                    break;
                }
                }

                cylinders[i] = new Cylinder(es, crankshaft, initial_piston_angle, initial_stroke);
            }
        }