Exemple #1
0
        /// <summary>
        /// get/create a single thread group of actions containing the given branch id.
        /// it is used for loading debugger viewer
        /// </summary>
        /// <param name="branchId">the given branch id to be included in the result group</param>
        /// <returns>the action group containing the given branch id</returns>
        public IActionGroup GetThreadGroup(UInt32 branchId)
        {
            List <ActionBranch> independentThreads = FindoutActionThreads(false);

            foreach (ActionBranch a in independentThreads)
            {
                if (a.ContainsAction(branchId))
                {
                    IActionGroup g = a as IActionGroup;
                    if (g != null)
                    {
                        g = (IActionGroup)g.Clone();
                        g.ResetGroupId(_method.MethodID);                        //all threads has the same group id. they can be distinguished at runtime by thread id
                        return(g);
                    }
                    AB_ActionString s = a as AB_ActionString;
                    if (s != null)
                    {
                        IActionGroup sg = s.GetThreadGroup(branchId);
                        sg.ResetGroupId(_method.MethodID);                        //all threads has the same group id. they can be distinguished at runtime by thread id
                        return(sg);
                    }
                    List <UInt32>  used = new List <uint>();
                    AB_ActionGroup ag   = new AB_ActionGroup(_actsHolder);
                    ag.SetOwnerMethod(used, _method);
                    ag.BranchId = _method.MethodID;                     //all threads has the same group id. they can be distinguished at runtime by thread id
                    ag.AppendAction(a);
                    return(ag);
                }
            }
            return(null);
        }
Exemple #2
0
        /// <summary>
        /// before executing an action in a method.
        /// it can be called from different threads
        /// </summary>
        /// <param name="objectKey">ObjectKey of the owner of the method</param>
        /// <param name="methodWholeId">method id</param>
        /// <param name="branchId">action branch id of the action to be executed</param>
        /// <param name="executer">object instance executing the method</param>
        public void BeforeExecuteAction(string objectKey, UInt64 methodWholeId, UInt32 branchId, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;

            _ComponentDebugger.IncrementStackLevel(threadId);
            //check if it is at a break point
            MethodClass mc = _ComponentDebugger.GetMethod(methodWholeId);

            if (mc != null)
            {
                //MethodClass mc = mc0.Clone() as MethodClass;
                IActionGroup g      = mc;
                ActionBranch branch = mc.GetBranchByIdInGroup(branchId, ref g);
                if (branch != null)
                {
                    if (_ComponentDebugger.ShouldBreak(threadId) || branch.BreakBeforeExecute)
                    {
                        _ComponentDebugger.SetSelectedObject(executer);
                        _ComponentDebugger.SetAtBreak(threadId, true);
                        _debugUI.ShowBreakPoint(_ComponentDebugger);
                        branch.AtBreak = EnumActionBreakStatus.Before;
                        _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch);
                        waitForBreakPoint(threadId);
                    }
                }
            }
        }
Exemple #3
0
 public override void LoadActions(IActionGroup actions)
 {
     _actions        = actions as AB_Squential;
     ContentReadOnly = true;
     LoadMethod(actions.ActionList.Method, EnumParameterEditType.TypeReadOnly);
     //
     SetDebugBehavior();
 }
        private void clearBreakPointInMethod(int threadId, MethodClass method, IActionGroup group, ActionBranch branch)
        {
            MethodDesignerHolder h = getViewer(threadId, method, group, branch);

            if (h != null)
            {
                h.ClearBreakpoint();
            }
        }
		public ActionSetSummary(IActionGroup grp, string routingDesc)
		{
			m_actionset = grp;
			m_routingDesc = routingDesc;
			foreach (IAction action in grp.Actions)
			{
				m_actionSummaryList.Add(new ActionSummary(action));
			}
		}
Exemple #6
0
 private void WriteActionGroup(IActionGroup actionGroup)
 {
     foreach (IActionGroup subActionGroup in actionGroup.ActionGroups)
     {
         WriteActionGroup(subActionGroup);
     }
     foreach (IAction action in actionGroup.Actions)
     {
         WriteAction(action);
     }
 }
