fix check CDM status

This commit is contained in:
Nguyen Dinh Thuan
2024-09-17 23:28:02 +07:00
parent cdf3ab64f9
commit 56ba2b199b
3 changed files with 26 additions and 18 deletions
+23 -15
View File
@@ -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)
{
}
}
}
}
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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;