use of org.openmuc.jdlms.MethodResultCode in project open-smart-grid-platform by OSGP.
the class DeviceChannelsHelperTest method testDeinstallSlave4.
@Test
void testDeinstallSlave4() throws ProtocolAdapterException {
// unsuccessful deinstall with unsigned integer parameter (second
// attempt)
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.mBusSetup.callMethod(eq(MBusClientMethod.SLAVE_DEINSTALL), any(DataObject.class))).thenReturn(MethodResultCode.TYPE_UNMATCHED).thenReturn(MethodResultCode.SCOPE_OF_ACCESS_VIOLATION);
final MethodResultCode methodResultCode = this.deviceChannelsHelper.deinstallSlave(this.conn, this.device, (short) 1, this.mBusSetup);
assertThat(methodResultCode).isEqualTo(MethodResultCode.SCOPE_OF_ACCESS_VIOLATION);
verify(this.mBusSetup, times(2)).callMethod(eq(MBusClientMethod.SLAVE_DEINSTALL), any());
}
use of org.openmuc.jdlms.MethodResultCode in project open-smart-grid-platform by OSGP.
the class DeviceChannelsHelperTest method testDeinstallSlave.
@Test
void testDeinstallSlave() throws ProtocolAdapterException {
// successful deinstall with signed integer parameter
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.mBusSetup.callMethod(eq(MBusClientMethod.SLAVE_DEINSTALL), any())).thenReturn(MethodResultCode.SUCCESS);
final MethodResultCode methodResultCode = this.deviceChannelsHelper.deinstallSlave(this.conn, this.device, (short) 1, this.mBusSetup);
assertThat(methodResultCode).isEqualTo(MethodResultCode.SUCCESS);
verify(this.mBusSetup, times(1)).callMethod(eq(MBusClientMethod.SLAVE_DEINSTALL), any());
}
use of org.openmuc.jdlms.MethodResultCode in project open-smart-grid-platform by OSGP.
the class DeviceChannelsHelperTest method testDeinstallSlave2.
@Test
void testDeinstallSlave2() throws ProtocolAdapterException {
// successful deinstall with unsigned integer parameter after
// unsuccessful
// attempt with signed integer (TYPE_UNMATCHED)
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.mBusSetup.callMethod(eq(MBusClientMethod.SLAVE_DEINSTALL), any(DataObject.class))).thenReturn(MethodResultCode.TYPE_UNMATCHED).thenReturn(MethodResultCode.SUCCESS);
final MethodResultCode methodResultCode = this.deviceChannelsHelper.deinstallSlave(this.conn, this.device, (short) 1, this.mBusSetup);
assertThat(methodResultCode).isEqualTo(MethodResultCode.SUCCESS);
verify(this.mBusSetup, times(2)).callMethod(eq(MBusClientMethod.SLAVE_DEINSTALL), any());
}
use of org.openmuc.jdlms.MethodResultCode in project open-smart-grid-platform by OSGP.
the class DeviceChannelsHelper method deinstallSlave.
protected MethodResultCode deinstallSlave(final DlmsConnectionManager conn, final DlmsDevice device, final short channel, final CosemObjectAccessor mBusSetup) throws ProtocolAdapterException {
// in blue book version 10, the parameter is of type integer
DataObject parameter = DataObject.newInteger8Data((byte) 0);
conn.getDlmsMessageListener().setDescription("Call slave deinstall method");
MethodResultCode slaveDeinstallResultCode = mBusSetup.callMethod(MBusClientMethod.SLAVE_DEINSTALL, parameter);
if (slaveDeinstallResultCode == MethodResultCode.TYPE_UNMATCHED) {
// in blue book version 12, the parameter is of type unsigned, we
// will try again with that type
parameter = DataObject.newUInteger8Data((byte) 0);
slaveDeinstallResultCode = mBusSetup.callMethod(MBusClientMethod.SLAVE_DEINSTALL, parameter);
}
if (slaveDeinstallResultCode != MethodResultCode.SUCCESS) {
log.warn("Slave deinstall was not successfull on device {} on channel {}", device.getDeviceIdentification(), channel);
}
return slaveDeinstallResultCode;
}
use of org.openmuc.jdlms.MethodResultCode in project open-smart-grid-platform by OSGP.
the class ImageTransfer method initiateImageTransfer.
/**
* Initiates Image transfer.After a successful initiation, the value of the image_transfer_status
* attribute is (1) Image transfer initiated and the COSEM server is prepared to accept
* ImageBlocks.
*/
public void initiateImageTransfer() throws ProtocolAdapterException {
final List<DataObject> params = new ArrayList<>();
params.add(DataObject.newOctetStringData(this.imageIdentifier));
params.add(DataObject.newUInteger32Data(this.getImageSize()));
final DataObject parameter = DataObject.newStructureData(params);
this.setDescriptionForMethodCall(ImageTransferMethod.IMAGE_TRANSFER_INITIATE, parameter);
final MethodResultCode resultCode = this.imageTransferCosem.callMethod(ImageTransferMethod.IMAGE_TRANSFER_INITIATE, parameter);
if (resultCode != MethodResultCode.SUCCESS) {
log.warn("Method IMAGE_TRANSFER_INITIATE gave result {}", resultCode);
}
}
Aggregations