use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class ScanMbusChannelsCommandExecutor method makeAttributeAddressesShortIds.
/**
* @see #ATTRIBUTE_IDS_SHORT_ID
* @see #channelShortIdsFromGetResults(List, Protocol)
*/
private static AttributeAddress[] makeAttributeAddressesShortIds() {
final AttributeAddress[] shortIdAddresses = new AttributeAddress[NUMBER_OF_CHANNELS * NUMBER_OF_SHORT_ID_ATTRIBUTES_PER_CHANNEL];
int index = 0;
for (int channel = 1; channel <= NUMBER_OF_CHANNELS; channel++) {
final ObisCode obisCode = getObisCodeMbusClientSetup(channel);
for (int i = 0; i < NUMBER_OF_SHORT_ID_ATTRIBUTES_PER_CHANNEL; i++) {
shortIdAddresses[index++] = new AttributeAddress(CLASS_ID, obisCode, ATTRIBUTE_IDS_SHORT_ID[i]);
}
}
return shortIdAddresses;
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class GetMbusEncryptionKeyStatusCommandExecutor method getEncryptionKeyStatusTypeDto.
public EncryptionKeyStatusTypeDto getEncryptionKeyStatusTypeDto(final short channel, final DlmsConnectionManager conn) throws ProtocolAdapterException {
final ObisCode obisCode = OBIS_CODES.get(channel);
final AttributeAddress getParameter = new AttributeAddress(CLASS_ID, obisCode, ATTRIBUTE_ID);
conn.getDlmsMessageListener().setDescription("GetMbusEncryptionKeyStatusByChannel, retrieve attribute: " + JdlmsObjectToStringUtil.describeAttributes(getParameter));
LOGGER.info("Retrieving current M-Bus encryption key status by issuing get request for class id: {}, obis code: " + "{}, attribute id: {}", CLASS_ID, obisCode, ATTRIBUTE_ID);
final DataObject dataObject = this.getValidatedResultData(conn, getParameter);
return EncryptionKeyStatusTypeDto.valueOf(EncryptionKeyStatusType.fromValue(dataObject.getValue()).name());
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class SimulatedAlarmObjectSteps method deviceHasSomeAlarmsRegistered.
@Given("^device \"([^\"]*)\" has alarm register \"([^\"]*)\" with some value$")
public void deviceHasSomeAlarmsRegistered(final String deviceIdentification, final int alarmRegisterNr) {
this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
final ObisCode alarmRegisterObisCode = this.getAlarmRegisterObisCode(alarmRegisterNr);
final ObjectNode attributeValue = this.jsonObjectCreator.createAttributeValue("double-long-unsigned", ALARM_VALUE);
this.deviceSimulatorSteps.setDlmsAttributeValue(CLASS_ID, alarmRegisterObisCode, ATTRIBUTE_ID_VALUE, attributeValue, OBJECT_DESCRIPTION);
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class DeviceChannelsHelperTest method testGetObisCode.
@Test
void testGetObisCode() throws ProtocolAdapterException {
final int channel = 1;
final ObisCode obisCode = this.deviceChannelsHelper.getObisCode(this.device, channel);
assertThat(obisCode.asDecimalString()).isEqualTo(OBIS_CODE_MBUS_CHANNEL_ONE);
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class MBusClientObjectSteps method theValuesForMbusClientOnDeviceSimulatorAre.
@Then("^the values for the M-Bus client for channel (\\d+) on device simulator \"([^\"]*)\" are$")
public void theValuesForMbusClientOnDeviceSimulatorAre(final int channel, final String deviceIdentification, final Map<String, String> expectedAttributes) throws Throwable {
final ObisCode obisCode = new ObisCode(0, channel, 24, 1, 0, 255);
final ObjectNode attributeValuesNode = this.deviceSimulatorSteps.getDlmsAttributeValues(CLASS_ID, obisCode, "M-Bus client attributes");
expectedAttributes.forEach((key, value) -> {
switch(key) {
case MBUS_PRIMARY_ADDRESS:
this.verifyStandardAttribute(attributeValuesNode, ATTRIBUTE_ID_PRIMARY_ADDRESS, value);
break;
case MBUS_VERSION:
this.verifyStandardAttribute(attributeValuesNode, ATTRIBUTE_ID_VERSION, value);
break;
case MBUS_DEVICE_TYPE_IDENTIFICATION:
this.verifyStandardAttribute(attributeValuesNode, ATTRIBUTE_ID_DEVICE_TYPE, value);
break;
case MBUS_IDENTIFICATION_NUMBER:
this.verifyIdentificationNumber(attributeValuesNode, value);
break;
case MBUS_MANUFACTURER_IDENTIFICATION:
this.verifyManufacturerIdentification(attributeValuesNode, value);
break;
default:
throw new IllegalArgumentException("Unsupported attribute: " + key);
}
});
}
Aggregations