Esempio n. 1
0
 public void SetDescription(ICDescription desc)
 {
     this.Description = desc;
 }
Esempio n. 2
0
        public List <CircuitComponent> GenerateComponents()
        {
            CircuitComponent[] components = new CircuitComponent[Descriptions.Count];

            for (int i = 0; i < Descriptions.Count; i++)
            {
                ICComponentDescription iccd = Descriptions[i];
                CircuitComponent       dc   = null;
                switch (iccd.Type)
                {
                case "ANDGateLogic":
                    dc = new MinimalLogicGate(new ANDGateLogic());
                    break;

                case "NANDGateLogic":
                    dc = new MinimalLogicGate(new NANDGateLogic());
                    break;

                case "ORGateLogic":
                    dc = new MinimalLogicGate(new ORGateLogic());
                    break;

                case "NORGateLogic":
                    dc = new MinimalLogicGate(new NORGateLogic());
                    break;

                case "XORGateLogic":
                    dc = new MinimalLogicGate(new XORGateLogic());
                    break;

                case "XNORGateLogic":
                    dc = new MinimalLogicGate(new XNORGateLogic());
                    break;

                case "NOTGateLogic":
                    dc = new MinimalLogicGate(new NOTGateLogic());
                    break;

                case "Switch":
                    //CircuitSwitch cs = new CircuitSwitch(Vector2.Zero);
                    //cs.SetID(iccd.ID);
                    dc = new MinimalSwitch()
                    {
                        ID = iccd.ID
                    };
                    break;

                case "Lamp":
                    //CircuitLamp cl = new CircuitLamp(Vector2.Zero);
                    //cl.SetID(iccd.ID);
                    dc = new MinimalLamp()
                    {
                        ID = iccd.ID
                    };
                    break;

                default:
                    // It is not a built in thing - look for it in the IC files folder
                    ICDescription icd = iccd.Description;
                    dc = new DrawableIC(Vector2.Zero, icd.Name, icd, false);
                    break;
                }
                components[i] = dc;
            }

            for (int i = 0; i < Descriptions.Count; i++)
            {
                ICComponentDescription iccd = Descriptions[i];

                foreach (ICConnectionDescription connection in iccd.To)
                {
                    CircuitWire cw = new CircuitWire();

                    components[i].AddOutputWire(connection.OutIndex, cw);
                    components[connection.To].SetInputWire(connection.InIndex, cw);
                }
            }

            return(components.ToList());
        }