// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java
// public interface PololuMaestroServoCard {
// 
// 	interface State {
// 		short getPosition(short channel);
// 	}
// 	
// 	void setPosition(short channel, short position);
// 	void setSpeed(short channel, short speed);
// 	void setAcceleration(short channel, short acceleration);
// 
// 	short getPosition(short channel);
// 	State getState();
// 	
// 	MaestroCardType getType();
// 
// }
// 
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java
// public class Usb {
// 
//     public static EasyUsbDevice device(short vendorId, short productId) {
//         return first(devices(vendorId, productId));
//     }
// 
//     public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) {
//         return first(devices(shouldIncludeDevice));
//     }
// 
//     public static List<EasyUsbDevice> devices(short vendorId, short productId) {
//     	return devices(deviceHasVendorIdAndProductId(vendorId, productId));
//     }
// 
//     public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) {
//         final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice);
//         deviceFinder.exploreRootUsbHub();
// 		return deviceFinder.getDevices();
//     }
// 
//     public static UsbHub rootUsbHub() {
//         try {
//             return usbServices().getRootUsbHub();
//         } catch (Exception e) {
//             throw new UsbRuntimeException(e);
//         }
//     }
// 
//     public static UsbServices usbServices() {
//         try {
//             return UsbHostManager.getUsbServices();
//         } catch (Exception e) {
//             throw new UsbRuntimeException(e);
//         }
//     }
// 
//     private static <T> T first(List<T> l) {
//         try {
//             return l.get(0);
//         } catch (IndexOutOfBoundsException e) {
//             throw new UsbRuntimeException("No suitable USB Device found.");
//         }
//     }
//     
//     private Usb() {
//     }
// }


import com.iamcontent.io.usb.Usb;
import java.util.function.Predicate;
import javax.usb.UsbDevice;
import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.device.controller.pololu.maestro.usb;




/**
 * A factory for {@link AbstractUsbPololuMaestroServoCard}s.
 * @author Greg Elderfield
 */
public class UsbPololuMaestroServoCards {

	/**
	 * Creates an instance with the first Pololu Maestro {@link UsbDevice} that is found.
	 */
	public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() {
		return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice()));
	}

	/**
	 * Creates an instance with the given UsbDevice.
	 */

// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java
// public interface PololuMaestroServoCard {
// 
// 	interface State {
// 		short getPosition(short channel);
// 	}
// 	
// 	void setPosition(short channel, short position);
// 	void setSpeed(short channel, short speed);
// 	void setAcceleration(short channel, short acceleration);
// 
// 	short getPosition(short channel);
// 	State getState();
// 	
// 	MaestroCardType getType();
// 
// }
// 
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java
// public class Usb {
// 
//     public static EasyUsbDevice device(short vendorId, short productId) {
//         return first(devices(vendorId, productId));
//     }
// 
//     public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) {
//         return first(devices(shouldIncludeDevice));
//     }
// 
//     public static List<EasyUsbDevice> devices(short vendorId, short productId) {
//     	return devices(deviceHasVendorIdAndProductId(vendorId, productId));
//     }
// 
//     public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) {
//         final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice);
//         deviceFinder.exploreRootUsbHub();
// 		return deviceFinder.getDevices();
//     }
// 
//     public static UsbHub rootUsbHub() {
//         try {
//             return usbServices().getRootUsbHub();
//         } catch (Exception e) {
//             throw new UsbRuntimeException(e);
//         }
//     }
// 
//     public static UsbServices usbServices() {
//         try {
//             return UsbHostManager.getUsbServices();
//         } catch (Exception e) {
//             throw new UsbRuntimeException(e);
//         }
//     }
// 
//     private static <T> T first(List<T> l) {
//         try {
//             return l.get(0);
//         } catch (IndexOutOfBoundsException e) {
//             throw new UsbRuntimeException("No suitable USB Device found.");
//         }
//     }
//     
//     private Usb() {
//     }
// }


// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java
import com.iamcontent.io.usb.Usb;
import java.util.function.Predicate;
import javax.usb.UsbDevice;
import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard;

/**
  IAmContent Public Libraries.
  Copyright (C) 2015-2021 Greg Elderfield
  @author Greg Elderfield, support@jarchitect.co.uk
 
  This program is free software; you can redistribute it and/or modify it under the terms of the
  GNU General Public License as published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along with this program;
  if not, write to the Free Software Foundation, Inc., 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package com.iamcontent.device.controller.pololu.maestro.usb;




/**
 * A factory for {@link AbstractUsbPololuMaestroServoCard}s.
 * @author Greg Elderfield
 */
public class UsbPololuMaestroServoCards {

	/**
	 * Creates an instance with the first Pololu Maestro {@link UsbDevice} that is found.
	 */
	public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() {
		return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice()));
	}

	/**
	 * Creates an instance with the given UsbDevice.
	 */

	public static PololuMaestroServoCard usbPololuMaestroServoCard(UsbDevice device) {
