Exemple #1
0
        static int Main(string[] args)
        {
            Logger.EnableLogger();
            if (args.Length < 1 || args.Length > 2)
            {
                Console.WriteLine("Usage: HydrometNotifications.exe alarm_group [\"m/d/yyyy hh:mm\"]");
                Console.WriteLine("Where: alarm_group argument is required");
                Console.WriteLine("[m/d/yyyy] is an optional date argument the default is now");
                Console.WriteLine("");
                return(-1);
            }

            Performance perf = new Performance();

            var alarms = new AlarmGroup(args[0]);

            DateTime t = DateTime.Now;

            if (args.Length == 2)
            {
                t = DateTime.Parse(args[1]);
            }
            else
            if (alarms.Interval.ToLower() == "d")
            {
                t = DateTime.Now.Date.AddDays(-1); // hydromet daily
            }


            alarms.ProcessGroup(t);
            perf.Report();
            PostgreSQL.ClearAllPools();
            return(0);
        }
Exemple #2
0
        public void AnyFlags()
        {
            var a = new AlarmGroup("test_flags", true, true);

            a.UpdateRows("active", false);
            a.ProcessGroup(new DateTime(2013, 2, 15));

            Assert.AreEqual(1, a.AlarmCount);
        }
Exemple #3
0
        public void SiteDown()
        {
            var a = new AlarmGroup("test_down", true, true);

            a.UpdateRows("active", false);
            a.ProcessGroup(DateTime.Now);  // non existant site will give error

            Assert.AreEqual(1, a.AlarmCount);
        }
Exemple #4
0
        public void BasoApril2014()
        {
            DateTime t = new DateTime(2014, 4, 10); // this should NOT create an alarm.

            var a = new AlarmGroup("test_baso", false, true);

            a.UpdateRows("active", false);
            a.ProcessGroup(t);

            Assert.AreEqual(0, a.AlarmCount);
        }
Exemple #5
0
        public void BasoDuringWinter()
        {
            DateTime t = new DateTime(2001, 11, 15); // no minimums during November

            var a = new AlarmGroup("test_baso", false, true);

            a.UpdateRows("active", false);
            a.ProcessGroup(t);

            Assert.AreEqual(0, a.AlarmCount);
        }
Exemple #6
0
        public void TestStateChanges()
        {
            DateTime t = new DateTime(1994, 2, 26);
            var      a = new AlarmGroup("test_rogue_state", false, true);

            a.ProcessGroup(t);
            Assert.AreEqual(0, a.AlarmCount);

            t = new DateTime(1994, 2, 27);
            a = new AlarmGroup("test_rogue_state", false, true);
            a.ProcessGroup(t);
            Assert.AreEqual(1, a.AlarmCount);
        }
Exemple #7
0
        public void LimitAlarm()
        {
            var a = new AlarmGroup("test_cmo", true, true);

            a.UpdateRows("active", false);
            a.ProcessGroup(new DateTime(2012, 6, 5)); // reservoir is above spillway.
            Assert.AreEqual(1, a.ProcessCount);

            // now clear the alarm when reservoir has gone back down.
            a.ProcessGroup(new DateTime(2012, 9, 12));

            Assert.AreEqual(1, a.ClearCount);
            Assert.AreEqual(1, a.ProcessCount);
        }