Search in sources :

Example 1 with InletReading

use of com.vmware.flowgate.poweriqworker.model.InletReading in project flowgate by vmware.

the class SyncPduAssetJobTest method getInlets.

List<Inlet> getInlets() {
    Inlet inlet = new Inlet();
    List<Inlet> inlets = new ArrayList<Inlet>();
    inlet.setId(23L);
    inlet.setOrdinal(1);
    inlet.setPduId(128L);
    inlet.setPueIt(true);
    inlet.setPueTotal(true);
    inlet.setSource(true);
    InletReading inletReading = new InletReading();
    inletReading.setCurrent(1.2);
    inletReading.setApparentPower(20.0);
    inletReading.setVoltage(200.0);
    inletReading.setReadingTime("2018/10/18 05:57:26 +0300");
    inletReading.setActivePower(26.6);
    inletReading.setUnutilizedCapacity(15.2);
    inlet.setReading(inletReading);
    inlets.add(inlet);
    return inlets;
}
Also used : ArrayList(java.util.ArrayList) InletReading(com.vmware.flowgate.poweriqworker.model.InletReading) Inlet(com.vmware.flowgate.poweriqworker.model.Inlet)

Example 2 with InletReading

use of com.vmware.flowgate.poweriqworker.model.InletReading in project flowgate by vmware.

the class PowerIQService method getValueUnits.

