//キャリブレーション BridgeDataEventData AddCalibretion(BridgeDataEventArgs e) { try { if (e.Index == (int)bridgeCmbL.SelectedIndex) { LeftTenStatus.Slope = Double.Parse(LeftSlope.Text); LeftTenStatus.Intercept = Double.Parse(LeftIntercept.Text); conVlu.Index = (int)bridgeCmbL.SelectedIndex; conVlu.Value = Math.Round((LeftTenStatus.Slope * e.Value) + LeftTenStatus.Intercept, 5); } if (e.Index == (int)bridgeCmbR.SelectedIndex) { RightTenStatus.Slope = Double.Parse(RightSlope.Text); RightTenStatus.Intercept = Double.Parse(RightIntercept.Text); conVlu.Index = (int)bridgeCmbR.SelectedIndex; conVlu.Value = Math.Round((RightTenStatus.Slope * e.Value) + RightTenStatus.Intercept, 5); } } catch { } return(conVlu); }
//BridgeChange event handler...display the data from a bridge change event void br_Data(object sender, BridgeDataEventArgs e) { //キャリブレーション BridgeDataEventData convertValue = AddCalibretion(e); //初期値未設定 if ((LeftTenStatus.TenInt == 0) | (RightTenStatus.TenInt == 0)) { //初期値設定へ InitialTensionSetting(convertValue); } //初期値設定済 else { //接圧監視へ MonitorTension(convertValue); } if (convertValue.Index == bridgeCmbL.SelectedIndex) { leftValueTxt.Text = convertValue.Value.ToString(); OutputLog("L," + convertValue.Value.ToString() + ","); } if (convertValue.Index == bridgeCmbR.SelectedIndex) { rightValueTxt.Text = convertValue.Value.ToString(); OutputLog("R," + convertValue.Value.ToString() + "\n"); } }
//BridgeChange event handler...display the data from a bridge change event void br_Data(object sender, BridgeDataEventArgs e) { if (e.Index == bridgeCmb.SelectedIndex) { valueTxt.Text = e.Value.ToString(); convertTxt.Text = Math.Round((slope * e.Value) + Yint, 2).ToString(); } }
public void bridge_BridgeData(object sender, BridgeDataEventArgs e) { last_values[e.Index, datacounters[e.Index]] = p1[e.Index] * (float)e.Value + p0[e.Index]; last_values_raw[e.Index, datacounters[e.Index]] = (float)e.Value; if (++datacounters[e.Index] > 127) { datacounters[e.Index] = 0; } }
//BridgeChange event handler...display the data from a bridge change event void br_Data(object sender, BridgeDataEventArgs e) { if (e.Index == bridgeCmb.SelectedIndex) { valueTxt.Text = e.Value.ToString(); convertTxt.Text = Math.Round((slope * e.Value) + Yint, 2).ToString(); //Log output sb.AppendLine(DateTime.Now.ToString(Settings.Default.tStampFormat) + "," + bridgeCmb.SelectedIndex + "," + br.bridges[e.Index].Gain + "," + (value1 == 0 ? "," : value1Calib.ToString() + "," + value1.ToString()) + "," + (value2 == 0 ? "," : value2Calib.ToString() + "," + value2.ToString()) + "," + e.Value.ToString() + "," + convertTxt.Text); } }
// オートキャリブレーション private void AutoCalibration(BridgeDataEventArgs e) { // サンプリング数は初期値の場合と同じにする var calibEndCount = Int32.Parse(ConfigurationManager.AppSettings.Get("InitSampNum")); // 値格納 if ((dataL.Count < calibEndCount) | (dataR.Count < calibEndCount)) { if (e.Index == (int)bridgeCmbL.SelectedIndex) { dataL.Add(e.Value); } if (e.Index == (int)bridgeCmbR.SelectedIndex) { dataR.Add(e.Value); } } else { // センサーOFF br.bridges[(int)bridgeCmbL.SelectedIndex].Enabled = false; br.bridges[(int)bridgeCmbR.SelectedIndex].Enabled = false; // キャリブレーションの設定 double sum = 0; foreach (double data in dataL) { sum += data; } LeftTenStatus.Intercept = (sum / dataL.Count); LeftIntercept.Text = LeftTenStatus.Intercept.ToString(); dataL.Clear(); sum = 0; foreach (double data in dataR) { sum += data; } RightTenStatus.Intercept = (sum / dataR.Count); LeftIntercept.Text = RightTenStatus.Intercept.ToString(); dataR.Clear(); // ボタン復帰 CalibStartBtn.Enabled = true; } }
// 変位イベント BridgeChange event handler...display the data from a bridge change event void Br_Data(object sender, BridgeDataEventArgs e) { // オートキャリブレーション中なら if (CalibStartBtn.Enabled == false) { AutoCalibration(e); return; } // キャリブレーション反映 BridgeDataEventData convertValue = AddCalibration(e); // 初期値未設定 if ((LeftTenStatus.TenInt == 0) | (RightTenStatus.TenInt == 0)) { // 初期値設定へ InitialTensionSetting(convertValue); } // 初期値設定済 else { // 値取得・表示更新 if (MonitorTension(convertValue)) { // トラバース制御 ControlTraversal(); } } // 表示更新とログ出力 if (convertValue.Index == bridgeCmbL.SelectedIndex) { leftValueTxt.Text = convertValue.Value.ToString(); OutputLog("L," + convertValue.Value.ToString() + ","); } if (convertValue.Index == bridgeCmbR.SelectedIndex) { rightValueTxt.Text = convertValue.Value.ToString(); OutputLog("R," + convertValue.Value.ToString() + "\n"); } }
static void bridge_BridgeData(object sender, BridgeDataEventArgs e) { Console.WriteLine("Bridge {0} Data {1}", e.Index, e.Value); }
//BridgeChange event handler...display the data from a bridge change event void br_Data(object sender, BridgeDataEventArgs e) { if (e.Index == bridgeCmb.SelectedIndex) { valueTxt.Text = e.Value.ToString(); convertTxt.Text = Math.Round((slope*e.Value) + Yint, 2).ToString(); } }
//BridgeChange event handler...display the data from a bridge change event void br_Data(object sender, BridgeDataEventArgs e) { if (e.Index == bridgeCmb.SelectedIndex) { valueTxt.Text = e.Value.ToString(); convertTxt.Text = Math.Round((slope*e.Value) + Yint, 2).ToString(); //Log output sb.AppendLine(DateTime.Now.ToString(Settings.Default.tStampFormat) + "," + bridgeCmb.SelectedIndex + "," + br.bridges[e.Index].Gain + "," + (value1==0 ? "," : value1Calib.ToString() + "," + value1.ToString()) + "," + (value2==0 ? "," : value2Calib.ToString() + "," + value2.ToString()) + "," + e.Value.ToString() + "," + convertTxt.Text); } }