private void btnCalib_Click(object sender, System.EventArgs e) { ThreadManager.CreateThread(link => { link.Name = "Calibration"; Recalibration.Calibration(); picCalibration.InvokeAuto(() => picCalibration.Image = Properties.Resources.ValidOk96); CalibrationDone?.Invoke(); }).StartThread(); btnTrap.Focus(); }
private void ZeroCalibrationHandler(object sender, EventArgs eventArgs) { if (_adcList.Count < _zeroCalibrationCount) { _adcList.Add((double[])CurrAdcVals.Clone()); } else { ParseDone -= ZeroCalibrationHandler; var zeroVals = new double[4]; for (int i = 0; i < zeroVals.Count(); i++) { zeroVals[i] = _adcList.Average(doubles => doubles[i]); if (_startupCalib) { var w = 0.1; var koef_new = w / zeroVals[i]; var koef_old = w / MainConfig.ZeroAdcVals[i]; var offset_percent = (100 * koef_new) / koef_old; offset_percent = (100 - offset_percent) * 10; WeightKoefs[i] += (WeightKoefs[i] * offset_percent) / 100; } } if (!_startupCalib) { MainConfig.Update(null, zeroVals); } zeroAdcVals = zeroVals; if (CalibrationDone != null) { CalibrationDone.Invoke(null, null); } _zeroCorrection = true; _startupCalib = false; _adcList.Clear(); } //------------ }
private void WeightCalibrationHandler(object o, EventArgs eventArgs) { if (_adcList.Count < _calibrationParams.EntryCount) { _adcList.Add((double[])CurrAdcVals.Clone()); } else { ParseDone -= WeightCalibrationHandler; var aver = _adcList.Average(val => val[_calibrationParams.TenzNumber]); double koef = _calibrationParams.Weight / aver; WeightKoefs[_calibrationParams.TenzNumber] = koef; if (CalibrationDone != null) { CalibrationDone.Invoke(null, null); } _adcList.Clear(); _calibrationParams = null; ExchangeConfig.Period = _periodBuf; } }
void Calibration() { Int32 speedX = CalibrateAxis(ref calStateX, moveToZeroSpeedX, moveFromZeroSpeedX, !lx); Int32 speedY = CalibrateAxis(ref calStateY, moveToZeroSpeedY, moveFromZeroSpeedY, !ly); Int32 speedZ = CalibrateAxis(ref calStateZ, moveToZeroSpeedZ, moveFromZeroSpeedZ, !lz); Int32 speedA = CalibrateAxis(ref calStateA, moveToZeroSpeedA, moveFromZeroSpeedA, !la); if (calStateX == AxisCalStates.calIdle && calStateY == AxisCalStates.calIdle && calStateZ == AxisCalStates.calIdle && calStateA == AxisCalStates.calIdle) { Stop(); state = States.Idle; SetCoordinates(0, 0, 0, 0); if (CalibrationDone != null) { CalibrationDone.Invoke(this, null); } } else { Move(speedX, speedY, -speedZ, speedA); } }
private void FastWeightCalibrationHandler(object o, EventArgs eventArgs) { if (_adcList.Count < _calibrationParams.EntryCount) { _adcList.Add((double[])CurrAdcVals.Clone()); } else { ParseDone -= FastWeightCalibrationHandler; for (int i = 0; i < 4; i++) { var aver = _adcList.Average(val => val[i]); double koef = _calibrationParams.Weight / aver; WeightKoefs[i] = koef; } if (CalibrationDone != null) { CalibrationDone.Invoke(null, null); } _adcList.Clear(); _calibrationParams = null; } }