示例#1
0
 private void StartMSMonitor()
 {
     if (this.MSMonitor == null)
     {
         this.MSMonitor = new MSMonitor();
     }
     else
     {
         this.MSMonitor.Again = true;
     }
 }
示例#2
0
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            if (this.MTEnabled == false || this.MTBusy)
            {
                return;
            }

            this.MTBusy = true;

            try
            {
                // ---- 3001

                if (this.RequestCloseWindow)
                {
                    this.RequestCloseWindow = false;
                    this.CloseWindow();
                    this.XPressed = false;
                    return;
                }

                // North >

                if (Ground.I.NorthMessage != "")
                {
                    this.NextNorthMessage = Ground.I.NorthMessage;
                    Ground.I.NorthMessage = "";
                    this.NorthMessageDisplayTimerCountDown = Ground.I.Config.MessageDisplayTimerCountMax;
                }
                if (1 <= this.NorthMessageDisplayTimerCountDown && --this.NorthMessageDisplayTimerCountDown == 0)
                {
                    this.NextNorthMessage = "";
                }

                if (this.NextNorthMessage != null && this.WindowState != FormWindowState.Minimized)                 // 最小化時にコントロールを移動・リサイズすると変になるので、
                {
                    this.North.Text       = this.NextNorthMessage;
                    this.NextNorthMessage = null;

                    if (this.North.Text == "")
                    {
                        this.MainSheet.Top = this.North.Top;
                    }
                    else
                    {
                        this.MainSheet.Top = this.North.Top + this.North.Height + 2;

                        if (Ground.I.NorthStickRight)
                        {
                            this.North.Left = this.MainSheet.Left + this.MainSheet.Width - this.North.Width;
                        }
                        else
                        {
                            this.North.Left = this.MainSheet.Left;
                        }
                    }
                    this.MainSheet.Height = this.SouthBar.Top - this.MainSheet.Top - 3;
                }

                // < North

                if (this.MSMonitor != null && this.MSMonitor.IsStarted())
                {
                    MSMonitor mon = this.MSMonitor;

                    for (int c = 0; c < 300; c++)                     // HACK: ループ回数_適当
                    {
                        if (this.MainSheet.RowCount <= mon.RowIndex)
                        {
                            this.MSMonitorOutput = mon.GetOutput();
                            this.MSMonitorStatus = mon.GetStatus();

                            if (this.MSMonitor.Again)
                            {
                                this.MSMonitor = new MSMonitor();
                            }
                            else
                            {
                                this.MSMonitor = null;
                            }

                            break;
                        }

                        {
                            AudioInfo info = this.MS_GetRow(mon.RowIndex);

                            if (info.Status == AudioInfo.Status_e.READY)
                            {
                                mon.ReadyCount++;
                            }
                            else if (info.Status == AudioInfo.Status_e.PROCESSING)
                            {
                                mon.ProcessingCount++;
                            }
                            else if (info.Status == AudioInfo.Status_e.ERROR)
                            {
                                mon.ErrorCount++;
                            }
                            else if (info.Status == AudioInfo.Status_e.SUCCESSFUL)
                            {
                                mon.SuccessfulCount++;
                            }
                            else
                            {
                                throw null;                                 // never
                            }
                        }

                        mon.RowIndex++;
                    }
                }

                if (this.MTCount % 5 == 0)                 // 頻度を下げる。
                {
                    Ground.I.SouthWestMessage = string.Format(
                        "{0}{1} / {2} 行 中 {3} 行 選択中 / {4}",
                        this.MSMonitor == null ? "" : this.MSMonitor.RowIndex + " ",
                        Ground.I.ConverterActive ? this.PatrolRowIndex + " [コンバータ実行中]" : "[コンバータ停止]",
                        this.MainSheet.RowCount,
                        this.MainSheet.SelectedRows.Count,
                        this.MSMonitorOutput
                        );
                }

                if (Ground.I.Converter.IsCompleted())
                {
                    ConverterTask task   = Ground.I.Converter.GetTask();
                    AudioInfo     info   = task.Info;
                    int           rowidx = this.MS_GetProcessingRowIndex();

                    if (rowidx == -1)
                    {
                        throw null;
                    }

                    this.MS_SetRow(rowidx, info);
                    this.PatrolRowIndex = rowidx + 1;
                    Ground.I.Converter.Reset();

                    this.StartMSMonitor();
                }

                if (1 <= this.MainSheet.RowCount)
                {
                    if (this.MainSheet.RowCount <= this.PatrolRowIndex)
                    {
                        this.PatrolRowIndex = 0;
                    }

                    // ---- Patrol ----

                    if (Ground.I.ConverterActive && Ground.I.Converter.IsReady())
                    {
                        AudioInfo info = this.MS_GetRow(this.PatrolRowIndex);

                        if (info.Status == AudioInfo.Status_e.READY)
                        {
                            info.Status = AudioInfo.Status_e.PROCESSING;
                            this.MS_SetRow(this.PatrolRowIndex, info);
                            Ground.I.Converter.Start(new ConverterTask()
                            {
                                Info = info,
                            });

                            this.StartMSMonitor();
                        }
                    }

                    // ----

                    this.PatrolRowIndex++;
                }

                if (Ground.I.SouthMessage != "")
                {
                    this.South.Text       = Ground.I.SouthMessage;
                    Ground.I.SouthMessage = "";
                    this.SouthMessageDisplayTimerCountDown = Ground.I.Config.MessageDisplayTimerCountMax;
                }
                if (1 <= this.SouthMessageDisplayTimerCountDown && --this.SouthMessageDisplayTimerCountDown == 0)
                {
                    this.South.Text = "";
                }

                if (Ground.I.SouthWestMessage != "")
                {
                    if (this.SouthWest.Text != Ground.I.SouthWestMessage)
                    {
                        this.SouthWest.Text = Ground.I.SouthWestMessage;
                    }

                    Ground.I.SouthWestMessage = "";
                }

                {
                    Color foreColor     = Consts.LabelDefForeColor;
                    Color backColor     = Consts.LabelDefBackColor;
                    bool  completedFlag = false;

                    if (Ground.I.ConverterActive)
                    {
                        bool blink = (this.MTCount / 10) % 2 == 0;

                        switch (this.MSMonitorStatus)
                        {
                        case MSMonitor.Status_e.READY:
                            if (blink)
                            {
                                foreColor = Color.White;
                                backColor = Color.Green;
                            }
                            break;

                        case MSMonitor.Status_e.完了:
                        case MSMonitor.Status_e.完了エラーあり:
                            completedFlag = true;
                            break;

                        case MSMonitor.Status_e.処理中:
                            if (blink)
                            {
                                foreColor = Color.White;
                                backColor = Color.Blue;
                            }
                            break;

                        case MSMonitor.Status_e.処理中エラーあり:
                            if (blink)
                            {
                                foreColor = Color.White;
                                backColor = Color.OrangeRed;
                            }
                            break;

                        default:
                            throw null;                                     // never
                        }
                    }
                    else
                    {
                        switch (this.MSMonitorStatus)
                        {
                        case Charlotte.MSMonitor.Status_e.READY:
                            break;

                        case MSMonitor.Status_e.完了:
                            backColor = Color.Cyan;
                            break;

                        case MSMonitor.Status_e.完了エラーあり:
                            backColor = Color.Orange;
                            break;

                        case MSMonitor.Status_e.処理中:
                            foreColor = Color.FromArgb(0, 0, 100);
                            break;

                        case MSMonitor.Status_e.処理中エラーあり:
                            foreColor = Color.FromArgb(100, 0, 0);
                            break;

                        default:
                            throw null;                                     // never
                        }
                    }
                    if (this.SouthWest.ForeColor != foreColor)
                    {
                        this.SouthWest.ForeColor = foreColor;
                    }

                    if (this.SouthWest.BackColor != backColor)
                    {
                        this.SouthWest.BackColor = backColor;
                    }

                    if (completedFlag)
                    {
                        Ground.I.ConverterActive = false;
                        this.RefreshUI();

                        Ground.I.SouthMessage = "処理完了によりコンバータを停止しました。";
                    }
                }

                if (this.MTCount % 20 == 0)                 // 頻度を下げる。
                {
                    if (Ground.I.ConverterActive && this.MainSheet.RowCount == 0)
                    {
                        Ground.I.ConverterActive = false;
                        this.RefreshUI();

                        Ground.I.SouthMessage = "処理すべきデータが無いのでコンバータを停止しました。";
                    }
                }
            }
            catch (Exception ex)
            {
                ProcMain.WriteLog(ex);
            }
            finally
            {
                this.MTBusy = false;
                this.MTCount++;
            }
        }