Exemple #1
0
 /// <summary>
 /// リフレッシュ
 /// </summary>
 private void refresh0()
 {
     refresh();
     LOG.NoJumpNext();
     LOG.WriteMesFormatLine(LLV.INF, Mes.Format.FromString("@LogGroupPanel.Welcome@"));
     LOG.NoJumpNext();
     LOG.WriteLine(LLV.INF, "          Version {0}", null, Application.ProductVersion);
     LOG.NoJumpNext();
     LOG.WriteMesFormatLine(LLV.INF, Mes.Format.FromString("@LogGroupPanel.LangInfo@"), Properties.Resources.li_hint);
     _tarPane.Invalidate(null);
 }
Exemple #2
0
 private void Reset(SpeechHandler[] handlers)
 {
     _talkID = null;
     foreach (var handler in handlers)
     {
         LOG.WriteLine(LLV.DEV, $"☆STOPPING {GetType().Name} instance {handler.TimeGenerated.ToString(TimeUtil.FormatYMDHMSms)}");
         Application.DoEvents();
         handler?.FireStop();            // STOP NAudio device
         handler?.Recognizer?.Dispose(); // STOP Azure Cognitive Service // await handler?.Recognizer?.StopContinuousRecognitionAsync();
         LOG.WriteLine(LLV.DEV, $"★STOPPED {GetType().Name} instance {handler.TimeGenerated.ToString(TimeUtil.FormatYMDHMSms)}");
     }
 }
Exemple #3
0
 public override void Start(NamedId who)
 {
     base.Start(who);
     if (!string.IsNullOrEmpty(Hot.SelectedText))
     {
         Clipboard.SetText(Hot.SelectedText);
         LOG.WriteLine(LLV.DEV, $"Copy {Hot.SelectedText}");
     }
     else
     {
         LOG.WriteLine(LLV.DEV, $"Cannot Copy because of NULL");
     }
 }
Exemple #4
0
        private void Btn_Click(object sender, EventArgs e)
        {
            Hot.IsPlaying = !Hot.IsPlaying;
            Btn.Checked = Hot.IsPlaying;

            if (Hot.IsPlaying)
            {
                LOG.WriteLine(LLV.INF, $"START at {DateTime.Now.ToString(TimeUtil.FormatYMDHMSms)}");
                Token.Add(TokenStart, this);
            }
            else
            {
                LOG.WriteLine(LLV.INF, $"Requested to STOP at {DateTime.Now.ToString(TimeUtil.FormatYMDHMSms)}");
                GetRoot().SetUrgentToken(TokenStop, TokenStop, null);
            }
        }
Exemple #5
0
        private void OnCancel(object sender, SpeechRecognitionEventArgs e)
        {
            if (_talkID == null)
            {
                return;
            }

            LOG.NoJumpNext();
            LOG.WriteLine(LLV.DEV, $"{DateTime.Now.ToString(TimeUtil.FormatYMDHMSms)} {GetType().Name}({GetTargetRecognizeLanguage()}).OnCancel : {e.Result.Text}");
            Hot.SpeechEventQueue.Enqueue(new SpeechEvent
            {
                RowID         = ID.Value,
                Action        = SpeechEvent.Actions.Canceled,
                TimeGenerated = DateTime.Now,
                SessionID     = _talkID,
                Text          = e.Result.Text,
            });
            _talkID = null;
            Token.Add(TokenSpeechEventQueued, this);
            GetRoot().FlushFeatureTriggers();
        }
