//private async Task<TestKind> GetUpOrdownAsync(double volate, ICommunicationProtocol _communicationProtocol) //{ // if (volate - (await _communicationProtocol.ReadStataThree()).AVolate > 0) // return TestKind.ControlsVolateUP; // else // return TestKind.ControlsVolateDown; //} private async Task <TestKind> GetUpOrdownHighAsync(double volate, ICommunicationProtocol _communicationProtocol) { if (volate - (await _communicationProtocol.GetCgfVolateDouble()) > 0) { return(TestKind.ControlsVolateUP); } else { return(TestKind.ControlsVolateDown); } }
public async Task <bool> SettindHighVolate(double voltage, ICommunicationProtocol _communicationProtocol, Xmldata.IXmlconfig _xmlconfig, CancellationToken token, int TimeOver = 5) { if (voltage < 0.5) { await DownVolateZero(_communicationProtocol, _xmlconfig, token); return(true); } await ControlsPowerStata(true, _communicationProtocol, token); await Task.Delay(100); int i = 0; double foredata = 0; double needdouble = Convert.ToDouble(_xmlconfig.GetAddNodeValue("UpvolateNeedHighdouble")); double Abs = Convert.ToDouble(_xmlconfig.GetAddNodeValue("Abs")); await _communicationProtocol.ThicknessAdjustable(true); while (Math.Abs(voltage - (await _communicationProtocol.GetCgfVolateDouble())) >= 1) { token.ThrowIfCancellationRequested(); var data = await _communicationProtocol.GetCgfVolateDouble(); var needchangecgf = voltage - data; if (needchangecgf > 0) { await _communicationProtocol.SetTestPra(TestKind.ControlsVolateUP, 1, token); await Task.Delay(50, token); } else { await _communicationProtocol.SetTestPra(TestKind.ControlsVolateDown, 1, token); await Task.Delay(50, token); } if (i++ > 0 && data < 0.1 && foredata < 0.1 && (await _communicationProtocol.GetCgfVolateDouble()) < 0.1) { throw new OperationCanceledException(); } foredata = data; } await _communicationProtocol.ThicknessAdjustable(false); while (Math.Abs(voltage - (await _communicationProtocol.GetCgfVolateDouble())) < 1) { token.ThrowIfCancellationRequested(); var data = await _communicationProtocol.GetCgfVolateDouble(); var needchangecgf = voltage - data; if (Math.Abs(voltage - data) / voltage > needdouble) { if (needchangecgf > 0) { await _communicationProtocol.SetTestPra(TestKind.ControlsVolateUP, 1, token); await Task.Delay(50, token); } else { await _communicationProtocol.SetTestPra(TestKind.ControlsVolateDown, 1, token); await Task.Delay(50, token); } } else { break; } if (i++ > 0 && data < 0.1 && foredata < 0.1 && (await _communicationProtocol.GetCgfVolateDouble()) < 0.1) { throw new OperationCanceledException(); } foredata = data; } return(true); }