@Override
protected void internalReceiveCommand(String itemName,
Command command) {
HDanywhereBindingProvider provider = findFirstMatchingBindingProvider(itemName);
if (provider == null) {
logger.trace("doesn't find matching binding provider [itemName={}, command={}]", itemName, command);
return;
}
List<String> hosts = provider.getHosts(itemName);
int sourcePort = Integer.valueOf(command.toString());
for(String aHost : hosts) {
Integer numberOfPorts = matrixCache.get(aHost);
if(numberOfPorts == null) {
// we default to the smallest matrix currently sold by HDanywhere
numberOfPorts = 4;
}
if(sourcePort > numberOfPorts) {
// nice try - we can switch to a port that does not physically exist
logger.warn("{} goes beyond the physical number of {} ports available on the matrix {}",new Object[]{sourcePort,numberOfPorts,aHost});
} else {
List<Integer> ports = provider.getPorts(aHost,itemName);
String httpMethod = "GET";
String url = "http://"+aHost+"/switch.cgi?command=3&data0=";
for(Integer aPort : ports) {