Beispiel #1
0
        private void UpdateReaderInformation()
        {
            try
            {
                NurApi.ReaderInfo        readerInfo = hNur.GetReaderInfo();
                NurApi.DeviceCapabilites deviceCaps = hNur.GetDeviceCaps();

                AddLog(string.Format("Device: {0} - {1}",
                                     readerInfo.name,
                                     readerInfo.altSerial
                                     ));

                if ((deviceCaps.secChipMajorVersion != 0 ||
                     deviceCaps.secChipMinorVersion != 0) &&
                    deviceCaps.secChipMinorVersion != 255)
                {
                    AddLog(string.Format("Firmware: {0} / {1}.{2}.{3}.{4}",
                                         readerInfo.GetVersionString(),
                                         deviceCaps.secChipMajorVersion, deviceCaps.secChipMinorVersion,
                                         deviceCaps.secChipMaintenanceVersion, deviceCaps.secChipReleaseVersion));
                }
                else
                {
                    AddLog("Firmware: " + readerInfo.GetVersionString());
                }
            }
            catch (NurApiException e)
            {
                AddLog("Update reader information failed, error: " + e.error + ".");
                AddLog("Message: " + e.Message);
            }
        }
        /// <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;
                }
            }
        }
Beispiel #3
0
        private void PopulateTxLevel(ComboBox cb, int setLevel)
        {
            double power;
            double value;
            int    index  = 0;
            string strMax = "0: 500mW";

            int topLevel = 27;

            try
            {
                NurApi.DeviceCapabilites dc = hNur.GetDeviceCaps();
                topLevel = dc.maxTxdBm;
            }
            catch { }

            cb.Items.Clear();
            cb.DropDownStyle = ComboBoxStyle.DropDownList;

            if (topLevel == 30)
            {
                strMax = "0: 1W";
            }

            for (double i = 0; i <= 19; i++, index++)
            {
                if (index == 0)
                {
                    cb.Items.Add(strMax);
                }
                else
                {
                    power = (topLevel - i) / 10;
                    value = Math.Round(Math.Pow(10, power));
                    cb.Items.Add(index + ": " + value.ToString() + "mW");
                }
            }

            if (setLevel >= 0 && setLevel <= 19)
            {
                cb.SelectedIndex = setLevel;
            }
            else
            {
                cb.SelectedIndex = 0;
            }
        }
Beispiel #4
0
        private void FillTxLevels()
        {
            disableEvents++;

            TxLevelSel.Items.Clear();
            try
            {
                NurApi.DeviceCapabilites deviceCaps = hNur.GetDeviceCaps();
                for (int txLevel = 0; txLevel < deviceCaps.txSteps; txLevel++)
                {
                    int dBm = deviceCaps.maxTxdBm - (txLevel * deviceCaps.txAttnStep);
                    int mW  = 0;
                    if (txLevel == 0)
                    {
                        mW = deviceCaps.maxTxmW;
                    }
                    else
                    {
                        mW = (int)Math.Round(Math.Pow(10, (double)dBm / 10));
                    }
                    TxLevelSel.Items.Add(string.Format("{0} dBm / {1} mW", dBm, mW));
                }
                TxLevelSel.Enabled       = true;
                TxLevelSel.SelectedIndex = hNur.TxLevel;
            }
            catch (Exception e)
            {
                TxLevelSel.Items.Add(e.Message);
                TxLevelSel.Enabled = false;
            }

            // Set all per antenna TX levels to follow the main TX level
            int[] antennaPower = hNur.AntennaPower;
            for (int i = 0; i < antennaPower.Length; i++)
            {
                antennaPower[i] = -1;
            }
            int[] antennaPowerEx = hNur.AntennaPowerEx;
            for (int i = 0; i < antennaPowerEx.Length; i++)
            {
                antennaPowerEx[i] = -1;
            }

            disableEvents--;
        }