Beispiel #1
0
        //Controls receiver
        static void Main()
        {
            EnvironmentMonitor r = new EnvironmentMonitor(); try

            { r.WhenGetPropertyNamesThenSetPropertyNames();
              r.WhenGetReadingsFromSensorThenAnalyze(); }
            catch (TimeoutException) { AlertWrapper.PrintOnConsole("Sensor is disconnected"); }
        }
Beispiel #2
0
 void WhenWantToAlertForLowerLimitsForTemperature(int valueInInt, string[] values)
 {
     if (valueInInt < 0)
     {
         AlertWrapper.PrintOnConsole("Temperature reached Low Error level:" + valueInInt.ToString() + "C at " + WhenWantValueOfProperty("Time", values) + " on " + WhenWantValueOfProperty("Date", values));
     }
     else
     {
         AlertWrapper.PrintOnConsole("Temperature reached Low Warning level:" + valueInInt.ToString() + "C at " + WhenWantValueOfProperty("Time", values) + " on " + WhenWantValueOfProperty("Date", values));
     }
 }
Beispiel #3
0
        void WhenHumidityIsOutOfLimitsThenAlert(string valueInString, string[] values)
        {
            int valueInInt = int.Parse((valueInString.Split('%'))[0]);

            if (valueInInt > 90)
            {
                AlertWrapper.PrintOnConsole("Humidity reached Error level:" + valueInString + " at " + WhenWantValueOfProperty("Time", values) + " on " + WhenWantValueOfProperty("Date", values));
            }
            else if (valueInInt > 70)
            {
                AlertWrapper.PrintOnConsole("Humidity reached Warning level:" + valueInString + " at " + WhenWantValueOfProperty("Time", values) + " on " + WhenWantValueOfProperty("Date", values));
            }
        }
Beispiel #4
0
 public void WhenAnalyzeTemperature(string[] values)
 {
     try
     {
         string valueInString = WhenWantValueOfProperty("Temperature", values);
         if (!valueInString.Equals("NA"))
         {
             WhenTemperatureIsOutOfLimitsThenAlert(valueInString, values);
         }
         else
         {
             //NA means either temperature is not provided by CSV or its value is not in AnalyzerObj practical limits
             AlertWrapper.PrintOnConsole("Temperature value not provided by sender.Possibility of error in temperature sensor.");
         }
     }
     catch (PropertyNotFoundException e)
     {
         AlertWrapper.PrintOnConsole(e.Message);
     }
 }