public void Trigger(object sender) { // Invoke from main thread Action <object> TriggerDele = Trigger; if (ui.InvokeRequired) { ui.Invoke(TriggerDele, new object[] { sender }); return; } ui.checkBoxTriggerOn.Checked = true; ui.TriggerTimer.Stop(); ui.TriggerTimer.Start(); if (CurrentPort.Signal == null) { return; } // show Crosstalk values. In red if threshold is reached int i = 0; foreach (var xtalk in CurrentPort.CrosstalkSignals) { var val = xtalk.Signal.SignalDelegate() * xtalk.Factor; ui.CrosstalkLabels[i].Text = String.Format("{0:0.000}", val); if (CurrentPort.IsCrosstalk(xtalk)) { ui.CrosstalkLabels[i].ForeColor = System.Drawing.Color.Red; } else { ui.CrosstalkLabels[i].ForeColor = System.Drawing.Color.Black; } i++; } // check if filter prevents triggering if (CurrentPort.Filter != null) { ui.labelFilterValue.Text = String.Format("{0:0.000}", CurrentPort.Filter.SignalDelegate()); double filterVal = CurrentPort.Filter.SignalDelegate(); if (CurrentPort.FilterEnabled && (filterVal < CurrentPort.FilterMin || filterVal > CurrentPort.FilterMax)) { return; } } // check if crosstalk prevents triggering foreach (var xsig in CurrentPort.CrosstalkSignals) { if (CurrentPort.IsCrosstalk(xsig)) { return; } } if (CurrentPort.Signal != null) { ui.velocityMapControl.SetTrigger(CurrentPort.Signal.SignalDelegate()); } }