private static DeviceValueEntry GetDeviceValue(System.Collections.Generic.Dictionary <string, string> result) { DeviceValueEntry deviceValueEntry = new DeviceValueEntry(); System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator(); while (enumerator.MoveNext()) { string current = enumerator.Current; string text = result[current]; if ("\0".Equals(text)) { text = System.Convert.ToString(-1000); } else { if (string.IsNullOrEmpty(text)) { text = System.Convert.ToString(-500); } } int num = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1)); if (num == 1) { ApcDeviceStatusMib apcDeviceStatusMib = new ApcDeviceStatusMib(num); ApcPhaseStatusMib apcPhaseStatusMib = new ApcPhaseStatusMib(num); System.Convert.ToInt32(text); if (current.StartsWith(apcDeviceStatusMib.PowerStatus)) { deviceValueEntry.Power = System.Convert.ToString((float)System.Convert.ToInt32(text) / 100f * 1000f); } else { if (current.StartsWith(apcDeviceStatusMib.PowerDsptStatus)) { deviceValueEntry.PowerDissipation = System.Convert.ToString((float)System.Convert.ToInt32(text) / 10f); } else { if (current.StartsWith(apcPhaseStatusMib.CurrentStatus)) { deviceValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(text) / 10f); } else { if (current.StartsWith(apcPhaseStatusMib.VoltageStatus)) { deviceValueEntry.Voltage = text; } } } } } } return(deviceValueEntry); }
private void setDeviceTable(System.DateTime dateTime, DeviceValueEntry deviceValueEntry, int deviceId) { try { DeviceAutoValue deviceAutoValue = new DeviceAutoValue(); if (deviceValueEntry == null) { deviceValueEntry = new DeviceValueEntry(); } else { deviceAutoValue.DeviceState = 1; } deviceAutoValue.Current = this.ParseDeviceValue(deviceValueEntry.Current); deviceAutoValue.Power = this.ParseDeviceValue(deviceValueEntry.Power); deviceAutoValue.Voltage = this.ParseDeviceValue(deviceValueEntry.Voltage); deviceAutoValue.PowerDissipation = this.ParseDeviceValue(deviceValueEntry.PowerDissipation); deviceAutoValue.DoorSensorStatus = deviceValueEntry.DoorSensorStatus; deviceAutoValue.LeakCurrentStatus = deviceValueEntry.LeakCurrentStatus; deviceAutoValue.DeviceId = deviceId; deviceAutoValue.InsertTime = this.parseSecondTime(dateTime); this.presentValue.DeviceTable.Rows.Add(new object[] { deviceAutoValue.DeviceId, deviceAutoValue.Voltage, deviceAutoValue.Current, deviceAutoValue.Power, deviceAutoValue.PowerDissipation, deviceAutoValue.DeviceState, deviceAutoValue.DoorSensorStatus, deviceAutoValue.LeakCurrentStatus, deviceAutoValue.InsertTime }); } catch (System.Exception ex) { throw ex; } }
private static DeviceValueEntry GetDeviceValue(System.Collections.Generic.Dictionary <string, string> result) { string s = "0"; DeviceValueEntry deviceValueEntry = new DeviceValueEntry(); System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator(); while (enumerator.MoveNext()) { string current = enumerator.Current; string text = result[current]; if ("\0".Equals(text)) { text = System.Convert.ToString(-1000); } else { if (string.IsNullOrEmpty(text)) { text = System.Convert.ToString(-500); } } int num = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1)); if (num == 1) { EatonInputCurrentMib_M2 eatonInputCurrentMib_M = new EatonInputCurrentMib_M2(num); EatonInputVoltageMib_M2 eatonInputVoltageMib_M = new EatonInputVoltageMib_M2(num); EatonInputPowerMib_M2 eatonInputPowerMib_M = new EatonInputPowerMib_M2(num); float arg_B2_0 = (float)System.Convert.ToInt32(text) / 1000f; if (current.StartsWith(eatonInputCurrentMib_M.CurrentValue)) { deviceValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f); } else { if (current.StartsWith(eatonInputVoltageMib_M.VoltageValue)) { deviceValueEntry.Voltage = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f); } else { if (current.StartsWith(eatonInputPowerMib_M.PowerValue)) { deviceValueEntry.Power = text; } else { if (current.StartsWith(eatonInputPowerMib_M.PowerValue_VA)) { s = text; } } } } } } if (double.Parse(deviceValueEntry.Current) <= 0.0) { deviceValueEntry.Current = (double.Parse(s) / double.Parse(deviceValueEntry.Voltage)).ToString("F2"); } return(deviceValueEntry); }