當前位置: 首頁>>代碼示例>>C#>>正文


C# Circuit類代碼示例

本文整理匯總了C#中Circuit的典型用法代碼示例。如果您正苦於以下問題:C# Circuit類的具體用法?C# Circuit怎麽用?C# Circuit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Circuit類屬於命名空間,在下文中一共展示了Circuit類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SimulationSchematic

        public SimulationSchematic(Circuit.Schematic Schematic)
            : base(Schematic)
        {
            InitializeComponent();

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, Delete_Executed, Delete_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, SelectAll_Executed, SelectAll_CanExecute));

            Focusable = true;
            Cursor = Cursors.Cross;

            Tool = new ProbeTool(this);

            int pad = Grid * 2;
            int align = Grid * 10;

            Circuit.Coord lb = Schematic.LowerBound;
            Circuit.Coord ub = Schematic.UpperBound;
            lb = Floor(lb - pad, align);
            ub = Ceiling(ub + pad, align);

            Width = ub.x - lb.x;
            Height = ub.y - lb.y;
            Origin = -lb;
        }
開發者ID:alexbv16,項目名稱:LiveSPICE,代碼行數:25,代碼來源:SimulationSchematic.cs

示例2: SchematicEditor

        public SchematicEditor(Circuit.Schematic Schematic)
            : base(Schematic)
        {
            InitializeComponent();

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, Save_Executed));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.SaveAs, SaveAs_Executed));

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, Delete_Executed, Delete_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, Cut_Executed, Cut_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, Copy_Executed, Copy_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, Paste_Executed, Paste_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, SelectAll_Executed, SelectAll_CanExecute));

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, Undo_Executed, Undo_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, Redo_Executed, Redo_CanExecute));

            Focusable = true;
            Cursor = Cursors.Cross;

            edits = new EditStack();

            Tool = new SelectionTool(this);

            Width = 1600;
            Height = 1600;

            Origin = SnapToGrid(new Circuit.Coord((int)Width / 2, (int)Height / 2));
        }
開發者ID:alexbv16,項目名稱:LiveSPICE,代碼行數:29,代碼來源:SchematicEditor.cs

示例3: IC

        /// <summary>
        /// Define an IC based on a circuit with identified input and output ports.
        /// Ports must be a member of the circuit.
        /// </summary>
        /// <param name="circuit"></param>
        /// <param name="inputs"></param>
        /// <param name="outputs"></param>
        /// <param name="name"></param>
        public IC(Circuit circuit, UserInput[] inputs, UserOutput[] outputs, string name)
            : base(inputs.Length, outputs.Length)
        {
            foreach (UserInput p in inputs)
                if (!circuit.Contains(p))
                    throw new ArgumentException("not all inputs part of circuit");

            // we wire up the output ports so that any internal
            // change in the circuit results in
            // passing notification up the chain
            // this is not needed for input because
            // any input change will cause compute to be called
            // automatically
            foreach (UserOutput p in outputs)
            {
                p.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(p_PropertyChanged);
                if (!circuit.Contains(p))
                    throw new ArgumentException("not all outputs part of circuit");
            }
            _inputs = inputs;
            _outputs = outputs;
            _circuit = circuit;
            _name = name;

            RunCompute();
        }
開發者ID:buptkang,項目名稱:LogicPad,代碼行數:34,代碼來源:IC.cs

