Example #1
0
 public Diode(Joint j1, Joint j2, Wire w)
 {
     Joints[0] = j1;
     Joints[1] = j2;
     W = w;
     w.Direction = Wire.WireDirection.J1ToJ2;
     constructor();
 }
Example #2
0
        public override void PostLoad()
        {
            base.PostLoad();

            Joints[0] = (Joint)Components.ComponentsManager.GetComponent(j0);
            Joints[1] = (Joint)Components.ComponentsManager.GetComponent(j1);
            if (w != Int32.MinValue)
            {
                W = (Wire)Components.ComponentsManager.GetComponent(w);
            }

            for (int i = 0; i < Joints.Length; i++)
            {
                try
                {
                    Joints[i].ContainingComponents.Add(this);
                }
                catch { }
            }
        }
Example #3
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                    case Rotation.cw0:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw90:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs90cw[i * 2], JointLocs90cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw180:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs180cw[i * 2], JointLocs180cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw270:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs270cw[i * 2], JointLocs270cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    default:
                        break;
                }

                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }

            Joints[1].Graphics.Visible = false;
            Joints[1].CanBeGround = false;
            Joints[1].CanProvidePower = true;
            Joints[1].IsProvidingPower = true;
            Joints[1].SendingVoltage = 5;

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].Initialize();
            }

            W = new Wire(Joints[0], Joints[1]);
            W.AddComponentToManager();
            W.Graphics.Visible = false;
            W.IsRemovable = false;
            W.Initialize();
        }
Example #4
0
        public void SetIsolated(Wire from, Joint j)
        {
            if (j.IsUpdated || j.ConnectedWires.Count > 2) return;
            j.IsUpdated = true;

            for (int i = 0; i < j.ConnectedWires.Count; i++)
            {
                if (j.ConnectedWires[i] != from && !j.ConnectedWires[i].IsUpdated && !j.ConnectedWires[i].IsIsolated)
                {
                    j.ConnectedWires[i].IsUpdated = true;
                    j.ConnectedWires[i].IsIsolated = true;
                    if (j.ConnectedWires[i].J1 == j)
                        SetIsolated(j.ConnectedWires[i], j.ConnectedWires[i].J2);
                    else
                        SetIsolated(j.ConnectedWires[i], j.ConnectedWires[i].J1);
                }
            }
        }
Example #5
0
        public override void PostLoad()
        {
            base.PostLoad();

            Joints[0] = (Joint)Components.ComponentsManager.GetComponent(j0);
            Joints[1] = (Joint)Components.ComponentsManager.GetComponent(j1);
            W = (Wire)Components.ComponentsManager.GetComponent(w);
            W.IsRemovable = IsRemovable;

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].ContainingComponents.Add(this);
            }
        }
Example #6
0
        public override void PostLoad()
        {
            base.PostLoad();

            Joints[0] = (Joint)Components.ComponentsManager.GetComponent(j0);
            Joints[1] = (Joint)Components.ComponentsManager.GetComponent(j1);
            W = (Wire)Components.ComponentsManager.GetComponent(w);
            Resistance = res;
            if (com != -1)
            {
                connectedComponent = ComponentsManager.GetComponent(com);
                connector = ComponentsManager.GetComponent(con) as RotatableConnector;
            }

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].ContainingComponents.Add(this);
            }
        }
Example #7
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                    case Rotation.cw0:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw90:
                        break;
                    case Rotation.cw180:
                        break;
                    case Rotation.cw270:
                        break;
                    default:
                        break;
                }
                Joints[i].CanRemove = false;

                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }

            for (int i = 4; i < Joints.Length; i++)
            {
                Joints[i].CanBeGround = true;
                Joints[i].CanProvidePower = true;
                Joints[i].IsGround = true;
                Joints[i].Graphics.Visible = false;
            }

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].Initialize();
            }

            for (int i = 0; i < Wires.Length; i++)
            {
                Wires[i] = new Wire(Joints[i], Joints[i + 4]);
                Wires[i].Resistance = 400;
                Wires[i].AddComponentToManager();
                Wires[i].Graphics.Visible = false;
                Wires[i].IsRemovable = false;
                Wires[i].Initialize();
            }

            UpdateIO();
        }
