MicrochipPotentiometerDeviceController { public void setTerminalConfiguration(final DeviceControllerTerminalConfiguration config) throws IOException { if (config == null) { throw new RuntimeException("null-config is not allowed!"); } final DeviceControllerChannel channel = config.getChannel(); if (channel == null) { throw new RuntimeException("null-channel is not allowed. For devices " + "knowing just one wiper Channel.A is mandatory for " + "parameter 'channel'"); } byte memAddr = config.getChannel().getTerminalControllAddress(); int tcon = read(memAddr); tcon = setBit(tcon, channel.getHardwareConfigControlBit(), config.isChannelEnabled()); tcon = setBit(tcon, channel.getTerminalAConnectControlBit(), config.isPinAEnabled()); tcon = setBit(tcon, channel.getWiperConnectControlBit(), config.isPinWEnabled()); tcon = setBit(tcon, channel.getTerminalBConnectControlBit(), config.isPinBEnabled()); write(memAddr, tcon); } MicrochipPotentiometerDeviceController(final I2CDevice i2cDevice); DeviceControllerDeviceStatus getDeviceStatus(); void increase(final DeviceControllerChannel channel, final int steps); void decrease(final DeviceControllerChannel channel, final int steps); int getValue(final DeviceControllerChannel channel, final boolean nonVolatile); void setValue(final DeviceControllerChannel channel, final int value,
			final boolean nonVolatile); DeviceControllerTerminalConfiguration getTerminalConfiguration(
			final DeviceControllerChannel channel); void setTerminalConfiguration(final DeviceControllerTerminalConfiguration config); void setWiperLock(final DeviceControllerChannel channel,
			final boolean locked); void setWriteProtection(final boolean enabled); @Override String toString(); @Override boolean equals(final Object obj); static final boolean VOLATILE_WIPER; static final boolean NONVOLATILE_WIPER; }
@Test public void testSetTerminalConfiguration() throws IOException { try { controller.setTerminalConfiguration(null); fail("Got no RuntimeException on calling 'setTerminalConfiguration(null)'!"); } catch (RuntimeException e) { } try { controller.setTerminalConfiguration(new DeviceControllerTerminalConfiguration( null, false, false, false, false)); fail("Got no RuntimeException on calling 'setTerminalConfiguration(tcon)' " + " where tcon.getChannel() is null!"); } catch (RuntimeException e) { } mockReadResult(i2cDevice, (byte) 0, (byte) 0b0101010101, null); DeviceControllerTerminalConfiguration tconA = new DeviceControllerTerminalConfiguration( DeviceControllerChannel.A, true, true, true, false); controller.setTerminalConfiguration(tconA); testForWriteAndRead((byte) 0b1001100); verify(i2cDevice).write(new byte[] { (byte) 0b1000000, (byte) 0b01011110 }, 0, 2); DeviceControllerTerminalConfiguration tconB = new DeviceControllerTerminalConfiguration( DeviceControllerChannel.B, false, false, false, true); controller.setTerminalConfiguration(tconB); testForWriteAndRead((byte) 0b1001100, 2); verify(i2cDevice).write(new byte[] { (byte) 0b1000000, (byte) 0b00010101 }, 0, 2); }