示例4: execute

        public override void execute(Circuit sim)
        {
            if(!pins[1].value && lastClock) {
                bool q = pins[3].value;
                if(pins[0].value) {
                    if(pins[2].value) {
                        q = !q;
                    } else {
                        q = true;
                    }
                } else if(pins[2].value) {
                    q = false;
                }
                pins[3].value = q;
                pins[4].value = !q;
            }
            lastClock = pins[1].value;

            if(hasResetPin) {
                if(pins[5].value) {
                    pins[3].value = false;
                    pins[4].value = true;
                }
            }
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:25,代碼來源:JKFlipFlopElm.cs

示例5: TwoToOneMuxTest

        public void TwoToOneMuxTest(int int0, int int1, int int2, bool out0)
        {
            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();
            var logicIn2 = sim.Create<LogicInput>();
            var logicOut0 = sim.Create<LogicOutput>();

            var tri0 = sim.Create<TriStateBuffer>();
            var tri1 = sim.Create<TriStateBuffer>();

            var invert0 = sim.Create<Inverter>();

            sim.Connect(logicIn0.leadOut, tri0.leadIn);
            sim.Connect(logicIn1.leadOut, tri1.leadIn);

            sim.Connect(logicIn2.leadOut, tri0.leadGate);
            sim.Connect(logicIn2.leadOut, invert0.leadIn);
            sim.Connect(invert0.leadOut, tri1.leadGate);

            sim.Connect(tri0.leadOut, tri1.leadOut);

            logicIn0.setPosition(int0);
            logicIn1.setPosition(int1);
            logicIn2.setPosition(int2);

            sim.doTicks(100);

            Debug.Log(out0, tri0.getLeadVoltage(1), tri1.getLeadVoltage(1));
            Assert.AreEqual(out0, logicOut0.isHigh());
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:32,代碼來源:TriStateBufferTest.cs

示例6: InductorFrequencyTest

        public void InductorFrequencyTest(double frequency, double current)
        {
            Circuit sim = new Circuit();

            var source0 = sim.Create<Voltage>(Voltage.WaveType.AC);
            source0.frequency = frequency;
            source0.phaseShift = 90;

            var resistor0 = sim.Create<Resistor>(100);
            var induct0 = sim.Create<InductorElm>(0.4);

            sim.Connect(source0, 1, resistor0, 0);
            sim.Connect(resistor0, 1, induct0, 0);
            sim.Connect(induct0, 1, source0, 0);

            var inductScope = sim.Watch(induct0);

            double cycleTime = 1 / source0.frequency;
            double quarterCycleTime = cycleTime / 4;

            int steps = (int)(cycleTime / sim.timeStep);
            for(int x = 1; x <= steps; x++)
                sim.doTick();

            Assert.AreEqual(current, Math.Round(inductScope.Max((f) => f.current), 12));
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:26,代碼來源:ACVoltageTest.cs

示例7: NANDTest

        public void NANDTest(bool in0, bool in1, bool in2, double in3)
        {
            Circuit sim = new Circuit();

            var volt0 = sim.Create<VoltageInput>();
            var res0 = sim.Create<Resistor>(5000);
            var nmos0 = sim.Create<NMosfet>();
            var nmos1 = sim.Create<NMosfet>();
            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();
            var logicOut0 = sim.Create<LogicOutput>();
            var grnd0 = sim.Create<Ground>();

            sim.Connect(volt0.leadPos, res0.leadIn);
            sim.Connect(res0.leadOut, nmos0.leadDrain);

            sim.Connect(logicOut0.leadIn, nmos0.leadDrain);
            sim.Connect(nmos0.leadGate, logicIn0.leadOut);

            sim.Connect(nmos0.leadSrc, nmos1.leadDrain);

            sim.Connect(nmos1.leadGate, logicIn1.leadOut);
            sim.Connect(nmos1.leadSrc, grnd0.leadIn);

            if(in0) logicIn0.toggle();
            if(in1) logicIn1.toggle();

            sim.doTicks(100);

            Assert.AreEqual(in2, logicOut0.isHigh());
            Assert.AreEqual(in3, Math.Round(grnd0.getCurrent(), 3));
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:32,代碼來源:NMOSTest.cs

示例8: CapacitorCapacitanceTest

        public void CapacitorCapacitanceTest(double capacitance, double current)
        {
            Circuit sim = new Circuit();

            var source0 = sim.Create<Voltage>(Voltage.WaveType.AC);
            source0.frequency = 80;

            var resistor0 = sim.Create<Resistor>(200);
            var cap0 = sim.Create<CapacitorElm>(capacitance);

            sim.Connect(source0, 1, resistor0, 0);
            sim.Connect(resistor0, 1, cap0, 0);
            sim.Connect(cap0, 1, source0, 0);

            var capScope = sim.Watch(cap0);

            double cycleTime = 1 / source0.frequency;
            double quarterCycleTime = cycleTime / 4;

            int steps = (int)(cycleTime / sim.timeStep);
            for(int x = 1; x <= steps; x++)
                sim.doTick();

            double charge = cap0.capacitance * cap0.getVoltageDelta();

            Debug.Log(charge); // F = I x L
            Debug.Log(cap0.getCurrent(), charge / cap0.capacitance); // I = F / L
            Debug.Log(cap0.capacitance, charge / cap0.getCurrent()); // L = F / I

            Assert.AreEqual(current, Math.Round(capScope.Max((f) => f.current), 12));
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:31,代碼來源:ACVoltageTest.cs

示例9: CapacitorFrequencyTest

        public void CapacitorFrequencyTest(double frequency, double current)
        {
            Circuit sim = new Circuit();

            var source0 = sim.Create<Voltage>(Voltage.WaveType.AC);
            source0.frequency = frequency;

            var resistor0 = sim.Create<Resistor>(200);
            var cap0 = sim.Create<CapacitorElm>(3E-5);

            sim.Connect(source0, 1, resistor0, 0);
            sim.Connect(resistor0, 1, cap0, 0);
            sim.Connect(cap0, 1, source0, 0);

            var capScope = sim.Watch(cap0);

            double cycleTime = 1 / source0.frequency;
            double quarterCycleTime = cycleTime / 4;

            int steps = (int)(cycleTime / sim.timeStep);
            for(int x = 1; x <= steps; x++)
                sim.doTick();

            Assert.AreEqual(current, Math.Round(capScope.Max((f) => f.current), 12));
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:25,代碼來源:ACVoltageTest.cs

示例10: execute

 public override void execute(Circuit sim)
 {
     if(pins[0].value && !modestate) {
         modestate = true;
         data = 0;
         if(pins[2].value) data += 128;
         if(pins[3].value) data += 64;
         if(pins[4].value) data += 32;
         if(pins[5].value) data += 16;
         if(pins[6].value) data += 8;
         if(pins[7].value) data += 4;
         if(pins[8].value) data += 2;
         if(pins[9].value) data += 1;
     } else if(pins[1].value && !clockstate) {
         clockstate = true;
         if((data & 1) == 0) {
             pins[10].value = false;
         } else {
             pins[10].value = true;
         }
         data = (byte)(data >> 1);
     }
     if(!pins[0].value)
         modestate = false;
     if(!pins[1].value)
         clockstate = false;
 }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:27,代碼來源:PisoShiftElm.cs

示例11: GetCircuitStatistics

        public virtual CircuitStatistics GetCircuitStatistics(Circuit circuit)
        {
            var races = _raceRepository.GetRacesAllAtCircuit(circuit);

            var lastRace = races.OrderBy(x => x.StartDate).LastOrDefault(x => x.Entries.Count() > 0);
            var previousWinner = new DriverContract { Driver = new Driver() { AtomicName = "* None *", Name = "* None *" } };
            if (lastRace != null) {
                var previousWinningResult = lastRace.GetRaceResults().FirstOrDefault(x => x.Position == 1);
                if (previousWinningResult != null) {
                    previousWinner = previousWinningResult.Entrant;
                }
            }

            // Qualifying Record
            var record = decimal.MaxValue;
            var qualifyingRecordHolder = new DriverContract { Driver = new Driver() { AtomicName = "* None *", Name = "* None *" } };
            foreach (var race in races) {
                var polePosition = race.GetQualificationResults().Where(x => x.LapTime > 0).OrderBy(x => x.LapTime).FirstOrDefault();
                if (polePosition != null) {
                    if (polePosition.LapTime < record) {
                        record = polePosition.LapTime;
                        qualifyingRecordHolder = polePosition.Entrant;
                    }
                }
            }

            return new CircuitStatistics(circuit, previousWinner, record, qualifyingRecordHolder);
        }
開發者ID:robgray,項目名稱:f1speedguides,代碼行數:28,代碼來源:Statistician.cs

示例12: LawOfResistorsInSeriesTest

        public void LawOfResistorsInSeriesTest(int in0)
        {
            Circuit sim = new Circuit();

            var volt0 = sim.Create<DCVoltageSource>();
            var volt1 = sim.Create<DCVoltageSource>();
            var resCompare = sim.Create<Resistor>(in0 * 100);

            List<Resistor> resistors = new List<Resistor>();
            for(int i = 0; i < in0; i++)
                resistors.Add(sim.Create<Resistor>());

            sim.Connect(volt0.leadPos, resistors.First().leadIn);

            for(int i = 1; i < in0 - 1; i++)
                sim.Connect(resistors[i - 1].leadOut, resistors[i].leadIn);

            sim.Connect(volt0.leadNeg, resistors.Last().leadOut);

            sim.Connect(volt1.leadPos, resCompare.leadIn);
            sim.Connect(resCompare.leadOut, volt1.leadNeg);

            sim.doTicks(100);

            Assert.AreEqual(Math.Round(resistors.Last().getCurrent(), 12), Math.Round(resCompare.getCurrent(), 12));
        }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:26,代碼來源:ResistorTest.cs

示例13: stamp

 public override void stamp(Circuit sim)
 {
     int vn = sim.nodeCount + pins[2].voltSource;
     sim.stampNonLinear(vn);
     sim.stampNonLinear(0);
     sim.stampNonLinear(lead_node[2]);
 }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:7,代碼來源:PhaseCompElm.cs

示例14: MouseUp

 public override void MouseUp(Circuit.Coord At)
 {
     b = At;
     Target.Select();
     if (a == b)
     {
         Circuit.Node node = Simulation.NodeAt(At);
         IEnumerable<Circuit.Element> at = Target.AtPoint(a);
         IEnumerable<Circuit.Symbol> probes = ProbesOf(at);
         if (!probes.Any() && node != null)
         {
             Probe probe = Simulation.Probes.FirstOrDefault(i => i.ConnectedTo == node);
             if (probe != null)
             {
                 // There's already a probe on this node, move the probe here.
                 ((Circuit.Symbol)probe.Tag).Position = a;
             }
             else
             {
                 // Make a new probe connected to this node.
                 probe = new Probe(Colors.ArgMin(i => Simulation.Probes.Count(j => j.Color == i)));
                 Target.Schematic.Add(new Circuit.Symbol(probe) { Position = a });
             }
         }
         else
         {
             Target.Select(probes.FirstOrDefault());
         }
     }
 }
開發者ID:alexbv16,項目名稱:LiveSPICE,代碼行數:30,代碼來源:ProbeTool.cs

示例15: execute

 public override void execute(Circuit sim)
 {
     if(pins[loadPin].value && !lastLoad)
         for(int i = 0; i != bits; i++)
             pins[i + bits].value = pins[i].value;
     lastLoad = pins[loadPin].value;
 }
開發者ID:DotNetSparky,項目名稱:SharpCircuit,代碼行數:7,代碼來源:LatchElm.cs


注:本文中的Circuit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。