Ejemplo n.º 1
0
        internal void Spin(double rpm, BWheel sender)
        {
            Rpm = rpm;

            // Spin all the driven wheels.
            foreach (BWheel dw in _attached)
            {
                // Avoid calling spin on the sender.
                // If this clause didn't exist, this method would be
                // called recursevely until the callstack overflows.
                if (object.ReferenceEquals(sender, dw))
                {
                    continue;
                }

                // Calculates the RPM of the attached wheel.
                dw.Spin(Rpm / (dw.Cogs / Convert.ToDouble(Cogs)), this);
            }

            // Spin all the coupled wheels.
            foreach (BWheel cw in _coupled)
            {
                // Avoid calling spin on the sender.
                // If this clause didn't exist, this method would be
                // called recursevely until the callstack overflows.
                if (object.ReferenceEquals(sender, cw))
                {
                    continue;
                }

                // The rpm for coupled wheels is the same
                // across all coupled wheels.
                cw.Spin(Rpm, this);
            }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
                        #if true
            var a = new BWheel(24);
            var b = new BWheel(72);
            var c = new BWheel(36);
            var d = new BWheel(108);
            var e = new BWheel(12);
            var f = new BWheel(48);
            var g = new BWheel(16);

            a.Attach(b);
            b.Couples(c);
            c.Attach(d);
            b.Attach(e);
            b.Attach(e);
            e.Attach(b);
            e.Attach(f);
            e.Attach(g);

            a.Spin(18d);

            Console.WriteLine($"Gear a RPM: {a.Rpm}");
            Console.WriteLine($"Gear b RPM: {b.Rpm}");
            Console.WriteLine($"Gear c RPM: {c.Rpm}");
            Console.WriteLine($"Gear d RPM: {d.Rpm}");
            Console.WriteLine($"Gear e RPM: {e.Rpm}");
            Console.WriteLine($"Gear f RPM: {f.Rpm}");
            Console.WriteLine($"Gear g RPM: {g.Rpm}");
                        #endif
        }
Ejemplo n.º 3
0
 internal void Coupled(BWheel w)
 {
     _coupled.Add(w);
 }
Ejemplo n.º 4
0
 internal void Driven(BWheel w)
 {
     _attached.Add(w);
 }
Ejemplo n.º 5
0
 public void Couple(BWheel w)
 {
     _coupled.Add(w);
     w.Coupled(this);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Couples a wheel.
 /// </summary>
 /// <param name="w">Another wheel.</param>
 public void Couples(BWheel w)
 {
     Couple(w);
 }
Ejemplo n.º 7
0
 public void Attach(BWheel w)
 {
     _attached.Add(w);
     w.Driven(this);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Drives another wheel.
 /// </summary>
 /// <param name="w">Another wheel.</param>
 public void Drives(BWheel w)
 {
     Attach(w);
 }