Exemple #1
0
 public void DoingAttack(float t, bool increaseFlow)
 {
     switch (flowState)
     {
         // inside window means its time to increase the flow
         // and go into doing attack mode
         case FlowState.inside_window:
             if (increaseFlow)
             {
                 flow_level++;
                 if (flow_level >= flow_level_count)
                     flow_level = flow_level_count - 1;
             }
             flowState = FlowState.doing_attack;
             timer = t;
             break;
         // already doing an attack, so this does nothing
         case FlowState.doing_attack:
             // too soon
             break;
         // outside window means its time to go into doing attack mode
         case FlowState.outside_window:
             flow_level = 0;
             timer = t;
             flowState = FlowState.doing_attack;
             break;
         case FlowState.offset_time:
             flow_level = 0;
             timer = t;
             flowState = FlowState.doing_attack;
             break;
     }
     //offset_time = attack.TimeAfterAttack * this.getRate() + attack.FlowStart;
     //window_time = attack.FlowDuration;
 }
Exemple #2
0
        /// <summary>
        /// Creates new type context, flow context and flow state for the routine.
        /// </summary>
        public static FlowState CreateInitialState(SourceRoutineSymbol/*!*/routine)
        {
            Contract.ThrowIfNull(routine);

            // create typeCtx
            var typeCtx = routine.TypeRefContext;

            // create FlowContext 
            var flowCtx = new FlowContext(typeCtx, routine);

            // create FlowState
            var state = new FlowState(flowCtx);

            // handle input parameters type
            var parameters = routine.Parameters.OfType<SourceParameterSymbol>().ToImmutableArray();
            foreach (var p in parameters)
            {
                state.SetVar(p.Name, p.GetResultType(typeCtx));

                if (p.Syntax.PassedByRef)
                {
                    state.SetVarRef(p.Name);
                }
            }

            // $this
            if (routine.HasThis)
            {
                InitThisVar(flowCtx, state);
            }

            //
            return state;
        }
            bool IHttp2StreamVisitor.Visit(IHttp2Stream stream)
            {
                FlowState state = _controller.GetState(stream);

                if (IsWritable(state) != state.MarkedWritability())
                {
                    NotifyWritabilityChanged(state);
                }

                return(true);
            }
Exemple #4
0
        public void Disconnect()
        {
            Send(new Packet(Packet.DataType.command, "__disconnect"));               //TODO recieve disconnect
            stream.Close();
            client.Close();
            Sending      = Reading = Connected = false;
            Disconnected = true;
            Flow         = FlowState.none;
#if DEBUG
            Console.WriteLine(DEBUG_TAG + " Disconnected from remote host");
#endif
        }
Exemple #5
0
 protected internal override void WindowSize(FlowState state, int initialWindowSize)
 {
     base.WindowSize(state, initialWindowSize);
     try
     {
         CheckStateWritability(state);
     }
     catch (Http2Exception e)
     {
         ThrowHelper.ThrowHttp2RuntimeException_CaughtUnexpectedExceptionFromWindow(e);
     }
 }
        public override FlowState Execute(ScopeRuntimeContext context)
        {
            loopContext = new ScopeRuntimeContext(context);
            FlowState state = declarationStatement?.Execute(loopContext) ?? FlowState.Nominal;

            switch (state)
            {
            case FlowState.Nominal:
                //Continue
                break;

            case FlowState.LoopContinue:
            case FlowState.LoopBreak:
            case FlowState.Return:
            default:
                throw new Exception($"Unexpected FlowState: {state}");
            }

            bool continuing = true;

            foreach (object item in containerExpression.GetAs <IEnumerable>(loopContext))
            {
                loopVariable.Set(loopContext, item);
                bodyContext = new ScopeRuntimeContext(loopContext);

                state = loopBody.Execute(bodyContext);

                switch (state)
                {
                case FlowState.Nominal:
                case FlowState.LoopContinue:
                    //Do Nothing
                    break;

                case FlowState.LoopBreak:
                    continuing = false;
                    break;

                case FlowState.Return:
                    return(state);

                default:
                    throw new Exception($"Unexpected FlowState: {state}");
                }

                if (!continuing)
                {
                    break;
                }
            }

            return(FlowState.Nominal);
        }
