diff --git a/DataCheck.cs b/DataCheck.cs index da84ae6..b7bebff 100644 --- a/DataCheck.cs +++ b/DataCheck.cs @@ -10,7 +10,7 @@ namespace DataCheck } private void menu_check() { - string menuPath = @"\\SVR01\foods"; + string menuPath = @"\\JLDKTV\foods"; string menuPath_local = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foods"); if (!Directory.Exists(menuPath_local)) @@ -73,7 +73,7 @@ namespace DataCheck } private void news_check() { - string newsPath = @"\\SVR01\news"; + string newsPath = @"\\JLDKTV\news"; string newsPath_local = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "news"); if (!Directory.Exists(newsPath_local)) diff --git a/HttpServer.cs b/HttpServer.cs index 8b97cf1..bfd4757 100644 --- a/HttpServer.cs +++ b/HttpServer.cs @@ -40,9 +40,10 @@ namespace DualScreenDemo string randomFolderName = CreateRandomFolderAndRedirectHTML(baseDirectory); randomFolderPath = randomFolderName; + // 安裝包更新 string localAddress = GetLocalIPAddress(); - string externalAddress = File.Exists(@"\\svr01\txt\ip.txt") - ? File.ReadAllText(@"\\svr01\txt\ip.txt").Trim() + string externalAddress = File.Exists(@"\\JLDKTV\txt\ip.txt") + ? File.ReadAllText(@"\\JLDKTV\txt\ip.txt").Trim() : ""; _listener = new HttpListener(); @@ -427,36 +428,50 @@ namespace DualScreenDemo switch (data.Command) { case "pause": - // 执行暂停操作 + // 执行暂停操作 if (VideoPlayerForm.Instance.isPaused) { - PrimaryForm.Instance.videoPlayerForm.Play(); - PrimaryForm.Instance.pauseButton.Visible = true; - PrimaryForm.Instance.playButton.Visible = false; - PrimaryForm.Instance.syncPauseButton.Visible = true; - PrimaryForm.Instance.syncPlayButton.Visible = false; + PrimaryForm.Instance.Invoke(new System.Action(() => + { + PrimaryForm.Instance.videoPlayerForm.Play(); + PrimaryForm.Instance.pauseButton.Visible = true; + PrimaryForm.Instance.playButton.Visible = false; + PrimaryForm.Instance.syncPauseButton.Visible = true; + PrimaryForm.Instance.syncPlayButton.Visible = false; + })); } else { - PrimaryForm.Instance.videoPlayerForm.Pause(); - PrimaryForm.Instance.pauseButton.Visible = false; - PrimaryForm.Instance.playButton.Visible = true; - PrimaryForm.Instance.syncPauseButton.Visible = false; - PrimaryForm.Instance.syncPlayButton.Visible = true; + PrimaryForm.Instance.Invoke(new System.Action(() => + { + PrimaryForm.Instance.videoPlayerForm.Pause(); + PrimaryForm.Instance.pauseButton.Visible = false; + PrimaryForm.Instance.playButton.Visible = true; + PrimaryForm.Instance.syncPauseButton.Visible = false; + PrimaryForm.Instance.syncPlayButton.Visible = true; + })); } break; case "volume_up": // 执行音量增大操作 PrimaryForm.SendCommandThroughSerialPort("a2 b3 a4"); - OverlayForm.MainForm.Invoke(new System.Action(() => { + OverlayForm.MainForm.Invoke(new System.Action(() => + { OverlayForm.MainForm.ShowVolumeUpLabel(); + PrimaryForm.Instance.volumeUpTimer.Start(); + OverlayForm.MainForm.HideAllLabels(); + PrimaryForm.Instance.volumeUpTimer.Stop(); })); break; case "mic_up": // 执行麦克风增大操作 PrimaryForm.SendCommandThroughSerialPort("a2 b5 a4"); - OverlayForm.MainForm.Invoke(new System.Action(() => { + OverlayForm.MainForm.Invoke(new System.Action(() => + { OverlayForm.MainForm.ShowMicUpLabel(); + PrimaryForm.Instance.micControlTimer.Start(); + OverlayForm.MainForm.HideAllLabels(); + PrimaryForm.Instance.micControlTimer.Stop(); })); break; case "mute": @@ -485,15 +500,23 @@ namespace DualScreenDemo case "volume_down": // 执行音量减小操作 PrimaryForm.SendCommandThroughSerialPort("a2 b4 a4"); - OverlayForm.MainForm.Invoke(new System.Action(() => { + OverlayForm.MainForm.Invoke(new System.Action(() => + { OverlayForm.MainForm.ShowVolumeDownLabel(); + PrimaryForm.Instance.volumeDownTimer.Start(); + OverlayForm.MainForm.HideAllLabels(); + PrimaryForm.Instance.volumeDownTimer.Stop(); })); break; case "mic_down": // 执行麦克风减小操作 PrimaryForm.SendCommandThroughSerialPort("a2 b6 a4"); - OverlayForm.MainForm.Invoke(new System.Action(() => { + OverlayForm.MainForm.Invoke(new System.Action(() => + { OverlayForm.MainForm.ShowMicDownLabel(); + PrimaryForm.Instance.micControlTimer.Start(); + OverlayForm.MainForm.HideAllLabels(); + PrimaryForm.Instance.micControlTimer.Stop(); })); break; case "original_song": diff --git a/Program.cs b/Program.cs index bc1feba..425a2e1 100644 --- a/Program.cs +++ b/Program.cs @@ -2,7 +2,7 @@ using System.IO; using Microsoft.Win32; using System.Diagnostics; using DBObj; -using HeartbeatSender; +using DataCheck; namespace DualScreenDemo { @@ -17,16 +17,28 @@ namespace DualScreenDemo [STAThread] static void Main() { + + Console.WriteLine("隱藏滑鼠游標"); - // Cursor.Hide(); + Cursor.Hide(); AppDomain.CurrentDomain.ProcessExit += (s, e) => { Cursor.Show(); }; + Console.WriteLine("正在喚醒SVR裝置(每3分鐘呼叫一次)..."); + _ = Task.Run(async () => + { + while (true) + { + _ = Directory.Exists(@"\\svr01\video"); + _ = Directory.Exists(@"\\svr02\video"); + await Task.Delay(180000); // 每3min送一次 + } + }); + + // Console.WriteLine("正在與中控取得聯繫..."); + var sender = new HeartbeatSender.heartbeatSender(); - Console.WriteLine("正在與中控取得聯繫"); - /*var sender = new HeartbeatSender.heartbeatSender(); - // 同步呼叫非同步登入取得 token bool loginSuccess = sender.LoginAndGetTokenAsync().GetAwaiter().GetResult(); @@ -35,21 +47,26 @@ namespace DualScreenDemo // 先送一次心跳 (同步呼叫) sender.SendHeartbeatAsync().GetAwaiter().GetResult(); - // 背景持續每3秒送心跳 + // 背景持續每5分鐘送心跳 _ = Task.Run(async () => { while (true) { await sender.SendHeartbeatAsync(); - await Task.Delay(300000); // 每3秒送一次 + await Task.Delay(300000); // 每5min送一次 } }); + Console.WriteLine("正在發送心跳中..."); } else { Console.WriteLine("登入失敗,無法送出心跳"); } - */ + //之後需要做添加同步菜單+酒單+背景圖(若圖規格有做正規化) + // DataCheck.cs 有預寫好相關流程函式 + Console.WriteLine("更新菜單和酒單..."); + dataCheck Checkprocess = new dataCheck(); + try { // COM 初始化 @@ -62,7 +79,7 @@ namespace DualScreenDemo // 初始化管理器 songListManager = new SongListManager(); // 使用单例 - //artistManager = new ArtistManager(); + //artistManager = new ArtistManager(); var commandHandler = new CommandHandler(songListManager); serialPortManager = new SerialPortManager(commandHandler); @@ -106,9 +123,22 @@ namespace DualScreenDemo primaryForm.ShowSendOffScreen(); }; } + WatchDog _watchDog = new WatchDog( + () => VideoPlayerForm.Instance.GetCurrentVideoStatus(), + () => primaryForm.IsAppResponsive() + ); + _watchDog.Start(); + Console.WriteLine("啟動WatchDog進行監聽"); + AppDomain.CurrentDomain.ProcessExit += (s, e) => + { + _watchDog.Stop(); + }; + primaryForm.Show(); Application.Run(primaryForm); + + } catch (Exception ex) {