public static int getPinNumber(String pinName) throws InvalidGPIOException{

		int pinNumber = -1;
		// See if we have the JSON for this Pin
		JSONObject pinJSON = DTO.findDetails(pinName);
		if (pinJSON != null && pinJSON.containsKey("gpio")) {
			try {
				pinNumber = Integer.parseInt((String) pinJSON.get("gpio"));
			} catch (ClassCastException f) {
				pinNumber = ((Long)pinJSON.get("gpio")).intValue();
			}
		} else {
			Matcher matcher = pinPatternAlt.matcher(pinName);
			if (matcher.find()) {
				pinNumber = Integer.parseInt(matcher.group(matcher.groupCount()));
			} else {
				matcher = pinPattern.matcher(pinName);
				if (matcher.find()) {
					pinNumber = Integer.parseInt(matcher.group(3));
					pinNumber += Integer.parseInt(matcher.group(2))*32;
				} else {
					throw new InvalidGPIOException("Could not match " + pinName + ". As a valid gpio pinout number");
				}
			}
			
		}
		
		return pinNumber;
	
	}