public List<ValueUnit> getValueUnits(Map<String, String> pduInfoFromPowerIQ, PowerIQAPIClient client, HashMap<AdvanceSettingType, String> advanceSettingMap) {
    List<ValueUnit> values = new ArrayList<ValueUnit>();
    Long pduId = Long.parseLong(pduInfoFromPowerIQ.get(FlowgateConstant.PDU_ID_FROM_POWERIQ));
    List<Outlet> outlets = client.getOutlets(pduId);
    Pdu pdu = client.getPduByID(pduId);
    if (outlets.isEmpty() && pdu.getReading() == null) {
        return values;
    }
    String dateFormat = advanceSettingMap.get(AdvanceSettingType.DateFormat);
    String timezone = advanceSettingMap.get(AdvanceSettingType.TimeZone);
    String PDU_AMPS_UNIT = advanceSettingMap.get(AdvanceSettingType.PDU_AMPS_UNIT);
    String PDU_POWER_UNIT = advanceSettingMap.get(AdvanceSettingType.PDU_POWER_UNIT);
    String PDU_VOLT_UNIT = advanceSettingMap.get(AdvanceSettingType.PDU_VOLT_UNIT);
    if (PDU_AMPS_UNIT == null) {
        // By default the Current unit in powerIQ is Amps.
        PDU_AMPS_UNIT = POWERIQ_CURRENT_UNIT;
    }
    if (PDU_POWER_UNIT == null) {
        // By default the active_power unit in powerIQ is watt.
        PDU_POWER_UNIT = POWERIQ_POWER_UNIT;
    }
    if (PDU_VOLT_UNIT == null) {
        // By default the voltage unit in powerIQ is volt.
        PDU_VOLT_UNIT = POWERIQ_VOLTAGE_UNIT;
    }
    double inlteTotalPower = 0.0;
    double inletTotalCurrent = 0.0;
    double inletVoltage = 0.0;
    Reading pduReading = pdu.getReading();
    List<InletReading> inletReadings = null;
    List<InletPoleReading> inletPoleReadings = null;
    if (pduReading != null) {
        inletReadings = pduReading.getInletReadings();
        inletPoleReadings = pduReading.getInletPoleReadings();
    }
    if (inletReadings != null && !inletReadings.isEmpty()) {
        String time = null;
        for (InletReading inletReading : inletReadings) {
            time = inletReading.getReadingTime();
            if (time != null) {
                break;
            }
        }
        long valueTime = -1;
        if (time != null) {
            valueTime = WormholeDateFormat.getLongTime(time, dateFormat, timezone);
        }
        if (valueTime == -1) {
            logger.error("Failed to translate the time string: " + time + ".And the dateformat is " + dateFormat);
        } else {
            for (InletReading reading : inletReadings) {
                String extraIdentifier = FlowgateConstant.INLET_NAME_PREFIX + reading.getInletOrdinal();
                Double voltage = reading.getVoltage();
                if (voltage != null) {
                    ValueUnit voltageValue = new ValueUnit();
                    voltageValue.setExtraidentifier(extraIdentifier);
                    voltageValue.setKey(MetricName.PDU_VOLTAGE);
                    voltageValue.setTime(valueTime);
                    voltageValue.setValueNum(voltageValue.translateUnit(voltage, MetricUnit.valueOf(PDU_VOLT_UNIT), MetricUnit.V));
                    voltageValue.setUnit(MetricUnit.V.toString());
                    values.add(voltageValue);
                    inletVoltage = voltageValue.getValueNum();
                }
                Double current = reading.getCurrent();
                if (current != null) {
                    ValueUnit currentValue = new ValueUnit();
                    currentValue.setExtraidentifier(extraIdentifier);
                    currentValue.setKey(MetricName.PDU_CURRENT);
                    currentValue.setTime(valueTime);
                    currentValue.setValueNum(currentValue.translateUnit(current, MetricUnit.valueOf(PDU_AMPS_UNIT), MetricUnit.A));
                    currentValue.setUnit(MetricUnit.A.toString());
                    values.add(currentValue);
                    inletTotalCurrent += currentValue.getValueNum();
                }
                Double activePower = reading.getActivePower();
                if (activePower != null) {
                    ValueUnit activePowerValue = new ValueUnit();
                    activePowerValue.setExtraidentifier(extraIdentifier);
                    activePowerValue.setKey(MetricName.PDU_ACTIVE_POWER);
                    activePowerValue.setTime(valueTime);
                    activePowerValue.setValueNum(activePowerValue.translateUnit(activePower, MetricUnit.valueOf(PDU_POWER_UNIT), MetricUnit.kW));
                    activePowerValue.setUnit(MetricUnit.kW.toString());
                    values.add(activePowerValue);
                }
                Double apparentPower = reading.getApparentPower();
                if (apparentPower != null) {
                    ValueUnit apparentPowerValue = new ValueUnit();
                    apparentPowerValue.setExtraidentifier(extraIdentifier);
                    apparentPowerValue.setKey(MetricName.PDU_APPARENT_POWER);
                    apparentPowerValue.setTime(valueTime);
                    apparentPowerValue.setValueNum(apparentPowerValue.translateUnit(apparentPower, MetricUnit.valueOf(PDU_POWER_UNIT), MetricUnit.kW));
                    apparentPowerValue.setUnit(MetricUnit.kW.toString());
                    values.add(apparentPowerValue);
                    inlteTotalPower += apparentPowerValue.getValueNum();
                }
                Double freeCapacity = reading.getUnutilizedCapacity();
                if (freeCapacity != null) {
                    ValueUnit freeCapacityValue = new ValueUnit();
                    freeCapacityValue.setExtraidentifier(extraIdentifier);
                    freeCapacityValue.setKey(MetricName.PDU_FREE_CAPACITY);
                    freeCapacityValue.setTime(valueTime);
                    freeCapacityValue.setValueNum(freeCapacityValue.translateUnit(freeCapacity, MetricUnit.valueOf(PDU_AMPS_UNIT), MetricUnit.A));
                    freeCapacityValue.setUnit(MetricUnit.A.toString());
                    values.add(freeCapacityValue);
                }
            }
            ValueUnit total_current = new ValueUnit();
            total_current.setKey(MetricName.PDU_TOTAL_CURRENT);
            total_current.setTime(valueTime);
            total_current.setUnit(MetricUnit.A.toString());
            total_current.setValueNum(inletTotalCurrent);
            values.add(total_current);
            ValueUnit total_power = new ValueUnit();
            total_power.setKey(MetricName.PDU_TOTAL_POWER);
            total_power.setTime(valueTime);
            total_power.setUnit(MetricUnit.kW.toString());
            total_power.setValueNum(inlteTotalPower);
            values.add(total_power);
        }
    }
    if (inletPoleReadings != null && !inletPoleReadings.isEmpty()) {
        String inletPoleReadingTime = null;
        for (InletPoleReading inletPoleReading : inletPoleReadings) {
            inletPoleReadingTime = inletPoleReading.getReadingTime();
            if (inletPoleReadingTime != null) {
                break;
            }
        }
        long valueTime = -1;
        if (inletPoleReadingTime != null) {
            valueTime = WormholeDateFormat.getLongTime(inletPoleReadingTime, dateFormat, timezone);
        }
        if (valueTime == -1) {
            logger.error("Failed to translate the time string: " + inletPoleReadingTime + ".And the dateformat is " + dateFormat);
        } else {
            for (InletPoleReading reading : inletPoleReadings) {
                String extraIdentifier = FlowgateConstant.INLET_NAME_PREFIX + reading.getInletOrdinal() + FlowgateConstant.INLET_POLE_NAME_PREFIX + reading.getInletPoleOrdinal();
                Double currentValue = reading.getCurrent();
                if (currentValue != null) {
                    ValueUnit current = new ValueUnit();
                    current.setExtraidentifier(extraIdentifier);
                    current.setKey(MetricName.PDU_CURRENT);
                    current.setTime(valueTime);
                    current.setValueNum(current.translateUnit(currentValue, MetricUnit.valueOf(PDU_AMPS_UNIT), MetricUnit.A));
                    current.setUnit(MetricUnit.A.toString());
                    values.add(current);
                }
                Double voltageValue = reading.getVoltage();
                if (voltageValue != null) {
                    ValueUnit voltage = new ValueUnit();
                    voltage.setExtraidentifier(extraIdentifier);
                    voltage.setKey(MetricName.PDU_VOLTAGE);
                    voltage.setTime(valueTime);
                    voltage.setValueNum(voltage.translateUnit(voltageValue, MetricUnit.valueOf(PDU_VOLT_UNIT), MetricUnit.V));
                    voltage.setUnit(MetricUnit.V.toString());
                    values.add(voltage);
                }
                Double freeCapacityValue = reading.getUnutilizedCapacity();
                if (freeCapacityValue != null) {
                    ValueUnit freeCapacity = new ValueUnit();
                    freeCapacity.setExtraidentifier(extraIdentifier);
                    freeCapacity.setKey(MetricName.PDU_FREE_CAPACITY);
                    freeCapacity.setTime(valueTime);
                    freeCapacity.setValueNum(freeCapacity.translateUnit(freeCapacityValue, MetricUnit.valueOf(PDU_AMPS_UNIT), MetricUnit.A));
                    freeCapacity.setUnit(MetricUnit.A.toString());
                    values.add(freeCapacity);
                }
            }
        }
    }
    if (!outlets.isEmpty()) {
        String time = null;
        for (Outlet outlet : outlets) {
            time = outlet.getReading().getReadingTime();
            if (time != null) {
                break;
            }
        }
        long valueTime = -1;
        if (time != null) {
            valueTime = WormholeDateFormat.getLongTime(time, dateFormat, timezone);
        }
        if (valueTime == -1) {
            logger.error("Failed to translate the time string: " + time + ".And the dateformat is " + dateFormat);
        } else {
            double totalOutletCurrentUsed = 0.0;
            double totalOutletPowerUsed = 0.0;
            for (Outlet outlet : outlets) {
                OutletReading reading = outlet.getReading();
                String extraIdentifier = FlowgateConstant.OUTLET_NAME_PREFIX + outlet.getOrdinal();
                Double voltage = reading.getVoltage();
                if (voltage != null) {
                    ValueUnit voltageValue = new ValueUnit();
                    voltageValue.setExtraidentifier(extraIdentifier);
                    voltageValue.setKey(MetricName.PDU_VOLTAGE);
                    voltageValue.setTime(valueTime);
                    voltageValue.setValueNum(voltageValue.translateUnit(voltage, MetricUnit.valueOf(PDU_VOLT_UNIT), MetricUnit.V));
                    voltageValue.setUnit(MetricUnit.V.toString());
                    values.add(voltageValue);
                }
                Double current = reading.getCurrent();
                if (current != null) {
                    ValueUnit currentValue = new ValueUnit();
                    currentValue.setExtraidentifier(extraIdentifier);
                    currentValue.setKey(MetricName.PDU_CURRENT);
                    currentValue.setTime(valueTime);
                    currentValue.setValueNum(currentValue.translateUnit(current, MetricUnit.valueOf(PDU_AMPS_UNIT), MetricUnit.A));
                    currentValue.setUnit(MetricUnit.A.toString());
                    values.add(currentValue);
                    totalOutletCurrentUsed += currentValue.getValueNum();
                }
                Double active_power = reading.getActivePower();
                if (active_power != null) {
                    ValueUnit activePowerValue = new ValueUnit();
                    activePowerValue.setExtraidentifier(extraIdentifier);
                    activePowerValue.setKey(MetricName.PDU_ACTIVE_POWER);
                    activePowerValue.setTime(valueTime);
                    activePowerValue.setValueNum(activePowerValue.translateUnit(active_power, MetricUnit.valueOf(PDU_POWER_UNIT), MetricUnit.kW));
                    activePowerValue.setUnit(MetricUnit.kW.toString());
                    values.add(activePowerValue);
                }
                Double apparent_power = reading.getApparentPower();
                if (apparent_power != null) {
                    ValueUnit apparentPowerValue = new ValueUnit();
                    apparentPowerValue.setExtraidentifier(extraIdentifier);
                    apparentPowerValue.setKey(MetricName.PDU_APPARENT_POWER);
                    apparentPowerValue.setTime(valueTime);
                    apparentPowerValue.setValueNum(apparentPowerValue.translateUnit(apparent_power, MetricUnit.valueOf(PDU_POWER_UNIT), MetricUnit.kW));
                    apparentPowerValue.setUnit(MetricUnit.kW.toString());
                    values.add(apparentPowerValue);
                    totalOutletPowerUsed += apparentPowerValue.getValueNum();
                }
                Double freeCapacity = reading.getUnutilizedCapacity();
                if (freeCapacity != null) {
                    ValueUnit freeCapacityValue = new ValueUnit();
                    freeCapacityValue.setExtraidentifier(extraIdentifier);
                    freeCapacityValue.setKey(MetricName.PDU_FREE_CAPACITY);
                    freeCapacityValue.setTime(valueTime);
                    freeCapacityValue.setValueNum(freeCapacityValue.translateUnit(freeCapacity, MetricUnit.valueOf(PDU_AMPS_UNIT), MetricUnit.A));
                    freeCapacityValue.setUnit(MetricUnit.A.toString());
                    values.add(freeCapacityValue);
                }
            }
            String rate_current = pduInfoFromPowerIQ.get(FlowgateConstant.PDU_RATE_AMPS);
            DecimalFormat df = new DecimalFormat("#.0000");
            if (totalOutletCurrentUsed == 0.0) {
                totalOutletCurrentUsed = inletTotalCurrent;
            }
            if (rate_current != null) {
                Double rate_current_value = Double.parseDouble(rate_current);
                ValueUnit current_load = new ValueUnit();
                current_load.setKey(MetricName.PDU_CURRENT_LOAD);
                current_load.setTime(valueTime);
                current_load.setUnit(MetricUnit.percent.toString());
                current_load.setValueNum(Double.parseDouble(df.format(totalOutletCurrentUsed / rate_current_value)));
                values.add(current_load);
            }
            String real_rate_power = getRealRatePower(inletVoltage, pduInfoFromPowerIQ);
            if (totalOutletPowerUsed == 0.0) {
                totalOutletPowerUsed = inlteTotalPower;
            }
            if (real_rate_power != null) {
                Double rate_power_value = Double.parseDouble(real_rate_power);
                ValueUnit power_load = new ValueUnit();
                power_load.setKey(MetricName.PDU_POWER_LOAD);
                power_load.setTime(valueTime);
                power_load.setUnit(MetricUnit.percent.toString());
                power_load.setValueNum(Double.parseDouble(df.format(totalOutletPowerUsed / rate_power_value)));
                values.add(power_load);
            }
        }
    }
    return values;
}
Also used : Pdu(com.vmware.flowgate.poweriqworker.model.Pdu) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) InletReading(com.vmware.flowgate.poweriqworker.model.InletReading) OutletReading(com.vmware.flowgate.poweriqworker.model.OutletReading) InletPoleReading(com.vmware.flowgate.poweriqworker.model.InletPoleReading) Reading(com.vmware.flowgate.poweriqworker.model.Reading) SensorReading(com.vmware.flowgate.poweriqworker.model.SensorReading) PduOutlet(com.vmware.flowgate.common.model.PduOutlet) Outlet(com.vmware.flowgate.poweriqworker.model.Outlet) InletReading(com.vmware.flowgate.poweriqworker.model.InletReading) ValueUnit(com.vmware.flowgate.common.model.ValueUnit) InletPoleReading(com.vmware.flowgate.poweriqworker.model.InletPoleReading) OutletReading(com.vmware.flowgate.poweriqworker.model.OutletReading)

