Search in sources :

Example 41 with ValueUnit

use of com.vmware.flowgate.common.model.ValueUnit in project flowgate by vmware.

the class AssetControllerTest method createHumiditySensorRealtimeData.

RealTimeData createHumiditySensorRealtimeData(long time, String sensorAssetId) {
    List<ValueUnit> valueunits = new ArrayList<ValueUnit>();
    ValueUnit humidityValue = new ValueUnit();
    humidityValue.setValueNum(20);
    humidityValue.setTime(time);
    humidityValue.setUnit(MetricUnit.percent.toString());
    humidityValue.setKey(MetricName.HUMIDITY);
    valueunits.add(humidityValue);
    RealTimeData realTimeData = new RealTimeData();
    realTimeData.setId(UUID.randomUUID().toString());
    realTimeData.setAssetID(sensorAssetId);
    realTimeData.setValues(valueunits);
    realTimeData.setTime(time);
    return realTimeData;
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) ArrayList(java.util.ArrayList) ValueUnit(com.vmware.flowgate.common.model.ValueUnit)

Example 42 with ValueUnit

use of com.vmware.flowgate.common.model.ValueUnit in project flowgate by vmware.

the class AssetControllerTest method createPduRealTimeData.

RealTimeData createPduRealTimeData(Long time) {
    RealTimeData realTimeData = createServerPDURealTimeData(time);
    List<ValueUnit> valueunits = realTimeData.getValues();
    ValueUnit valueunitActivePower = new ValueUnit();
    valueunitActivePower.setKey(MetricName.PDU_ACTIVE_POWER);
    valueunitActivePower.setUnit(MetricUnit.kW.toString());
    valueunitActivePower.setExtraidentifier("OUTLET:7");
    valueunitActivePower.setValueNum(0.2);
    valueunitActivePower.setTime(time);
    valueunits.add(valueunitActivePower);
    ValueUnit valueunitFreeCapacity = new ValueUnit();
    valueunitFreeCapacity.setKey(MetricName.PDU_FREE_CAPACITY);
    valueunitFreeCapacity.setUnit(MetricUnit.A.toString());
    valueunitFreeCapacity.setExtraidentifier("OUTLET:7");
    valueunitFreeCapacity.setValueNum(20);
    valueunitFreeCapacity.setTime(time);
    valueunits.add(valueunitFreeCapacity);
    ValueUnit valueunitL1FreeCapacity = new ValueUnit();
    valueunitL1FreeCapacity.setKey(MetricName.PDU_FREE_CAPACITY);
    valueunitL1FreeCapacity.setUnit(MetricUnit.A.toString());
    valueunitL1FreeCapacity.setExtraidentifier("INLET:1" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunitL1FreeCapacity.setValueNum(34);
    valueunitL1FreeCapacity.setTime(time);
    valueunits.add(valueunitL1FreeCapacity);
    ValueUnit valueunitL1Current = new ValueUnit();
    valueunitL1Current.setKey(MetricName.PDU_CURRENT);
    valueunitL1Current.setUnit(MetricUnit.A.toString());
    valueunitL1Current.setExtraidentifier("INLET:1" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunitL1Current.setValueNum(6);
    valueunitL1Current.setTime(time);
    valueunits.add(valueunitL1Current);
    ValueUnit valueunitL1Voltage = new ValueUnit();
    valueunitL1Voltage.setKey(MetricName.PDU_VOLTAGE);
    valueunitL1Voltage.setUnit(MetricUnit.V.toString());
    valueunitL1Voltage.setExtraidentifier("INLET:1" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunitL1Voltage.setValueNum(220);
    valueunitL1Voltage.setTime(time);
    valueunits.add(valueunitL1Voltage);
    ValueUnit valueunit1L1FreeCapacity = new ValueUnit();
    valueunit1L1FreeCapacity.setKey(MetricName.PDU_FREE_CAPACITY);
    valueunit1L1FreeCapacity.setUnit(MetricUnit.A.toString());
    valueunit1L1FreeCapacity.setExtraidentifier("INLET:2" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunit1L1FreeCapacity.setValueNum(24);
    valueunit1L1FreeCapacity.setTime(time);
    valueunits.add(valueunit1L1FreeCapacity);
    ValueUnit valueunit1L1Current = new ValueUnit();
    valueunit1L1Current.setKey(MetricName.PDU_CURRENT);
    valueunit1L1Current.setUnit(MetricUnit.A.toString());
    valueunit1L1Current.setExtraidentifier("INLET:2" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunit1L1Current.setValueNum(6);
    valueunit1L1Current.setTime(time);
    valueunits.add(valueunit1L1Current);
    ValueUnit valueunit1L1Voltage = new ValueUnit();
    valueunit1L1Voltage.setKey(MetricName.PDU_VOLTAGE);
    valueunit1L1Voltage.setUnit(MetricUnit.V.toString());
    valueunit1L1Voltage.setExtraidentifier("INLET:2" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunit1L1Voltage.setValueNum(240);
    valueunit1L1Voltage.setTime(time);
    valueunits.add(valueunit1L1Voltage);
    realTimeData.setId(UUID.randomUUID().toString());
    realTimeData.setValues(valueunits);
    realTimeData.setTime(time);
    return realTimeData;
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) ValueUnit(com.vmware.flowgate.common.model.ValueUnit)

Example 43 with ValueUnit

use of com.vmware.flowgate.common.model.ValueUnit in project flowgate by vmware.

the class AssetControllerTest method realTimeDatabatchCreationExample.

@Test
public void realTimeDatabatchCreationExample() throws JsonProcessingException, Exception {
    List<RealTimeData> realtimedatas = new ArrayList<RealTimeData>();
    long currentTime = System.currentTimeMillis();
    RealTimeData realtimedata1 = createServerPDURealTimeData(currentTime);
    List<ValueUnit> valueunits = realtimedata1.getValues();
    ValueUnit tempValue = new ValueUnit();
    tempValue.setValueNum(32);
    tempValue.setTime(currentTime);
    tempValue.setUnit(MetricUnit.C.toString());
    tempValue.setKey(MetricName.TEMPERATURE);
    valueunits.add(tempValue);
    ValueUnit humidityValue = new ValueUnit();
    humidityValue.setValueNum(20);
    humidityValue.setTime(currentTime);
    humidityValue.setUnit("%");
    humidityValue.setKey(MetricName.HUMIDITY);
    valueunits.add(humidityValue);
    realtimedata1.setAssetID("assetid1");
    realtimedatas.add(realtimedata1);
    RealTimeData realtimedata2 = createServerPDURealTimeData(currentTime);
    realtimedata2.setAssetID("assetid2");
    realtimedatas.add(realtimedata2);
    FieldDescriptor[] fieldpath = new FieldDescriptor[] { fieldWithPath("id").description("ID of the RealTimeData"), fieldWithPath("assetID").description("ID of the asset, created by flowgate"), fieldWithPath("values").description("List of ValueUnit"), fieldWithPath("time").description("Create time of ValueUnit"), subsectionWithPath("values").description("A list of sensor data. eg. Humidity , Electric... ").type(ValueUnit[].class) };
    this.mockMvc.perform(post("/v1/assets/sensordata/batchoperation").contentType(MediaType.APPLICATION_JSON_VALUE).content(objectMapper.writeValueAsString(realtimedatas))).andExpect(status().isCreated()).andDo(document("assets-realTimeDatabatchCreation-example", requestFields(fieldWithPath("[]").description("An array of RealTimeData")).andWithPrefix("[].", fieldpath)));
    realtimeDataRepository.deleteById(realtimedata1.getId());
    realtimeDataRepository.deleteById(realtimedata2.getId());
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) ArrayList(java.util.ArrayList) ValueUnit(com.vmware.flowgate.common.model.ValueUnit) FieldDescriptor(org.springframework.restdocs.payload.FieldDescriptor) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 44 with ValueUnit

use of com.vmware.flowgate.common.model.ValueUnit in project flowgate by vmware.

the class AssetControllerTest method createPduAllRealTimeData.

RealTimeData createPduAllRealTimeData(Long time) {
    RealTimeData realTimeData = new RealTimeData();
    List<ValueUnit> valueunits = new ArrayList<ValueUnit>();
    // PDU current 1.455 = sum(OutLet-Current)
    ValueUnit pduCurrentValueUnit = new ValueUnit();
    pduCurrentValueUnit.setKey(MetricName.PDU_TOTAL_CURRENT);
    pduCurrentValueUnit.setValueNum(1.455);
    pduCurrentValueUnit.setTime(time);
    pduCurrentValueUnit.setUnit(MetricUnit.A.toString());
    valueunits.add(pduCurrentValueUnit);
    // PDU voltage 221
    ValueUnit pduVoltageValueUnit = new ValueUnit();
    pduVoltageValueUnit.setKey(MetricName.PDU_VOLTAGE);
    pduVoltageValueUnit.setValueNum(221);
    pduVoltageValueUnit.setTime(time);
    pduVoltageValueUnit.setUnit(MetricUnit.V.toString());
    valueunits.add(pduVoltageValueUnit);
    // PDU power 0.322 sum(OutLet-Power)
    ValueUnit pduPowerValueUnit = new ValueUnit();
    pduPowerValueUnit.setKey(MetricName.PDU_TOTAL_POWER);
    pduPowerValueUnit.setValueNum(0.322);
    pduPowerValueUnit.setTime(time);
    pduPowerValueUnit.setUnit(MetricUnit.kW.toString());
    valueunits.add(pduPowerValueUnit);
    // PDU powerLoad 0.05
    ValueUnit powerLoadValueUnit = new ValueUnit();
    powerLoadValueUnit.setKey(MetricName.PDU_POWER_LOAD);
    powerLoadValueUnit.setValueNum(0.05);
    powerLoadValueUnit.setTime(time);
    powerLoadValueUnit.setUnit(MetricUnit.percent.toString());
    valueunits.add(powerLoadValueUnit);
    // PDU currentLoad 0.05
    ValueUnit currentLoadValueUnit = new ValueUnit();
    currentLoadValueUnit.setKey(MetricName.PDU_CURRENT_LOAD);
    currentLoadValueUnit.setValueNum(0.05);
    currentLoadValueUnit.setTime(time);
    currentLoadValueUnit.setUnit(MetricUnit.percent.toString());
    valueunits.add(currentLoadValueUnit);
    // Outlet:1 apparent power 0.081
    ValueUnit outLetApparentPowerValueUnit = new ValueUnit();
    outLetApparentPowerValueUnit.setKey(MetricName.PDU_APPARENT_POWER);
    outLetApparentPowerValueUnit.setValueNum(0.081);
    outLetApparentPowerValueUnit.setExtraidentifier("OUTLET:1");
    outLetApparentPowerValueUnit.setTime(time);
    outLetApparentPowerValueUnit.setUnit(MetricUnit.kW.toString());
    valueunits.add(outLetApparentPowerValueUnit);
    // Outlet:1 active power 0.054
    ValueUnit valueunitActivePower = new ValueUnit();
    valueunitActivePower.setKey(MetricName.PDU_ACTIVE_POWER);
    valueunitActivePower.setUnit(MetricUnit.kW.toString());
    valueunitActivePower.setExtraidentifier("OUTLET:1");
    valueunitActivePower.setValueNum(0.054);
    valueunitActivePower.setTime(time);
    valueunits.add(valueunitActivePower);
    // Outlet:1 current 0.365
    ValueUnit currentValueUnit = new ValueUnit();
    currentValueUnit.setKey(MetricName.PDU_CURRENT);
    currentValueUnit.setValueNum(0.365);
    currentValueUnit.setExtraidentifier("OUTLET:1");
    currentValueUnit.setTime(time);
    currentValueUnit.setUnit(MetricUnit.A.toString());
    valueunits.add(currentValueUnit);
    // Outlet:1 voltage 221
    ValueUnit voltageValueUnit = new ValueUnit();
    voltageValueUnit.setKey(MetricName.PDU_VOLTAGE);
    voltageValueUnit.setValueNum(221);
    voltageValueUnit.setExtraidentifier("OUTLET:1");
    voltageValueUnit.setTime(time);
    voltageValueUnit.setUnit(MetricUnit.V.toString());
    valueunits.add(voltageValueUnit);
    // Outlet:1 freeCapacity 9.635
    ValueUnit valueunitFreeCapacity = new ValueUnit();
    valueunitFreeCapacity.setKey(MetricName.PDU_FREE_CAPACITY);
    valueunitFreeCapacity.setUnit(MetricUnit.A.toString());
    valueunitFreeCapacity.setExtraidentifier("OUTLET:1");
    valueunitFreeCapacity.setValueNum(9.635);
    valueunitFreeCapacity.setTime(time);
    valueunits.add(valueunitFreeCapacity);
    // Outlet:2 apparent power 0.241
    ValueUnit outLet2ApparentPowerValueUnit = new ValueUnit();
    outLet2ApparentPowerValueUnit.setKey(MetricName.PDU_APPARENT_POWER);
    outLet2ApparentPowerValueUnit.setValueNum(0.241);
    outLet2ApparentPowerValueUnit.setExtraidentifier("OUTLET:2");
    outLet2ApparentPowerValueUnit.setTime(time);
    outLet2ApparentPowerValueUnit.setUnit(MetricUnit.kW.toString());
    valueunits.add(outLet2ApparentPowerValueUnit);
    // Outlet:2 active power 0.2
    ValueUnit outLet2valueunitActivePower = new ValueUnit();
    outLet2valueunitActivePower.setKey(MetricName.PDU_ACTIVE_POWER);
    outLet2valueunitActivePower.setUnit(MetricUnit.kW.toString());
    outLet2valueunitActivePower.setExtraidentifier("OUTLET:2");
    outLet2valueunitActivePower.setValueNum(0.2);
    outLet2valueunitActivePower.setTime(time);
    valueunits.add(outLet2valueunitActivePower);
    // Outlet:2 current 1.09
    ValueUnit outLet2currentValueUnit = new ValueUnit();
    outLet2currentValueUnit.setKey(MetricName.PDU_CURRENT);
    outLet2currentValueUnit.setValueNum(1.09);
    outLet2currentValueUnit.setExtraidentifier("OUTLET:2");
    outLet2currentValueUnit.setTime(time);
    outLet2currentValueUnit.setUnit(MetricUnit.A.toString());
    valueunits.add(outLet2currentValueUnit);
    // Outlet:2 voltage 221
    ValueUnit outLet2voltageValueUnit = new ValueUnit();
    outLet2voltageValueUnit.setKey(MetricName.PDU_VOLTAGE);
    outLet2voltageValueUnit.setValueNum(221);
    outLet2voltageValueUnit.setExtraidentifier("OUTLET:2");
    outLet2voltageValueUnit.setTime(time);
    outLet2voltageValueUnit.setUnit(MetricUnit.V.toString());
    valueunits.add(outLet2voltageValueUnit);
    // Outlet:2 freeCapacity 8.91
    ValueUnit outLet2valueunitFreeCapacity = new ValueUnit();
    outLet2valueunitFreeCapacity.setKey(MetricName.PDU_FREE_CAPACITY);
    outLet2valueunitFreeCapacity.setUnit(MetricUnit.A.toString());
    outLet2valueunitFreeCapacity.setExtraidentifier("OUTLET:2");
    outLet2valueunitFreeCapacity.setValueNum(8.91);
    outLet2valueunitFreeCapacity.setTime(time);
    valueunits.add(outLet2valueunitFreeCapacity);
    // Inlet Pole metrics 30.545
    ValueUnit valueunitL1FreeCapacity = new ValueUnit();
    valueunitL1FreeCapacity.setKey(MetricName.PDU_FREE_CAPACITY);
    valueunitL1FreeCapacity.setUnit(MetricUnit.A.toString());
    valueunitL1FreeCapacity.setExtraidentifier("INLET:1" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunitL1FreeCapacity.setValueNum(30.545);
    valueunitL1FreeCapacity.setTime(time);
    valueunits.add(valueunitL1FreeCapacity);
    // 1.455
    ValueUnit valueunitL1Current = new ValueUnit();
    valueunitL1Current.setKey(MetricName.PDU_CURRENT);
    valueunitL1Current.setUnit(MetricUnit.A.toString());
    valueunitL1Current.setExtraidentifier("INLET:1" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunitL1Current.setValueNum(1.455);
    valueunitL1Current.setTime(time);
    valueunits.add(valueunitL1Current);
    // 221
    ValueUnit valueunitL1Voltage = new ValueUnit();
    valueunitL1Voltage.setKey(MetricName.PDU_VOLTAGE);
    valueunitL1Voltage.setUnit(MetricUnit.V.toString());
    valueunitL1Voltage.setExtraidentifier("INLET:1" + FlowgateConstant.INLET_POLE_NAME_PREFIX + 1);
    valueunitL1Voltage.setValueNum(221);
    valueunitL1Voltage.setTime(time);
    valueunits.add(valueunitL1Voltage);
    realTimeData.setId(UUID.randomUUID().toString());
    realTimeData.setValues(valueunits);
    realTimeData.setTime(time);
    return realTimeData;
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) ArrayList(java.util.ArrayList) ValueUnit(com.vmware.flowgate.common.model.ValueUnit)

Example 45 with ValueUnit

use of com.vmware.flowgate.common.model.ValueUnit in project flowgate by vmware.

the class AssetControllerTest method createServerPDURealTimeData.

RealTimeData createServerPDURealTimeData(long time) {
    List<ValueUnit> valueunits = new ArrayList<ValueUnit>();
    ValueUnit totalPowerValueUnit = new ValueUnit();
    totalPowerValueUnit.setKey(MetricName.PDU_TOTAL_POWER);
    totalPowerValueUnit.setValueNum(1.033);
    totalPowerValueUnit.setTime(time);
    totalPowerValueUnit.setUnit(MetricUnit.kW.toString());
    valueunits.add(totalPowerValueUnit);
    ValueUnit totalCurrentValueUnit = new ValueUnit();
    totalCurrentValueUnit.setKey(MetricName.PDU_TOTAL_CURRENT);
    totalCurrentValueUnit.setValueNum(4.566);
    totalCurrentValueUnit.setTime(time);
    totalCurrentValueUnit.setUnit(MetricUnit.A.toString());
    valueunits.add(totalCurrentValueUnit);
    ValueUnit apparentPowerValueUnit = new ValueUnit();
    apparentPowerValueUnit.setKey(MetricName.PDU_APPARENT_POWER);
    apparentPowerValueUnit.setValueNum(1.033);
    apparentPowerValueUnit.setExtraidentifier("OUTLET:7");
    apparentPowerValueUnit.setTime(time);
    apparentPowerValueUnit.setUnit(MetricUnit.kW.toString());
    valueunits.add(apparentPowerValueUnit);
    ValueUnit currentValueUnit = new ValueUnit();
    currentValueUnit.setKey(MetricName.PDU_CURRENT);
    currentValueUnit.setValueNum(0.633);
    currentValueUnit.setExtraidentifier("OUTLET:7");
    currentValueUnit.setTime(time);
    currentValueUnit.setUnit(MetricUnit.A.toString());
    valueunits.add(currentValueUnit);
    ValueUnit voltageValueUnit = new ValueUnit();
    voltageValueUnit.setKey(MetricName.PDU_VOLTAGE);
    voltageValueUnit.setValueNum(226);
    voltageValueUnit.setExtraidentifier("OUTLET:7");
    voltageValueUnit.setTime(time);
    voltageValueUnit.setUnit(MetricUnit.V.toString());
    valueunits.add(voltageValueUnit);
    ValueUnit powerLoadValueUnit = new ValueUnit();
    powerLoadValueUnit.setKey(MetricName.PDU_POWER_LOAD);
    powerLoadValueUnit.setValueNum(0.134);
    powerLoadValueUnit.setTime(time);
    powerLoadValueUnit.setUnit(MetricUnit.percent.toString());
    valueunits.add(powerLoadValueUnit);
    ValueUnit currentLoadValueUnit = new ValueUnit();
    currentLoadValueUnit.setKey(MetricName.PDU_CURRENT_LOAD);
    currentLoadValueUnit.setValueNum(0.1427);
    currentLoadValueUnit.setTime(time);
    currentLoadValueUnit.setUnit(MetricUnit.percent.toString());
    valueunits.add(currentLoadValueUnit);
    RealTimeData realTimeData = new RealTimeData();
    realTimeData.setId(UUID.randomUUID().toString());
    realTimeData.setAssetID("0001bdc8b25d4c2badfd045ab61aabfa");
    realTimeData.setValues(valueunits);
    realTimeData.setTime(time);
    return realTimeData;
}
Also used : RealTimeData(com.vmware.flowgate.common.model.RealTimeData) ArrayList(java.util.ArrayList) ValueUnit(com.vmware.flowgate.common.model.ValueUnit)

Aggregations

ValueUnit (com.vmware.flowgate.common.model.ValueUnit)63 ArrayList (java.util.ArrayList)42 RealTimeData (com.vmware.flowgate.common.model.RealTimeData)28 HashMap (java.util.HashMap)25 MetricData (com.vmware.flowgate.common.model.MetricData)23 Test (org.junit.Test)23 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 TranslateContext (com.vmware.flowgate.common.model.TranslateContext)13 Map (java.util.Map)11 List (java.util.List)9 Asset (com.vmware.flowgate.common.model.Asset)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 WormholeException (com.vmware.flowgate.common.exception.WormholeException)3 MetricUnit (com.vmware.flowgate.common.model.ValueUnit.MetricUnit)3 PowerManageMetricsRequestBody (com.vmware.flowgate.openmanage.datamodel.PowerManageMetricsRequestBody)3 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)3 FacilitySoftwareConfig (com.vmware.flowgate.common.model.FacilitySoftwareConfig)2 DevicePower (com.vmware.flowgate.openmanage.datamodel.DevicePower)2 Outlet (com.vmware.flowgate.poweriqworker.model.Outlet)2 Pdu (com.vmware.flowgate.poweriqworker.model.Pdu)2