use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class SimulatedAlarmObjectSteps method deviceAlarmRegistersHasNotBeenCleared.
@Then("^alarm register \"([^\"]*)\" of device \"([^\"]*)\" has not been cleared$")
public void deviceAlarmRegistersHasNotBeenCleared(final int alarmRegisterNr, final String deviceIdentification) {
this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
final ObisCode alarmRegisterObisCode = this.getAlarmRegisterObisCode(alarmRegisterNr);
final ObjectNode result = this.deviceSimulatorSteps.getDlmsAttributeValue(CLASS_ID, alarmRegisterObisCode, ATTRIBUTE_ID_VALUE, OBJECT_DESCRIPTION);
assertThat(result.get("value").intValue()).isNotZero();
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class SimulatedAlarmObjectSteps method deviceAlarmRegistersHasBeenCleared.
@Then("^alarm register \"([^\"]*)\" of device \"([^\"]*)\" has been cleared$")
public void deviceAlarmRegistersHasBeenCleared(final int alarmRegisterNr, final String deviceIdentification) {
this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
final ObisCode alarmRegisterObisCode = this.getAlarmRegisterObisCode(alarmRegisterNr);
final ObjectNode result = this.deviceSimulatorSteps.getDlmsAttributeValue(CLASS_ID, alarmRegisterObisCode, ATTRIBUTE_ID_VALUE, OBJECT_DESCRIPTION);
assertThat(result.get("value").intValue()).isZero();
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class MBusClientObjectSteps method deviceSimulationOfMBusClientObject.
@Given("^device simulation of \"([^\"]*)\" with M-Bus client version (\\d+) values for channel (\\d+)$")
public void deviceSimulationOfMBusClientObject(final String deviceIdentification, final int version, final int channel, final Map<String, String> inputSettings) throws Throwable {
this.deviceSimulatorSteps.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
final ObisCode obisCode = new ObisCode(0, channel, 24, 1, 0, 255);
inputSettings.forEach((key, value) -> {
switch(key) {
case MBUS_PRIMARY_ADDRESS:
this.setStandardAttribute(value, "unsigned", ATTRIBUTE_ID_PRIMARY_ADDRESS, obisCode);
break;
case MBUS_IDENTIFICATION_NUMBER:
this.setIdentificationNumberAttribute(value, obisCode, version);
break;
case MBUS_MANUFACTURER_IDENTIFICATION:
this.setManufacturerIdAttribute(value, obisCode);
break;
case MBUS_VERSION:
this.setStandardAttribute(value, "unsigned", ATTRIBUTE_ID_VERSION, obisCode);
break;
case MBUS_DEVICE_TYPE_IDENTIFICATION:
this.setStandardAttribute(value, "unsigned", ATTRIBUTE_ID_DEVICE_TYPE, obisCode);
break;
case MBUS_ENCRYPTION_KEY_STATUS:
this.setStandardAttribute(value, "enumerate", ATTRIBUTE_ID_ENCRYPTION_KEY_STATUS, obisCode);
break;
default:
throw new IllegalArgumentException("Unsupported attribute: " + key);
}
});
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class DeviceSimulatorSteps method deviceSimulationOfObisCodeWithClassIdAndAttributes.
@Given("^device simulation of \"([^\"]*)\" with classid (\\d+) obiscode \"([^\"]*)\" and attributes$")
public void deviceSimulationOfObisCodeWithClassIdAndAttributes(final String deviceIdentification, final int classId, final String obisCode, final List<List<String>> attributes) throws Throwable {
/*
* Currently the first argument: deviceIdentification, is not used yet,
* because in all scenarios created so far that make use of dynamic
* device simulator properties, only one meter was read. In future
* scenarios it may be possible that within a single scenario two (or
* more) meters should be read, and that both meters should read their
* own set of dynamic properties. In that case the deviceIdentification
* parameter can be used to make this distinction.
*/
this.deviceSimulationOfEquipmentIdentifier(deviceIdentification);
this.setDlmsAttributeValues(classId, new ObisCode(obisCode), this.jsonObjectCreator.convertTableToJsonObject(attributes), GENERIC_ATTRIBUTES_FROM_SCENARIO);
}
use of org.openmuc.jdlms.ObisCode in project open-smart-grid-platform by OSGP.
the class DeviceSimulatorSteps method theValuesForClassidObiscodeOnDeviceSimulatorAre.
@Then("^the values for classid (\\d+) obiscode \"([^\"]*)\" on device simulator \"([^\"]*)\" are$")
public void theValuesForClassidObiscodeOnDeviceSimulatorAre(final int classId, final String obisCode, final String deviceIdentification, final List<List<String>> expectedAttributes) throws Throwable {
final ObjectNode attributeValuesNode = this.getDlmsAttributeValues(classId, new ObisCode(obisCode), GENERIC_ATTRIBUTES_FROM_SCENARIO);
final ObjectNode expectedAttributeValuesNode = this.jsonObjectCreator.convertTableToJsonObject(expectedAttributes);
expectedAttributeValuesNode.fields().forEachRemaining(field -> {
final String attributeId = field.getKey();
final JsonNode expectedAttributeValue = field.getValue();
final JsonNode actualAttributeValue = attributeValuesNode.get(attributeId);
assertThat(actualAttributeValue).as("a value must be available for attributeId: " + attributeId).isNotNull();
assertThat(actualAttributeValue).as("value for attributeId: " + attributeId).isEqualTo(expectedAttributeValue);
});
}
Aggregations