Exemple #7
0
 /// <summary>
 /// find the smallest group containing the branch
 /// </summary>
 /// <param name="id"></param>
 /// <param name="group"></param>
 /// <returns></returns>
 public ActionBranch GetBranchInGroup(UInt32 id, ref IActionGroup group)
 {
     foreach (ActionBranch ab in this)
     {
         ActionBranch a = ab.GetBranchInGroup(id, ref group);
         if (a != null)
         {
             return(a);
         }
     }
     return(null);
 }
Exemple #8
0
        /// <summary>
        /// find the smallest group containing the branch
        /// </summary>
        /// <param name="id"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public override ActionBranch GetBranchInGroup(UInt32 id, ref IActionGroup group)
        {
            ActionBranch a = base.GetBranchInGroup(id, ref group);

            if (a != null)
            {
                return(a);
            }
            if (_list != null)
            {
                return(_list.GetBranchInGroup(id, ref group));
            }
            return(null);
        }
        private void showBreakPointInMethod(int threadId, MethodClass method, IActionGroup group, ActionBranch branch)
        {
            MethodDesignerHolder h = getViewer(threadId, method, group, branch);

            if (h == null)
            {
                IActionGroup g = (IActionGroup)(group.Clone());
                g = g.GetThreadGroup(branch.BranchId);
                //create a viewer
                SplitContainer c            = getLastContainer(splitContainer1);
                SplitContainer newContainer = new SplitContainer();
                newContainer.Dock = DockStyle.Fill;
                c.Panel2.Controls.Add(newContainer);
                c.Panel2Collapsed            = false;
                newContainer.Panel2Collapsed = true;
                h          = Activator.CreateInstance(g.ViewerHolderType, this, _designer) as MethodDesignerHolder;
                h.ThreadId = threadId;
                h.SetBackgroundText(group.GroupName);
                h.Dock = DockStyle.Fill;
                newContainer.Panel1.Controls.Add(h);
                h.LoadActions(g);
                _currentThreadId              = threadId;
                h.DesignerSelected           += new EventHandler(h_DesignerSelected);
                newContainer.Panel1.GotFocus += new EventHandler(Panel1_GotFocus);
                newContainer.SplitterMoved   += new SplitterEventHandler(newContainer_SplitterMoved);
                newContainer.Resize          += new EventHandler(newContainer_Resize);
            }
            else
            {
                if (h.ActionGroup.GroupFinished)
                {
                    h.ActionGroup.GroupFinished = false;
                    ThreadDebug td = ThreadData(threadId);
                    if (td.Status == EnumRunStatus.Finished)
                    {
                        FormDebugger f = this.FindForm() as FormDebugger;
                        if (f != null)
                        {
                            td.Status = f.DebugCommandStatus;
                        }
                        else
                        {
                            td.Status = EnumRunStatus.Run;
                        }
                    }
                    UpdateViewersBackColor();
                }
            }
            h.UpdateBreakpoint(branch);
        }
        /// <summary>
        /// find the smallest group containing the branch
        /// </summary>
        /// <param name="id"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public override ActionBranch GetBranchInGroup(UInt32 id, ref IActionGroup group)
        {
            if (this.BranchId == id)
            {
                return(this);
            }
            IActionGroup g = this;
            ActionBranch a = base.GetBranchInGroup(id, ref g);

            if (a != null)
            {
                group = g;
                return(a);
            }
            return(null);
        }
        public void Initialise(IPolicy policy, IPolicyChannel channel, IActionGroup group)
        {
            //if the action group has changed, don't bother trying to select the
            //same action that was selected prior to this call
            if (group != m_actionGroup)
            {
                m_selectedActionIndex = -1;
            }

            m_policy = policy;
            m_channel = channel;
            m_actionGroup = group;

            FillCatalogActions();
            FillAssignedActions();

            this.actiongroupNameTextBox.Focus();
        }
Exemple #12
0
        /// <summary>
        /// find the smallest group containing the branch
        /// </summary>
        /// <param name="id"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public override ActionBranch GetBranchInGroup(UInt32 id, ref IActionGroup group)
        {
            ActionBranch a = base.GetBranchInGroup(id, ref group);

            if (a == null)
            {
                if (_ifActions != null)
                {
                    a = _ifActions.GetBranchInGroup(id, ref group);
                }
            }
            if (a == null)
            {
                if (_elseActions != null)
                {
                    a = _elseActions.GetBranchInGroup(id, ref group);
                }
            }
            return(a);
        }