Exemple #7
0
 void NotifyWritabilityChanged(FlowState state)
 {
     state.MarkedWritability(!state.MarkedWritability());
     try
     {
         _listener.WritabilityChanged(state.Stream);
     }
     catch (Exception cause)
     {
         Logger.CaughtExceptionFromListenerWritabilityChanged(cause);
     }
 }
Exemple #8
0
 void CheckConnectionThenStreamWritabilityChanged(FlowState state)
 {
     // It is possible that the connection window and/or the individual stream writability could change.
     if (IsWritableConnection() != _controller._connectionState.MarkedWritability())
     {
         CheckAllWritabilityChanged();
     }
     else if (IsWritable(state) != state.MarkedWritability())
     {
         NotifyWritabilityChanged(state);
     }
 }
Exemple #9
0
        /// <summary>
        /// Initializes <c>$this</c> variable, its type and initialized state.
        /// </summary>
        private static void InitThisVar(FlowContext/*!*/ctx, FlowState/*!*/initialState)
        {
            var thisVarType = ctx.TypeRefContext.GetThisTypeMask();
            if (thisVarType.IsUninitialized)
            {
                thisVarType = TypeRefMask.AnyType;
            }

            //
            var thisIdx = ctx.GetVarIndex(VariableName.ThisVariableName);
            initialState.SetVarUsed(thisIdx);
            initialState.SetVar(thisIdx, thisVarType);
        }
Exemple #10
0
    public void Init(FlowManager _mgr)
    {
        m_mgr = _mgr;

        m_curNPC        = null;
        m_curAction     = null;
        m_curChoiceList = null;
        m_curState      = FlowState.GetNPC;

        m_choiceID = -1;

        m_nextNPC       = NPCName.Player;
        m_nextNPCAction = NPCActionName.PlayerIntro1;
    }
Exemple #11
0
        public IState AddStepState(string stepId, string updateValue)
        {
            var flowState = new FlowState
            {
                FlowStateId = stepId,
                Value       = updateValue,
                UserInChat  = _userInChatPersistance
            };

            _db.Add(flowState);
            _userStates.Add(flowState);
            _nextState = new DatabaseState(_index + 1, _userStates, _db, _userInChatPersistance);
            return(NextState); //todo: low получается, что AddStepState должен возвращать void
        }
Exemple #12
0
 void CheckStateWritability(FlowState state)
 {
     if (IsWritable(state) != state.MarkedWritability())
     {
         if (state == _controller._connectionState)
         {
             CheckAllWritabilityChanged();
         }
         else
         {
             NotifyWritabilityChanged(state);
         }
     }
 }
 public void NextFlowState()
 {
     if (flow == FlowState.AfterGame)
     {
         return;
     }
     if (flow == FlowState.PostPlayQuestionsDual)
     {
         FileDump.CloseSessionFile();
     }
     flow = (FlowState)((int)flow + 1);
     SaveFlowState();
     GameOverScreen.deathCount = 0;
 }
Exemple #14
0
 void StopMove()
 {
     rect.localPosition = new Vector3(550f, 0, 0);
     //流れた後の待機処理
     if (WaveFinish)
     {
         flowState  = FlowState.FLOWMOVING;
         WaveFinish = false;
         text.text  = "NEXT";
     }
     if (ChangeWave)
     {
         flowState = FlowState.STATEPOSITION;
         wave++;
     }
 }
    public void NextAsync(Flow nextFlow, onChangedFlow onChanged = null)
    {
        bool isFailed = false;

        isFailed = isFailed | _State != FlowState.Idle;
        isFailed = isFailed | (((int)nextFlow < 0) || ((int)nextFlow >= SceneNames.Length));
        if (isFailed)
        {
            onChanged?.Invoke(false);
            return;
        }
        _OnChangeFlowEvent = onChanged;
        _State             = FlowState.NextAsyncLoading;
        NextFlow           = nextFlow;
        StartCoroutine(loadScene());
    }