Exemple #6
0
        private void CopyWavToMp3(string wavFileName)
        {
            Task.Run(() =>
            {
                try
                {
                    var reader      = new MediaFoundationReader(wavFileName);
                    var mp3         = MediaFoundationEncoder.SelectMediaType(AudioSubtypes.MFAudioFormat_MP3, reader.WaveFormat, 64000);
                    var mp3FileName = Path.Combine(Path.GetDirectoryName(wavFileName), $"{Path.GetFileNameWithoutExtension(wavFileName)}.mp3");

                    using (var converter = new MediaFoundationEncoder(mp3))
                    {
                        converter.Encode(mp3FileName, reader);
                    }
                    File.Delete(wavFileName);
                    LOG.WriteLine(LLV.INF, $"Saved as {Path.GetFileName(mp3FileName)} at {Path.GetDirectoryName(mp3FileName)}");
                }
                catch (Exception ex)
                {
                    LOG.WriteLine(LLV.WAR, $"Saved as {wavFileName}");
                }
            });
        }
Exemple #7
0
        private void OnRecognizing(object sender, SpeechRecognitionEventArgs e)
        {
            LOG.NoJumpNext();
            LOG.WriteLine(LLV.DEV, $"{DateTime.Now.ToString(TimeUtil.FormatYMDHMSms)} {GetType().Name}({GetTargetRecognizeLanguage()}).OnRecognizing : {e.Result.Text}");

            if (_talkID == null)
            {
                _talkID = Guid.NewGuid().ToString();
                Hot.SpeechEventQueue.Enqueue(new SpeechEvent
                {
                    RowID         = ID.Value,
                    Action        = SpeechEvent.Actions.Start,
                    TimeGenerated = DateTime.Now,
                    SessionID     = _talkID,
                });
                Hot.SpeechEventQueue.Enqueue(new SpeechEvent
                {
                    RowID         = ID.Value,
                    Action        = SpeechEvent.Actions.SetColor,
                    TimeGenerated = DateTime.Now,
                    SessionID     = _talkID,
                    Text          = GetBarColor().ToArgb().ToString(),
                });
            }

            Hot.SpeechEventQueue.Enqueue(new SpeechEvent
            {
                RowID         = ID.Value,
                Action        = SpeechEvent.Actions.Recognizing,
                TimeGenerated = DateTime.Now,
                SessionID     = _talkID,
                Text          = e.Result.Text,
            });
            Token.Add(TokenSpeechEventQueued, this);
            GetRoot().FlushFeatureTriggers();
        }
Exemple #8
0
 public void NameC(MyToken token)
 {
     LOG.WriteLine(LLV.ERR, "NameC is not expected token.");
 }
Exemple #9
0
 private void OnSessionStopped(object sender, SessionEventArgs e)
 {
     LOG.NoJumpNext();
     LOG.WriteLine(LLV.DEV, $"{DateTime.Now.ToString(TimeUtil.FormatYMDHMSms)} {GetType().Name}({GetTargetRecognizeLanguage()}).OnSessionStopped : {e}");
 }
Exemple #10
0
 public void NameB(MyToken token)
 {
     LOG.WriteLine(LLV.INF, "NameB OK.");
 }
Exemple #11
0
 public void SaveLocationAsOrigin()
 {
     PositionBackup = Location;
     LOG.WriteLine(LLV.INF, $"Move Start from {Location}");
 }