Exemple #13
0
 public ActionBranch GetJumpToActionBranch(UInt32 branchId)
 {
     foreach (ActionBranch a in this)
     {
         if (a.BranchId == branchId)
         {
             return(a);
         }
         AB_ActionString abs = a as AB_ActionString;
         if (abs != null)
         {
             if (abs.ActionCount > 0)
             {
                 if (abs.ActionList[0].BranchId == branchId)
                 {
                     return(a);
                 }
             }
         }
         else
         {
             IActionGroup ia = a as IActionGroup;
             if (ia != null)
             {
                 if (ia.ActionList != null)
                 {
                     ActionBranch ab = ia.ActionList.GetJumpToActionBranch(branchId);
                     if (ab != null)
                     {
                         return(ab);
                     }
                 }
             }
         }
     }
     return(null);
 }
 private bool GetActions()
 {
     bool ret = false;
     if (m_channel.Actions != null)
     {
         IActionMatrixCell cell = m_channel.Actions[m_activeSenderAddressCollection, m_activeRecipientAddressCollection];
         if (cell != null)
         {
             m_actiongroup = cell.ActionConditionGroups[0].ActionGroup;
             ret = true;
         }
     }
     return ret;
 }
        /// <summary>
        /// Removes an ActionGroup from a policy set's master catalogue
        /// </summary>
        /// <param name="policySet">The policy set from whose catalogue we will remove the ActionGroup</param>
        /// <param name="actionGroup">The ActionGroup to remove</param>
        private static void RemoveActionGroup(IPolicySet policySet, IActionGroup actionGroup)
        {
            if (null == policySet || null == actionGroup)
            {
                return;
            }

            foreach (IActionGroup childActionGroup in actionGroup.ActionGroups)
            {
                RemoveActionGroup(policySet, childActionGroup);
            }

            foreach (IAction childAction in actionGroup.Actions)
            {
                RemoveAction(policySet, childAction);
            }

            policySet.MasterCatalogue.ActionGroups.Remove(actionGroup);
        }
        private void WriteActionGroup(XmlNode xmlParentNode, IActionGroup actionGroup)
        {
            XmlNode xmlActionGroupNode = m_xmlDocument.CreateElement("ActionGroup");
            xmlParentNode.AppendChild(xmlActionGroupNode);

            XmlHelpers.AddIdAttribute(xmlActionGroupNode, actionGroup);
            XmlHelpers.AddAttribute(xmlActionGroupNode, "precedence", actionGroup.Precedence.ToString(CultureInfo.InvariantCulture));
            XmlHelpers.AddReadOnlyAttribute(xmlActionGroupNode, actionGroup.ReadOnly);

            WriteActionGroups(xmlActionGroupNode, actionGroup.ActionGroups);
            WriteActions(xmlActionGroupNode, actionGroup.Actions);
        }
 public void SetActions(IActionGroup actiongroup)
 {
     Display();
 }
        public void WriteActionGroup(IActionGroup actionGroup)
        {
            if (null == actionGroup)
                return;

            CollectionInserter<IActionGroup>.Insert(m_actionGroups, actionGroup);
        }
 private MethodDesignerHolder getViewer(int threadId, SplitContainer c, MethodClass method, IActionGroup group, ActionBranch branch)
 {
     for (int i = 0; i < c.Panel1.Controls.Count; i++)
     {
         MethodDesignerHolder h = c.Panel1.Controls[i] as MethodDesignerHolder;
         if (h != null)
         {
             if (h.ThreadId == threadId)
             {
                 if (h.Method.WholeActionId == method.WholeActionId)
                 {
                     if (group.GroupId == h.ActionGroup.GroupId)
                     {
                         if (h.ActionList.ContainsAction(branch.BranchId))
                         {
                             return(h);
                         }
                     }
                 }
             }
         }
     }
     for (int i = 0; i < c.Panel2.Controls.Count; i++)
     {
         SplitContainer s = c.Panel2.Controls[i] as SplitContainer;
         if (s != null)
         {
             MethodDesignerHolder h = getViewer(threadId, s, method, group, branch);
             if (h != null)
             {
                 return(h);
             }
         }
     }
     return(null);
 }
 private MethodDesignerHolder getViewer(int threadId, MethodClass method, IActionGroup group, ActionBranch branch)
 {
     return(getViewer(threadId, splitContainer1, method, group, branch));
 }
 void m_actiongroupControl_OnGroupnameChanged(object sender, string text, IActionGroup group)
 {
     if (text != group.Name.Value)
     {
         group.Name.Value = text;
         UpdateChannelStateUI();
         StateMachine.ChildForm.IsModified = true;
     }
 }
