Exemplo n.º 1
0
        // Line number
        // Account number
        // Code
        // Zone
        // Area
        // User
        // Timestamp
        // New/Old
        // ASCII
        public static SiaAlarm Process(string data)
        {
            var alarm = new SiaAlarm
            {
                Interface = GetInterface(data.Substring(0, 4)) //Line number
            };

            AlarmFormat(alarm, data);

            return(alarm);
        }
Exemplo n.º 2
0
        private static string GetEventString(SiaAlarm alrm)
        {
            var s = $"Event: {alrm.Code} - {alrm.Ascii}";

            if (!string.IsNullOrEmpty(alrm.Zone))
            {
                s += $"\tZone: {alrm.Zone}";
            }
            if (!string.IsNullOrEmpty(alrm.Area))
            {
                s += $"\tArea: {alrm.Area}";
            }
            if (!string.IsNullOrEmpty(alrm.User))
            {
                s += $"\tUser: {alrm.User}";
            }

            return(s);
        }
Exemplo n.º 3
0
 public async Task SendToWebhook(SiaAlarm alarm)
 => await SendToWebhook(accountsHandler.GetUsername(alarm.AccountNumber), SiaAlarm.GetWebhookAlarmString(alarm));
Exemplo n.º 4
0
 public void LogAlarm(SiaAlarm alarm)
 {
     lock (logLock) alarms.Add(alarm);
 }
Exemplo n.º 5
0
 public static string GetWebhookAlarmString(SiaAlarm alrm)
 => $"Account: {alrm.AccountNumber} ({alrm.Interface})\n{GetEventString(alrm)}\n";