private void WriteActionsFromTransition(CodeStatementCollection statements, StateType state, TransitionType transition) { WriteActions(statements, state, transition.action, transition.Items); }
// // if (connection.Endpoint.Name == "CpeB") { // context.TransitionName = "EvConnectionIncoming[connection.Endpoint.Name == \"CpeB\"]"; // StateMachineHelper.ProcessTransitionBegin<CallBase01ContextAlice, CallBase01Context, CallBase01StateAlice>(context, CallBase01StateA_End.Instance); // StateMachineHelper.ProcessTransitionEnd<CallBase01ContextAlice, CallBase01Context, CallBase01StateAlice>(context, CallBase01StateA_End.Instance); // // Notify the end of this state machine. // context.OnEnd(); // return; //} private void WriteTransition(CodeMemberMethod eventMethod, StateType state, TransitionType transition) { StateType stateNext = Model.GetStateType(transition.nextState); if (stateNext == null) { eventMethod.Comments.Add( new CodeCommentStatement( "Internal transition from state " + state.name + " triggered by event " + Model.GetTransitionName(transition))); } else if (stateNext == state) { eventMethod.Comments.Add(new CodeCommentStatement("Self transition from state " + state.name + " triggered by event " + Model.GetTransitionName(transition))); } else { eventMethod.Comments.Add(new CodeCommentStatement( "Transition from state " + state.name + " to " + transition.nextState + " triggered by event " + Model.GetTransitionName(transition))); if (stateNext.StateParallel == state.StateParallel) { eventMethod.Comments.Add( new CodeCommentStatement( "The next state " + transition.nextState + " is within the context " + GetContextClassName(state))); if (stateNext.Type.HasFlag(StateType.TypeFlags.HISTORY)) { eventMethod.Comments.Add( new CodeCommentStatement( "The next state " + transition.nextState + " is historical")); } } else { eventMethod.Comments.Add( new CodeCommentStatement( "The next state " + transition.nextState + " belonging to context " + GetContextClassName(stateNext) + " is outside the context " + GetContextClassName(state))); } } string condition = Model.GetCondition(transition); if (String.IsNullOrEmpty(condition) == false) { CodeConditionStatement transitionCondition = new CodeConditionStatement( // The condition to test. new CodeSnippetExpression(condition), // The statements to execute if the condition evaluates to true. GetProcessTransitionStatements(state, transition)); eventMethod.Statements.Add(transitionCondition); } else { eventMethod.Statements.AddRange(GetProcessTransitionStatements(state, transition)); } }