use of com.vmware.flowgate.nlyteworker.model.PowerStripsRealtimeValue in project flowgate by vmware.
the class SycnRealTimeDataJobTest method getPowerStripsRealtimeValue1.
public ResponseEntity<JsonResultForPDURealtimeValue> getPowerStripsRealtimeValue1() {
JsonResultForPDURealtimeValue pduvalue = new JsonResultForPDURealtimeValue();
List<PowerStripsRealtimeValue> value = new ArrayList<PowerStripsRealtimeValue>();
PowerStripsRealtimeValue power = new PowerStripsRealtimeValue();
power.setName("RealtimePower");
power.setValue(20);
power.setRecordedDateTime("2018-09-20T14:35:25Z");
value.add(power);
PowerStripsRealtimeValue current = new PowerStripsRealtimeValue();
current.setName("RealtimeLoad");
current.setValue(20);
current.setUnit("");
current.setRecordedDateTime("2018-09-20T14:35:25Z");
value.add(current);
PowerStripsRealtimeValue voltage = new PowerStripsRealtimeValue();
voltage.setName("RealtimeVoltage");
voltage.setUnit("Volts");
voltage.setValue(120);
voltage.setRecordedDateTime("2018-09-20T14:35:25Z");
value.add(voltage);
pduvalue.setValue(value);
return new ResponseEntity<JsonResultForPDURealtimeValue>(pduvalue, HttpStatus.OK);
}
use of com.vmware.flowgate.nlyteworker.model.PowerStripsRealtimeValue in project flowgate by vmware.
the class NlyteDataService method generateValueUnits.
public List<ValueUnit> generateValueUnits(List<PowerStripsRealtimeValue> values, HashMap<AdvanceSettingType, String> advanceSettingMap) {
List<ValueUnit> valueunits = new ArrayList<ValueUnit>();
long currenttime = System.currentTimeMillis();
String dateFormat = advanceSettingMap.get(AdvanceSettingType.DateFormat);
String timezone = advanceSettingMap.get(AdvanceSettingType.TimeZone);
String current = advanceSettingMap.get(AdvanceSettingType.PDU_AMPS_UNIT);
String power = advanceSettingMap.get(AdvanceSettingType.PDU_POWER_UNIT);
String voltage = advanceSettingMap.get(AdvanceSettingType.PDU_VOLT_UNIT);
for (PowerStripsRealtimeValue value : values) {
String valueDateTime = value.getRecordedDateTime();
long recordedTime = WormholeDateFormat.getLongTime(valueDateTime, dateFormat, timezone);
if (recordedTime > currenttime || recordedTime == -1) {
logger.error("Failed to translate the time string: " + valueDateTime);
continue;
}
if (sensorValueTypeMap.containsKey(value.getName())) {
ValueUnit valueunit = new ValueUnit();
valueunit.setKey(sensorValueTypeMap.get(value.getName()));
String unit = value.getUnit();
MetricUnit targetUnit = null, sourceUnit = null;
switch(sensorValueTypeMap.get(value.getName())) {
case MetricName.PDU_TOTAL_CURRENT:
if (unit != null && !unit.isEmpty()) {
sourceUnit = MetricUnit.valueOf(unit.toUpperCase());
} else {
sourceUnit = MetricUnit.valueOf(current.toUpperCase());
}
targetUnit = MetricUnit.A;
break;
case MetricName.PDU_TOTAL_POWER:
if (unit != null && !unit.isEmpty()) {
sourceUnit = MetricUnit.valueOf(unit.toUpperCase());
} else {
sourceUnit = MetricUnit.valueOf(power.toUpperCase());
}
targetUnit = MetricUnit.kW;
break;
case MetricName.PDU_VOLTAGE:
if (unit != null && !unit.isEmpty()) {
sourceUnit = MetricUnit.valueOf(unit.toUpperCase());
} else {
sourceUnit = MetricUnit.valueOf(voltage.toUpperCase());
}
targetUnit = MetricUnit.V;
break;
default:
break;
}
valueunit.setUnit(targetUnit.toString());
try {
valueunit.setValueNum(valueunit.translateUnit(value.getValue(), sourceUnit, targetUnit));
} catch (WormholeException e) {
logger.error("Cannot translate Unit", e);
}
valueunit.setTime(recordedTime);
valueunits.add(valueunit);
} else {
continue;
}
}
return valueunits;
}
use of com.vmware.flowgate.nlyteworker.model.PowerStripsRealtimeValue in project flowgate by vmware.
the class SycnRealTimeDataJobTest method getPowerStripsRealtimeValue.
public ResponseEntity<JsonResultForPDURealtimeValue> getPowerStripsRealtimeValue() {
JsonResultForPDURealtimeValue pduvalue = new JsonResultForPDURealtimeValue();
List<PowerStripsRealtimeValue> value = new ArrayList<PowerStripsRealtimeValue>();
PowerStripsRealtimeValue power = new PowerStripsRealtimeValue();
power.setName("RealtimePower");
power.setUnit("kw");
power.setValue(20);
power.setRecordedDateTime("2018-09-20T14:35:25Z");
value.add(power);
PowerStripsRealtimeValue current = new PowerStripsRealtimeValue();
current.setName("RealtimeLoad");
current.setUnit("Amps");
current.setValue(20);
current.setRecordedDateTime("2018-09-20T14:35:25Z");
value.add(current);
PowerStripsRealtimeValue voltage = new PowerStripsRealtimeValue();
voltage.setName("RealtimeVoltage");
voltage.setUnit("Volts");
voltage.setValue(120);
voltage.setRecordedDateTime("2018-09-20T14:35:25Z");
value.add(voltage);
pduvalue.setValue(value);
return new ResponseEntity<JsonResultForPDURealtimeValue>(pduvalue, HttpStatus.OK);
}
Aggregations