private void TryUpdateSetup(bool justConnected) { try { NurApi.ModuleSetup setup = new NurApi.ModuleSetup(); setup.opFlags &= ~((uint)NurApi.OPFLAGS_EN_TUNEEVENTS); hNur.SetModuleSetup(NurApi.SETUP_OPFLAGS, ref setup); hNur.StoreCurrentSetup(NurApi.STORE_ALL); } catch { } try { mSetup = hNur.GetModuleSetup(); SetupToControls(); if (justConnected) { mSetup.perAntPower[0] = -1; mSetup.perAntPower[1] = -1; mSetup.perAntPower[2] = -1; mSetup.perAntPower[3] = -1; hNur.SetModuleSetup(NurApi.SETUP_PERANTPOWER, ref mSetup); hNur.StoreCurrentSetup(NurApi.STORE_ALL); AddLog("Power limits set to 0."); } } catch (NurApiException e) { AddLog("Module setup update failed, error: " + e.error + "."); AddLog("Message: " + e.Message); } }
private bool ControlsToSetup(ref NurApi.ModuleSetup setup, ref int setupFlags) { int flags = 0; if (!ParseInt(ref setup.inventoryQ, QEdit.Text, 0, 15)) { AddLog("Q parameter parse error."); return(false); } // TX setup.txLevel = TxLevelSel.SelectedIndex; flags |= NurApi.SETUP_TXLEVEL; setup.txModulation = ModulationSel.SelectedIndex; flags |= NurApi.SETUP_TXMOD; // RX setup.linkFreq = IndexToLf(LFSel.SelectedIndex); flags |= NurApi.SETUP_LINKFREQ; setup.rxDecoding = MillerSel.SelectedIndex; flags |= NurApi.SETUP_RXDEC; // Other setup.inventorySession = SessionSel.SelectedIndex; flags |= NurApi.SETUP_INVSESSION; setup.inventoryTarget = TargetSel.SelectedIndex; flags |= NurApi.SETUP_INVTARGET; setupFlags = flags; return(true); }
private void TryUpdateSetup() { try { mSetup = hNur.GetModuleSetup(); SetupToControls(); } catch (NurApiException e) { AddLog("Module setup update failed, error: " + e.error + "."); AddLog("Message: " + e.Message); } }
void TrySetSettings() { NurApi.ModuleSetup setup = new NurApi.ModuleSetup(); setup.txLevel = TxLevelSel.SelectedIndex; setup.txModulation = TxModSel.SelectedIndex; try { hNur.SetModuleSetup(NurApi.SETUP_TXLEVEL | NurApi.SETUP_TXMOD, ref setup); } catch { /* ... */ } }
private bool ControlsToSetup(ref NurApi.ModuleSetup setup, ref int setupFlags) { int flags = 0; int ant, antMask; /* if (!ParseInt(ref setup.inventoryQ, QEdit.Text, 0, 15)) * { * AddLog("Q parameter parse error."); * return false; * } */ // TX setup.txLevel = TxLevelSel.SelectedIndex; flags |= NurApi.SETUP_TXLEVEL; setup.txModulation = ModulationSel.SelectedIndex; flags |= NurApi.SETUP_TXMOD; // RX // setup.linkFreq = IndexToLf(LFSel.SelectedIndex); // flags |= NurApi.SETUP_LINKFREQ; // setup.rxDecoding = MillerSel.SelectedIndex; // flags |= NurApi.SETUP_RXDEC; // Other setup.inventorySession = SessionSel.SelectedIndex; flags |= NurApi.SETUP_INVSESSION; setup.inventoryTarget = TargetSel.SelectedIndex; flags |= NurApi.SETUP_INVTARGET; antMask = 0; ant = IndexToAnt(AntSel.SelectedIndex, ref antMask); mSetup.selectedAntenna = ant; mSetup.antennaMask = antMask; flags |= (NurApi.SETUP_ANTMASK | NurApi.SETUP_SELECTEDANTENNA); setupFlags = flags; return(true); }
private void SetSetup(bool store) { int flags = 0; NurApi.ModuleSetup setup = new NurApi.ModuleSetup(); if (ControlsToSetup(ref setup, ref flags)) { try { hNur.SetModuleSetup(flags, ref setup); AddLog("Setup is set."); } catch (Exception ex) { AddLog("Apply setup error."); AddLog(ex.Message); } if (store) { try { hNur.StoreCurrentSetup(); AddLog("Setup is stored into the module."); } catch (Exception ex) { AddLog("Store setup error."); AddLog(ex.Message); } } } else { AddLog("Parse error(s)."); } }
private void GetSettingsFromControls() { try { // Get current settings NurApi.ModuleSetup newSetup = hNur.GetModuleSetup(); // Get setting from Combo boxes newSetup.regionId = regionCombo.SelectedIndex; switch (lfCombo.SelectedIndex) { case 0: newSetup.linkFreq = 160000; break; case 1: newSetup.linkFreq = 256000; break; case 2: newSetup.linkFreq = 320000; break; } newSetup.rxDecoding = rxDecCombo.SelectedIndex; newSetup.txModulation = txModCombo.SelectedIndex; newSetup.txLevel = txLevelCombo.SelectedIndex; newSetup.rxSensitivity = rxSensitivity_ComboBox.SelectedIndex; //newSetup.antennaMask = 0; newSetup.selectedAntenna = GetNurComboBoxValue(selectedAntenna); switch (autoTune_ComboBox.SelectedIndex) { case 1: newSetup.autotune.mode = NurApi.AUTOTUNE_MODE_ENABLE; break; case 2: newSetup.autotune.mode = NurApi.AUTOTUNE_MODE_ENABLE | NurApi.AUTOTUNE_MODE_THRESHOLD_ENABLE; break; case 0: default: newSetup.autotune.mode = 0; break; } newSetup.autotune.threshold_dBm = (sbyte)autoTuneTreshold_UpDown.Value; newSetup.opFlags = enTuneEvents_CheckBox.Checked ? newSetup.opFlags | (uint)NurApi.OPFLAGS_EN_TUNEEVENTS : newSetup.opFlags & ~(uint)NurApi.OPFLAGS_EN_TUNEEVENTS; newSetup.inventoryQ = qCombo.SelectedIndex; newSetup.inventoryRounds = roundsCombo.SelectedIndex; newSetup.inventorySession = sessionCombo.SelectedIndex; newSetup.inventoryTarget = targetCombo.SelectedIndex; newSetup.periodSetup = periodCombo.SelectedIndex; newSetup.inventoryEpcLength = GetNurComboBoxValue(invEpcLenCombo); // Get settings from Numeric UpDown boxses newSetup.readRssiFilter.min = Convert.ToSByte(readRssiMin.Value); newSetup.readRssiFilter.max = Convert.ToSByte(readRssiMax.Value); newSetup.writeRssiFilter.min = Convert.ToSByte(writeRssiMin.Value); newSetup.writeRssiFilter.max = Convert.ToSByte(writeRssiMax.Value); newSetup.inventoryRssiFilter.min = Convert.ToSByte(inventoryRssiMin.Value); newSetup.inventoryRssiFilter.max = Convert.ToSByte(inventoryRssiMax.Value); // Set settings to NurApi hNur.SetModuleSetup(NurApi.SETUP_ALL, ref newSetup); } catch (NurApiException ex) { MessageBox.Show(ex.ToString(), Program.appName); UpdateSettingControls(); } }
private void UpdateSettingControls() { disableEvents++; try { // Get current settings NurApi.ModuleSetup currenSetup = hNur.GetModuleSetup(); // Update Combo boxes regionCombo.SelectedIndex = currenSetup.regionId; switch (currenSetup.linkFreq) { case 160000: lfCombo.SelectedIndex = 0; break; case 256000: lfCombo.SelectedIndex = 1; break; case 320000: lfCombo.SelectedIndex = 2; break; } rxDecCombo.SelectedIndex = currenSetup.rxDecoding; txModCombo.SelectedIndex = currenSetup.txModulation; txLevelCombo.SelectedIndex = currenSetup.txLevel; rxSensitivity_ComboBox.SelectedIndex = currenSetup.rxSensitivity; UpdateAntennaControls(currenSetup.selectedAntenna); switch (currenSetup.autotune.mode) { case NurApi.AUTOTUNE_MODE_ENABLE: autoTune_ComboBox.SelectedIndex = 1; break; case NurApi.AUTOTUNE_MODE_ENABLE | NurApi.AUTOTUNE_MODE_THRESHOLD_ENABLE: autoTune_ComboBox.SelectedIndex = 2; break; case 0: default: autoTune_ComboBox.SelectedIndex = 0; break; } autoTuneTreshold_UpDown.Value = currenSetup.autotune.threshold_dBm; enTuneEvents_CheckBox.Checked = (currenSetup.opFlags & NurApi.OPFLAGS_EN_TUNEEVENTS) != 0; qCombo.SelectedIndex = currenSetup.inventoryQ; sessionCombo.SelectedIndex = currenSetup.inventorySession; roundsCombo.SelectedIndex = currenSetup.inventoryRounds; targetCombo.SelectedIndex = currenSetup.inventoryTarget; periodCombo.SelectedIndex = currenSetup.periodSetup; SelectNurComboBox(invEpcLenCombo, currenSetup.inventoryEpcLength); // Set Numeric UpDown boxs readRssiMin.Value = currenSetup.readRssiFilter.min; readRssiMax.Value = currenSetup.readRssiFilter.max; writeRssiMin.Value = currenSetup.writeRssiFilter.min; writeRssiMax.Value = currenSetup.writeRssiFilter.max; inventoryRssiMin.Value = currenSetup.inventoryRssiFilter.min; inventoryRssiMax.Value = currenSetup.inventoryRssiFilter.max; } catch (NurApiException ex) { MessageBox.Show(ex.ToString(), Program.appName); this.Enabled = false; } disableEvents--; }
/// <summary> /// Updates the info. /// </summary> /// <param name="hNur">The NUR module handler.</param> private void UpdateInfo(NurApi hNur) { bool outdated = false; treeView1.Nodes.Clear(); TreeNode node; TreeNode dllNode = treeView1.Nodes.Add("DLL Versions"); try { string fileVersion = hNur.GetFileVersion(); mhlDevice = fileVersion.IndexOf("MHL") >= 0; dllNode.Nodes.Add("NurApi.dll - " + fileVersion); dllNode.Nodes.Add("NurApiDotNetWCE.dll - " + NurUtils.NurApiDotNetVersion); } catch (NurApiException ex) { AddExceptionNode(dllNode, ex, true); } if (hNur.IsConnected()) { TreeNode fwinfoNode = treeView1.Nodes.Add("FWINFO (parsed string)"); TreeNode structsNode = treeView1.Nodes.Add("Module settings (structs)"); try { NurApi.ReaderInfo readerInfo = hNur.GetReaderInfo(); label1.Text = "Reader: " + readerInfo.name + ", " + readerInfo.GetVersionString(); DumpObject(structsNode, readerInfo, null); } catch (NurApiException ex) { AddExceptionNode(structsNode, ex, false); } try { DumpObject(structsNode, GetVersions(hNur), null); //DumpObject(structsNode, hNur.GetVersions(), null); } catch (NurApiException ex) { AddExceptionNode(structsNode, ex, false); } try { NurFwInfoParser fwinfo = new NurFwInfoParser(hNur.GetFWINFO()); foreach (KeyValuePair <string, string> entry in fwinfo.keypairs) { fwinfoNode.Nodes.Add(entry.Key + " = " + entry.Value); } } catch (NurApiException ex) { AddExceptionNode(fwinfoNode, ex, false); if (!mhlDevice) { fwinfoNode.Expand(); outdated = true; } } try { DumpObject(structsNode, hNur.GetDeviceCaps(), null); } catch (NurApiException ex) { AddExceptionNode(structsNode, ex, false); } //try //{ // DumpObject(structsNode, hNur.GetEthConfig(), null); //} //catch (NurApiException ex) //{ // AddExceptionNode(structsNode, ex, false); //} try { DumpObject(structsNode, hNur.GetModuleSetup(), null); } catch (NurApiException ex) { AddExceptionNode(structsNode, ex, false); } //try //{ // DumpObject(structsNode, hNur.GetSensorConfig(), null); //} //catch (NurApiException ex) //{ // AddExceptionNode(structsNode, ex, false); //} TreeNode regNode = treeView1.Nodes.Add("Regions"); int numRegions = 0; try { NurApi.ReaderInfo readerInfo = hNur.GetReaderInfo(); // Dump region infos for (int i = 0; i < readerInfo.numRegions; i++) { NurApi.RegionInfo ri = hNur.GetRegionInfo(i); DumpObject(regNode, ri, string.Format("{0}: {1}", i, ri.name)); numRegions++; } // Dump CustomHoptable try { NurApi.CustomHoptableEx customHoptableEx = hNur.GetCustomHoptableEx(); DumpObject(regNode, customHoptableEx, string.Format("{0}: {1}", NurApi.REGIONID_CUSTOM, "customHoptableEx")); numRegions++; } catch (NurApiException ex) { try { AddExceptionNode(regNode, ex, false); NurApi.CustomHoptable customHoptable = hNur.GetCustomHoptable(); DumpObject(regNode, customHoptable, string.Format("{0}: {1}", NurApi.REGIONID_CUSTOM, "customHoptable")); numRegions++; } catch (NurApiException ex2) { AddExceptionNode(regNode, ex2, false); } } } catch (NurApiException ex) { AddExceptionNode(structsNode, ex, true); } regNode.Text = string.Format("{0} ({1} pcs)", regNode.Text, numRegions); TreeNode antNode = treeView1.Nodes.Add("Antennas"); try { NurApi.ModuleSetup moduleSetup = hNur.GetModuleSetup(); antNode.Nodes.Add("Selected - " + (moduleSetup.selectedAntenna == -1 ? "Auto" : moduleSetup.selectedAntenna.ToString())); if (moduleSetup.antennaMask != 0) { antNode.Nodes.Add("Enabled - " + GetEnabledAntennas(moduleSetup.antennaMask)); node = antNode.Nodes.Add("Reflected Powers"); if (MeasureReflectedPowers(hNur, node)) { antNode.Expand(); } } else { node = antNode.Nodes.Add("No Enabled Antennas!!!"); node.ForeColor = System.Drawing.Color.Red; node.Expand(); } } catch (NurApiException) { node = antNode.Nodes.Add("Can't get antenna settings"); node.ForeColor = System.Drawing.Color.Red; node.Expand(); } structsNode.Expand(); } else { label1.Text = "No Connection"; } if (outdated) { node = treeView1.Nodes.Add("The NUR modules firmware might be outdated. Please check for updates."); node.ForeColor = System.Drawing.Color.Red; node.Nodes.Add("E-mail: [email protected]"); node.Expand(); } }