Ejemplo n.º 1
0
        private static System.Collections.Generic.Dictionary <int, SensorThreshold> GetSensorThreshold(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorThreshold> dictionary = new System.Collections.Generic.Dictionary <int, SensorThreshold>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            ApcSensorConfigMib apcSensorConfigMib = null;
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if ("\0".Equals(text))
                {
                    text = System.Convert.ToString(-1000);
                }
                else
                {
                    if (text == null || string.IsNullOrEmpty(text) || text.Equals("Null"))
                    {
                        text = System.Convert.ToString(-500);
                    }
                    else
                    {
                        if (text.Equals("-1"))
                        {
                            text = System.Convert.ToString(-600);
                        }
                    }
                }
                int num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorThreshold value = new SensorThreshold(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    apcSensorConfigMib = new ApcSensorConfigMib(num2);
                    num = num2;
                }
                SensorThreshold sensorThreshold = dictionary[num2];
                if (current.StartsWith(apcSensorConfigMib.MaxTemperature))
                {
                    sensorThreshold.MaxTemperatureMT = (float)System.Convert.ToInt32(text);
                }
                else
                {
                    if (current.StartsWith(apcSensorConfigMib.MinHumidity))
                    {
                        sensorThreshold.MinHumidityMT = (float)System.Convert.ToInt32(text);
                    }
                }
            }
            return(dictionary);
        }
Ejemplo n.º 2
0
        private static System.Collections.Generic.Dictionary <int, SensorThreshold> GetSensorThreshold_Empty(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorThreshold> dictionary = new System.Collections.Generic.Dictionary <int, SensorThreshold>();
            int             num   = 1;
            SensorThreshold value = new SensorThreshold(num);

            dictionary.Add(num, value);
            SensorThreshold sensorThreshold = dictionary[num];
            string          value2          = System.Convert.ToString(-600);

            sensorThreshold.MaxTemperatureMT = (float)System.Convert.ToInt32(value2);
            sensorThreshold.MinHumidityMT    = (float)System.Convert.ToInt32(value2);
            return(dictionary);
        }
Ejemplo n.º 3
0
        private static System.Collections.Generic.Dictionary <int, SensorThreshold> GetSensorThreshold(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorThreshold> dictionary = new System.Collections.Generic.Dictionary <int, SensorThreshold>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            EatonSensorTemperatureMib_M2 eatonSensorTemperatureMib_M   = null;
            EatonSensorHumidityMib_M2    eatonSensorHumidityMib_M      = null;
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if ("\0".Equals(text))
                {
                    text = System.Convert.ToString(-10000);
                }
                else
                {
                    if (text == null || string.IsNullOrEmpty(text))
                    {
                        text = System.Convert.ToString(-5000);
                    }
                }
                int num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorThreshold value = new SensorThreshold(num2);
                    dictionary.Add(num2, value);
                }
                SensorThreshold sensorThreshold = dictionary[num2];
                if (num != num2)
                {
                    num = num2;
                    eatonSensorTemperatureMib_M = new EatonSensorTemperatureMib_M2(num2);
                    eatonSensorHumidityMib_M    = new EatonSensorHumidityMib_M2(num2);
                }
                float num3 = (float)System.Convert.ToInt32(text) / 10f;
                if (current.StartsWith(eatonSensorHumidityMib_M.MaxHumidityMT))
                {
                    sensorThreshold.MaxHumidityMT = num3;
                }
                else
                {
                    if (current.StartsWith(eatonSensorTemperatureMib_M.MaxTemperatureMT))
                    {
                        sensorThreshold.MaxTemperatureMT = num3;
                    }
                    else
                    {
                        if (current.StartsWith(eatonSensorHumidityMib_M.MinHumidityMt))
                        {
                            sensorThreshold.MinHumidityMT = num3;
                        }
                        else
                        {
                            if (!current.StartsWith(eatonSensorTemperatureMib_M.MinTemperatureMt))
                            {
                                return(new System.Collections.Generic.Dictionary <int, SensorThreshold>());
                            }
                            sensorThreshold.MinTemperatureMT = num3;
                        }
                    }
                }
            }
            return(dictionary);
        }
Ejemplo n.º 4
0
 public bool SetSensorThreshold(SensorThreshold ssrThreshold, string myMac)
 {
     return(this.se.CheckDeviceMac(myMac) >= 0 && this.se.SetSensorThreshold(ssrThreshold));
 }
Ejemplo n.º 5
0
        public static System.Collections.Generic.List <LeafVarBinding> SetSensorThresholdVariablesApcPDU(SensorThreshold threshold, DevModelConfig modelcfg)
        {
            System.Collections.Generic.List <LeafVarBinding> list = new System.Collections.Generic.List <LeafVarBinding>();
            LeafVarBinding     leafVarBinding     = new LeafVarBinding();
            LeafVarBinding     leafVarBinding2    = new LeafVarBinding();
            int                sensorNumber       = threshold.SensorNumber;
            ApcSensorConfigMib apcSensorConfigMib = new ApcSensorConfigMib(sensorNumber);

            if (threshold.MaxTemperatureMT != -500f && threshold.MaxTemperatureMT != -600f)
            {
                leafVarBinding.Add(apcSensorConfigMib.HighTemperature, 0);
                leafVarBinding2.Add(apcSensorConfigMib.MaxTemperature, System.Convert.ToInt32(threshold.MaxTemperatureMT));
                leafVarBinding2.Add(apcSensorConfigMib.HighTemperature, System.Convert.ToInt32(threshold.MaxTemperatureMT) - 1);
            }
            if (threshold.MinHumidityMT != -500f && threshold.MinHumidityMT != -600f)
            {
                leafVarBinding.Add(apcSensorConfigMib.LowHumidity, 99);
                leafVarBinding2.Add(apcSensorConfigMib.MinHumidity, System.Convert.ToInt32(threshold.MinHumidityMT));
                leafVarBinding2.Add(apcSensorConfigMib.LowHumidity, System.Convert.ToInt32(threshold.MinHumidityMT) + 1);
            }
            list.Add(leafVarBinding);
            list.Add(leafVarBinding2);
            return(list);
        }