Example #8
0
        public override void PostLoad()
        {
            base.PostLoad();

            Joints[0] = (Joint)Components.ComponentsManager.GetComponent(j0);
            Joints[1] = (Joint)Components.ComponentsManager.GetComponent(j1);
            Joints[2] = (Joint)Components.ComponentsManager.GetComponent(j2);
            Joints[3] = (Joint)Components.ComponentsManager.GetComponent(j3);
            Joints[4] = (Joint)Components.ComponentsManager.GetComponent(j4);
            Joints[5] = (Joint)Components.ComponentsManager.GetComponent(j5);
            W1 = (Wire)Components.ComponentsManager.GetComponent(w1);
            W2 = (Wire)Components.ComponentsManager.GetComponent(w2);
            W3 = (Wire)Components.ComponentsManager.GetComponent(w3);

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].ContainingComponents.Add(this);
            }
        }
Example #9
0
        private void HasGroundProviderAtBranch(Wire from, Joint j, ref bool ground, ref bool provider)
        {
            if (ground && provider) return;
            if (j.IsUpdated) return;

            ground |= j.IsGround;
            provider |= j.IsProvidingPower;
            j.IsUpdated = true;

            for (int i = 0; i < j.ConnectedWires.Count; i++)
            {
                if (j.ConnectedWires[i] != from && !j.ConnectedWires[i].IsUpdated && !j.ConnectedWires[i].IsIsolated)
                {
                    j.ConnectedWires[i].IsUpdated = true;
                    if (j.ConnectedWires[i].J1 == j)
                    {
                        if (j.ConnectedWires[i].IsConnected)
                            HasGroundProviderAtBranch(j.ConnectedWires[i], j.ConnectedWires[i].J2, ref ground, ref provider);
                    }
                    else
                        if (j.ConnectedWires[i].IsConnected)
                            HasGroundProviderAtBranch(j.ConnectedWires[i], j.ConnectedWires[i].J1, ref ground, ref provider);
                }
            }
        }
Example #10
0
        private void GetBranchInfoForCurrent(Wire from, Joint j, ref double Resistance, ref Joint end, Wire start = null)
        {
            if (j.ConnectedWires.Count > 2 || from == start)
            {
                end = j;
                return;
            }
            if (start == null)
                start = from;

            for (int i = 0; i < j.ConnectedWires.Count; i++)
            {
                if (j.ConnectedWires[i] != from)
                {
                    Resistance += j.ConnectedWires[i].Resistance;
                    if (j.ConnectedWires[i].J2 != j)
                        GetBranchInfoForCurrent(j.ConnectedWires[i], j.ConnectedWires[i].J2, ref Resistance, ref end, start);
                    if (j.ConnectedWires[i].J1 != j)
                        GetBranchInfoForCurrent(j.ConnectedWires[i], j.ConnectedWires[i].J1, ref Resistance, ref end, start);
                }
            }

            if (end == null)
                end = j;
        }
Example #11
0
 void CircuitPart_onWireSendingCurrentChanged(Wire w, double v_new, double v_old)
 {
     J[0, w.localIndSelf] = v_new;
     if (v_old == 0 && v_new != 0)
         wireSendingVoltageCount++;
     if (v_old != 0 && v_new == 0)
         wireSendingVoltageCount--;
     Recalculate = true;
 }
Example #12
0
        void CircuitPart_onWireResistanceChanged(Wire w, double v_new, double v_old)
        {
            lock (Y)
            {
                if (v_new == 0)
                {
                    Y[w.localIndSelf, w.localIndSelf] = ZERO_RESISTANCE;
                }
                else
                {
                    Y[w.localIndSelf, w.localIndSelf] = 1 / v_new;
                }

                Recalculate = true;
            }
        }
Example #13
0
        void CircuitPart_onWireIsConnectedChanged(Wire w, bool v_new, bool v_old)
        {
            if (v_new)
                SetAWire(w.localIndSelf, w.localJointInd1, w.localJointInd2, 1, -1);
            else
                SetAWire(w.localIndSelf, w.localJointInd1, w.localJointInd2, 0, 0);

            onAChanged();
            Recalculate = true;
        }
Example #14
0
 void CircuitPart_onWireDirectionChanged(Wire w, Wire.WireDirection v_old, Wire.WireDirection v_new)
 {
     Recalculate = true;
 }
Example #15
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                case Rotation.cw0:
                    Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                    break;

                case Rotation.cw90:
                    Joints[i] = Joint.GetJoint(new Vector2(JointLocs90cw[i * 2], JointLocs90cw[i * 2 + 1]) + Graphics.Position);
                    break;

                case Rotation.cw180:
                    break;

                case Rotation.cw270:
                    break;

                default:
                    break;
                }
                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }

            Joints[6].Graphics.Visible = false;
            Joints[7].Graphics.Visible = false;

            Joints[6].CanBeGround = true;
            Joints[7].CanBeGround = true;
            Joints[6].IsGround    = true;
            Joints[7].IsGround    = true;

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].Initialize();
            }

            Wires[0] = new Wire(Joints[0], Joints[2]);
            Wires[0].AddComponentToManager();
            Wires[1] = new Wire(Joints[1], Joints[3]);
            Wires[1].AddComponentToManager();
            Wires[2] = new Wire(Joints[0], Joints[3]);
            Wires[2].AddComponentToManager();
            Wires[3] = new Wire(Joints[1], Joints[2]);
            Wires[3].AddComponentToManager();
            Wires[4] = new Wire(Joints[4], Joints[6]);
            Wires[4].AddComponentToManager();
            Wires[5] = new Wire(Joints[5], Joints[7]);
            Wires[5].AddComponentToManager();

            Wires[2].IsConnected = false;
            Wires[3].IsConnected = false;

            for (int i = 0; i < Wires.Length; i++)
            {
                Wires[i].Resistance       = 10;
                Wires[i].Graphics.Visible = false;
                Wires[i].IsRemovable      = false;
                Wires[i].Initialize();
            }

            Wires[4].Resistance = 400;
            Wires[5].Resistance = 400;
        }
Example #16
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                    case Rotation.cw0:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw90:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs90cw[i * 2], JointLocs90cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw180:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs180cw[i * 2], JointLocs180cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw270:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs270cw[i * 2], JointLocs270cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    default:
                        break;
                }
                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }
            Joints[3].Graphics.Visible = false;
            Joints[3].CanBeGround = true;
            Joints[3].IsGround = true;
            Joints[3].CanProvidePower = false;
            Joints[3].IsProvidingPower = false;

            Joints[4].Graphics.Visible = false;
            Joints[4].CanProvidePower = true;
            Joints[4].IsProvidingPower = true;
            Joints[4].CanBeGround = false;
            Joints[4].IsGround = false;

            Joints[5].Graphics.Visible = false;
            Joints[5].CanBeGround = true;
            Joints[5].IsGround = true;
            Joints[5].CanProvidePower = false;
            Joints[5].IsProvidingPower = false;

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].Initialize();
            }

            W1 = new Wire(Joints[0], Joints[3]);
            W1.Direction = Wire.WireDirection.J1ToJ2;
            W1.Resistance = 300;
            W1.AddComponentToManager();
            W1.Graphics.Visible = false;
            W1.Initialize();

            W2 = new Wire(Joints[1], Joints[5]);
            W2.Direction = Wire.WireDirection.J1ToJ2;
            W2.Resistance = 300;
            W2.AddComponentToManager();
            W2.Graphics.Visible = false;
            W2.Initialize();

            W3 = new Wire(Joints[4], Joints[2]);
            //W3.Direction = Wire.WireDirection.J1ToJ2;
            W3.Resistance = 5;
            W3.AddComponentToManager();
            W3.Graphics.Visible = false;
            W3.Initialize();
        }
Example #17
0
        private void HasWireVoltageSourceAtBranch(Wire w, Joint from, ref bool has)
        {
            if (w.IsUpdated) return;

            has |= w.CanSendVoltageOrCurrent;
            if (has) return;

            w.IsUpdated = true;

            if (from != w.J1)
                for (int i = 0; i < w.J1.ConnectedWires.Count; i++)
                    HasWireVoltageSourceAtBranch(w.J1.ConnectedWires[i], w.J1, ref has);
            if (from != w.J2)
                for (int i = 0; i < w.J2.ConnectedWires.Count; i++)
                    HasWireVoltageSourceAtBranch(w.J2.ConnectedWires[i], w.J2, ref has);
        }
