// This is called when NurApi is fully connected to device and ready to communicate private async void MApi_ConnectedEvent(object sender, NurApi.NurEventArgs e) { // Update reader info, run in task because NurApi calls may block await Task.Run(async() => { try { NurApi.ReaderInfo rdrInfo = mApi.GetReaderInfo(); // Update UI in UI thread await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // Update listview item if (mConnectedDev != null) { mConnectedDev.ConnState = NurApiTransport.State.Connected; mConnectedDev.UpdateInfo(); } // Update UI ConnInfo.Text = string.Format("Connected {0} | Serial {1} | FW {2}", rdrInfo.name, rdrInfo.serial, rdrInfo.GetVersionString()); InventoryButton.IsEnabled = true; ConnButton.Content = "Disconnect"; }); } catch (Exception ex) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ConnInfo.Text = "Error " + ex.ToString(); }); } }); }
/// <summary> /// Handles the DisconnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_DisconnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; conStatusDesc.Text = "Disconnected"; UpdateButtons(); }
/// <summary> /// Handles the ConnectedEvent event of the hNur control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs"/> instance containing the event data.</param> /// <exception cref="System.NotImplementedException"></exception> void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { if (hNur != null && hNur.IsConnected()) { try { // Get the ReaderInfo readerInfo = hNur.GetReaderInfo(); } catch (NurApiException) { // Firmware may be too old so use the defaults readerInfo.name = NA; } try { // Get the Device Capabilites devCaps = hNur.GetDeviceCaps(); if (devCaps.txAttnStep == 3) { throw new Exception("Firmware may be too old so use the defaults"); } } catch (Exception) { // Firmware may be too old so use the defaults devCaps.maxTxmW = 500; devCaps.maxTxdBm = 27; devCaps.txAttnStep = 1; devCaps.txSteps = 20; devCaps.maxAnt = 4; } } }
// This gets called when module is connected void nur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { // Connected, display module info NurApi.ReaderInfo ri = nur.GetReaderInfo(); lstbox.Items.Add(ri.name + " connected"); lstbox.Items.Add("Version: " + ri.GetVersionString()); }
/// <summary> /// Handles the ConnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; InitializInventoryRead(); this.Enabled = true; }
// Connected event handler void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { // Set window title UpdateAppTitle(); // Here is a proper place to configure reader on the fly if needed hNur.TxLevel = 0; // Set Tx power to max level }
// Reader disconnected void mApi_DisconnectedEvent(object sender, NurApi.NurEventArgs e) { connectbutton.Text = "Connect"; SetInfo("Status", "Disconnected"); startbutton.Text = "Start Positioning"; startbutton.Enabled = false; }
private async void Api_DisconnectedEvent(object sender, NurApi.NurEventArgs e) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // Update UI ButtonState = false; AccInfo = "Disconnected"; }); }
private async void Api_ConnectedEvent(object sender, NurApi.NurEventArgs e) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // Update UI InvButtonState = true; InvButtonText = "Simple Inventory"; InvStreamButtonText = "Start Inventory Stream"; }); }
void OnModuleConnect(object sender, NurApi.NurEventArgs e) { AddLog("Device connected."); TryUpdateReaderInfo(); TryUpdateSetup(); currentTag = null; EnableByTagPresence(); EnableOpControls(CONNECTED); ConnectBtn.Text = "Disconnect"; }
void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { EnableControls(true); TrySetDefaults(); try { StatusText.Text = hNur.GetReaderInfo().GetVersionString(); } catch { } }
/// <summary> /// Handles the DisconnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_DisconnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; this.Text = string.Format("{0} {1} ({2}/{3})", System.Reflection.Assembly.GetEntryAssembly().GetName().Name, System.Reflection.Assembly.GetEntryAssembly().GetName().Version, hNur.GetFileVersion(), NurUtils.NurApiDotNetVersion); }
// Disconnected event handler void hNur_DisconnectedEvent(object sender, NurApi.NurEventArgs e) { // Get NurApi object that generated the event NurApi hNur = sender as NurApi; SendMessage("DISCONNECTED"); // Releace user NURAPI object hNur.Dispose(); nurApis.Remove(hNur); }
/// <summary> /// Handles the ConnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; this.Text = string.Format("{0} App:{1} Net:{2} Dll:{3} Fw:{4}", System.Reflection.Assembly.GetEntryAssembly().GetName().Name, System.Reflection.Assembly.GetEntryAssembly().GetName().Version, NurUtils.NurApiDotNetVersion, hNur.GetFileVersion(), hNur.GetReaderInfo().GetVersionString()); }
private static void HNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { Console.WriteLine("Nur Connected"); try { hNur.StartInventoryStream(); } catch (Exception ex) { Console.WriteLine("Could not start inventory stream [" + ex.Message + "]"); } }
void OnModuleDisconnect(object sender, NurApi.NurEventArgs e) { AddLog("Device discconnected."); TagList.Items.Clear(); SelectedTag.Text = "Selected:"; currentTag = null; EnableByTagPresence(); EnableOpControls(NOT_CONNECTED); UsbAutoChk.Checked = false; ConnectBtn.Text = "Connect"; UsbAutoChk.Checked = false; }
void OnReaderConnect(object sender, NurApi.NurEventArgs e) { EnableCtls(true); TryUpdateInformation(); TryUpdateSetup(true); PopulateTxLevel(TxLevelSel, mSetup.txLevel); UpdateLogSettings(); AddLog("Connected."); if (AutoScanChk.Checked) { AddLog("Auto scan..."); DoGetTags(); } }
void OnReaderConnect(object sender, NurApi.NurEventArgs e) { EnableCtls(true); UpdateReaderInformation(); FillTxLevels(); FillPhysAntListView(); ModuleSetupToControls(); UpdateLogSettings(); AddLog("Connected to reader"); if (AutoScanChk.Checked) { AddLog("Auto scan..."); DoGetTags(); } }
// This is called when NurApi is fully connected to device and ready to communicate private async void Api_ConnectedEvent(object sender, NurApi.NurEventArgs e) { System.Diagnostics.Debug.WriteLine("Api_ConnectedEvent"); NurApi connApi = sender as NurApi; App.NurApi = connApi; await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { NurDeviceWatcherInfo knownDev = connApi.UserData as NurDeviceWatcherInfo; // Save connect spec to settings //mLocalSettings.Values["devicespec"] = DeviceSpecStr; mLocalSettings.Values["devicespec"] = knownDev.SpecStr; // Update listview entry knownDev.ConnState = NurApiTransport.State.Connected; knownDev.UpdateInfo(); if (knownDev == SelectedDev) { ConnButtonText = "Disconnect"; } }); // Update reader info await Task.Run(async() => { try { NurApi.ReaderInfo rdrInfo = App.NurApi.GetReaderInfo(); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ConnInfo = string.Format("Connected {0} | Serial {1} | FW {2}", rdrInfo.name, rdrInfo.serial, rdrInfo.GetVersionString()); }); } catch (Exception ex) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { ConnInfo = "Error"; await App.ShowException(ex); }); } }); }
// Reader connected void mApi_ConnectedEvent(object sender, NurApi.NurEventArgs e) { try { connectbutton.Text = "Disconnect"; SetInfo("Status", "Connected"); startbutton.Text = "Start Gate"; startbutton.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); connectbutton.Text = "Connect"; SetInfo("Status", "Device not supported"); } }
/// <summary> /// Handles the ConnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; try { isAutoTuneSupported = true; this.Enabled = true; CreateListOfPhysicalAntennas(); UpdateAntennaSelection(); UpdateAntennaTuneSettings(); } catch (NurApiException) { this.Enabled = false; } }
/// <summary> /// Handles the ConnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; try { this.Enabled = NurCapabilities.I.DeviceCaps.tune; if (NurCapabilities.I.DeviceCaps.tune == false) { AddMessage("Not available with this module!!!"); } } catch (NurApiException) { this.Enabled = false; } }
// Reader connected void mApi_ConnectedEvent(object sender, NurApi.NurEventArgs e) { connectbutton.Text = "Disconnect"; // Make sure reader supports beam antenna configuration if (mApi.GetDeviceCaps().beamAntenna) { SetInfo("Status", "Connected"); startbutton.Text = "Start Positioning"; startbutton.Enabled = true; } else { SetInfo("Status", "Device not supported"); startbutton.Enabled = false; } }
/// <summary> /// Handles the ConnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; conStatusDesc.Text = "Connected"; UpdateButtons(); try { NurApi.EthConfig ethConfig = hNur.GetEthConfig(); tcpipAddr.Text = IpToString(ethConfig.ip); tcpipPort.Value = ethConfig.serverPort; } catch (NurApiException) { // Ignore this error } }
// Reader connected void mApi_ConnectedEvent(object sender, NurApi.NurEventArgs e) { try { connectbutton.Text = "Disconnect"; tagsPerAntennaControl1.Config(mApi); SetInfo("Status", "Connected"); startbutton.Text = "Start Positioning"; startbutton.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); connectbutton.Text = "Connect"; SetInfo("Status", "Device not supported"); } }
void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { try { //GetReaderInfo from module NurApi.ReaderInfo readerInfo = hNur.GetReaderInfo(); //Show results in Listbox listBox1.Items.Add("Name\t" + readerInfo.name); listBox1.Items.Add("Version\t" + readerInfo.GetVersionString()); listBox1.Items.Add("HW Ver\t" + readerInfo.hwVersion); listBox1.Items.Add("FCC\t " + readerInfo.fccId); listBox1.Items.Add("Serial\t" + readerInfo.serial); listBox1.Items.Add("SW Ver\t" + readerInfo.swVerMajor + "." + readerInfo.swVerMinor); } catch (Exception ex) //Handle error by show error message in Listbox { listBox1.Items.Add("Error: GetReaderInfo:" + ex.Message); } }
private async void Api_ConnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi.AccessoryFWInfo?accFwInfo = null; string connInfo = ""; try { // Get accessory device info await Task.Run(() => { accFwInfo = App.NurApi.AccGetFwInfo(); connInfo = App.NurApi.AccGetConnectionInfo(); }); } catch (Exception ex) { if (ex is NurApiException && (ex as NurApiException).error == NurApiErrors.NUR_ERROR_INVALID_COMMAND) { // This is not accessory device accFwInfo = null; } else { await App.ShowException(ex); return; } } // Update UI await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { ButtonState = true; if (accFwInfo != null) { AccInfo = string.Format("Accessory FW version: {0}; Connection info: {1}", accFwInfo?.FullAppVersion, connInfo); } else { AccInfo = "Connected device does not support accessory device commands"; } }); }
// This is called when NurApi is fully disconnect (and released resources) private async void MApi_DisconnectedEvent(object sender, NurApi.NurEventArgs e) { // Update UI in UI thread await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // Update listview item if (mConnectedDev != null) { mConnectedDev.ConnState = NurApiTransport.State.Disconnected; mConnectedDev.UpdateInfo(); mConnectedDev = null; } // Update UI InventoryButton.IsEnabled = false; ConnInfo.Text = "Disconnected"; ConnButton.Content = "Connect"; }); }
// Connected event handler void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { // Get NurApi object that generated the event NurApi hNur = sender as NurApi; SendMessage(string.Format("CONNECTED: {0}, {1}, {2}", hNur.GetReaderInfo().name, hNur.GetReaderInfo().altSerial, hNur.GetReaderInfo().GetVersionString() )); UpdateAppTitle(); // Here is a proper place to configure reader on the fly if needed //hNur.TxLevel = 0; // Set Tx power to max level // Start inventory stream hNur.StartInventoryStream(); }
/// <summary> /// Handles the ConnectedEvent event of the NUR module. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NurApi.NurEventArgs" /> instance containing the event data.</param> private void hNur_ConnectedEvent(object sender, NurApi.NurEventArgs e) { NurApi hNur = sender as NurApi; conStatusDesc.Text = "Connected"; UpdateButtons(); // Update default settings Properties.Settings.Default.connectionUsb = useUsbRadioBox.Checked; Properties.Settings.Default.connectionUsbAuto = useUsbAutoRadioBox.Checked; Properties.Settings.Default.connectionSerial = useSerialRadioBox.Checked; Properties.Settings.Default.connectionSocket = useSocketRadioBox.Checked; if (useSocketRadioBox.Checked) { Properties.Settings.Default.connectionSocketAddress = socketAddressTextBox.Text; Properties.Settings.Default.connectionSocketPort = (int)socketPortNumericUpDown.Value; } // Save default settings Properties.Settings.Default.Save(); }