Example 3 with InletReading

use of com.vmware.flowgate.poweriqworker.model.InletReading in project flowgate by vmware.

the class SyncPduAssetJobTest method createPdu.

Pdu createPdu() {
    Pdu pdu = new Pdu();
    pdu.setName("pek-wor-pdu-02");
    pdu.setPhase("THREE_PHASE");
    InletReading inletReading = new InletReading();
    inletReading.setCurrent(1.2);
    inletReading.setApparentPower(20.0);
    inletReading.setVoltage(200.0);
    inletReading.setReadingTime("2018/10/18 05:57:26 +0300");
    inletReading.setActivePower(26.6);
    inletReading.setUnutilizedCapacity(15.2);
    inletReading.setInletId(127);
    inletReading.setInletOrdinal(1);
    List<InletReading> inletReadings = new ArrayList<InletReading>();
    inletReadings.add(inletReading);
    Reading pduReading = new Reading();
    pduReading.setInletReadings(inletReadings);
    List<InletPoleReading> inletPoleReadings = new ArrayList<InletPoleReading>();
    InletPoleReading poleReadingL1 = new InletPoleReading();
    poleReadingL1.setCurrent(1.62);
    poleReadingL1.setInletPoleOrdinal(1);
    poleReadingL1.setInletOrdinal(1);
    poleReadingL1.setReadingTime("2018/10/18 05:57:26 +0300");
    poleReadingL1.setUnutilizedCapacity(7.38);
    poleReadingL1.setVoltage(122.1);
    InletPoleReading poleReadingL2 = new InletPoleReading();
    poleReadingL2.setCurrent(3.62);
    poleReadingL2.setInletPoleOrdinal(2);
    poleReadingL2.setInletOrdinal(1);
    poleReadingL2.setReadingTime("2018/10/18 05:57:26 +0300");
    poleReadingL2.setUnutilizedCapacity(5.38);
    poleReadingL2.setVoltage(112.1);
    InletPoleReading poleReadingL3 = new InletPoleReading();
    poleReadingL3.setCurrent(0.62);
    poleReadingL3.setInletPoleOrdinal(3);
    poleReadingL3.setInletOrdinal(1);
    poleReadingL3.setReadingTime("2018/10/18 05:57:26 +0300");
    poleReadingL3.setUnutilizedCapacity(8.38);
    poleReadingL3.setVoltage(102.1);
    inletPoleReadings.add(poleReadingL1);
    inletPoleReadings.add(poleReadingL2);
    inletPoleReadings.add(poleReadingL3);
    pduReading.setInletPoleReadings(inletPoleReadings);
    pdu.setReading(pduReading);
    return pdu;
}
Also used : Pdu(com.vmware.flowgate.poweriqworker.model.Pdu) InletReading(com.vmware.flowgate.poweriqworker.model.InletReading) InletPoleReading(com.vmware.flowgate.poweriqworker.model.InletPoleReading) Reading(com.vmware.flowgate.poweriqworker.model.Reading) OutletReading(com.vmware.flowgate.poweriqworker.model.OutletReading) ArrayList(java.util.ArrayList) InletReading(com.vmware.flowgate.poweriqworker.model.InletReading) InletPoleReading(com.vmware.flowgate.poweriqworker.model.InletPoleReading)

