diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml index 7c0dc75..88f4298 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml +++ b/Correlator/Dialog/CheckResponseDialog.xaml @@ -8,6 +8,7 @@ Height="560" AllowsTransparency="True" Background="Transparent" + Closed="CheckResponseDialog_OnClosed" DataContext="{Binding CheckResponse, Source={StaticResource Locator}}" Loaded="CheckResponseDialog_OnLoaded" ResizeMode="NoResize" diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml index 7c0dc75..88f4298 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml +++ b/Correlator/Dialog/CheckResponseDialog.xaml @@ -8,6 +8,7 @@ Height="560" AllowsTransparency="True" Background="Transparent" + Closed="CheckResponseDialog_OnClosed" DataContext="{Binding CheckResponse, Source={StaticResource Locator}}" Loaded="CheckResponseDialog_OnLoaded" ResizeMode="NoResize" diff --git a/Correlator/Dialog/CheckResponseDialog.xaml.cs b/Correlator/Dialog/CheckResponseDialog.xaml.cs index 78902ef..c2aa94c 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml.cs +++ b/Correlator/Dialog/CheckResponseDialog.xaml.cs @@ -1,6 +1,8 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Media; using System.Windows.Shapes; +using System.Windows.Threading; using Correlator.SensorHubTag; using Correlator.Util; @@ -11,7 +13,17 @@ /// public partial class CheckResponseDialog : Window { - public CheckResponseDialog(byte[] timeBytes) + private readonly DispatcherTimer _redResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + private readonly DispatcherTimer _blueResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + public CheckResponseDialog() { InitializeComponent(); @@ -31,14 +43,11 @@ RedCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1, timeBytes); - for (var i = 0; i < RedResponsePanel.Children.Count; i++) - { - var child = RedResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") - { - } - } + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1); + + _blueResponseTimer.Stop(); + _redResponseTimer.Start(); }; for (var i = 0; i < 60; i++) @@ -55,12 +64,37 @@ BlueCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2, timeBytes); - for (var i = 0; i < BlueResponsePanel.Children.Count; i++) + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2); + + _redResponseTimer.Stop(); + _blueResponseTimer.Start(); + }; + + _redResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) { - var child = BlueResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") + if (FlowStatus.SeqCaches.Contains((byte)i)) { + if (RedResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } + } + } + }; + + _blueResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) + { + if (FlowStatus.SeqCaches.Contains((byte)i)) + { + if (BlueResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } } } }; @@ -70,5 +104,10 @@ { MouseDown += delegate { DragMove(); }; } + + private void CheckResponseDialog_OnClosed(object sender, EventArgs e) + { + FlowStatus.IsShowing = false; + } } } \ No newline at end of file diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml index 7c0dc75..88f4298 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml +++ b/Correlator/Dialog/CheckResponseDialog.xaml @@ -8,6 +8,7 @@ Height="560" AllowsTransparency="True" Background="Transparent" + Closed="CheckResponseDialog_OnClosed" DataContext="{Binding CheckResponse, Source={StaticResource Locator}}" Loaded="CheckResponseDialog_OnLoaded" ResizeMode="NoResize" diff --git a/Correlator/Dialog/CheckResponseDialog.xaml.cs b/Correlator/Dialog/CheckResponseDialog.xaml.cs index 78902ef..c2aa94c 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml.cs +++ b/Correlator/Dialog/CheckResponseDialog.xaml.cs @@ -1,6 +1,8 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Media; using System.Windows.Shapes; +using System.Windows.Threading; using Correlator.SensorHubTag; using Correlator.Util; @@ -11,7 +13,17 @@ /// public partial class CheckResponseDialog : Window { - public CheckResponseDialog(byte[] timeBytes) + private readonly DispatcherTimer _redResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + private readonly DispatcherTimer _blueResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + public CheckResponseDialog() { InitializeComponent(); @@ -31,14 +43,11 @@ RedCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1, timeBytes); - for (var i = 0; i < RedResponsePanel.Children.Count; i++) - { - var child = RedResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") - { - } - } + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1); + + _blueResponseTimer.Stop(); + _redResponseTimer.Start(); }; for (var i = 0; i < 60; i++) @@ -55,12 +64,37 @@ BlueCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2, timeBytes); - for (var i = 0; i < BlueResponsePanel.Children.Count; i++) + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2); + + _redResponseTimer.Stop(); + _blueResponseTimer.Start(); + }; + + _redResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) { - var child = BlueResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") + if (FlowStatus.SeqCaches.Contains((byte)i)) { + if (RedResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } + } + } + }; + + _blueResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) + { + if (FlowStatus.SeqCaches.Contains((byte)i)) + { + if (BlueResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } } } }; @@ -70,5 +104,10 @@ { MouseDown += delegate { DragMove(); }; } + + private void CheckResponseDialog_OnClosed(object sender, EventArgs e) + { + FlowStatus.IsShowing = false; + } } } \ No newline at end of file diff --git a/Correlator/Util/CommandSender.cs b/Correlator/Util/CommandSender.cs index e7448d4..7570df9 100644 --- a/Correlator/Util/CommandSender.cs +++ b/Correlator/Util/CommandSender.cs @@ -113,10 +113,14 @@ byte[] oidTag = { 0x40, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 }; //获取时间(年-月-日-时-分-秒),年号-2000 + FlowStatus.HydrophoneWakeUpTimeBytes = new[] + { StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec }; byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data @@ -160,8 +164,7 @@ /// /// /// - /// - public static void StartCheckResponse(SerialPort sp, string devCode, byte[] timeBytes) + public static void StartCheckResponse(SerialPort sp, string devCode) { try { @@ -208,7 +211,9 @@ byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - timeBytes[0], timeBytes[1], timeBytes[2], timeBytes[3], timeBytes[4], timeBytes[5] + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml index 7c0dc75..88f4298 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml +++ b/Correlator/Dialog/CheckResponseDialog.xaml @@ -8,6 +8,7 @@ Height="560" AllowsTransparency="True" Background="Transparent" + Closed="CheckResponseDialog_OnClosed" DataContext="{Binding CheckResponse, Source={StaticResource Locator}}" Loaded="CheckResponseDialog_OnLoaded" ResizeMode="NoResize" diff --git a/Correlator/Dialog/CheckResponseDialog.xaml.cs b/Correlator/Dialog/CheckResponseDialog.xaml.cs index 78902ef..c2aa94c 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml.cs +++ b/Correlator/Dialog/CheckResponseDialog.xaml.cs @@ -1,6 +1,8 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Media; using System.Windows.Shapes; +using System.Windows.Threading; using Correlator.SensorHubTag; using Correlator.Util; @@ -11,7 +13,17 @@ /// public partial class CheckResponseDialog : Window { - public CheckResponseDialog(byte[] timeBytes) + private readonly DispatcherTimer _redResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + private readonly DispatcherTimer _blueResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + public CheckResponseDialog() { InitializeComponent(); @@ -31,14 +43,11 @@ RedCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1, timeBytes); - for (var i = 0; i < RedResponsePanel.Children.Count; i++) - { - var child = RedResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") - { - } - } + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1); + + _blueResponseTimer.Stop(); + _redResponseTimer.Start(); }; for (var i = 0; i < 60; i++) @@ -55,12 +64,37 @@ BlueCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2, timeBytes); - for (var i = 0; i < BlueResponsePanel.Children.Count; i++) + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2); + + _redResponseTimer.Stop(); + _blueResponseTimer.Start(); + }; + + _redResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) { - var child = BlueResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") + if (FlowStatus.SeqCaches.Contains((byte)i)) { + if (RedResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } + } + } + }; + + _blueResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) + { + if (FlowStatus.SeqCaches.Contains((byte)i)) + { + if (BlueResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } } } }; @@ -70,5 +104,10 @@ { MouseDown += delegate { DragMove(); }; } + + private void CheckResponseDialog_OnClosed(object sender, EventArgs e) + { + FlowStatus.IsShowing = false; + } } } \ No newline at end of file diff --git a/Correlator/Util/CommandSender.cs b/Correlator/Util/CommandSender.cs index e7448d4..7570df9 100644 --- a/Correlator/Util/CommandSender.cs +++ b/Correlator/Util/CommandSender.cs @@ -113,10 +113,14 @@ byte[] oidTag = { 0x40, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 }; //获取时间(年-月-日-时-分-秒),年号-2000 + FlowStatus.HydrophoneWakeUpTimeBytes = new[] + { StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec }; byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data @@ -160,8 +164,7 @@ /// /// /// - /// - public static void StartCheckResponse(SerialPort sp, string devCode, byte[] timeBytes) + public static void StartCheckResponse(SerialPort sp, string devCode) { try { @@ -208,7 +211,9 @@ byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - timeBytes[0], timeBytes[1], timeBytes[2], timeBytes[3], timeBytes[4], timeBytes[5] + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data diff --git a/Correlator/Util/FlowStatus.cs b/Correlator/Util/FlowStatus.cs index 57b294a..e7af20b 100644 --- a/Correlator/Util/FlowStatus.cs +++ b/Correlator/Util/FlowStatus.cs @@ -1,4 +1,5 @@ -using Correlator.Model; +using System.Collections.Generic; +using Correlator.Model; namespace Correlator.Util { @@ -30,5 +31,20 @@ //水听器模式 public static bool IsHydrophone = false; + + //点名对话框是否已显示 + public static bool IsShowing = false; + + //数据包index + public static readonly List SeqCaches = new List(); + + //水听器下发唤醒指令时间戳 + public static byte[] HydrophoneWakeUpTimeBytes = new byte[6]; + + //水听器红色信号接收器数据 + public static List RedSensorBytes = new List(); + + //水听器蓝色信号接收器数据 + public static List BlueSensorBytes = new List(); } } \ No newline at end of file diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml index 7c0dc75..88f4298 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml +++ b/Correlator/Dialog/CheckResponseDialog.xaml @@ -8,6 +8,7 @@ Height="560" AllowsTransparency="True" Background="Transparent" + Closed="CheckResponseDialog_OnClosed" DataContext="{Binding CheckResponse, Source={StaticResource Locator}}" Loaded="CheckResponseDialog_OnLoaded" ResizeMode="NoResize" diff --git a/Correlator/Dialog/CheckResponseDialog.xaml.cs b/Correlator/Dialog/CheckResponseDialog.xaml.cs index 78902ef..c2aa94c 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml.cs +++ b/Correlator/Dialog/CheckResponseDialog.xaml.cs @@ -1,6 +1,8 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Media; using System.Windows.Shapes; +using System.Windows.Threading; using Correlator.SensorHubTag; using Correlator.Util; @@ -11,7 +13,17 @@ /// public partial class CheckResponseDialog : Window { - public CheckResponseDialog(byte[] timeBytes) + private readonly DispatcherTimer _redResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + private readonly DispatcherTimer _blueResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + public CheckResponseDialog() { InitializeComponent(); @@ -31,14 +43,11 @@ RedCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1, timeBytes); - for (var i = 0; i < RedResponsePanel.Children.Count; i++) - { - var child = RedResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") - { - } - } + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1); + + _blueResponseTimer.Stop(); + _redResponseTimer.Start(); }; for (var i = 0; i < 60; i++) @@ -55,12 +64,37 @@ BlueCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2, timeBytes); - for (var i = 0; i < BlueResponsePanel.Children.Count; i++) + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2); + + _redResponseTimer.Stop(); + _blueResponseTimer.Start(); + }; + + _redResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) { - var child = BlueResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") + if (FlowStatus.SeqCaches.Contains((byte)i)) { + if (RedResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } + } + } + }; + + _blueResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) + { + if (FlowStatus.SeqCaches.Contains((byte)i)) + { + if (BlueResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } } } }; @@ -70,5 +104,10 @@ { MouseDown += delegate { DragMove(); }; } + + private void CheckResponseDialog_OnClosed(object sender, EventArgs e) + { + FlowStatus.IsShowing = false; + } } } \ No newline at end of file diff --git a/Correlator/Util/CommandSender.cs b/Correlator/Util/CommandSender.cs index e7448d4..7570df9 100644 --- a/Correlator/Util/CommandSender.cs +++ b/Correlator/Util/CommandSender.cs @@ -113,10 +113,14 @@ byte[] oidTag = { 0x40, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 }; //获取时间(年-月-日-时-分-秒),年号-2000 + FlowStatus.HydrophoneWakeUpTimeBytes = new[] + { StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec }; byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data @@ -160,8 +164,7 @@ /// /// /// - /// - public static void StartCheckResponse(SerialPort sp, string devCode, byte[] timeBytes) + public static void StartCheckResponse(SerialPort sp, string devCode) { try { @@ -208,7 +211,9 @@ byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - timeBytes[0], timeBytes[1], timeBytes[2], timeBytes[3], timeBytes[4], timeBytes[5] + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data diff --git a/Correlator/Util/FlowStatus.cs b/Correlator/Util/FlowStatus.cs index 57b294a..e7af20b 100644 --- a/Correlator/Util/FlowStatus.cs +++ b/Correlator/Util/FlowStatus.cs @@ -1,4 +1,5 @@ -using Correlator.Model; +using System.Collections.Generic; +using Correlator.Model; namespace Correlator.Util { @@ -30,5 +31,20 @@ //水听器模式 public static bool IsHydrophone = false; + + //点名对话框是否已显示 + public static bool IsShowing = false; + + //数据包index + public static readonly List SeqCaches = new List(); + + //水听器下发唤醒指令时间戳 + public static byte[] HydrophoneWakeUpTimeBytes = new byte[6]; + + //水听器红色信号接收器数据 + public static List RedSensorBytes = new List(); + + //水听器蓝色信号接收器数据 + public static List BlueSensorBytes = new List(); } } \ No newline at end of file diff --git a/Correlator/Util/SerialPortManager.cs b/Correlator/Util/SerialPortManager.cs index 0e43937..248847f 100644 --- a/Correlator/Util/SerialPortManager.cs +++ b/Correlator/Util/SerialPortManager.cs @@ -77,16 +77,20 @@ case 11293: //数据采集 HandleCorrelatorData(strDeviceId, tags); break; - case 30: //显示点名弹窗 + case 30: if (FlowStatus.IsHydrophone && FlowStatus.CanCollectData) { //A3 20 00 18 21 17 00 08 22 01 01 22 01 0B 82 01 10 00 00 51 00 06 17 06 19 02 1A 04 88 38 // 解析年月日时分秒 - var timeBytes = new byte[6]; - Array.Copy(receiveData, 22, timeBytes, 0, 6); Application.Current.Dispatcher.Invoke(delegate { - Messenger.Default.Send(timeBytes, MessengerToken.ShowCheckResponseDialog); + //显示点名弹窗 + if (!FlowStatus.IsShowing) + { + //因为是广播发的数据,所以会收到两条回复,但是只需要显示一次对话框 + Messenger.Default.Send("", MessengerToken.ShowCheckResponseDialog); + FlowStatus.IsShowing = true; + } }); } diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml index 7c0dc75..88f4298 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml +++ b/Correlator/Dialog/CheckResponseDialog.xaml @@ -8,6 +8,7 @@ Height="560" AllowsTransparency="True" Background="Transparent" + Closed="CheckResponseDialog_OnClosed" DataContext="{Binding CheckResponse, Source={StaticResource Locator}}" Loaded="CheckResponseDialog_OnLoaded" ResizeMode="NoResize" diff --git a/Correlator/Dialog/CheckResponseDialog.xaml.cs b/Correlator/Dialog/CheckResponseDialog.xaml.cs index 78902ef..c2aa94c 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml.cs +++ b/Correlator/Dialog/CheckResponseDialog.xaml.cs @@ -1,6 +1,8 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Media; using System.Windows.Shapes; +using System.Windows.Threading; using Correlator.SensorHubTag; using Correlator.Util; @@ -11,7 +13,17 @@ /// public partial class CheckResponseDialog : Window { - public CheckResponseDialog(byte[] timeBytes) + private readonly DispatcherTimer _redResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + private readonly DispatcherTimer _blueResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + public CheckResponseDialog() { InitializeComponent(); @@ -31,14 +43,11 @@ RedCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1, timeBytes); - for (var i = 0; i < RedResponsePanel.Children.Count; i++) - { - var child = RedResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") - { - } - } + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1); + + _blueResponseTimer.Stop(); + _redResponseTimer.Start(); }; for (var i = 0; i < 60; i++) @@ -55,12 +64,37 @@ BlueCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2, timeBytes); - for (var i = 0; i < BlueResponsePanel.Children.Count; i++) + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2); + + _redResponseTimer.Stop(); + _blueResponseTimer.Start(); + }; + + _redResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) { - var child = BlueResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") + if (FlowStatus.SeqCaches.Contains((byte)i)) { + if (RedResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } + } + } + }; + + _blueResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) + { + if (FlowStatus.SeqCaches.Contains((byte)i)) + { + if (BlueResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } } } }; @@ -70,5 +104,10 @@ { MouseDown += delegate { DragMove(); }; } + + private void CheckResponseDialog_OnClosed(object sender, EventArgs e) + { + FlowStatus.IsShowing = false; + } } } \ No newline at end of file diff --git a/Correlator/Util/CommandSender.cs b/Correlator/Util/CommandSender.cs index e7448d4..7570df9 100644 --- a/Correlator/Util/CommandSender.cs +++ b/Correlator/Util/CommandSender.cs @@ -113,10 +113,14 @@ byte[] oidTag = { 0x40, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 }; //获取时间(年-月-日-时-分-秒),年号-2000 + FlowStatus.HydrophoneWakeUpTimeBytes = new[] + { StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec }; byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data @@ -160,8 +164,7 @@ /// /// /// - /// - public static void StartCheckResponse(SerialPort sp, string devCode, byte[] timeBytes) + public static void StartCheckResponse(SerialPort sp, string devCode) { try { @@ -208,7 +211,9 @@ byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - timeBytes[0], timeBytes[1], timeBytes[2], timeBytes[3], timeBytes[4], timeBytes[5] + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data diff --git a/Correlator/Util/FlowStatus.cs b/Correlator/Util/FlowStatus.cs index 57b294a..e7af20b 100644 --- a/Correlator/Util/FlowStatus.cs +++ b/Correlator/Util/FlowStatus.cs @@ -1,4 +1,5 @@ -using Correlator.Model; +using System.Collections.Generic; +using Correlator.Model; namespace Correlator.Util { @@ -30,5 +31,20 @@ //水听器模式 public static bool IsHydrophone = false; + + //点名对话框是否已显示 + public static bool IsShowing = false; + + //数据包index + public static readonly List SeqCaches = new List(); + + //水听器下发唤醒指令时间戳 + public static byte[] HydrophoneWakeUpTimeBytes = new byte[6]; + + //水听器红色信号接收器数据 + public static List RedSensorBytes = new List(); + + //水听器蓝色信号接收器数据 + public static List BlueSensorBytes = new List(); } } \ No newline at end of file diff --git a/Correlator/Util/SerialPortManager.cs b/Correlator/Util/SerialPortManager.cs index 0e43937..248847f 100644 --- a/Correlator/Util/SerialPortManager.cs +++ b/Correlator/Util/SerialPortManager.cs @@ -77,16 +77,20 @@ case 11293: //数据采集 HandleCorrelatorData(strDeviceId, tags); break; - case 30: //显示点名弹窗 + case 30: if (FlowStatus.IsHydrophone && FlowStatus.CanCollectData) { //A3 20 00 18 21 17 00 08 22 01 01 22 01 0B 82 01 10 00 00 51 00 06 17 06 19 02 1A 04 88 38 // 解析年月日时分秒 - var timeBytes = new byte[6]; - Array.Copy(receiveData, 22, timeBytes, 0, 6); Application.Current.Dispatcher.Invoke(delegate { - Messenger.Default.Send(timeBytes, MessengerToken.ShowCheckResponseDialog); + //显示点名弹窗 + if (!FlowStatus.IsShowing) + { + //因为是广播发的数据,所以会收到两条回复,但是只需要显示一次对话框 + Messenger.Default.Send("", MessengerToken.ShowCheckResponseDialog); + FlowStatus.IsShowing = true; + } }); } diff --git a/Correlator/ViewModel/HomePageProViewModel.cs b/Correlator/ViewModel/HomePageProViewModel.cs index 2e4adba..a6f15df 100644 --- a/Correlator/ViewModel/HomePageProViewModel.cs +++ b/Correlator/ViewModel/HomePageProViewModel.cs @@ -554,8 +554,12 @@ }); //水听器 - Messenger.Default.Register(this, MessengerToken.ShowCheckResponseDialog, - timeBytes => { new CheckResponseDialog(timeBytes) { Owner = _homePageWindow }.Show(); }); + Messenger.Default.Register(this, MessengerToken.ShowCheckResponseDialog, s => + { + _runningSeconds = 0; + _runningTimer.Stop(); + new CheckResponseDialog { Owner = _homePageWindow }.Show(); + }); } /// diff --git a/Correlator/Dialog/CheckResponseDialog.xaml b/Correlator/Dialog/CheckResponseDialog.xaml index 7c0dc75..88f4298 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml +++ b/Correlator/Dialog/CheckResponseDialog.xaml @@ -8,6 +8,7 @@ Height="560" AllowsTransparency="True" Background="Transparent" + Closed="CheckResponseDialog_OnClosed" DataContext="{Binding CheckResponse, Source={StaticResource Locator}}" Loaded="CheckResponseDialog_OnLoaded" ResizeMode="NoResize" diff --git a/Correlator/Dialog/CheckResponseDialog.xaml.cs b/Correlator/Dialog/CheckResponseDialog.xaml.cs index 78902ef..c2aa94c 100644 --- a/Correlator/Dialog/CheckResponseDialog.xaml.cs +++ b/Correlator/Dialog/CheckResponseDialog.xaml.cs @@ -1,6 +1,8 @@ -using System.Windows; +using System; +using System.Windows; using System.Windows.Media; using System.Windows.Shapes; +using System.Windows.Threading; using Correlator.SensorHubTag; using Correlator.Util; @@ -11,7 +13,17 @@ /// public partial class CheckResponseDialog : Window { - public CheckResponseDialog(byte[] timeBytes) + private readonly DispatcherTimer _redResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + private readonly DispatcherTimer _blueResponseTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1) + }; + + public CheckResponseDialog() { InitializeComponent(); @@ -31,14 +43,11 @@ RedCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1, timeBytes); - for (var i = 0; i < RedResponsePanel.Children.Count; i++) - { - var child = RedResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") - { - } - } + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev1); + + _blueResponseTimer.Stop(); + _redResponseTimer.Start(); }; for (var i = 0; i < 60; i++) @@ -55,12 +64,37 @@ BlueCheckButton.Click += delegate { - CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2, timeBytes); - for (var i = 0; i < BlueResponsePanel.Children.Count; i++) + FlowStatus.SeqCaches.Clear(); + CommandSender.StartCheckResponse(SerialPortManager.Get.Sp, DevCode.Dev2); + + _redResponseTimer.Stop(); + _blueResponseTimer.Start(); + }; + + _redResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) { - var child = BlueResponsePanel.Children[i] as Ellipse; - if (child?.Fill.ToString() == "#FFD3D3D3") + if (FlowStatus.SeqCaches.Contains((byte)i)) { + if (RedResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } + } + } + }; + + _blueResponseTimer.Tick += delegate + { + for (var i = 1; i <= 60; i++) + { + if (FlowStatus.SeqCaches.Contains((byte)i)) + { + if (BlueResponsePanel.Children[i - 1] is Ellipse child) + { + child.Fill = new SolidColorBrush(Colors.LimeGreen); + } } } }; @@ -70,5 +104,10 @@ { MouseDown += delegate { DragMove(); }; } + + private void CheckResponseDialog_OnClosed(object sender, EventArgs e) + { + FlowStatus.IsShowing = false; + } } } \ No newline at end of file diff --git a/Correlator/Util/CommandSender.cs b/Correlator/Util/CommandSender.cs index e7448d4..7570df9 100644 --- a/Correlator/Util/CommandSender.cs +++ b/Correlator/Util/CommandSender.cs @@ -113,10 +113,14 @@ byte[] oidTag = { 0x40, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 }; //获取时间(年-月-日-时-分-秒),年号-2000 + FlowStatus.HydrophoneWakeUpTimeBytes = new[] + { StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec }; byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - StringUtil.Year, StringUtil.Mon, StringUtil.Day, StringUtil.Hor, StringUtil.Min, StringUtil.Sec + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data @@ -160,8 +164,7 @@ /// /// /// - /// - public static void StartCheckResponse(SerialPort sp, string devCode, byte[] timeBytes) + public static void StartCheckResponse(SerialPort sp, string devCode) { try { @@ -208,7 +211,9 @@ byte[] timeTag = { 0x10, 0x00, 0x00, 0x51, 0x00, 0x06, - timeBytes[0], timeBytes[1], timeBytes[2], timeBytes[3], timeBytes[4], timeBytes[5] + FlowStatus.HydrophoneWakeUpTimeBytes[0], FlowStatus.HydrophoneWakeUpTimeBytes[1], + FlowStatus.HydrophoneWakeUpTimeBytes[2], FlowStatus.HydrophoneWakeUpTimeBytes[3], + FlowStatus.HydrophoneWakeUpTimeBytes[4], FlowStatus.HydrophoneWakeUpTimeBytes[5] }; //时间oid //wrap the whole data diff --git a/Correlator/Util/FlowStatus.cs b/Correlator/Util/FlowStatus.cs index 57b294a..e7af20b 100644 --- a/Correlator/Util/FlowStatus.cs +++ b/Correlator/Util/FlowStatus.cs @@ -1,4 +1,5 @@ -using Correlator.Model; +using System.Collections.Generic; +using Correlator.Model; namespace Correlator.Util { @@ -30,5 +31,20 @@ //水听器模式 public static bool IsHydrophone = false; + + //点名对话框是否已显示 + public static bool IsShowing = false; + + //数据包index + public static readonly List SeqCaches = new List(); + + //水听器下发唤醒指令时间戳 + public static byte[] HydrophoneWakeUpTimeBytes = new byte[6]; + + //水听器红色信号接收器数据 + public static List RedSensorBytes = new List(); + + //水听器蓝色信号接收器数据 + public static List BlueSensorBytes = new List(); } } \ No newline at end of file diff --git a/Correlator/Util/SerialPortManager.cs b/Correlator/Util/SerialPortManager.cs index 0e43937..248847f 100644 --- a/Correlator/Util/SerialPortManager.cs +++ b/Correlator/Util/SerialPortManager.cs @@ -77,16 +77,20 @@ case 11293: //数据采集 HandleCorrelatorData(strDeviceId, tags); break; - case 30: //显示点名弹窗 + case 30: if (FlowStatus.IsHydrophone && FlowStatus.CanCollectData) { //A3 20 00 18 21 17 00 08 22 01 01 22 01 0B 82 01 10 00 00 51 00 06 17 06 19 02 1A 04 88 38 // 解析年月日时分秒 - var timeBytes = new byte[6]; - Array.Copy(receiveData, 22, timeBytes, 0, 6); Application.Current.Dispatcher.Invoke(delegate { - Messenger.Default.Send(timeBytes, MessengerToken.ShowCheckResponseDialog); + //显示点名弹窗 + if (!FlowStatus.IsShowing) + { + //因为是广播发的数据,所以会收到两条回复,但是只需要显示一次对话框 + Messenger.Default.Send("", MessengerToken.ShowCheckResponseDialog); + FlowStatus.IsShowing = true; + } }); } diff --git a/Correlator/ViewModel/HomePageProViewModel.cs b/Correlator/ViewModel/HomePageProViewModel.cs index 2e4adba..a6f15df 100644 --- a/Correlator/ViewModel/HomePageProViewModel.cs +++ b/Correlator/ViewModel/HomePageProViewModel.cs @@ -554,8 +554,12 @@ }); //水听器 - Messenger.Default.Register(this, MessengerToken.ShowCheckResponseDialog, - timeBytes => { new CheckResponseDialog(timeBytes) { Owner = _homePageWindow }.Show(); }); + Messenger.Default.Register(this, MessengerToken.ShowCheckResponseDialog, s => + { + _runningSeconds = 0; + _runningTimer.Stop(); + new CheckResponseDialog { Owner = _homePageWindow }.Show(); + }); } /// diff --git a/Correlator/ViewModel/HomePageViewModel.cs b/Correlator/ViewModel/HomePageViewModel.cs index f9b5892..b517a30 100644 --- a/Correlator/ViewModel/HomePageViewModel.cs +++ b/Correlator/ViewModel/HomePageViewModel.cs @@ -483,7 +483,7 @@ }); Messenger.Default.Register(this, MessengerToken.ShowCheckResponseDialog, - timeBytes => { new CheckResponseDialog(timeBytes) { Owner = _homePageWindow }.ShowDialog(); }); + timeBytes => { new CheckResponseDialog { Owner = _homePageWindow }.Show(); }); Messenger.Default.Register(this, MessengerToken.StartCalculate, it => {