Exemple #1
0
        private static System.Collections.Generic.Dictionary <int, SensorValueEntry> GetSensorValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            ApcSensorStatusMib apcSensorStatusMib = null;
            int num = 0;

            while (enumerator.MoveNext())
            {
                string text  = enumerator.Current;
                string text2 = result[text];
                if ("\0".Equals(text2) || "n/a".Equals(text2) || "N/A".Equals(text2) || "-1".Equals(text2))
                {
                    text2 = System.Convert.ToString(-1000);
                }
                else
                {
                    if (string.IsNullOrEmpty(text2) || text2.Equals("Null"))
                    {
                        text2 = System.Convert.ToString(-500);
                    }
                }
                if (text.LastIndexOf(".0") > 0)
                {
                    text = text.Substring(0, text.LastIndexOf(".0"));
                }
                int num2 = System.Convert.ToInt32(text.Substring(text.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorValueEntry value = new SensorValueEntry(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    apcSensorStatusMib = new ApcSensorStatusMib(num2);
                    num = num2;
                }
                SensorValueEntry sensorValueEntry = dictionary[num2];
                if (text.StartsWith(apcSensorStatusMib.Humidity))
                {
                    sensorValueEntry.Humidity = text2;
                }
                else
                {
                    if (text.StartsWith(apcSensorStatusMib.Temperature))
                    {
                        if (text2.Equals(System.Convert.ToString(-1000)) || text2.Equals(System.Convert.ToString(-500)))
                        {
                            sensorValueEntry.Temperature = text2;
                        }
                        else
                        {
                            sensorValueEntry.Temperature = ((float)System.Convert.ToInt32(text2) / 10f).ToString();
                        }
                    }
                }
            }
            return(dictionary);
        }
Exemple #2
0
        private static System.Collections.Generic.Dictionary <int, SensorValueEntry> GetSensorValue_Empty(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
            int num = 1;
            SensorValueEntry sensorValueEntry = new SensorValueEntry(num);
            string           text             = System.Convert.ToString(-1000);

            sensorValueEntry.Humidity    = text;
            sensorValueEntry.Temperature = text;
            dictionary.Add(num, sensorValueEntry);
            return(dictionary);
        }
Exemple #3
0
        private static System.Collections.Generic.Dictionary <int, SensorValueEntry> GetSensorValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string value   = result[current];
                if ("\0".Equals(value) || "n/a".Equals(value) || "N/A".Equals(value))
                {
                    value = System.Convert.ToString(-10000);
                }
                else
                {
                    if (string.IsNullOrEmpty(value))
                    {
                        value = System.Convert.ToString(-5000);
                    }
                }
                string text = ((float)System.Convert.ToInt32(value) / 10f).ToString();
                int    num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorValueEntry value2 = new SensorValueEntry(num2);
                    dictionary.Add(num2, value2);
                }
                if (num != num2)
                {
                    new SensorValueMib(num2);
                    num = num2;
                }
                SensorValueEntry             sensorValueEntry            = dictionary[num2];
                EatonSensorTemperatureMib_M2 eatonSensorTemperatureMib_M = new EatonSensorTemperatureMib_M2(num2);
                EatonSensorHumidityMib_M2    eatonSensorHumidityMib_M    = new EatonSensorHumidityMib_M2(num2);
                if (current.StartsWith(eatonSensorTemperatureMib_M.TemperatureValue))
                {
                    sensorValueEntry.Temperature = text;
                }
                else
                {
                    if (current.StartsWith(eatonSensorHumidityMib_M.HumidityValue))
                    {
                        sensorValueEntry.Humidity = text;
                    }
                }
            }
            return(dictionary);
        }
Exemple #4
0
 private void setSensorTable(System.DateTime dateTime, System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary, int deviceId, int sensorNumbers, string mac, System.Collections.Generic.IDictionary <string, System.Collections.Generic.IDictionary <int, SensorMapping> > sensorIdMapper)
 {
     try
     {
         if (dictionary == null || dictionary.Count < 1)
         {
             dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
             for (int i = 1; i <= sensorNumbers; i++)
             {
                 dictionary.Add(i, new SensorValueEntry(i));
             }
         }
         System.Collections.Generic.IEnumerator <int> enumerator = dictionary.Keys.GetEnumerator();
         while (enumerator.MoveNext())
         {
             int current = enumerator.Current;
             if (sensorIdMapper.ContainsKey(mac) && sensorIdMapper[mac].ContainsKey(current))
             {
                 SensorValueEntry sensorValueEntry = dictionary[current];
                 SensorAutoValue  sensorAutoValue  = new SensorAutoValue();
                 SensorMapping    sensorMapping    = sensorIdMapper[mac][current];
                 int sensorLocation = sensorMapping.SensorLocation;
                 sensorAutoValue.DeviceId    = deviceId;
                 sensorAutoValue.Humidity    = this.ParseDeviceValue(sensorValueEntry.Humidity);
                 sensorAutoValue.InsertTime  = this.parseSecondTime(dateTime);
                 sensorAutoValue.Press       = this.ParseDeviceValue(sensorValueEntry.Pressure);
                 sensorAutoValue.Temperature = this.ParseDeviceValue(sensorValueEntry.Temperature);
                 sensorAutoValue.Type        = current;
                 this.presentValue.SensorTable.Rows.Add(new object[]
                 {
                     sensorAutoValue.DeviceId,
                     sensorAutoValue.Humidity,
                     sensorAutoValue.Temperature,
                     sensorAutoValue.Press,
                     sensorAutoValue.Type,
                     sensorLocation,
                     sensorAutoValue.InsertTime
                 });
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }