public static YModuleProxy FindModule(string name) { // cases to handle: // name ="" no matching unknwn // name ="" unknown exists // name != "" no matching unknown // name !="" unknown exists YModule func = null; YModuleProxy res = (YModuleProxy)YFunctionProxy.FindSimilarUnknownFunction("YModuleProxy"); if (name == "") { if (res != null) { return(res); } res = (YModuleProxy)YFunctionProxy.FindSimilarKnownFunction("YModuleProxy"); if (res != null) { return(res); } func = YModule.FirstModule(); if (func != null) { name = func.get_hardwareId(); if (func.get_userData() != null) { return((YModuleProxy)func.get_userData()); } } } else { // allow to get module from the name of any function int p = name.IndexOf("."); if (p > 0) { name = name.Substring(0, p) + ".module"; } func = YModule.FindModule(name); if (func.get_userData() != null) { return((YModuleProxy)func.get_userData()); } } if (res == null) { res = new YModuleProxy(func, name); } if (func != null) { res.linkToHardware(name); if (func.isOnline()) { res.arrival(); } } return(res); }
private void moduleInventory() { YModule m, currentmodule; string name; int index; comboBox1.Items.Clear(); currentmodule = null; m = YModule.FirstModule(); while (m != null) { name = m.get_serialNumber(); if (name.Substring(0, 8) == "VOLTAGE1") { comboBox1.Items.Add(m); } m = m.nextModule(); } if (comboBox1.Items.Count == 0) { comboBox1.Enabled = false; bt_10V.Enabled = false; bt_50V.Enabled = false; bt_300V.Enabled = false; ACDCcheckBox.Enabled = false; toolStripStatusLabel2.Text = "Connect a Yocto-Volt device"; } else { comboBox1.Enabled = true; bt_10V.Enabled = true; bt_50V.Enabled = true; bt_300V.Enabled = true; ACDCcheckBox.Enabled = true; index = 0; for (int i = 0; i < comboBox1.Items.Count; i++) { if (comboBox1.Items[i].Equals(currentmodule)) { index = i; } } if (comboBox1.Items.Count == 1) { toolStripStatusLabel2.Text = "One Yocto-Volt device connected"; } else { toolStripStatusLabel2.Text = comboBox1.Items.Count.ToString() + " Yocto-Volt devices connected"; } comboBox1.SelectedIndex = index; } }
static void Main(string[] args) { int i; List <string> hubs = new List <string>(); List <string> shield = new List <string>(); List <string> devices = new List <string>(); string errmsg = ""; if (YAPI.RegisterHub("usb", ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error : " + errmsg); Environment.Exit(0); } for (i = 0; i < args.Length; i++) { Console.WriteLine("Update module connected to hub " + args[i]); if (YAPI.RegisterHub(args[i], ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error: " + errmsg); Environment.Exit(1); } } //fist step construct the list of all hub /shield and devices connected YModule module = YModule.FirstModule(); while (module != null) { string product = module.get_productName(); string serial = module.get_serialNumber(); if (product == "YoctoHub-Shield") { shield.Add(serial); } else if (product.StartsWith("YoctoHub")) { hubs.Add(serial); } else if (product != "VirtualHub") { devices.Add(serial); } module = module.nextModule(); } // fist upgrades all Hubs... upgradeSerialList(hubs); // ... then all shield.. upgradeSerialList(shield); // ... and finaly all devices upgradeSerialList(devices); Console.WriteLine("All devices are now up to date"); YAPI.FreeAPI(); }
/** * <summary> * Enumère toutes les fonctions de type Module. * <para> * Returns an array of strings representing hardware identifiers for all Module functions presently connected. * </para> * </summary> */ public static new string[] GetSimilarFunctions() { List <string> res = new List <string>(); YModule it = YModule.FirstModule(); while (it != null) { res.Add(it.get_hardwareId()); it = it.nextModule(); } return(res.ToArray()); }
private void RefreshInventory() { LinearLayout layout = FindViewById <LinearLayout>(Resource.Id.InventoryList); layout.RemoveAllViews(); YAPI.UpdateDeviceList(); YModule module = YModule.FirstModule(); while (module != null) { string line = module.SerialNumber + " (" + module.ProductName + ")"; TextView tx = new TextView(this); tx.Text = line; layout.AddView(tx); module = module.NextModule(); } }
static void Main(string[] args) { YModule m; string errmsg = ""; if (YAPI.RegisterHub("usb", ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error: " + errmsg); Environment.Exit(0); } Console.WriteLine("Device list"); m = YModule.FirstModule(); while (m != null) { Console.WriteLine(m.get_serialNumber() + " (" + m.get_productName() + ")"); m = m.nextModule(); } YAPI.FreeAPI(); }
void YoctopuceInitialisation() { Debug.Log("Use Yoctopuce Lib " + YAPI.GetAPIVersion()); string errmsg = ""; int res = YAPI.RegisterHub("usb", ref errmsg); if (res != YAPI.SUCCESS) { Debug.Log("error with RegisterHub:" + errmsg); errorText.text = errmsg; return; } YModule module = YModule.FirstModule(); while (module != null) { string product = module.get_productName(); if (product == "Yocto-3D" || product == "Yocto-3D-V2") { Debug.Log("Use " + product + " " + module.get_serialNumber()); break; } module = module.nextModule(); } if (module == null) { errorText.text = "No Yocto-3D or Yocto-3D-V2 found"; return; } string serial = module.get_serialNumber(); tilt_x = YTilt.FindTilt(serial + ".tilt1"); tilt_z = YTilt.FindTilt(serial + ".tilt2"); tilt_x.registerValueCallback(TiltCallbackX); tilt_z.registerValueCallback(TiltCallbackZ); }
private void moduleInventory() { YModule m, currentmodule; string name; int index; comboBox1.Items.Clear(); currentmodule = null; m = YModule.FirstModule(); while (m != null) { if (m.get_productName() == "Yocto-3D") { comboBox1.Items.Add(m); //stop the datalogger YDataLogger d = YDataLogger.FindDataLogger(m.get_serialNumber() + ".dataLogger"); d.set_recording(YDataLogger.RECORDING_OFF); } m = m.nextModule(); } if (comboBox1.Items.Count == 0) { comboBox1.Enabled = false; reset.Enabled = false; loadButton.Enabled = false; } else { comboBox1.Enabled = true; reset.Enabled = true; loadButton.Enabled = true; index = 0; comboBox1.SelectedIndex = index; } }