Example #18
0
        private void SetBranchCurrent(Wire from, Joint j, double current, Wire start = null)
        {
            if (j.ConnectedWires.Count > 2 || from == start)
                return;
            if (start == null)
                start = from;

            for (int i = 0; i < j.ConnectedWires.Count; i++)
            {
                if (j.ConnectedWires[i] != from)
                {
                    j.ConnectedWires[i].SetCurrent(current);
                    j.ConnectedWires[i].IsUpdated = true;
                    if (j.ConnectedWires[i].J2 != j)
                        SetBranchCurrent(j.ConnectedWires[i], j.ConnectedWires[i].J2, current, start);
                    if (j.ConnectedWires[i].J1 != j)
                        SetBranchCurrent(j.ConnectedWires[i], j.ConnectedWires[i].J1, current, start);
                }
            }
        }
Example #19
0
        private void SetPartCurrent(Wire w)
        {
            double res = w.Resistance;
            Joint j1 = null, j2 = null;

            if (w.IsIsolated)
            {
                w.IsUpdated = true;
                w.SetCurrent(0);
                return;
            }

            GetBranchInfoForCurrent(w, w.J1, ref res, ref j1);
            GetBranchInfoForCurrent(w, w.J2, ref res, ref j2);

            if (j1 == j2)
            {
                w.IsUpdated = true;
                w.SetCurrent(0);
                return;
            }

            double cur = Math.Abs(j1.Voltage - j2.Voltage) / res;
            w.IsUpdated = true;
            w.SetCurrent(cur);
            SetBranchCurrent(w, w.J1, cur);
            SetBranchCurrent(w, w.J2, cur);
        }
Example #20
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                case Rotation.cw0:
                    Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                    break;

                case Rotation.cw90:
                    Joints[i] = Joint.GetJoint(new Vector2(JointLocs90cw[i * 2], JointLocs90cw[i * 2 + 1]) + Graphics.Position);
                    break;

                case Rotation.cw180:
                    Joints[i] = Joint.GetJoint(new Vector2(JointLocs180cw[i * 2], JointLocs180cw[i * 2 + 1]) + Graphics.Position);
                    break;

                case Rotation.cw270:
                    Joints[i] = Joint.GetJoint(new Vector2(JointLocs270cw[i * 2], JointLocs270cw[i * 2 + 1]) + Graphics.Position);
                    break;

                default:
                    break;
                }
                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }
            Joints[3].Graphics.Visible = false;
            Joints[3].CanBeGround      = true;
            Joints[3].IsGround         = true;
            Joints[3].CanProvidePower  = false;
            Joints[3].IsProvidingPower = false;

            Joints[4].Graphics.Visible = false;
            Joints[4].CanProvidePower  = true;
            Joints[4].IsProvidingPower = true;
            Joints[4].CanBeGround      = false;
            Joints[4].IsGround         = false;

            Joints[5].Graphics.Visible = false;
            Joints[5].CanProvidePower  = false;
            Joints[5].IsProvidingPower = false;
            Joints[5].CanBeGround      = true;
            Joints[5].IsGround         = true;

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].Initialize();
            }

            W1            = new Wire(Joints[0], Joints[3]);
            W1.Direction  = Wire.WireDirection.J1ToJ2;
            W1.Resistance = 300;
            W1.AddComponentToManager();
            W1.Graphics.Visible = false;
            W1.Initialize();

            W2            = new Wire(Joints[1], Joints[5]);
            W2.Direction  = Wire.WireDirection.J1ToJ2;
            W2.Resistance = 300;
            W2.AddComponentToManager();
            W2.Graphics.Visible = false;
            W2.Initialize();

            W3 = new Wire(Joints[4], Joints[2]);
            //W3.Direction = Wire.WireDirection.J1ToJ2;
            W3.Resistance = 5;
            W3.AddComponentToManager();
            W3.Graphics.Visible = false;
            W3.Initialize();
        }
Example #21
0
 public override void InitAddChildComponents()
 {
     for (int i = 0; i < Joints.Length; i++)
     {
         Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
         Joints[i].Initialize();
         Joints[i].CanRemove = false;
         Joints[i].ContainingComponents.Add(this);
     }
     W = new Wire(Joints[0], Joints[1]);
     W.Direction = Wire.WireDirection.J1ToJ2;
     W.Resistance = 1;
     W.AddComponentToManager();
     W.Graphics.Visible = false;
     W.Initialize();
 }
