use of org.openmuc.framework.server.spi.ServerMappingContainer in project OpenMUC by isc-konstanz.
the class ModbusServer method bindMappings.
private void bindMappings(List<ServerMappingContainer> mappings) {
if (logger.isDebugEnabled()) {
logger.debug("Bind mappings of {} channel.", mappings.size());
}
for (final ServerMappingContainer container : mappings) {
String serverAddress = container.getServerMapping().getServerAddress();
PrimaryTable primaryTable = PrimaryTable.getEnumfromString(serverAddress.substring(0, serverAddress.indexOf(':')));
int modbusAddress = Integer.parseInt(serverAddress.substring(serverAddress.indexOf(':') + 1, serverAddress.lastIndexOf(':')));
String dataTypeStr = serverAddress.substring(serverAddress.lastIndexOf(':') + 1);
DataType dataType = DataType.valueOf(dataTypeStr);
logMapping(primaryTable, modbusAddress, dataType, container.getChannel());
switch(primaryTable) {
case INPUT_REGISTERS:
addInputRegisters(spi, modbusAddress, dataType, container.getChannel());
break;
case HOLDING_REGISTERS:
addHoldingRegisters(spi, modbusAddress, dataType, container.getChannel());
break;
case COILS:
// TODO: create for coils
break;
case DISCRETE_INPUTS:
// TODO: create for discrete inputs
break;
default:
}
}
}
use of org.openmuc.framework.server.spi.ServerMappingContainer in project OpenMUC by isc-konstanz.
the class DataManager method notifyServer.
/**
* Updates a specified ServerService with mapped channels.
*
* @param serverService
* ServerService object to updating
*/
protected void notifyServer(ServerService serverService) {
List<ServerMappingContainer> relatedServerMappings = new ArrayList<>();
for (ChannelConfig config : rootConfig.channelConfigsById.values()) {
for (ServerMapping serverMapping : config.getServerMappings()) {
if (serverMapping.getId().equals(serverService.getId())) {
relatedServerMappings.add(new ServerMappingContainer(this.getChannel(config.getId()), serverMapping));
}
}
}
serverService.serverMappings(relatedServerMappings);
}
Aggregations