Exemple #16
0
 void FlowMoving()
 {
     //右から左へ流れる
     rect.localPosition -= new Vector3(Mathf.Abs(speed), 0, 0);
     if (rect.localPosition.x > -100 && rect.localPosition.x < 100)
     {
         speed = 5f;
     }
     else if (rect.localPosition.x < -550)
     {
         flowState = FlowState.STOPMOVE;
     }
     else
     {
         speed = 12f;
     }
 }
Exemple #17
0
        /// <summary>
        /// Verifies that the provided objects keys defined from the state are actually
        /// provided with its behavior execution and put in the keys array.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="context">The context.</param>
        /// <exception cref="Exception">The context for behavior of state '" + state.Name + "' should provide the object '" + item + "' but it's not provided.</exception>
        public static void VerifyProvidedAttributes(FlowState state, params string[] keys)
        {
            if (state.BehaviorType == null)
            {
                return;
            }

            IEnumerable <string> providedObjects = GetProvidedObjectsKeys(state.BehaviorType);

            foreach (var item in providedObjects)
            {
                if (!keys.Contains(item))
                {
                    throw new Exception("The context for behavior of state '" + state.Name + "' should provide the object '" + item + "' but it's not provided.");
                }
            }
        }
        private void PauseResumeGame(object parameter = null)
        {
            switch (flowState)
            {
            case FlowState.Running:
                timer.Stop();
                flowState = FlowState.Pause;
                Message   = Localization.GamePaused;
                break;

            case FlowState.Pause:
            default:
                timer.Start();
                flowState = FlowState.Running;
                Message   = Localization.GameResumed;
                break;
            }
        }
Exemple #19
0
    public void SetFlow(FlowState flow)
    {
        m_currentFlow = flow;
        DeactivateAll();

        switch (flow)
        {
        case FlowState.MenuScreen:
            menuScreen.SetActive(true);
            break;

        case FlowState.MainGame:
            mainGameScreen.SetActive(true);
            Spawner.Instance.SpawnYukari();
            m_paused = false;
            break;
        }
    }
    public void BackAsync(onChangedFlow onChanged = null)
    {
        bool isFailed = false;

        isFailed = isFailed | _State != FlowState.Idle;
        isFailed = isFailed | (FlowHistory.Count < 1);
        if (isFailed)
        {
            onChanged?.Invoke(false);
            return;
        }
        int index = FlowHistory.Count - 1;
        var next  = FlowHistory[index];

        _OnChangeFlowEvent = onChanged;
        _State             = FlowState.BackAsyncLoading;
        NextFlow           = next;
        StartCoroutine(loadScene());
    }
Exemple #21
0
        public FlowState GetState(string stateId, bool loadAllInfo = true)
        {
            FlowState state = repoFlowState.Query(o => o.StateId == stateId).FirstOrDefault();

            if (state == null)
            {
                throw new ArgumentNullException(string.Format("Flow state with Id {0} not defined!", stateId));
            }

            if (loadAllInfo)
            {
                state.Flow       = GetFlow(o => o.FlowId == state.FlowId, false);
                state.Operations = repoStateOp.Query(o => o.StateId == stateId).OrderBy(o => o.Operation.Code).ToArray();
                state.Incomes    = repoStateIncome.Query(o => o.StateId == stateId).OrderBy(o => o.Income.Code).ToArray();
                state.Outcomes   = repoStateOutcome.Query(o => o.StateId == stateId).OrderBy(o => o.Outcome.Code).ToArray();
            }

            return(state);
        }
        public async Task <FlowElementResult> ExecuteAsync(object args, FlowState state)
        {
            if (!IsLoggingEnabled)
            {
                return(await _element.ExecuteAsync(args, state));
            }
            try
            {
                var res = await _element.ExecuteAsync(args, state);

                _logger.Info($"ExecuteAsyncInternal result={res}, args={JsonSerializer.SerializeToString(args)}");
                return(res);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Error on ExecuteAsyncInternal with args={JsonSerializer.SerializeToString(args)}");
                throw;
            }
        }