Exemple #22
0
        /// <summary>
        /// finish execute an action
        /// </summary>
        /// <param name="objectKey"></param>
        /// <param name="methodWholeId"></param>
        /// <param name="branchId"></param>
        /// <param name="executer"></param>
        public void AfterExecuteAction(string objectKey, UInt64 methodWholeId, UInt32 branchId, object executer)
        {
            if (_ComponentDebugger.Stopping)
            {
                return;
            }
            int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;

            _ComponentDebugger.DecrementStackLevel(threadId);
            //check if it is at a break point
            MethodClass mc = _ComponentDebugger.GetMethod(methodWholeId);

            if (mc != null)
            {
                IActionGroup g      = mc;
                ActionBranch branch = mc.GetBranchByIdInGroup(branchId, ref g);
                if (branch != null)
                {
                    IActionGroup g0 = branch as IActionGroup;
                    if (g0 != null)
                    {
                        //finished calling a group of actions
                        MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, g0.GroupId);
                        if (h != null)
                        {
                            h.ActionGroup.GroupFinished = true;
                            _ComponentDebugger.UpdateViewersBackColor();
                        }
                    }
                    else
                    {
                        ISingleAction sa = branch as ISingleAction;
                        if (sa != null)
                        {
                            CustomMethodPointer ac = sa.ActionData.ActionMethod as CustomMethodPointer;
                            if (ac != null)
                            {
                                //finished calling a custom action
                                MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, ac.MethodDef.MethodID);
                                if (h != null)
                                {
                                    h.ActionGroup.GroupFinished = true;
                                    _ComponentDebugger.UpdateViewersBackColor();
                                }
                            }
                        }
                    }
                    EnumRunStatus status = _ComponentDebugger.GetRunStatus(threadId);
                    bool          b      = (status == EnumRunStatus.Pause || status == EnumRunStatus.StepInto);
                    if (!b)
                    {
                        if (status == EnumRunStatus.StepOver && _ComponentDebugger.ReachStepOver(threadId))
                        {
                            b = true;
                        }
                        if (!b)
                        {
                            if (status == EnumRunStatus.StepOut && _ComponentDebugger.ReachStepOut(threadId))
                            {
                                b = true;
                            }
                        }
                    }

                    if (b || branch.BreakAfterExecute)
                    {
                        _ComponentDebugger.SetSelectedObject(executer);
                        _ComponentDebugger.SetAtBreak(threadId, true);
                        _debugUI.ShowBreakPoint(_ComponentDebugger);
                        branch.AtBreak = EnumActionBreakStatus.After;
                        _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch);
                        waitForBreakPoint(threadId);
                        branch.AtBreak = EnumActionBreakStatus.None;
                        _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch);
                    }
                    else
                    {
                        branch.AtBreak = EnumActionBreakStatus.None;
                        _ComponentDebugger.ClearBreakPointInMethod(threadId, mc, g, branch);
                    }
                }
            }
        }
 public void ClearBreakPointInMethod(int threadId, MethodClass method, IActionGroup group, ActionBranch branch)
 {
     this.Invoke(miClearBreakPointInMethod, threadId, method, group, branch);
 }
        private static bool ValidateActionGroup(string policyName, IActionGroup actionGroup, PolicySetValidator.AddViolationMessageHandler AddMessage)
        {
            if (0 < actionGroup.Actions.Count)
            {
                ValidateActions(policyName, actionGroup.Actions, AddMessage);
                return true;
            }

            foreach (IActionGroup subActionGroup in actionGroup.ActionGroups)
            {
                if (ValidateActionGroup(policyName, subActionGroup, AddMessage))
                    return true;
            }

            return false;
        }