Example 4 with InletReading

use of com.vmware.flowgate.poweriqworker.model.InletReading in project flowgate by vmware.

the class SyncRealTimeDataJobTest method createPdu.

Pdu createPdu() {
    Pdu pdu = new Pdu();
    pdu.setName("pek-wor-pdu-02");
    pdu.setPhase("THREE_PHASE");
    InletReading inletReading = new InletReading();
    inletReading.setCurrent(1.2);
    inletReading.setApparentPower(20.0);
    inletReading.setVoltage(200.0);
    inletReading.setReadingTime("2018/10/18 05:57:26 +0300");
    inletReading.setActivePower(26.6);
    inletReading.setUnutilizedCapacity(15.2);
    inletReading.setInletId(127);
    inletReading.setInletOrdinal(1);
    List<InletReading> inletReadings = new ArrayList<InletReading>();
    inletReadings.add(inletReading);
    Reading pduReading = new Reading();
    pduReading.setInletReadings(inletReadings);
    List<InletPoleReading> inletPoleReadings = new ArrayList<InletPoleReading>();
    InletPoleReading poleReadingL1 = new InletPoleReading();
    poleReadingL1.setCurrent(1.62);
    poleReadingL1.setInletPoleOrdinal(1);
    poleReadingL1.setInletOrdinal(1);
    poleReadingL1.setReadingTime("2018/10/18 05:57:26 +0300");
    poleReadingL1.setUnutilizedCapacity(7.38);
    poleReadingL1.setVoltage(122.1);
    InletPoleReading poleReadingL2 = new InletPoleReading();
    poleReadingL2.setCurrent(3.62);
    poleReadingL2.setInletPoleOrdinal(2);
    poleReadingL2.setInletOrdinal(1);
    poleReadingL2.setReadingTime("2018/10/18 05:57:26 +0300");
    poleReadingL2.setUnutilizedCapacity(5.38);
    poleReadingL2.setVoltage(112.1);
    InletPoleReading poleReadingL3 = new InletPoleReading();
    poleReadingL3.setCurrent(0.62);
    poleReadingL3.setInletPoleOrdinal(3);
    poleReadingL3.setInletOrdinal(1);
    poleReadingL3.setReadingTime("2018/10/18 05:57:26 +0300");
    poleReadingL3.setUnutilizedCapacity(8.38);
    poleReadingL3.setVoltage(102.1);
    inletPoleReadings.add(poleReadingL1);
    inletPoleReadings.add(poleReadingL2);
    inletPoleReadings.add(poleReadingL3);
    pduReading.setInletPoleReadings(inletPoleReadings);
    pdu.setReading(pduReading);
    return pdu;
}
Also used : Pdu(com.vmware.flowgate.poweriqworker.model.Pdu) InletReading(com.vmware.flowgate.poweriqworker.model.InletReading) InletPoleReading(com.vmware.flowgate.poweriqworker.model.InletPoleReading) Reading(com.vmware.flowgate.poweriqworker.model.Reading) OutletReading(com.vmware.flowgate.poweriqworker.model.OutletReading) ArrayList(java.util.ArrayList) InletReading(com.vmware.flowgate.poweriqworker.model.InletReading) InletPoleReading(com.vmware.flowgate.poweriqworker.model.InletPoleReading)