Exemple #23
0
    protected void Start()
    {
        currentState = defaultState;

        // Start intro cinematic
        if (!debug)
        {
            cinematic.PlayIntroduction();
        }
        else
        {
            SetCurrentStateToWordSelection();
        }

        // On word selection ending, make it so that we switch to switch
        situation.OnSituationEnded         += SetCurrentStateToWordSelection;
        wordSelection.OnWordSelectionEnded += SetCurrentStateToSpeech;
        speech.OnSpeechEnded         += SetCurrentStateToOpponentSpeech;
        opponentSpeech.OnSpeechEnded += SetCurrentStateToCinematic;
    }
Exemple #24
0
 void FlowMoving()
 {
     //右から左へ流れる
     rect.localPosition -= new Vector3(Mathf.Abs(speed), 0, 0);
     //中心付近で原則
     if (rect.localPosition.x > -100 && rect.localPosition.x < 100)
     {
         speed = 5f;
     }
     //-550以降まで流れないように
     else if (rect.localPosition.x < -550)
     {
         flowState = FlowState.STOPMOVE;
     }
     //基本速度
     else
     {
         speed = 12f;
     }
 }
Exemple #25
0
        private void ExecuteFlowCommand(FlowCommand flowCommand)
        {
            switch (flowCommand)
            {
            case FlowCommand.Start:
                if (currentFlowState != FlowState.Condition || BoolStack.Summarise())
                {
                    currentFlowState = FlowState.Body;
                }
                break;

            case FlowCommand.Condition:
                currentFlowState = FlowState.Condition;
                BoolStack.Clear();
                break;

            default:
                currentFlowState = FlowState.Clear;
                break;
            }
        }
