private void InBit_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.DIBits.Count) { return; } DIBit bit = _io.DIBits[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="DIBit"/> with this device. /// </summary> /// <param name="bit">The <see cref="DIBit"/>.</param> public void RegisterDIBit(DIBit bit) { _diBits.Add(bit.Channel, 0); }
/// <summary> /// Registers the specified <see cref="DIBit" /> with this device. /// </summary> /// <param name="bit">The <see cref="DIBit"/></param> public void RegisterDIBit(DIBit bit) { }