Exemple #12
0
 public void OnPartsMoved(EventTokenPartsMovedTrigger token)
 {
     if (movingWorkParts?.OriginalPosition != null)
     {
         try
         {
             var procs = Parts.GetParts <PartsJitProcess>(LAYER.JitProcess, a => a.IsConnecting).ToArray();
             if (procs.Length == 0)
             {
                 // Just Move work
                 return;
             }
             else if (procs.Length == 1)  // Set Work.Next
             {
                 var pw = Hot.ActiveTemplate.Jac.GetWork(movingWorkParts.ID);
                 var pp = Hot.ActiveTemplate.Jac.GetProcess(procs[0].ID);
                 if (pw.Next?.Process?.ID != procs[0].ID)
                 {
                     var jacredo =
                         $@"
                         {movingWorkParts.ID}
                             Next = new Location
                                 Stage = TheStage
                                 Path = '\'
                                 Process = {procs[0].ID}
                         Gui.UpdateCassetteValue = {movingWorkParts.ID}
                         Gui.SelectParts = {movingWorkParts.ID}
                     ";
                     string jacundo = "";
                     if (pw.Next == null)
                     {
                         jacundo = $@"
                             {movingWorkParts.ID}
                                 Next = null
                         ";
                     }
                     else
                     {
                         jacundo = $@"
                             {movingWorkParts.ID}
                                 Next = new Location
                                     Stage = TheStage
                                     Path = '\'
                                     Process = {(pw.Next.Process?.ID ?? "null")}
                         ";
                     }
                     {
                         jacundo += $@"
                             Gui.UpdateCassetteValue = {movingWorkParts.ID}
                             Gui.SelectParts = {movingWorkParts.ID}
                         ";
                     }
                     SetNewAction(token, jacredo, jacundo);
                     LOG.WriteLine(LLV.WAR, $"The Work.Next = {pp.Name}"); // TODO: Support Multi language with LOG.AddMes (VS2019 is now not work Resources.resw editor)
                 }
                 else
                 {
                     LOG.WriteLine(LLV.WAR, "The process is already set to this work."); // TODO: Support Multi language with LOG.AddMes (VS2019 is now not work Resources.resw editor)
                 }
             }
             else
             {
                 LOG.WriteLine(LLV.WAR, "Need to select ONE process to set work destination."); // TODO: Support Multi language with LOG.AddMes (VS2019 is now not work Resources.resw editor)
             }
             movingWorkParts.Location            = movingWorkParts.OriginalPosition;
             movingWorkParts.IsSelected          = false;
             movingWorkParts.IsCancellingMove    = true;
             movingWorkParts.IsSelectingLocation = false;
         }
         finally
         {
             foreach (var pp in Parts.GetParts <PartsJitProcess>(LAYER.JitProcess))
             {
                 pp.IsConnecting = false;
             }
             movingWorkParts.IsSelectingLocation = false;
             movingWorkParts.IsSelected          = false;
             movingWorkParts = null;
             Redraw();
         }
     }
 }