Exemple #26
0
        private void ieStateCompleted(FlowState <WebPageAction, WebPageCondition> state, ref bool isStop)
        {
            if (this.isStop)
            {
                isStop = true;
                return;
            }

            switch (state.Name)
            {
            case resultPageInstallJQueryStateName:
                this.ie.ExecuteJQuery(JQuery.Create("'li.g'"), "__jlis");

                int resultCount = this.ie.ExecuteJQuery <int> (JQuery.Create("__jlis").Length( ), "__jfSearch");

                for (int index = 0; index < resultCount; index++)
                {
                    this.ie.ExecuteJQuery(JQuery.Create("__jlis").Eq(index.ToString( )), "__jli");

                    string title = this.ie.ExecuteJQuery <string> (JQuery.Create("__jli").Find("'.r'").Text( ), "__jfSearch");
                    string url   = this.ie.ExecuteJQuery <string> (JQuery.Create("__jli").Find("'a.l'").Attr("'href'"), "__jfSearch");

                    if (!string.IsNullOrEmpty(title) && !string.IsNullOrEmpty(url) && !this.results.ContainsKey(url))
                    {
                        this.listPage.Items.Add(title + "-" + url);
                        this.results.Add(url, title);
                    }
                }

                (this.nextPageState.StartActions[0] as ExecuteJavaScriptAction).Code = string.Format("window.location = '{0}';", this.ie.ExecuteJQuery <string> (JQuery.Create("'#pnnext'").Attr("'href'"), "__jfSearch"));

                if (this.currentPageIndex++ >= this.numericPageCount.Value)
                {
                    this.stopSearch( );
                    isStop = true;
                }

                break;
            }
        }
            /// <summary>
            /// Constructs the complete flow state in the point
            /// (<paramref name="x"/>, <paramref name="y"/>) for the given set of
            /// parameters.
            /// </summary>
            /// <param name="x">x-coordinate</param>
            /// <param name="y">y-coordinate</param>
            /// <param name="kappa">Heat capacity ratio</param>
            /// <param name="pi">
            /// Pressure offset in case of a stiffened gas, cf.
            /// <see cref="MaterialProperty.StiffenedGas"/>
            /// </param>
            /// <param name="a0">
            /// The characteristic stagnation speed of sound of the flow.
            /// </param>
            /// <param name="p0">
            /// The characteristic stagnation pressure of the flow. Beware: In case
            /// of a stiffened gas, larger values are required in order to obtain a
            /// valid flow field
            /// </param>
            /// <returns>
            /// The exact solution to the Ringleb problem in
            /// (<paramref name="x"/>, <paramref name="y"/>).
            /// </returns>
            public static FlowState GetFlowState(double x, double y, double kappa, double pi, double a0, double p0)
            {
                double tau = ComputeTau(x, y, kappa);
                // Compute theta from y because using x may cause problems
                double theta = 0.5 * Math.Acos(2.0 * (y - EvaluateG(tau, kappa)) *
                                               Math.Sqrt(2.0 / (kappa - 1.0)) * tau * Math.Pow(1.0 - tau, 1.0 / (kappa - 1.0)));

                double rho0  = kappa * (p0 + pi) / a0 / a0;
                var    state = new FlowState(
                    V: Math.Sqrt(2.0 * a0 * a0 * tau / (kappa - 1.0)),
                    theta: theta,
                    tau: tau,
                    pressure: (p0 + pi) * Math.Pow(1.0 - tau, kappa / (kappa - 1.0)) - pi,
                    density: rho0 * Math.Pow(1.0 - tau, 1.0 / (kappa - 1.0)),
                    velocity_2d: a0 * Math.Sqrt(2.0 * tau / (kappa - 1.0)) *
                    new Vector(Math.Cos(theta), Math.Sin(theta)),
                    Mach: Math.Sqrt(2.0 / (kappa - 1.0) * tau / (1.0 - tau)),
                    kappa: kappa,
                    pi: pi);

                return(state);
            }
Exemple #28
0
        private void Resume(FlowState flowState)
        {
            if (flowState == null)
            {
                throw new ArgumentException("{B01A87E7-337F-491B-8E34-6B1EE352DCC7}");
            }

            this.previousDataStack       = flowState.PreviousDataStack;
            this.previousRepopulateStack = flowState.PreviousRepopulateStack;
            this.forwardRepopulateStack  = flowState.ForwardRepopulateStack;


            //get backup data for previous visible form

            ResetValuesOnBackup(this.previousDataStack.Pop());

            //set is baching up to true only if SaveState was invoked from the client.  Because the repopulate stack was increased in the SaveState method only only if SaveState was invoked from the client.
            //isNewDialogState is true when the state is saved automatically for each new dialog
            //isBackingUp = !isNewDialogState;
            this.Director.ExecuteRulesEngine();
            //isBackingUp = false;
        }
Exemple #29
0
    void FixedUpdate()
    {
        if (spiroController == null)
        {
            return;
        }

        spiroController.UpdateSpiroController();
        currentState = spiroController.GetFlowState();

        currentFlowPercentage = ((float)FlowLMin / maxFlowLMin) * 100;

        if (debug)
        {
            Debug.Log(currentState + " " + FlowLMin.ToString("f"));
        }

        if (currentState != previousState)
        {
            if (onDeviceStateChanged != null)
            {
                onDeviceStateChanged(currentState);
            }
        }

        previousState = currentState;

        //Show/Hide disconnect screen if connection state changes
        currentConnectionState = spiroController.IsConnected;
        if (currentConnectionState != lastConnectionState)
        {
            lastConnectionState = currentConnectionState;
            if (deviceType == DeviceType.AIRNEXT)
            {
                Time.timeScale = 1; //Establishing bluetooth connection to spirometer does not work when timescale is 0!
            }
        }
    }
