fix check CDM status
This commit is contained in:
+23
-15
@@ -50,22 +50,30 @@ namespace SafeBagDE70.Admin
|
|||||||
|
|
||||||
public void Emit(LogEvent logEvent)
|
public void Emit(LogEvent logEvent)
|
||||||
{
|
{
|
||||||
var message = logEvent.RenderMessage(_formatProvider);
|
try
|
||||||
var logLevel = logEvent.Level.ToString();
|
{
|
||||||
var timestampedMessage = $"[{logEvent.Timestamp:HH:mm:ss}] [{logLevel}]{message}";
|
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
|
// Ensure the message is added on the UI thread
|
||||||
App.Current.Dispatcher.Invoke(() => {
|
App.Current.Dispatcher.Invoke(() => {
|
||||||
AppData.logCollection.Add(timestampedMessage);
|
AppData.logCollection.Add(timestampedMessage);
|
||||||
if (AppData.logCollection.Count > AppData.MaxLogCount)
|
if (AppData.logCollection.Count > AppData.MaxLogCount)
|
||||||
{
|
{
|
||||||
AppData.logCollection.RemoveAt(0); // Remove the oldest event
|
AppData.logCollection.RemoveAt(0); // Remove the oldest event
|
||||||
}
|
}
|
||||||
if (AppData.logListView != null && AppData.logListView.Items.Count > 0)
|
if (AppData.logListView != null && AppData.logListView.Items.Count > 0)
|
||||||
{
|
{
|
||||||
AppData.logListView.ScrollIntoView(AppData.logListView.Items[AppData.logListView.Items.Count - 1]);
|
AppData.logListView.ScrollIntoView(AppData.logListView.Items[AppData.logListView.Items.Count - 1]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@
|
|||||||
private byte[] recv_buf = new byte[8192];
|
private byte[] recv_buf = new byte[8192];
|
||||||
private byte[] m_send_buf = new byte[8192];
|
private byte[] m_send_buf = new byte[8192];
|
||||||
public RecvData recv_dat = new RecvData();
|
public RecvData recv_dat = new RecvData();
|
||||||
private SendDataStruct send_dat = new SendDataStruct();
|
public SendDataStruct send_dat = new SendDataStruct();
|
||||||
private SendStatus cmd_result;
|
public SendStatus cmd_result;
|
||||||
private LockParam lock_param = new LockParam();
|
private LockParam lock_param = new LockParam();
|
||||||
private byte[] recv_serialset = new byte[256];
|
private byte[] recv_serialset = new byte[256];
|
||||||
private Com232C m_ccom = null;
|
private Com232C m_ccom = null;
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ namespace SafeBagDE70
|
|||||||
if (!AppData.IsInTransaction)
|
if (!AppData.IsInTransaction)
|
||||||
{
|
{
|
||||||
AppData.GetCDMState();
|
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.CDMSTATE.CDMStatus = "CDM: LỖI";
|
||||||
AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.DISCONNECT_SERIALPORT;
|
AppData.DeviceStatus.CDMStatus = (int)CDMStatusCode.DISCONNECT_SERIALPORT;
|
||||||
|
|||||||
Reference in New Issue
Block a user