static void Main(string[] args) { string errmsg = ""; // configure the API to contact any networked device if (YAPI.RegisterHub("usb", ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error: " + errmsg); Environment.Exit(0); } if (YAPI.RegisterHub("net", ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error: " + errmsg); Environment.Exit(0); } // each time a new device is connected/discovered // arrivalCallback will be called. YAPI.RegisterDeviceArrivalCallback(arrivalCallback); // each time a device is disconnected/removed // removalCallback will be called. YAPI.RegisterDeviceRemovalCallback(removalCallback); Console.WriteLine("Waiting for hubs to signal themselves..."); while (true) { YAPI.UpdateDeviceList(ref errmsg); YAPI.Sleep(1000, ref errmsg); showNetwork(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { if (!started) { string url = this.url.Text; try { YAPI.RegisterLogFunction(yoctoLog); await YAPI.RegisterHub(url); YAPI.RegisterDeviceArrivalCallback(deviceArrival); YAPI.RegisterDeviceRemovalCallback(deviceRemoval); } catch (YAPI_Exception ex) { Output.Text = "Error:" + ex.Message + "\n"; return; } timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 100); // 100 Milliseconds timer.Tick += new EventHandler <object>(Each_Tick); timer.Start(); initButton.Content = "Stop"; started = true; } else { timer.Stop(); YAPI.FreeAPI(); initButton.Content = "Start"; started = false; } }
private void Form1_Load(object sender, EventArgs e) { YAPI.RegisterDeviceArrivalCallback(arrivalCallback); YAPI.RegisterDeviceRemovalCallback(removalCallback); // currentGps = YGps.FirstGps(); // if (currentGps != null) arrivalCallback(currentGps.get_module()); }
private void Form1_Load(object sender, EventArgs e) { // we wanna know when device list changes YAPI.RegisterDeviceArrivalCallback(devicelistchanged); YAPI.RegisterDeviceRemovalCallback(devicelistchanged); moduleInventory(); UpdateListTimer.Interval = 1000; UpdateListTimer.Start(); }
// form contents init private void Form1_Load(object sender, EventArgs e) { // we wanna know when device list changes YAPI.RegisterDeviceArrivalCallback(deviceArrival); YAPI.RegisterDeviceRemovalCallback(deviceRemoval); InventoryTimer.Interval = 500; InventoryTimer.Start(); RefreshTimer.Interval = 500; RefreshTimer.Start(); }
private void Form1_Load(object sender, EventArgs e) { moduleInventory(); YAPI.RegisterDeviceArrivalCallback(devicelistchanged); YAPI.RegisterDeviceRemovalCallback(devicelistchanged); deviceScanTimer.Interval = 1000; deviceScanTimer.Start(); refreshTimer.Interval = 200; refreshTimer.Start(); }
private void Form1_Load(object sender, EventArgs e) { // we wanna know when device list changes YAPI.RegisterDeviceArrivalCallback(deviceArrival); YAPI.RegisterDeviceRemovalCallback(deviceRemoval); toolStripStatusLabel1.Text = "Connect a device featuring a temperature sensor"; // start timers InventoryTimer.Interval = 1000; InventoryTimer.Start(); RefreshTimer.Interval = 100; RefreshTimer.Start(); }
public YoctoLightV3Manager() { string errorMsg = string.Empty; if (YAPI.RegisterHub("usb", ref errorMsg) != YAPI.SUCCESS) { throw new InvalidOperationException(errorMsg); } YAPI.RegisterDeviceArrivalCallback(this.OnDeviceConnected); YAPI.RegisterDeviceRemovalCallback(this.OnDeviceDisconnected); this.workingThread = new Thread(this.RunSensorLoop) { IsBackground = true }; this.workingThread.Start(); }
static void Main(string[] args) { string errmsg = ""; if (YAPI.RegisterHub("usb", ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error : " + errmsg); Environment.Exit(0); } YAPI.RegisterDeviceArrivalCallback(deviceArrival); Console.WriteLine("Hit Ctrl-C to Stop "); while (true) { YAPI.UpdateDeviceList(ref errmsg); // traps plug/unplug events YAPI.Sleep(500, ref errmsg); // traps others events } }
public Form1() { string errmsg = ""; InitializeComponent(); card_exp.Text = ""; card_extra.Text = ""; // Setup Yoctopuce API YAPI.DisableExceptions(); if (DEBUG) { YAPI.RegisterLogFunction(this.Log); } if (YAPI.RegisterHub("usb", ref errmsg) != YAPI.SUCCESS) { Log("Cannot connect to USB devices:"); Log(errmsg); } YAPI.RegisterDeviceArrivalCallback(this.ArrivalCallback); }
public Form1() { InitializeComponent(); caledit[0] = C0; caledit[1] = C1; caledit[2] = C2; caledit[3] = C3; caledit[4] = C4; rawedit[0] = R0; rawedit[1] = R1; rawedit[2] = R2; rawedit[3] = R3; rawedit[4] = R4; //register arrival/removal callbacks YAPI.RegisterDeviceArrivalCallback(arrivalCallback); YAPI.RegisterDeviceRemovalCallback(removalCallback); timer1.Enabled = true; }
static void Main(string[] args) { string errmsg = ""; Console.WriteLine("Waiting for hubs to signal themselves..."); // configure the API to contact any networked device if (YAPI.RegisterHub("net", ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error: " + errmsg); Environment.Exit(0); } // each time a new device is connected/discovered // arrivalCallback will be called. YAPI.RegisterDeviceArrivalCallback(arrivalCallback); // wait for 30 seconds, doing nothing. for (int i = 0; i < 30; i++) { YAPI.UpdateDeviceList(ref errmsg); YAPI.Sleep(1000, ref errmsg); } }
public Form1() { history = new List <PanelDesc.WizardSteps>(); YoctoTimer = new Timer(); YoctoTimer.Interval = 100; YAPI.RegisterDeviceArrivalCallback(DeviceArrival); YAPI.RegisterDeviceRemovalCallback(DeviceRemoval); YoctoTimer.Tick += YoctoTimer_Tick; YoctoTimer.Enabled = true; InitializeComponent(); Controls.Remove(UILabel); new PanelDesc(PanelDesc.WizardSteps.WELCOME, WelcomePanelResize, WelcomeDrawPanel, WelcomePanelClearContents, WelcomePanelNextClicked); new PanelDesc(PanelDesc.WizardSteps.CHOOSESENSOR, ChooseSensorPanelResize, ChooseSensorDrawPanel, ChooseSensorClearContents, ChooseSensorPanelNextClicked); new PanelDesc(PanelDesc.WizardSteps.RESETWARNNG, WarningResetPanelResize, WarningResetDrawPanel, WarningResetClearContents, WarningResetPanelNextClicked); new PanelDesc(PanelDesc.WizardSteps.CHOOSEEXCITATION, ChooseExcitationPanelResize, ChooseExcitationDrawPanel, ChooseExcitationClearContents, ChooseExcitation_NextClicked); new PanelDesc(PanelDesc.WizardSteps.CLEARLOAD, ClearLoadPanelResize, ClearLoadDrawPanel, ClearLoadClearContents, ClearLoadNextClicked); new PanelDesc(PanelDesc.WizardSteps.REFWEIGHT, PutRefWeightPanelResize, PutRefWeightnDrawPanel, PutRefWeightClearContents, PutRefWeightnDrawPanel_NextClicked); new PanelDesc(PanelDesc.WizardSteps.REMOVEREFLOAD, RemoveRefLoadPanelResize, RemoveRefLoadDrawPanel, RemoveRefLoadClearContents, RemoveRefLoadNextClicked); new PanelDesc(PanelDesc.WizardSteps.READY4TEMPCOMPENS, ReadyForCompensationPanelResize, ReadyForCompensationDrawPanel, ReadyForCompensationClearContents, ReadyForCompensationNextClicked); new PanelDesc(PanelDesc.WizardSteps.DEVICEDISCONNECTED, DeviceDisconnectedPanelResize, DeviceDisconnectedDrawPanel, DeviceDisconnectedClearContents, DeviceDisconnectedNextClicked); new PanelDesc(PanelDesc.WizardSteps.MONITORDATA, MonitorPanelResize, MonitorPanelDrawPanel, MonitorPanelClearContents, MonitorPanelNextClicked); new PanelDesc(PanelDesc.WizardSteps.DATASOURCE, ChooseDataSourcePanelResize, ChooseDataSourceDrawPanel, ChooseDataSourcePanelClearContents, ChooseDataSourcePanelNextClicked); new PanelDesc(PanelDesc.WizardSteps.DATALOADING, LoadingDataPanelResize, LoadingDataDrawPanel, LoadingDataPanelClearContents, LoadingDataPanelNextClicked); new PanelDesc(PanelDesc.WizardSteps.DOYOURTHING, computePanelResize, computeDrawPanel, computePanelClearContents, ComputePanelNextClicked); new PanelDesc(PanelDesc.WizardSteps.CONFIRMCOMPENSATION, ConfirmCompensatioPanelResize, ConfirmCompensationDrawPanel, ConfirmCompensationPanelClearContents, ConfirmCompensationNextClicked); new PanelDesc(PanelDesc.WizardSteps.COMPENSATIONDONE, CompensationDonePanelResize, CompensationDoneDrawPanel, CompensationDonePanelClearContents, CompensationDoneNextClicked); DrawPrevNextButtons(); WelcomeDrawPanel(); GenericResize(); if (constants.OpenLogWindowAtStartUp) { LogManager.Show(); } }
public static bool initYoctopuceLibrary(ref string errmsg, bool silent) { if (LibraryAPIInitialized) { return(true); } log(".NET Proxy library initialization"); apiMutex.WaitOne(); LibraryAPIInitialized = YAPI.InitAPI(YAPI.DETECT_NONE, ref errmsg) == YAPI.SUCCESS; YAPI.RegisterLogFunction(apilog); apiMutex.ReleaseMutex(); if (!silent) { string msg = "Yoctopuce low-level API initialization failed (" + errmsg + ")"; throw new YoctoApiProxyException(msg); } if (LibraryAPIInitialized) { //InternalStuff.log("registering arrival/removal"); YAPI.RegisterDeviceArrivalCallback(YFunctionProxy.deviceArrival); YAPI.RegisterDeviceRemovalCallback(YFunctionProxy.deviceRemoval); } new Thread(() => { Thread.CurrentThread.IsBackground = true; InternalStuff.log("Starting inner processing thread..."); string err = ""; while (!InnerThreadMustStop) { //InternalStuff.log("YAPI processing..."); try { if (LibraryAPIInitialized) { YAPI.UpdateDeviceList(ref err); } } catch (Exception e) { InternalStuff.log("YUpdateDeviceList error !!(" + e.Message + ")"); } for (int i = 0; i < 20 & !InnerThreadMustStop; i++) { try { if (LibraryAPIInitialized) { YAPI.Sleep(100, ref err); } } catch (Exception e) { InternalStuff.log("YSleep error (" + e.Message + ")"); } } } InternalStuff.log("Stopping inner processing thread..."); InnerThreadMustStop = false; }).Start(); return(LibraryAPIInitialized); }
public static bool initYoctopuceLibrary(ref string errmsg, bool silent) { if (LibraryAPIInitialized) { return(true); } log(".NET Proxy library initialization"); apiMutex.WaitOne(); YAPI.RegisterLogFunction(apilog); LibraryAPIInitialized = YAPI.InitAPI(YAPI.DETECT_NONE, ref errmsg) == YAPI.SUCCESS; apiMutex.ReleaseMutex(); if (LibraryAPIInitialized) { InternalStuff.log("yapi.dll version is " + YoctoProxyManager.DllVersion); InternalStuff.log("yapi.dll file is " + YAPI.GetYAPIDllPath()); InternalStuff.log("yapi.dll architecture is " + YoctoProxyManager.DllArchitecture); } if (!silent) { string msg = "Yoctopuce low-level API initialization failed (" + errmsg + ")"; throw new YoctoApiProxyException(msg); } if (LibraryAPIInitialized) { //InternalStuff.log("registering arrival/removal"); YAPI.RegisterDeviceArrivalCallback(YFunctionProxy.deviceArrival); YAPI.RegisterDeviceRemovalCallback(YFunctionProxy.deviceRemoval); new Thread(() => { Thread.CurrentThread.IsBackground = true; InternalStuff.log("Starting inner processing thread..."); bool aborting = false; string err = ""; while (!InnerThreadMustStop && !aborting) { //InternalStuff.log("YAPI processing..."); try { if (LibraryAPIInitialized) { YAPI.UpdateDeviceList(ref err); } } catch (System.Threading.ThreadAbortException) { InternalStuff.log("Inner processing thead is aborting during UpdateDeviceList!"); aborting = true; YAPI.FreeAPI(); LibraryAPIInitialized = false; InternalStuff.log("API has been freed in a hurry"); } catch (Exception e) { InternalStuff.log("YUpdateDeviceList error !!(" + e.Message + ")"); } for (int i = 0; i < 20 & !InnerThreadMustStop & !aborting; i++) { try { if (LibraryAPIInitialized) { YAPI.Sleep(100, ref err); } } catch (System.Threading.ThreadAbortException) { InternalStuff.log("Inner processing thead is aborting during ysleep!"); aborting = true; YAPI.FreeAPI(); LibraryAPIInitialized = false; InternalStuff.log("API has been freed in a hurry"); } } catch (Exception e) { InternalStuff.log("YSleep error (" + e.GetType().ToString() + " " + e.Message + ")! "); } } InternalStuff.log("Stopping inner processing thread..."); InnerThreadMustStop = false; }).Start();