public void AppendAlarmLogMsg(string msg) { try { int th = Vehicle.MainFlowConfig.StringBuilderMax; int thHalf = th / 2; lock (SbAlarmMsg) { if (SbAlarmMsg.Length + msg.Length > th) { SbAlarmMsg.Remove(0, thHalf); } SbAlarmMsg.AppendLine($"{DateTime.Now:HH:mm:ss} {msg}"); } } catch (Exception ex) { LogException(GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, ex.Message); } }
public void ResetAllAlarms() { try { lock (dicHappeningAlarms) { dicHappeningAlarms = new ConcurrentDictionary <int, Alarm>(); LastAlarmMsg = ""; } string resetMessage = "Reset All Alarms."; LogAlarmHistory(resetMessage); AppendAlarmHistoryLogMsg(resetMessage); SbAlarmMsg.Clear(); //AlarmLogMsg = string.Concat(DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss.fff"), "\t", resetMessage); } catch (Exception ex) { LogException(GetType().Name + ":" + MethodBase.GetCurrentMethod().Name, ex.Message); } }