Exemple #1
0
        private bool MoveNext(ref int depth)
        {
            if (m_mainListIndex == int.MaxValue)
            {
                Logger.AlwaysLog("List was not reset since last addition", Logger.severity.ERROR);
                Reset();
                return(false);
            }
            CurrentIndex++;
            depth++;
            if (CurrentIndex > MaxIndex)
            {
                Logger.AlwaysLog("Over command limit: " + CurrentIndex, Logger.severity.DEBUG);
                return(false);
            }
            if (depth > MaxDepth)
            {
                Logger.AlwaysLog("Over maximum command depth: " + depth, Logger.severity.DEBUG);
                return(false);
            }
            if (m_sublist != null)
            {
                if (m_sublist.MoveNext(ref depth))
                {
                    Current = m_sublist.Current;
                    Logger.DebugLog("CurrentIndex: " + CurrentIndex + ", m_mainListIndex: " + m_mainListIndex + ", sublist CurrentIndex: " + m_sublist.CurrentIndex + ", sublist m_mainListIndex: " + m_sublist.m_mainListIndex);
                    return(true);
                }
                m_sublist = null;
            }
            m_mainListIndex++;
            if (m_mainListIndex >= m_mainList.Count)
            {
                Logger.DebugLog("End of main list, m_mainListIndex: " + m_mainListIndex + ", m_mainList.Count: " + m_mainList.Count);
                Current = null;
                return(false);
            }

            object element = m_mainList[m_mainListIndex];

            Current = element as AutopilotAction;
            if (Current != null)
            {
                Logger.DebugLog("CurrentIndex: " + CurrentIndex + ", m_mainListIndex: " + m_mainListIndex);
                return(true);
            }

            TextPanelMonitor monitor = (TextPanelMonitor)element;

            Logger.DebugLog("Resting sublist: " + monitor.TextPanel.nameWithId());
            m_sublist = monitor.AutopilotActions;
            m_sublist.Reset();
            return(MoveNext(ref depth));
        }
Exemple #2
0
        private void GetActions(IEnumerable <ACommand> commandList, AutopilotActionList actionList)
        {
            int       count = 0;
            const int limit = 1000;

            foreach (ACommand cmd in commandList)
            {
                TextPanel tp = cmd as TextPanel;
                if (tp == null)
                {
                    if (cmd.Action == null)
                    {
                        Logger.AlwaysLog("Command is missing action: " + cmd.DisplayString, Logger.severity.ERROR);
                        continue;
                    }

                    if (++count > limit)
                    {
                        Logger.DebugLog("Reached command limit");
                        m_syntaxErrors.AppendLine("Reached command limit");
                        return;
                    }
                    Logger.DebugLog("yield: " + cmd.DisplayString);
                    actionList.Add(cmd.Action);
                    continue;
                }

                TextPanelMonitor textPanelMonitor = tp.GetTextPanelMonitor(m_block, this);
                if (textPanelMonitor == null)
                {
                    Logger.DebugLog("Text panel not found: " + tp.SearchPanelName);
                    m_syntaxErrors.Append("Text panel not found: ");
                    m_syntaxErrors.AppendLine(tp.SearchPanelName);
                    continue;
                }
                if (textPanelMonitor.AutopilotActions.IsEmpty)
                {
                    Logger.DebugLog(textPanelMonitor.TextPanel.DisplayNameText + " has no commands");
                    m_syntaxErrors.Append(textPanelMonitor.TextPanel.DisplayNameText);
                    m_syntaxErrors.AppendLine(" has no commands");
                    continue;
                }

                actionList.Add(textPanelMonitor);
            }

            actionList.Reset();
        }
Exemple #3
0
        public AutopilotActionList GetActions()
        {
            using (MainLock.AcquireSharedUsing())
            {
                if (!m_actionList.IsEmpty)
                {
                    m_actionList.Reset();
                    return(m_actionList);
                }
                m_syntaxErrors.Clear();

                Commands = AutopilotTerminal.GetAutopilotCommands(m_block).ToString();
                List <ACommand> commands = new List <ACommand>();
                GetActions(Commands, m_actionList);
                if (m_syntaxErrors.Length != 0)
                {
                    m_block.UpdateCustomInfo();
                }
                return(m_actionList);
            }
        }