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); } }); }
/// <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); }
/// <summary> /// Registers the specified <see cref="DOBit"/> with this device. /// </summary> /// <param name="bit">The <see cref="DOBit"/>.</param> public void RegisterDOBit(DOBit bit) { }