Example 5 with InletReading

use of com.vmware.flowgate.poweriqworker.model.InletReading in project flowgate by vmware.

the class SyncRealTimeDataJobTest method createInletReading.

InletReading createInletReading() {
    InletReading inletReading = new InletReading();
    inletReading.setCurrent(1.2);
    inletReading.setApparentPower(20.0);
    inletReading.setVoltage(200.0);
    inletReading.setReadingTime("2018/10/18 05:57:26 +0300");
    return inletReading;
}
Also used : InletReading(com.vmware.flowgate.poweriqworker.model.InletReading)

Aggregations

InletReading (com.vmware.flowgate.poweriqworker.model.InletReading)6 ArrayList (java.util.ArrayList)5 InletPoleReading (com.vmware.flowgate.poweriqworker.model.InletPoleReading)3 OutletReading (com.vmware.flowgate.poweriqworker.model.OutletReading)3 Pdu (com.vmware.flowgate.poweriqworker.model.Pdu)3 Reading (com.vmware.flowgate.poweriqworker.model.Reading)3 Inlet (com.vmware.flowgate.poweriqworker.model.Inlet)2 PduOutlet (com.vmware.flowgate.common.model.PduOutlet)1 ValueUnit (com.vmware.flowgate.common.model.ValueUnit)1 Outlet (com.vmware.flowgate.poweriqworker.model.Outlet)1 SensorReading (com.vmware.flowgate.poweriqworker.model.SensorReading)1 DecimalFormat (java.text.DecimalFormat)1