Exemplo n.º 1
0
 public void DefineInitialList(ComplexState state)
 {
     state.ListInitial = new List <int>()
     {
         5, 6, 9
     };
 }
Exemplo n.º 2
0
 public Complex GetVoltage(ComplexState state)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
     return(state.Solution[_posNode] - state.Solution[_negNode]);
 }
Exemplo n.º 3
0
 public Complex GetCurrent(ComplexState state)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
     return(state.Solution[_branchEq]);
 }
Exemplo n.º 4
0
        public Complex GetCurrent(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            return((state.Solution[_contPosourceNode] - state.Solution[_contNegateNode]) * _bp.Coefficient.Value);
        }
Exemplo n.º 5
0
        public Complex GetCurrent(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            return(state.Solution[_contBranch] * _bp.Coefficient.Value);
        }
Exemplo n.º 6
0
        public Complex GetCurrent(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            Complex conductance = state.Laplace * _bp.Capacitance.Value;

            return((state.Solution[_posNode] - state.Solution[_negNode]) * conductance);
        }
Exemplo n.º 7
0
        public Complex GetPower(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            var voltage = state.Solution[_posNode] - state.Solution[_negNode];

            return(voltage * Complex.Conjugate(voltage) * _temp.Conductance);
        }
Exemplo n.º 8
0
        public Complex GetPower(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            Complex v = state.Solution[_posNode] - state.Solution[_negNode];

            return(-v *Complex.Conjugate(_ac));
        }
Exemplo n.º 9
0
        public Complex GetPower(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            Complex conductance = state.Laplace * _bp.Capacitance.Value;
            Complex voltage     = state.Solution[_posNode] - state.Solution[_negNode];

            return(voltage * Complex.Conjugate(voltage * conductance));
        }
Exemplo n.º 10
0
        public Complex GetCurrent(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            Complex geq     = Capacitance * state.Laplace + _load.Conduct;
            Complex voltage = state.Solution[_posPrimeNode] - state.Solution[_negNode];

            return(voltage * geq);
        }
Exemplo n.º 11
0
        public Complex GetPower(ComplexState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            Complex v = state.Solution[_posNode] - state.Solution[_negNode];
            Complex i = (state.Solution[_contPosourceNode] - state.Solution[_contNegateNode]) * _bp.Coefficient.Value;

            return(-v *Complex.Conjugate(i));
        }
Exemplo n.º 12
0
        private static void MoveHero()
        {
            IComponent hero = null;

            while (hero is null)
            {
                hero = GetComponent();
            }

            var stayState     = new SingleState(new StayCommand());
            var runState      = new SingleState(new RunCommand());
            var jumpState     = new ComplexState(new JumpCommand(), stayState);
            var attackState   = new ComplexState(new AttackCommand(), stayState);
            var heroContext   = new Context(stayState, hero.Title);
            var stateRestorer = new Restorer(heroContext);

            Console.WriteLine("Game start!");
            do
            {
                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.UpArrow:
                    heroContext.Update(jumpState);
                    stateRestorer.BackUp();
                    break;

                case ConsoleKey.LeftArrow:
                    heroContext.Update(runState);
                    stateRestorer.BackUp();
                    break;

                case ConsoleKey.RightArrow:
                    heroContext.Update(runState);
                    stateRestorer.BackUp();
                    break;

                case ConsoleKey.DownArrow:
                    heroContext.Update(attackState);
                    stateRestorer.BackUp();
                    break;

                case ConsoleKey.Escape:
                    return;

                default:
                    stateRestorer.Undo();
                    break;
                }

                heroContext.Request();
            } while (true);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrequencyBehavior"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public FrequencyBehavior(IComponentBindingContext context)
            : base(context)
        {
            ComplexState = context.GetState <IComplexSimulationState>();

            DrainPrime  = ComplexState.GetSharedVariable(context.Nodes[0]);
            _drainNode  = ComplexState.Map[DrainPrime];
            _gateNode   = ComplexState.Map[ComplexState.GetSharedVariable(context.Nodes[1])];
            SourcePrime = ComplexState.GetSharedVariable(context.Nodes[2]);
            _sourceNode = ComplexState.Map[SourcePrime];

            if (ModelParameters.DrainResistance > 0)
            {
                DrainPrime = ComplexState.CreatePrivateVariable(Name.Combine("drain"), Units.Volt);
            }
            _drainPrimeNode = ComplexState.Map[DrainPrime];

            if (ModelParameters.SourceResistance > 0)
            {
                SourcePrime = ComplexState.CreatePrivateVariable(Name.Combine("source"), Units.Volt);
            }
            _sourcePrimeNode = ComplexState.Map[SourcePrime];

            ComplexElements = new ElementSet <Complex>(ComplexState.Solver,
                                                       new MatrixLocation(_drainNode, _drainNode),
                                                       new MatrixLocation(_gateNode, _gateNode),
                                                       new MatrixLocation(_sourceNode, _sourceNode),
                                                       new MatrixLocation(_drainPrimeNode, _drainPrimeNode),
                                                       new MatrixLocation(_sourcePrimeNode, _sourcePrimeNode),
                                                       new MatrixLocation(_drainNode, _drainPrimeNode),
                                                       new MatrixLocation(_gateNode, _drainPrimeNode),
                                                       new MatrixLocation(_gateNode, _sourcePrimeNode),
                                                       new MatrixLocation(_sourceNode, _sourcePrimeNode),
                                                       new MatrixLocation(_drainPrimeNode, _drainNode),
                                                       new MatrixLocation(_drainPrimeNode, _gateNode),
                                                       new MatrixLocation(_drainPrimeNode, _sourcePrimeNode),
                                                       new MatrixLocation(_sourcePrimeNode, _gateNode),
                                                       new MatrixLocation(_sourcePrimeNode, _sourceNode),
                                                       new MatrixLocation(_sourcePrimeNode, _drainPrimeNode));
        }
Exemplo n.º 14
0
 public IEnumerable <int> DynamicEnumerateItemResult(ComplexState state)
 {
     return(state.ListFinal);
 }
Exemplo n.º 15
0
 public IEnumerable <int> DynamicEnumerateItem(ComplexState state)
 {
     return(state.ListInitial);
 }