Search in sources :

Example 1 with PowerQualityObjectMetadata

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata in project open-smart-grid-platform by OSGP.

the class GetActualPowerQualityCommandExecutorTest method generateMockedResult.

private List<GetResult> generateMockedResult(final List<GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata> metadatas, final AccessResultCode resultCode, final DataObject dateTimeDataObject) {
    final List<GetResult> results = new ArrayList<>();
    int idx = 1;
    for (final PowerQualityObjectMetadata metadata : metadatas) {
        if (metadata.getClassId() == CLASS_ID_CLOCK) {
            results.add(new GetResultImpl(dateTimeDataObject, resultCode));
        } else {
            results.add(new GetResultImpl(DataObject.newInteger64Data(idx++), resultCode));
            if (metadata.getClassId() == CLASS_ID_REGISTER) {
                final List<DataObject> scalerUnit = new ArrayList<>();
                scalerUnit.add(DataObject.newInteger64Data(1));
                scalerUnit.add(DataObject.newInteger64Data(DlmsUnitTypeDto.VOLT.getIndex()));
                results.add(new GetResultImpl(DataObject.newArrayData(scalerUnit), resultCode));
            }
        }
    }
    return results;
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) GetResultImpl(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl) ArrayList(java.util.ArrayList) PowerQualityObjectMetadata(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata)

Aggregations

ArrayList (java.util.ArrayList)1 GetResult (org.openmuc.jdlms.GetResult)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 PowerQualityObjectMetadata (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata)1 GetResultImpl (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.testutil.GetResultImpl)1