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; } }
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); }
static void state_StateChanged(IState newState) { state.StateChanged -= state_StateChanged; state = newState; state.StateChanged += state_StateChanged; state.Start(); }
/// <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; }
/// <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; }
/// <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; }
public NewsCrawlerState(MachineContext context, IState prev) : base(context) { this.prev = prev; this._timer = new Util.StaticTimer(TimeSpan.FromMinutes(3)); InitRssFeed(); }
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; }
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(); }
public void Set(AudioClip changeClip, float fadeTime, IState<PlayState> nextState) { this.audio.SwapSource(); this.audio.main.clip = changeClip; this.fadeTime = fadeTime; this.nextState = nextState; }
/// <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); }
public Water() { solidWater = new SolidWater(this); liquidWater = new LiquidWater(this); gasWater = new GasWater(this); state = liquidWater; }
public void StepHandler(IState state) { //IEnumerable<AbstractStep> availableSteps = state.GetAvailableSteps(); //BuildGraph(availableSteps); AbstractStep optimalStep = MakeDecision(state); _Game.DoStep(optimalStep, _PlayerType); }
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); }
public override void Explore(IState state, string description) { _state = ((IQuantumState)state); this.Text = description; Start(); }
public Android() { charging = new ChargingState(this); usb = new USBMountingState(this); adb = new AdbState(this); mobileState = charging; }
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; }
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(); }
public NieuwsBericht() { ConceptState = new States.ConceptState(this); InReviewState = new States.InReviewState(this); PublishedState = new States.PublishState(this); ArchivedState = new States.ArchivedState(this); }
public EnemyRanged(Vector2 pos) : base(pos) { nBuild.PolyColor = Color.Orange; this.initialSides = this.health; state = SetState(this.health); }
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; }
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); }
public RedState(IState state) : base(state) { Interest = decimal.Zero; LowerLimit = -100m; UpperLimit = decimal.Zero; }
/// <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; }
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); }
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); }
public void RegisterState(string name, IState state) { if (!m_States.ContainsKey(name)) { m_States[name] = state; } }
public MockController1(IUipNavigator navigator, IState state) { Assert.IsNotNull(navigator); Assert.IsNotNull(state); Navigator = navigator; State = state; }
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)); } }