// Path: src/org/jergometer/translation/I18n.java
// public class I18n {
//   @NonNls
//   public static final ResourceBundle bundle = Utf8ResourceBundle.getBundle("org.jergometer.translation.jergometer");
// 
//   public static String getString(@PropertyKey(resourceBundle = "org.jergometer.translation.jergometer") String key, Object... params) {
//     String value = bundle.getString(key);
//     if (params.length == 0) {
//       return value;
//     } else {
//       return String.format(value, params);
//     }
//   }
// 
//   public static char getMnemonic(@PropertyKey(resourceBundle = "org.jergometer.translation.jergometer") String key) {
//     String value = getString(key);
//     if (value == null) {
//       return '!';
//     }
//     return value.charAt(0);
//   }
// }


import gnu.io.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import org.jergometer.translation.I18n;

package org.jergometer.communication;




/**
 * KettlerBikeConnector connects to the bike via serial port (e.g. RS232 or USB).
 * It is used to receive data from the bike and to control it.
 */
public class KettlerBikeConnector implements BikeConnector {

// dynamic

	private SerialPort serialPort;
	public KettlerBikeReader reader = null;
	public KettlerBikeWriter writer = null;
	private int power;

	public void connect(String serialName, BikeListener listener) throws BikeException, UnsupportedCommOperationException, IOException {
		RXTXLibrary.init();

		Enumeration portList = CommPortIdentifier.getPortIdentifiers();

		while (portList.hasMoreElements()) {
			CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();

			if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
				if(portId.getName().equals(serialName)) {
					if(portId.isCurrentlyOwned()) {

// Path: src/org/jergometer/translation/I18n.java
// public class I18n {
//   @NonNls
//   public static final ResourceBundle bundle = Utf8ResourceBundle.getBundle("org.jergometer.translation.jergometer");
// 
//   public static String getString(@PropertyKey(resourceBundle = "org.jergometer.translation.jergometer") String key, Object... params) {
//     String value = bundle.getString(key);
//     if (params.length == 0) {
//       return value;
//     } else {
//       return String.format(value, params);
//     }
//   }
// 
//   public static char getMnemonic(@PropertyKey(resourceBundle = "org.jergometer.translation.jergometer") String key) {
//     String value = getString(key);
//     if (value == null) {
//       return '!';
//     }
//     return value.charAt(0);
//   }
// }


// Path: src/org/jergometer/communication/KettlerBikeConnector.java
import gnu.io.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import org.jergometer.translation.I18n;

package org.jergometer.communication;




/**
 * KettlerBikeConnector connects to the bike via serial port (e.g. RS232 or USB).
 * It is used to receive data from the bike and to control it.
 */
public class KettlerBikeConnector implements BikeConnector {

// dynamic

	private SerialPort serialPort;
	public KettlerBikeReader reader = null;
	public KettlerBikeWriter writer = null;
	private int power;

	public void connect(String serialName, BikeListener listener) throws BikeException, UnsupportedCommOperationException, IOException {
		RXTXLibrary.init();

		Enumeration portList = CommPortIdentifier.getPortIdentifiers();

		while (portList.hasMoreElements()) {
			CommPortIdentifier portId = (CommPortIdentifier) portList.nextElement();

			if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
				if(portId.getName().equals(serialName)) {
					if(portId.isCurrentlyOwned()) {

						throw new BikeException(I18n.getString("msg.serial_port_used_by_the_following_application", portId.getCurrentOwner()));
