From 56ba2b199b2e8483dfce01e0f25f36ee4081894b Mon Sep 17 00:00:00 2001 From: Nguyen Dinh Thuan Date: Tue, 17 Sep 2024 23:28:02 +0700 Subject: [PATCH] fix check CDM status --- Admin/LogViewerUC.xaml.cs | 38 +++++++++++++++++++++++--------------- De70Cmdv2.cs | 4 ++-- DepositSMUCv2.xaml.cs | 2 +- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Admin/LogViewerUC.xaml.cs b/Admin/LogViewerUC.xaml.cs index bc2a69d..a4873ff 100644 --- a/Admin/LogViewerUC.xaml.cs +++ b/Admin/LogViewerUC.xaml.cs @@ -50,22 +50,30 @@ namespace SafeBagDE70.Admin public void Emit(LogEvent logEvent) { - var message = logEvent.RenderMessage(_formatProvider); - var logLevel = logEvent.Level.ToString(); - var timestampedMessage = $"[{logEvent.Timestamp:HH:mm:ss}] [{logLevel}]{message}"; + try + { + var message = logEvent.RenderMessage(_formatProvider); + var logLevel = logEvent.Level.ToString(); + var timestampedMessage = $"[{logEvent.Timestamp:HH:mm:ss}] [{logLevel}]{message}"; - // Ensure the message is added on the UI thread - App.Current.Dispatcher.Invoke(() => { - AppData.logCollection.Add(timestampedMessage); - if (AppData.logCollection.Count > AppData.MaxLogCount) - { - AppData.logCollection.RemoveAt(0); // Remove the oldest event - } - if (AppData.logListView != null && AppData.logListView.Items.Count > 0) - { - AppData.logListView.ScrollIntoView(AppData.logListView.Items[AppData.logListView.Items.Count - 1]); - } - }); + // Ensure the message is added on the UI thread + App.Current.Dispatcher.Invoke(() => { + AppData.logCollection.Add(timestampedMessage); + if (AppData.logCollection.Count > AppData.MaxLogCount) + { + AppData.logCollection.RemoveAt(0); // Remove the oldest event + } + if (AppData.logListView != null && AppData.logListView.Items.Count > 0) + { + AppData.logListView.ScrollIntoView(AppData.logListView.Items[AppData.logListView.Items.Count - 1]); + } + }); + } + catch(Exception ex) + { + + } + } } } diff --git a/De70Cmdv2.cs b/De70Cmdv2.cs index dd2582c..4f0d810 100644 --- a/De70Cmdv2.cs +++ b/De70Cmdv2.cs @@ -23,8 +23,8 @@ private byte[] recv_buf = new byte[8192]; private byte[] m_send_buf = new byte[8192]; public RecvData recv_dat = new RecvData(); - private SendDataStruct send_dat = new SendDataStruct(); - private SendStatus cmd_result; + public SendDataStruct send_dat = new SendDataStruct(); + public SendStatus cmd_result; private LockParam lock_param = new LockParam(); private byte[] recv_serialset = new byte[256]; private Com232C m_ccom = null; diff --git a/DepositSMUCv2.xaml.cs b/DepositSMUCv2.xaml.cs index 05fcac7..f725357 100644 --- a/DepositSMUCv2.xaml.cs +++ b/DepositSMUCv2.xaml.cs @@ -426,7 +426,7 @@ namespace SafeBagDE70 if (!AppData.IsInTransaction) { AppData.GetCDMState(); - if (cCmdRsp.recv_dat.ret != Constants.E_OK) + if (AppData.cCmdRsp==null || AppData.cCmdRsp.cmd_result == SendStatus.SEND_DAT_ERR || AppData.cCmdRsp.cmd_result == SendStatus.SEND_ERR) { AppData.CDMSTATE.CDMStatus = "CDM: LỖI"; AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.DISCONNECT_SERIALPORT;