+ private static class Product {
+ final String name;
+ final int product;
+
+ Product (String name, int product) {
+ this.name = name;
+ this.product = product;
+ }
+ }
+
+ private static Product[] products = {
+ new Product("telemetrum", product_telemetrum),
+ new Product("teleballoon", product_telemetrum),
+ new Product("teledongle", product_teledongle),
+ new Product("teleterra", product_teledongle),
+ new Product("telebt", product_telebt),
+ new Product("telelaunch", product_telelaunch),
+ new Product("telelco", product_telelco),
+ new Product("telescience", product_telescience),
+ new Product("telepyro", product_telepyro),
+ new Product("telemega", product_telemega),
+ new Product("megadongle", product_megadongle),
+ new Product("telegps", product_telegps),
+ new Product("easymini", product_easymini),
+ new Product("telemini", product_telemini),
+ new Product("easymega", product_easymega)
+ };
+
+ public static int name_to_product(String name) {
+ String low = name.toLowerCase();
+
+ for (int i = 0; i < products.length; i++)
+ if (low.startsWith(products[i].name))
+ return products[i].product;
+ return product_any;
+ }
+
+ public static boolean has_9dof(int device_type) {
+ return device_type == product_telemega || device_type == product_easymega;
+ }
+
+ public static boolean has_radio(int device_type) {
+ return device_type != product_easymini && device_type != product_easymega;
+ }
+
+ public static boolean has_gps(int device_type) {
+ return device_type == product_telemetrum ||
+ device_type == product_telemega ||
+ device_type == product_telegps;
+ }
+