Exemple #30
0
        /// <summary>
        /// Updates flow state of incoming edge and gets merged states of all incoming edges.
        /// </summary>
        /// <param name="edgeLabel">Incoming edge label. Can be anything identifying the edge except <c>null</c>.</param>
        /// <param name="state">Flow state of the incoming edge.</param>
        /// <returns>Merged initial block state.</returns>
        internal FlowState UpdateIncomingFlowState(object edgeLabel, FlowState state)
        {
            Debug.Assert(edgeLabel != null, $"{nameof(edgeLabel)} is null");
            Debug.Assert(state != null, $"{nameof(state)} is null");

            if (_incommingFlowStates == null)
            {
                _incommingFlowStates = new Dictionary <object, FlowState>(ReferenceEqualityComparer.Default);
            }

            // update incoming flow state
            _incommingFlowStates[edgeLabel] = state.Clone();

            // merge states
            FlowState result = null;

            foreach (var s in _incommingFlowStates)
            {
                result = (result != null) ? result.Merge(s.Value) : s.Value;
            }

            Debug.Assert(result != null, $"{nameof(result)} is null");
            return(result);
        }
		private void ieStateCompleted ( FlowState<WebPageAction, WebPageCondition> state, ref bool isStop )
		{

			if ( this.isStop )
			{
				isStop = true;
				return;
			}

			switch ( state.Name )
			{
				case resultPageInstallJQueryStateName:
					this.ie.ExecuteJQuery ( JQuery.Create ( "'li.g'" ), "__jlis" );

					int resultCount = this.ie.ExecuteJQuery<int> ( JQuery.Create ( "__jlis" ).Length ( ), "__jfSearch" );

					for ( int index = 0; index < resultCount; index++ )
					{
						this.ie.ExecuteJQuery ( JQuery.Create ( "__jlis" ).Eq ( index.ToString ( ) ), "__jli" );

						string title = this.ie.ExecuteJQuery<string> ( JQuery.Create ( "__jli" ).Find ( "'.r'" ).Text ( ), "__jfSearch" );
						string url = this.ie.ExecuteJQuery<string> ( JQuery.Create ( "__jli" ).Find ( "'a.l'" ).Attr ( "'href'" ), "__jfSearch" );

						if ( !string.IsNullOrEmpty ( title ) && !string.IsNullOrEmpty ( url ) && !this.results.ContainsKey ( url ) )
						{
							this.listPage.Items.Add ( title + "-" + url );
							this.results.Add ( url, title );
						}

					}

					(this.nextPageState.StartActions[0] as ExecuteJavaScriptAction).Code = string.Format ( "window.location = '{0}';", this.ie.ExecuteJQuery<string> ( JQuery.Create ( "'#pnnext'" ).Attr ( "'href'" ), "__jfSearch" ) );

					if ( this.currentPageIndex++ >= this.numericPageCount.Value )
					{
						this.stopSearch ( );
						isStop = true;
					}

					break;
			}

		}
Exemple #32
0
        public override void VisitCFGConditionalEdge(ConditionalEdge x)
        {
            // build state for TrueBlock and FalseBlock properly, take minimal evaluation into account
            var state = _state;

            // true branch
            _state = state.Clone();
            VisitCondition(x.Condition, ConditionBranch.ToTrue);
            TraverseToBlock(_state, x.TrueTarget);

            // false branch
            _state = state.Clone();
            VisitCondition(x.Condition, ConditionBranch.ToFalse);
            TraverseToBlock(_state, x.FalseTarget);
        }
Exemple #33
0
 public void setTimer(float t)
 {
     timer = t + window_time;
     flowState = FlowState.inside_window;
 }
