Example #1
0
        public void Dump()
        {
            var sb = new CodeWriter();
            sb.AppendLine("state machine dump");

            foreach (var e in _events.Values)
            {
                sb.AppendComment();
                sb.AppendComment("event " + e.Name);
                foreach (var t in e.Triggers)
                {
                    sb.AppendLine("TRIGGER " + t.Name + " WHEN");
                    sb.AppendLine("  BEFORE [" + t.PreCondition + "] AFTER [" + t.PostCondition + "]");
                }
            }

            foreach (var t in Guards)
            {
                sb.AppendLine("GUARD " + t.Name + " " + t.Type + " WHEN ");
                if (t.Type == GuardType.TRANSITION)
                {
                    sb.AppendLine("  BEFORE [" + t.PreCondition + "]");
                    sb.AppendLine("  AFTER [" + t.PostCondition + "]");
                }
                else if (t.Type == GuardType.ENTER)
                {
                    sb.AppendLine("  AFTER [" + t.PostCondition + "]");
                }
                else if (t.Type == GuardType.LEAVE)
                {
                    sb.AppendLine("  BEFORE [" + t.PreCondition + "]");
                }
            }
            // sb.AppendLine("matrix:\n" + _matrix);

            Trace("{0}", sb);
        }