Example #22
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                    case Rotation.cw0:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw90:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs90cw[i * 2], JointLocs90cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw180:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs180cw[i * 2], JointLocs180cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw270:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs270cw[i * 2], JointLocs270cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    default:
                        break;
                }
                Joints[i].Initialize();
                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }

            W = new Wire(Joints[0], Joints[1]);
            W.Resistance = 250;
            W.Direction = Wire.WireDirection.J1ToJ2;
            W.AddComponentToManager();
            W.Graphics.Visible = false;
            W.Initialize();
        }
Example #23
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                    case Rotation.cw0:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw90:
                        break;
                    case Rotation.cw180:
                        break;
                    case Rotation.cw270:
                        break;
                    default:
                        break;
                }
                Joints[i].CanRemove = false;

                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }

            for (int i = 4; i < Joints.Length; i++)
            {
                Joints[i].CanProvidePower = true;
                Joints[i].CanBeGround = true;
                Joints[i].IsGround = true;
                Joints[i].Graphics.Visible = false;
            }

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].Initialize();
            }

            for (int i = 0; i < Wires.Length; i++)
            {
                Wires[i] = new Wire(Joints[i], Joints[i + 4]);
                Wires[i].Resistance = 400;
                Wires[i].AddComponentToManager();
                Wires[i].Graphics.Visible = false;
                Wires[i].IsRemovable = false;
                Wires[i].Initialize();
            }

            for (int i = 0; i < lasers.Length; i++)
            {
                lasers[i] = new MovementDetectorLaser();
                lasers[i].Graphics.Position = Graphics.Center;
                lasers[i].type = (MovementDetectorLaser.Direction)i;
                //lasers[i].AddComponentToManager();
                //lasers[i].Initialize();
            }

            GlobalEvents.onComponentPlacedByPlayer += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentPlacedByPlayer);
            GlobalEvents.onComponentRemoved += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentRemovedByPlayer);
            GlobalEvents.onComponentMoved += new GlobalEvents.ComponentEventHandler(GlobalEvents_onComponentMoved);
        }
Example #24
0
        public override void InitAddChildComponents()
        {
            for (int i = 0; i < Joints.Length; i++)
            {
                switch (rotation)
                {
                    case Rotation.cw0:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs0cw[i * 2], JointLocs0cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw90:
                        Joints[i] = Joint.GetJoint(new Vector2(JointLocs90cw[i * 2], JointLocs90cw[i * 2 + 1]) + Graphics.Position);
                        break;
                    case Rotation.cw180:
                        break;
                    case Rotation.cw270:
                        break;
                    default:
                        break;
                }
                Joints[i].CanRemove = false;
                Joints[i].ContainingComponents.Add(this);
            }

            Joints[6].Graphics.Visible = false;
            Joints[7].Graphics.Visible = false;

            Joints[6].CanBeGround = true;
            Joints[7].CanBeGround = true;
            Joints[6].IsGround = true;
            Joints[7].IsGround = true;

            for (int i = 0; i < Joints.Length; i++)
            {
                Joints[i].Initialize();
            }

            Wires[0] = new Wire(Joints[0], Joints[2]);
            Wires[0].AddComponentToManager();
            Wires[1] = new Wire(Joints[1], Joints[3]);
            Wires[1].AddComponentToManager();
            Wires[2] = new Wire(Joints[0], Joints[3]);
            Wires[2].AddComponentToManager();
            Wires[3] = new Wire(Joints[1], Joints[2]);
            Wires[3].AddComponentToManager();
            Wires[4] = new Wire(Joints[4], Joints[6]);
            Wires[4].AddComponentToManager();
            Wires[5] = new Wire(Joints[5], Joints[7]);
            Wires[5].AddComponentToManager();

            Wires[2].IsConnected = false;
            Wires[3].IsConnected = false;

            for (int i = 0; i < Wires.Length; i++)
            {
                Wires[i].Resistance = 10;
                Wires[i].Graphics.Visible = false;
                Wires[i].IsRemovable = false;
                Wires[i].Initialize();
            }

            Wires[4].Resistance = 400;
            Wires[5].Resistance = 400;
        }
Example #25
0
 public double GetBranchResistance(Wire w)
 {
     double r = 0;
     Joint j = null;
     GetBranchInfoForCurrent(w, w.J1, ref r, ref j);
     j = null;
     GetBranchInfoForCurrent(w, w.J2, ref r, ref j);
     r += w.Resistance;
     return r;
 }