Exemple #34
0
        public override void VisitCFGForeachMoveNextEdge(ForeachMoveNextEdge x)
        {
            var state = _state;
            // get type information from Enumeree to determine types value variable
            var elementType = HandleTraversableUse(x.EnumereeEdge.Enumeree);
            if (elementType.IsVoid) elementType = TypeRefMask.AnyType;

            // Body branch
            _state = state.Clone();
            // set key variable and value variable at current state

            var valueVar = x.ValueVariable;
            if (valueVar is BoundListEx)
            {
                throw new NotImplementedException();
                //VisitListEx(valueVar.List, elementType);
            }
            else
            {
                valueVar.Access = valueVar.Access.WithWrite(elementType);
                Accept(valueVar);

                //
                var keyVar = x.KeyVariable;
                if (keyVar != null)
                {
                    keyVar.Access = keyVar.Access.WithWrite(TypeRefMask.AnyType);
                    Accept(keyVar);
                }
            }
            TraverseToBlock(_state, x.BodyBlock);

            // End branch
            _state = state.Clone();
            TraverseToBlock(_state, x.NextBlock);
        }
Exemple #35
0
 public void Update(float dt)
 {
     switch (flowState)
     {
         // inside window means we decrease timer
         // if timer goes to zero and we are still
         // in the window, we lose flow, go to outside
         // window
         case FlowState.inside_window:
             timer -= dt;
             if (timer < 0.0f)
             {
                 timer = changing_attack_timer;
                 flowState = FlowState.outside_window;
             }
             break;
         // outside window means flow level 0
         case FlowState.outside_window:
             timer -= dt;
             break;
         // if doing attack wait until its time to go into window
         case FlowState.doing_attack:
             timer -= dt;
             if (timer < 0.0f)
             {
                 if (offset_time == 0.0f)
                 {
                     flowState = FlowState.inside_window;
                     timer = window_time;
                 }
                 else
                 {
                     flowState = FlowState.offset_time;
                     timer = offset_time;
                 }
             }
             break;
         case FlowState.offset_time:
             timer -= dt;
             if (timer < 0.0f)
             {
                 flowState = FlowState.inside_window;
                 timer = window_time;
             }
             break;
     }
 }
	/// <summary>
	/// Plays the animation for the new state.
	/// </summary>
	/// <param name='newState'>
	/// New state.
	/// </param>
	public virtual void PlayState(FlowState newState)
	{
		State = newState;
		Play();
	}
 private FlowState SaveFlowState(string flowId, string stateId, string taskId)
 {
     FlowState state = null;
     if (flowsCollection != null && flowStatesCollection != null && !string.IsNullOrEmpty (flowId) && !string.IsNullOrEmpty (taskId))
     {
         Flow flow = GetFlow (flowId);
         Task task = DBHelper.GetInstance ().GetTask (taskId);
         if (flow.States != null && (
             from fs in flow.States
             select fs.State).Contains (stateId))
         {
             state = GetFlowState (stateId);
             if (task != null && state.Task.Id.AsString != taskId)
             {
                 state.Task = new MongoDBRef (DBHelper.GetInstance ().TasksCollection ().Name, taskId);
                 flowStatesCollection.Save (state);
             }
         }
         else
         {
             state = new FlowState {
                 State = stateId,
                 Task = new MongoDBRef (DBHelper.GetInstance ().TasksCollection ().Name, taskId),
                 NextStates = null
             };
             flowStatesCollection.Save (state);
             if (flow.States == null) {
                 flow.States = new List<FlowState> ();
             }
             flow.States.Add (state);
             flowsCollection.Save (flow);
         }
     }
     return state;
 }
Exemple #38
0
 public void Apply(ClassifyDocumentsRequested @event)
 {
     _state = @event.State;
 }
Exemple #39
0
 protected internal override void EnqueueFrame(FlowState state, IHttp2RemoteFlowControlled frame)
 {
     base.EnqueueFrame(state, frame);
     CheckConnectionThenStreamWritabilityChanged(state);
 }
