コード例 #1
1
ファイル: StateChangeProcess.cs プロジェクト: atonse/Hangfire
        public bool ChangeState(StateContext context, IState toState, string oldStateName)
        {
            try
            {
                var filterInfo = GetFilters(context.Job);

                var electStateContext = new ElectStateContext(context, toState, oldStateName);
                var electedState = ElectState(electStateContext, filterInfo.ElectStateFilters);

                var applyStateContext = new ApplyStateContext(context, electedState, oldStateName);
                ApplyState(applyStateContext, filterInfo.ApplyStateFilters);

                // State transition was succeeded.
                return true;
            }
            catch (Exception ex)
            {
                var failedState = new FailedState(ex)
                {
                    Reason = "An exception occurred during the transition of job's state"
                };

                var applyStateContext = new ApplyStateContext(context, failedState, oldStateName);

                // We should not use any state changed filters, because
                // some of the could cause an exception.
                ApplyState(applyStateContext, Enumerable.Empty<IApplyStateFilter>());

                // State transition was failed due to exception.
                return false;
            }
        }
コード例 #2
0
ファイル: Dcpu.cs プロジェクト: mmcgill/dcpu_sharp
 public static Op FetchNextInstruction(IState state, ref ushort pc, ref ushort sp)
 {
     var firstWord = state.Get(pc++);
     return 0 == (firstWord & 0xF) ?
         (Op)DecodeNonBasic(state, firstWord, ref pc, ref sp) :
         (Op)DecodeBasic(state, firstWord, ref pc, ref sp);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: WadeTsai/NetduinoDemo
 static void state_StateChanged(IState newState)
 {
     state.StateChanged -= state_StateChanged;
     state = newState;
     state.StateChanged += state_StateChanged;
     state.Start();
 }
コード例 #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tacticalBlockage"></param>
 /// <param name="currentState"></param>
 public EncounteredBlockageState(ITacticalBlockage tacticalBlockage, IState planningState, BlockageRecoveryDEFCON defcon, SAUDILevel saudi)
 {
     this.TacticalBlockage = tacticalBlockage;
     this.PlanningState = planningState;
     this.Saudi = saudi;
     this.Defcon = defcon;
 }
コード例 #5
0
 /// <summary>
 /// Creates a json writer that writes to the <paramref name="writer"/> and uses
 /// the InvariantCulture for any formatting.
 /// </summary>
 /// <param name="writer">the text writer that will be written to</param>
 /// <param name="indent">setting that specifies whether to indent</param>
 /// <param name="culture">The culture to use for formatting</param>
 public JsonWriter(TextWriter writer, bool indent, CultureInfo culture)
 {
     this._writer = writer;
     _currentState = new InitialState(this);
     if (!indent)
         indentSize = 0;
 }
コード例 #6
0
 /// <summary>
 /// Constructs a <b>StateInfo</b> with the given configuration settings 
 /// and states collection.
 /// </summary>
 /// <param name="configSettings">The configuration settings.</param>
 /// <param name="states">The collection of states.</param>
 public StateInfo(
     Hashtable configSettings,
     IState[] states)
 {
     this.configSettings = configSettings;
     this.States = states;
 }
コード例 #7
0
ファイル: NewsCrawlerState.cs プロジェクト: bajdcc/NewsApp
 public NewsCrawlerState(MachineContext context, IState prev)
     : base(context)
 {
     this.prev = prev;
     this._timer = new Util.StaticTimer(TimeSpan.FromMinutes(3));
     InitRssFeed();
 }
コード例 #8
0
 internal OperationFailedException(IReadOnlyList<IState> operationStates, IReadOnlyList<IState> successStates, IState actualState)
     : base($"Operation failed. Expected a transition from one of [{String.Join(", ", operationStates)}] to one of [{String.Join(", ", successStates)}], but actually reached {actualState}")
 {
     this.OperationStates = operationStates;
     this.SuccessStates = successStates;
     this.ActualState = actualState;
 }
コード例 #9
0
    private void Awake()
    {
        receiver = GetComponent<ControllerWheels>();
        sphereCollider = this.GetComponent<SphereCollider>();
        //Debug.LogWarning("HARDCODED");
        sphereCollider.isTrigger = true;
        sphereCollider.radius = 20f;

        receiverColliders = GetComponents<Collider>().ToList();
        receiverColliders = GetComponentsInChildren<Collider>().ToList();
        receiverColliders.ForEach(hC => Physics.IgnoreCollision(sphereCollider, hC));

        m_hRigidbody = this.GetComponent<Rigidbody>();

        //FSM
        idle = new StateIdle(this);
        patrol = new StatePatrol(this);
        onAir = new StateOnAir(this);
        wait = new StateWait(this);

        patrol.Idle = idle;
        patrol.OnAir = onAir;
        onAir.Wait = wait;
        wait.Patrol = patrol;

        currentState = idle;
        currentState.OnStateEnter();
    }
コード例 #10
0
ファイル: CrossFade.cs プロジェクト: K-Yoshiki/menko
		public void Set(AudioClip changeClip, float fadeTime, IState<PlayState> nextState)
		{
			this.audio.SwapSource();
			this.audio.main.clip = changeClip;
			this.fadeTime = fadeTime;
			this.nextState = nextState;
		}
コード例 #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="lane"></param>
 public StayInLaneState(ArbiterLane lane, Probability confidence, IState previous)
 {
     this.Lane = lane;
     this.internalLaneState = new InternalState(lane.LaneId, lane.LaneId, confidence);
     this.IgnorableWaypoints = new List<IgnorableWaypoint>();
     this.CheckPreviousState(previous);
 }
コード例 #12
0
ファイル: Water.cs プロジェクト: paxan95g/lab4
 public Water()
 {
     solidWater = new SolidWater(this);
     liquidWater = new LiquidWater(this);
     gasWater = new GasWater(this);
     state = liquidWater;
 }
コード例 #13
0
 public void StepHandler(IState state)
 {
     //IEnumerable<AbstractStep> availableSteps = state.GetAvailableSteps();
     //BuildGraph(availableSteps);
     AbstractStep optimalStep = MakeDecision(state);
     _Game.DoStep(optimalStep, _PlayerType);
 }
コード例 #14
0
 public GoldState(IState state)
     : base(state)
 {
     Interest = 0.05m;
     LowerLimit = 1000m;
     UpperLimit = 10000000m;
 }
 public async Task Start(IState initialState, Session session,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     Logging.Logger.Write("Version 1.0.5 : 2016.08.02 14:18", Logging.LogLevel.Self, ConsoleColor.Yellow);
     var state = initialState;
     do
     {
         try
         {
             state = await state.Execute(session, cancellationToken);
         }
         catch (InvalidResponseException)
         {
             session.EventDispatcher.Send(new ErrorEvent
             {
                 Message = "Niantic Servers unstable, throttling API Calls."
             });
         }
         catch (OperationCanceledException)
         {
             session.EventDispatcher.Send(new ErrorEvent { Message = "Current Operation was canceled." });
             state = _initialState;
         }
         catch (Exception ex)
         {
             session.EventDispatcher.Send(new ErrorEvent { Message = ex.ToString() });
             state = _initialState;
         }
     } while (state != null);
 }
コード例 #16
0
        public override void Explore(IState state, string description)
        {
            _state = ((IQuantumState)state);
            this.Text = description;

            Start();
        }
コード例 #17
0
 public Android()
 {
     charging = new ChargingState(this);
     usb = new USBMountingState(this);
     adb = new AdbState(this);
     mobileState = charging;
 }
コード例 #18
0
ファイル: SimpleSearch.cs プロジェクト: haraldq/grappr
        public virtual bool Find(IState initialState)
        {
            if (Strategy == null) return false;

            Strategy.Add(new Node(initialState));
            while (Strategy.Count() > 0)
            {
                var n = Strategy.Remove();
                if (n.Parent != null && n.Successor != null)
                {
                    var eventArgs = new StateExpansionEventArgs(n.Parent.State, n.Successor, n.Cost, n.Depth);
                    OnSuccessorExpanded(this, eventArgs);

                    if (eventArgs.CancelExpansion)
                        return false;
                }

                if (n.State.IsTerminal)
                {
                    CreateSolution(n);
                    return true;
                }

                foreach (var node in n.Expand(_closed))
                {
                    Strategy.Add(node);
                    if (_closed != null) _closed.Add(node.State);
                }

            }

            return false;
        }
コード例 #19
0
    private void Awake()
    {
        m_hWeapon = this.GetComponent<Weapon>();
        Owner = GetComponent<Actor>();
        m_hIdle             = new StateIdle(this);
        m_hPatrol           = new StatePatrol(this);

        switch ((int)AimMode)
        {
            case 1:
                m_hPatrol.Next = new StateAimBallistic(this); 
                break;
            case 2:
                m_hPatrol.Next = new StateAimDirect(this); 
                break;
        }


        m_hPatrol.Next.Next = m_hPatrol;

        m_hCurrent          = m_hPatrol;
        m_hCurrent.OnStateEnter();

        
    }
コード例 #20
0
 public NieuwsBericht()
 {
     ConceptState = new States.ConceptState(this);
     InReviewState = new States.InReviewState(this);
     PublishedState = new States.PublishState(this);
     ArchivedState = new States.ArchivedState(this);
 }
コード例 #21
0
ファイル: EnemyRanged.cs プロジェクト: Kcanavrin/tesseract
 public EnemyRanged(Vector2 pos)
     : base(pos)
 {
     nBuild.PolyColor = Color.Orange;
     this.initialSides = this.health;
     state = SetState(this.health);
 }
コード例 #22
0
ファイル: EventTool.cs プロジェクト: Hakua/PokeSharp
		public void Enter(IFiniteStateMachine stateMachine, IState oldState) {
			this.EditorForm.editorcontrol.MouseEnter += onMouseEnter;
			this.EditorForm.editorcontrol.MouseLeave += onMouseLeave;
			this.EditorForm.editorcontrol.MouseDown += onMouseDown;
			this.EditorForm.editorcontrol.MouseUp += onMouseUp;
			this.EditorForm.editorcontrol.MouseDoubleClick += onMouseDoubleClick;
		}
コード例 #23
0
ファイル: AIHuman.cs プロジェクト: caseydedore/VIP
        void Start()
        {
            var idleState = new AIStateIdle(this, 0);
            var wanderState = new AIStateWander(this, 1);
            var combatState = new AIStateCombat(this, 2);
            var hideState = new AIStateHide(this, 3);
            var getHealthState = new AIStateGetHealth(this, 4);

            idleState.WanderID = wanderState.ID;
            idleState.CombatID = combatState.ID;
            idleState.GetHealthID = getHealthState.ID;

            idleState.TimeMax = 5f;

            wanderState.IdleID = idleState.ID;
            wanderState.CombatID = combatState.ID;
            wanderState.GetHealthID = getHealthState.ID;

            combatState.IdleID = idleState.ID;
            combatState.HideID = hideState.ID;

            hideState.IdleID = idleState.ID;

            getHealthState.IdleID = idleState.ID;

            states = new IState[]{idleState, wanderState, combatState, hideState, getHealthState};

            Begin(idleState);
        }
コード例 #24
0
 public RedState(IState state)
     : base(state)
 {
     Interest = decimal.Zero;
     LowerLimit = -100m;
     UpperLimit = decimal.Zero;
 }
コード例 #25
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tacticalBlockage"></param>
 /// <param name="currentState"></param>
 public EncounteredBlockageState(ITacticalBlockage tacticalBlockage, IState planningState)
 {
     this.TacticalBlockage = tacticalBlockage;
     this.PlanningState = planningState;
     this.Saudi = SAUDILevel.None;
     this.Defcon = BlockageRecoveryDEFCON.INITIAL;
 }
コード例 #26
0
ファイル: StateMachine.cs プロジェクト: XEngine/NecroBot
 public async Task Start(IState initialState, Session session, CancellationToken cancellationToken = default(CancellationToken))
 {
     _ctx = session;
     var state = initialState;
     do
     {
         try
         {
             state = await state.Execute(session, cancellationToken);
         }
         catch (InvalidResponseException)
         {
             session.EventDispatcher.Send(new ErrorEvent { Message = "The PokemonGo servers are having a bad time, chill." });
         }
         catch (OperationCanceledException)
         {
             session.EventDispatcher.Send(new ErrorEvent { Message = "The bot was stopped." });
             return;
         }
         catch (Exception ex)
         {
             session.EventDispatcher.Send(new ErrorEvent { Message = ex.ToString() });
             state = _initialState;
         }
     } while (state != null);
 }
コード例 #27
0
ファイル: StateMachine.cs プロジェクト: CalebD44/NecroBot
 public async Task Start(IState initialState, Session session,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     var state = initialState;
     do
     {
         try
         {
             state = await state.Execute(session, cancellationToken);
         }
         catch (InvalidResponseException)
         {
             session.EventDispatcher.Send(new ErrorEvent
             {
                 Message = "Niantic Servers unstable, throttling API Calls."
             });
         }
         catch (OperationCanceledException)
         {
             session.EventDispatcher.Send(new ErrorEvent {Message = "Current Operation was canceled."});
             state = _initialState;
         }
         catch (Exception ex)
         {
             session.EventDispatcher.Send(new ErrorEvent {Message = ex.ToString()});
             state = _initialState;
         }
     } while (state != null);
 }
コード例 #28
0
 public void RegisterState(string name, IState state)
 {
     if (!m_States.ContainsKey(name))
     {
         m_States[name] = state;
     }
 }
コード例 #29
0
        public MockController1(IUipNavigator navigator, IState state) {
            Assert.IsNotNull(navigator);
            Assert.IsNotNull(state);

            Navigator = navigator;
            State = state;
        }
コード例 #30
0
ファイル: Dcpu.cs プロジェクト: mmcgill/dcpu_sharp
 public static BasicOp DecodeBasic(IState state, ushort word, ref ushort pc, ref ushort sp)
 {
     byte opcode = (byte)(word & 0xF);
     byte a = (byte)((word >> 4) & 0x3F);
     var operandA = GetOperand(state, a, ref pc, ref sp);
     byte b = (byte)((word >> 10) & 0x3F);
     var operandB = GetOperand(state, b, ref pc, ref sp);
     switch (opcode) {
         case 0x01: return new Set(operandA, operandB);
         case 0x02: return new Add(operandA, operandB);
         case 0x03: return new Sub(operandA, operandB);
         case 0x04: return new Mul(operandA, operandB);
         case 0x05: return new Div(operandA, operandB);
         case 0x06: return new Mod(operandA, operandB);
         case 0x07: return new Shl(operandA, operandB);
         case 0x08: return new Shr(operandA, operandB);
         case 0x09: return new And(operandA, operandB);
         case 0x0a: return new Bor(operandA, operandB);
         case 0x0b: return new Xor(operandA, operandB);
         case 0x0c: return new Ife(operandA, operandB);
         case 0x0d: return new Ifn(operandA, operandB);
         case 0x0e: return new Ifg(operandA, operandB);
         case 0x0f: return new Ifb(operandA, operandB);
         default: throw new ArgumentException(string.Format("{0:X} is not a valid basic opcode", opcode));
     }
 }