Exemplo n.º 1
0
        private void EditFiltersButton_Click(object sender, EventArgs e)
        {
            AccessorySensorConfig?cfg = GetSelectedConfig();

            if (cfg.HasValue)
            {
                AccessorySensorFilter     filter  = new AccessorySensorFilter();
                AccessorySensorFeature    feature = (AccessorySensorFeature)cfg.Value.feature;
                AccessorySensorFilterFlag flags   = 0;
                /* Can only enable range filter if the sensor supports it */
                if (rangeCheckBox.Checked && feature.HasFlag(AccessorySensorFeature.Range))
                {
                    flags |= AccessorySensorFilterFlag.Range;
                }
                if (timeCheckBox.Checked)
                {
                    flags |= AccessorySensorFilterFlag.Time;
                }
                filter.flags = (ushort)flags;

                filter.rangeThreshold.lo = ushort.Parse(rangeLoTextBox.Text);
                filter.rangeThreshold.hi = ushort.Parse(rangeHiTextBox.Text);

                filter.timeThreshold.lo = ushort.Parse(timeLoTextBox.Text);
                filter.timeThreshold.hi = ushort.Parse(timeHiTextBox.Text);

                try
                {
                    nur.AccSensorSetFilter(cfg.Value.source, filter);
                }
                catch (NurApiException ex)
                {
                    MessageBox.Show(ex.ToString(), "Error");
                    return;
                }
            }
        }
Exemplo n.º 2
0
        private void SensorListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            AccessorySensorConfig?cfg = GetSelectedConfig();

            if (cfg.HasValue)
            {
                modeComboBox.Enabled       = true;
                modeComboBox.SelectedIndex = cfg.Value.mode;
                AccessorySensorFilter filter;
                try
                {
                    filter = nur.AccSensorGetFilter(cfg.Value.source);
                }
                catch (NurApiException ex)
                {
                    MessageBox.Show(ex.ToString(), "Error");
                    return;
                }

                AccessorySensorFeature feature = (AccessorySensorFeature)cfg.Value.feature;
                if (feature.HasFlag(AccessorySensorFeature.Range))
                {
                    rangeCheckBox.Enabled = true;
                }
                else
                {
                    rangeCheckBox.Enabled = false;
                }

                AccessorySensorFilterFlag flags = (AccessorySensorFilterFlag)filter.flags;
                if (flags.HasFlag(AccessorySensorFilterFlag.Range))
                {
                    rangeCheckBox.Checked = true;
                    rangeLoTextBox.Text   = filter.rangeThreshold.lo.ToString();
                    rangeHiTextBox.Text   = filter.rangeThreshold.hi.ToString();
                }
                else
                {
                    rangeCheckBox.Checked = false;
                    rangeLoTextBox.Text   = filter.rangeThreshold.lo.ToString();
                    rangeHiTextBox.Text   = filter.rangeThreshold.hi.ToString();
                }
                if (flags.HasFlag(AccessorySensorFilterFlag.Time))
                {
                    timeCheckBox.Checked = true;
                    timeLoTextBox.Text   = filter.timeThreshold.lo.ToString();
                    timeHiTextBox.Text   = filter.timeThreshold.hi.ToString();
                }
                else
                {
                    timeCheckBox.Checked = false;
                    timeLoTextBox.Text   = filter.timeThreshold.lo.ToString();
                    timeHiTextBox.Text   = filter.timeThreshold.hi.ToString();
                }
            }
            else
            {
                modeComboBox.Enabled = false;
                getValueTextBox.Clear();
            }
            GetSensorSettings();
        }