Exemple #40
0
 public void Apply(SeparateDocumentsRequested @event)
 {
     _state = @event.State;
 }
Exemple #41
0
        /// <summary>
        /// Called to initialize <see cref="VisitCFGBlock"/> call.
        /// Sets <see cref="_state"/> to known initial block state.
        /// </summary>
        protected virtual void VisitCFGBlockInit(BoundBlock/*!*/x)
        {
            Contract.ThrowIfNull(x.FlowState);   // state should be already set by previous edge
            _state = x.FlowState.Clone();        // TFlowState for the statements in the block

            this.CurrentBlock = x;
        }
Exemple #42
0
        /// <summary>
        /// Helper method that merges state with the target block and determines whether to continue by visiting the target block.
        /// </summary>
        /// <param name="state">Locals state in which we are entering the target.</param>
        /// <param name="target">Target block.</param>
        /// <remarks>Only for traversing into blocks within the same routine (same type context).</remarks>
        private void TraverseToBlock(FlowState/*!*/state, BoundBlock/*!*/target)
        {
            Contract.ThrowIfNull(state);    // state should be already set by previous block
            
            var targetState = target.FlowState;
            if (targetState != null)
            {
                Debug.Assert(targetState.FlowContext == state.FlowContext);

                // block was visited already,
                // merge and check whether state changed
                state = state.Merge(targetState);   // merge states into new one
                if (state.Equals(targetState))
                {
                    return; // state convergated, we don't have to analyse target block again
                }
            }
            else
            {
                // block was not visited yet
                state = state.Clone();              // copy state into new one
            }

            // update target block state
            target.FlowState = state;

            //
            _worklist.Enqueue(target);
        }
	/// <summary>
	/// Unity method.
	/// Awake this instance.
	/// </summary>
	public override void Awake ()
	{
		base.Awake ();
		
		State = FlowState.Intro;
	}
Exemple #44
0
 public PostToUserBehavior(FlowState state, Dictionary <string, object> context)
     : base(state, context)
 {
 }
Exemple #45
0
        public override FlowState Execute(ScopeRuntimeContext context)
        {
            loopContext = new ScopeRuntimeContext(context);
            FlowState state = initializationStatement?.Execute(loopContext) ?? FlowState.Nominal;

            switch (state)
            {
            case FlowState.Nominal:
                //Continue
                break;

            case FlowState.LoopContinue:
            case FlowState.LoopBreak:
            case FlowState.Return:
            default:
                throw new Exception($"Unexpected FlowState: {state}");
            }

            bool continuing = true;

            while (continuing && continueExpression.GetAs <bool>(loopContext))
            {
                bodyContext = new ScopeRuntimeContext(loopContext);

                state = loopBody.Execute(bodyContext);

                switch (state)
                {
                case FlowState.Nominal:
                case FlowState.LoopContinue:
                    //Do Nothing
                    break;

                case FlowState.LoopBreak:
                    continuing = false;
                    break;

                case FlowState.Return:
                    return(state);

                default:
                    throw new Exception($"Unexpected FlowState: {state}");
                }

                //Don't run incrementStatement if we are breaking out
                if (continuing)
                {
                    state = incrementStatement?.Execute(loopContext) ?? FlowState.Nominal;

                    switch (state)
                    {
                    case FlowState.Nominal:
                        //Do Nothing
                        break;

                    case FlowState.Return:
                    case FlowState.LoopContinue:
                    case FlowState.LoopBreak:
                    default:
                        throw new Exception($"Unexpected FlowState: {state}");
                    }
                }
            }

            return(FlowState.Nominal);
        }
	/// <summary>
	/// Advances the flow by going to the next state.
	/// </summary>
	public void AdvanceFlow()
	{
		if (State == FlowState.Intro) {
			State = FlowState.Idle;
		} else if (State == FlowState.Idle) {
			State = FlowState.Outro;
		}
	}