private static void Main() { var logger = new TcEventLogger(); try { logger.Connect(); //connect to localhost Console.WriteLine("Connected...waiting for events"); } catch (Exception ex) { Console.WriteLine("Failed to connect to event logger with exception:" + ex); } try { TcLoggedEventCollection e = logger.GetLoggedEvents(100); int count = e.Count; Console.WriteLine("Event log count: " + count); if (logger.IsConnected && count != 0) { // Call ClearAllAlarms first to ensure ClearLoggedEvents removes everything. logger.ClearAllAlarms(); logger.ClearLoggedEvents(); Console.WriteLine("Event log count after clear: " + e.Count); } } catch (Exception ex) { Console.WriteLine("Logger terminated with exception:" + ex); } }
public void LoggTest() { var eventlogger = new TcEventLogger(); eventlogger.Connect("164.4.3.67.1.1"); // "192.168.100.1.1.1"); var isConnected = eventlogger.IsConnected; eventlogger.MessageSent += obj => { Console.WriteLine(obj.EventClass); }; while (true) { var events = eventlogger.GetLoggedEvents(10000); var alarms = eventlogger.ActiveAlarms; foreach (TcLoggedEvent eEvent in events) { Console.WriteLine(eEvent.SourceName); } foreach (TcLoggedEvent alarm in alarms) { Console.WriteLine(alarm.SourceName); } Thread.Sleep(100); } }