Exemple #13
0
        /// <summary>
        /// 比較文字を指定して構築
        /// </summary>
        /// <param name="pattern"></param>
        public StringMatch(string pattern)
        {
            var reopt = RegexOptions.IgnoreCase | RegexOptions.Singleline;

            var isRegularExpressioning = false; // 正規表現構文中
            var isDoubleQuatationing   = false; // ダブルクォーテーション中
            var isEscaping             = false; // エスケープシーケンス中

            var expss = new List <List <string> >();
            var str   = new StringBuilder();

            var exps = new List <string>();

            expss.Add(exps);

            pattern = pattern.Trim();
            for (var ci = 0; ci < pattern.Length; ci++)
            {
                var c = pattern[ci];
                if (isRegularExpressioning == false)
                {
                    if (c == '\\' || isEscaping)
                    {
                        isEscaping = !isEscaping;
                        str.Append(c);
                        continue;
                    }
                    if (c == '{')
                    {
                        isRegularExpressioning = true;
                    }
                    if (c == '\"')
                    {
                        isDoubleQuatationing = !isDoubleQuatationing;
                        str.Append(c);
                        continue;
                    }
                    if (c == '|' && !isDoubleQuatationing)
                    {
                        var cc = str.ToString().Trim();
                        if (cc != null)
                        {
                            exps.Add(cc);
                            expss.Add(exps = new List <string>());   // 次のOR条件を準備
                        }
                        str = new StringBuilder();
                        continue;
                    }
                    if (char.IsWhiteSpace(c) && !isDoubleQuatationing)
                    {
                        var cc = str.ToString().Trim();
                        if (string.IsNullOrEmpty(cc) == false)
                        {
                            exps.Add(cc);
                        }
                        str = new StringBuilder();
                    }
                    else
                    {
                        str.Append(c);
                    }
                }
                else
                {
                    str.Append(c);
                    if (c == '}')
                    {
                        isRegularExpressioning = false;
                        exps.Add(str.ToString());
                        str = new StringBuilder();
                    }
                }
            }
            if (string.IsNullOrEmpty(str.ToString().Trim()) == false)
            {
                exps.Add(str.ToString());
            }

            // comsで処理
            foreach (var strs in expss)
            {
                var resRemove = new List <Regex>();
                _resRemoves.Add(resRemove);   // OR条件で複数登録できる
                var resCollect = new List <Regex>();
                _resCollects.Add(resCollect); // OR条件用に複数登録できる

                var nStartMark = 0;           // ^記号の個数
                var nEndMark   = 0;           // $記号の個数
                foreach (var com in strs)
                {
                    var com2 = StringMatch.ConvertSimpleAsterisk(com);
                    if (com2.StartsWith("^"))
                    {
                        nStartMark++;
                    }
                    if (com2.EndsWith("$") && com2.StartsWith("-") == false)
                    {
                        nEndMark++;
                    }
                }
                if (nStartMark > 1)
                {
                    LOG.WriteLine(LLV.WAR, "~で始まるのフィルタ指定が、2回以上重なりましたので、うまく検索できないと思います");
                }
                if (nEndMark > 1)
                {
                    LOG.WriteLine(LLV.WAR, "~で終わるのフィルタ指定が、2回以上重なりましたので、うまく検索できないと思います");
                }

                foreach (var com in strs)
                {
                    if (com.Length < 1)
                    {
                        continue;
                    }
                    if ((com.StartsWith("{") || com.StartsWith("-{")) && com.EndsWith("}"))
                    {
                        var re = new Regex(com.Substring(com.IndexOf('{') + 1, com.Length - com.IndexOf('{') - 2), reopt);
                        if (com[0] == '-')
                        {
                            resRemove.Add(re);
                            NRemove++;
                        }
                        else
                        {
                            resCollect.Add(re);
                        }
                    }
                    else
                    {
                        var    isRemove = false;
                        string restr;
                        if (com.StartsWith("-"))
                        {
                            restr = com.Substring(1, com.Length - 1);
                            if (string.IsNullOrEmpty(restr))
                            {
                                restr = " ";    // Trimで消えたスペースを復元
                            }
                            isRemove = true;
                        }
                        else
                        {
                            restr = com;
                        }

                        // ダブルクォーテーションを取る
                        var preC   = '\0';
                        var restr2 = new StringBuilder();
                        for (var i = 0; i < restr.Length; i++)
                        {
                            var c = restr[i];
                            if (c == '\"' && preC != '\\')
                            {
                                preC = c;
                                continue;
                            }
                            restr2.Append(c);
                            preC = c;
                        }
                        restr = restr2.ToString();

                        // シンプルアスタリスク表記をサポート
                        restr = StringMatch.ConvertSimpleAsterisk(restr);

                        // アスタリスクやクエスッションを正規表現のものに変換する
                        restr = restr.Replace(".", "\\.");
                        restr = restr.Replace("*", ".*");
                        restr = restr.Replace("?", ".?");

                        // 入力のクセから開放される
                        restr = Regex.Replace(restr, "&", "\\s*&\\s*"); // & 記号の前後に、スペース有ってもなくても良くする

                        // 連続したスペースを消す
                        int ll;
                        do
                        {
                            ll    = restr.Length;
                            restr = restr.Replace("  ", " ");
                        } while (ll != restr.Length);
                        restr = restr.Replace(" ", " +");

                        if (restr.Length > 0)
                        {
                            try
                            {
                                var re = new Regex(restr, reopt);
                                if (isRemove)
                                {
                                    resRemove.Add(re);
                                    NRemove++;
                                }
                                else
                                {
                                    resCollect.Add(re);
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }

            if (NRemove == 0)
            {
                _isAllMatch = IsMatch("龗鱻麤");
            }
            else
            {
                _isAllMatch = false;
            }
        }