示例#1
0
        //return true if breaked
        private bool update(int frame)
        {
            int _agenttype_index     = 0;
            int _agentinstance_index = 0;

            ConsoleDock.SetMesssages(frame);

            if (Plugin.EditMode == EditModes.Connect)
            {
                if (Plugin.UpdateMode == UpdateModes.Continue)
                {
                    SetTotalFrame(frame);
                    AgentDataPool.CurrentFrame = AgentDataPool.TotalFrames;
                }

                updateUI(frame);
            }

            lock (_lockObject) {
                if (_agenttype_index != -1 && _agentinstance_index != -1)
                {
                    //update could be entered multiple times for a 'frame' if there are multiple breakpoints in 'frame'
                    if (_agenttype_index == 0 && _agentinstance_index == 0)
                    {
                        AgentDataPool.CurrentFrame = frame;

                        // Global
                        //foreach (Plugin.InstanceName_t agentType in Plugin.InstanceNames)
                        //{
                        //    updateParameters(agentType.agentType_, agentType.agentType_.AgentTypeName, frame);
                        //}
                    }

                    this._break_prompt = "";

                    // Agent
                    while (_agenttype_index < Plugin.AgentTypes.Count)
                    {
                        AgentType agentType = Plugin.AgentTypes[_agenttype_index];

                        if (!agentType.IsInherited)
                        {
                            List <string> instances = AgentInstancePool.GetInstances(agentType.ToString());

                            while (_agentinstance_index < instances.Count)
                            {
                                string instance = instances[_agentinstance_index];
                                _agentinstance_index++;

                                // Parameters
                                updateParameters(agentType, instance, frame);

                                if (Plugin.EditMode == EditModes.Analyze)
                                {
                                    string agentName        = string.Format("{0}#{1}", agentType, instance);
                                    string behaviorFilename = FrameStatePool.GetBehaviorFilename(agentName, frame);

                                    if (_lastBreakFrame != frame)
                                    {
                                        _lastBreakPointIndex = 0;
                                    }

                                    // Breakpoint
                                    List <FrameStatePool.FrameState.Action> actions = FrameStatePool.GetActions(agentName, frame, behaviorFilename);
                                    HighlightBreakPoint.Instance = checkBreakpoint(behaviorFilename, actions, ref _lastBreakPointIndex);

                                    if (HighlightBreakPoint.Instance != null || agentName == Plugin.DebugAgentInstance)
                                    {
                                        // Highlights
                                        List <string> transitionIds    = FrameStatePool.GetHighlightTransitionIds(agentName, frame, behaviorFilename);
                                        List <string> highlightNodeIds = FrameStatePool.GetHighlightNodeIds(agentName, frame, behaviorFilename);
                                        List <string> updatedNodeIds   = FrameStatePool.GetUpdatedNodeIds(agentName, frame, behaviorFilename);
                                        Dictionary <string, FrameStatePool.NodeProfileInfos.ProfileInfo> profileInfos = FrameStatePool.GetProfileInfos(frame, behaviorFilename);

                                        updateHighlights(agentName, frame, transitionIds, highlightNodeIds, updatedNodeIds, HighlightBreakPoint.Instance, profileInfos);
                                    }

                                    // Return if there is breakpoint breaked.
                                    if (HighlightBreakPoint.Instance != null)
                                    {
                                        _lastBreakFrame = frame;
                                        return(true);
                                    }
                                }
                            }
                        }

                        _agenttype_index++;
                        _agentinstance_index = 0;
                    }

                    _agenttype_index     = -1;
                    _agentinstance_index = -1;

                    //after checking breakpoints, to check applog
                    _log_index = 0;
                }
            }

            lock (_lockObject) {
                if (_log_index != -1)
                {
                    if (Plugin.EditMode == EditModes.Analyze)
                    {
                        bool bCheckLog = (this.comboBoxLogFilter.Text != "");

                        if (bCheckLog)
                        {
                            if (Plugin.EditMode == EditModes.Analyze)
                            {
                                Debug.Check(true);
                            }
                            else if (MessageQueue.IsConnected)
                            {
                                Debug.Check(true);
                            }
                            else
                            {
                                bCheckLog = false;
                            }
                        }

                        if (bCheckLog)
                        {
                            List <string> logs = FrameStatePool.GetAppLog(frame, this.comboBoxLogFilter.Text);

                            if (logs != null && _log_index < logs.Count)
                            {
                                this._break_prompt = logs[_log_index++];
                                return(true);
                            }
                        }
                    }

                    _log_index = -1;
                }
            }

            return(false);
        }