// Checks the input values of the textboxes and start the calibration calculation. // If the caluclation is finished, the window can be closed with the button. private void buttonCalculate_Click(object sender, EventArgs e) { if (!_finished) { label5.Visible = true; bool abort = false; try { //Preload = Convert.ToDouble(textBox1.Text, Provider); _strCommaDot = textBox1.Text.Replace(".", ","); _preload = double.Parse(_strCommaDot); textBox1.Enabled = false; } catch (FormatException) { label5.Text = "wrong number format"; abort = true; } catch (OverflowException) { label5.Text = "Overflow! Number to big."; abort = true; } try { //Capacity = Convert.ToDouble(textBox2.Text, Provider); _strCommaDot = textBox2.Text.Replace(".", ","); _capacity = double.Parse(_strCommaDot); textBox2.Enabled = false; } catch (FormatException) { label5.Text = "wrong number format"; abort = true; } catch (OverflowException) { label5.Text = "Overflow! Number to big."; abort = true; } if (abort) { return; } _wtxObj.Calculate(_preload, _capacity); label5.Text = "Calibration done via Jetbus"; _finished = true; buttonCalculate.Text = "Close"; } else { Close(); } }
public bool CalibrationPreloadCapacityTest(Behavior behavior) { double preload = 1; double capacity = 2; double testdPreload = 0; double testdNominalLoad = 0; int testIntPreload = 0; int testIntNominalLoad = 0; double multiplierMv2D = 500000; // 2 / 1000000; // 2mV/V correspond 1 million digits (d) _jetTestConnection = new TestJetbusConnection(behavior, "wss://172.19.103.8:443/jet/canopen", "Administrator", "wtx", delegate { return(true); }); _wtxObj = new WtxJet(_jetTestConnection); _wtxObj.Connect(this.OnConnect, 100); _wtxObj.Calculate(preload, capacity); testdPreload = preload * multiplierMv2D; testdNominalLoad = testdPreload + (capacity * multiplierMv2D); testIntPreload = Convert.ToInt32(testdPreload); testIntNominalLoad = Convert.ToInt32(testdPreload); if ( _jetTestConnection.getDataBuffer.ContainsKey("2110/06") && _jetTestConnection.getDataBuffer.ContainsValue(testIntPreload) && _jetTestConnection.getDataBuffer.ContainsKey("2110/07") && _jetTestConnection.getDataBuffer.ContainsValue(testIntNominalLoad) ) { return(true); } else { return(false); } }