Exemplo n.º 1
0
        private void OutBit_Click(object sender, EventArgs e)
        {
            LEDButton led = sender as LEDButton;

            if (led == null || led.ReadOnly)
            {
                return;
            }

            int bitNum = Convert.ToInt32(led.Tag) + _bitGroup * NUM_IO_DISPLAY;

            if (bitNum >= _io.DOBits.Count)
            {
                return;
            }

            DOBit bit = _io.DOBits[bitNum];

            if (bit == null)
            {
                return;
            }

            bool prevState = led.Checked;

            led.Enabled = false;

            Task.Factory.StartNew <bool>(() =>
            {
                // toggle the value
                bool value = !bit.Get();
                bit.Set(value);
                return(value);
            })
            .ContinueWith(t =>
            {
                UIUtility.BeginInvoke(this, () =>
                {
                    led.Checked = t.Result;
                    led.Enabled = true;
                });

                if (t.IsFaulted)
                {
                    Notify.PopUpError(String.Format("Failed to Set {0}", bit.Name), t.Exception.InnerException);
                }
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Registers the specified <see cref="DOBit"/> with this device.
 /// </summary>
 /// <param name="bit">The <see cref="DOBit"/>.</param>
 public void RegisterDOBit(DOBit bit)
 {
     _doBits.Add(bit.Channel, 0);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Registers the specified <see cref="DOBit"/> with this device.
 /// </summary>
 /// <param name="bit">The <see cref="DOBit"/>.</param>
 public void RegisterDOBit(DOBit bit)
 {
 }