Ejemplo n.º 1
0
        public async Task <bool> SettindVolate(double voltage, ICommunicationProtocol _communicationProtocol, Xmldata.IXmlconfig _xmlconfig, CancellationToken token, int TimeOver = 0)
        {
            if (voltage < 0.5)
            {
                await DownVolateZero(_communicationProtocol, _xmlconfig, token);

                return(true);
            }
            await ControlsPowerStata(true, _communicationProtocol, token);

            await Task.Delay(100, token); int i = 0;
            double needdouble = Convert.ToDouble(_xmlconfig.GetAddNodeValue("UpvolateNeeddouble"));
            await _communicationProtocol.ThicknessAdjustable(true);

            double foredata = 0;

            while (true)
            {
                token.ThrowIfCancellationRequested();
                TestKind ts;
                var      data = await _communicationProtocol.ReadStataThree(token);

                if (data.Checked)
                {
                    ts = (voltage - data.AVolate) > 0 ? TestKind.ControlsVolateUP : TestKind.ControlsVolateDown;
                    if (Math.Abs(voltage - data.AVolate) >= 16)
                    {
                        await _communicationProtocol.SetTestPra(ts, 1, token);

                        await Task.Delay(100, token);
                    }
                    else
                    {
                        break;
                    }
                    if (i++ > 0 && data.AVolate < 1 && foredata < 1 && (await _communicationProtocol.ReadStataThree(token)).AVolate < 1)
                    {
                        throw new OperationCanceledException();
                    }
                    foredata = data.AVolate;
                }
            }
            await _communicationProtocol.ThicknessAdjustable(false); i = 0; foredata = 0;

            while (true)
            {
                TestKind ts;
                var      data = await _communicationProtocol.ReadStataThree(token);

                token.ThrowIfCancellationRequested();
                if (data.Checked)
                {
                    ts = (voltage - data.AVolate) > 0 ? TestKind.ControlsVolateUP : TestKind.ControlsVolateDown;
                    if (Math.Abs(voltage - data.AVolate) < 16)
                    {
                        if (Math.Abs(voltage - data.AVolate) / voltage > needdouble)
                        {
                            await _communicationProtocol.SetTestPra(ts, 1, token);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                    if (i++ > 0 && data.AVolate < 1 && foredata < 1 && (await _communicationProtocol.ReadStataThree(token)).AVolate < 1)
                    {
                        throw new OperationCanceledException();
                    }
                    foredata = data.AVolate;
                }
            }

            //if (Math.Abs(voltage - (await _communicationProtocol.ReadStataThree(token)).AVolate) / voltage > needdouble)
            //{
            //    token.ThrowIfCancellationRequested();



            //    if (++i > TimeOver)
            //        return false;
            //    goto heres;
            //}
            return(true);
        }
Ejemplo n.º 2
0
 public async Task DownAndClosePower(ICommunicationProtocol _communicationProtocolk, Xmldata.IXmlconfig _xmlconfig, CancellationToken token)
 {
     if (await _communicationProtocolk.GetPowerStata() && (await _communicationProtocolk.ReadStataThree(token)).AVolate > 10)
     {
         await DownVolateZero(_communicationProtocolk, _xmlconfig, token);
         await ControlsPowerStata(false, _communicationProtocolk, token);
     }
     else
     {
         await ControlsPowerStata(false, _communicationProtocolk, token);
     }
     await ControlsPowerStata(false, _communicationProtocolk, token);
 }
Ejemplo n.º 3
0
        public async Task <bool> SettindHighVolateByLow(double voltage, ICommunicationProtocol _communicationProtocol, Xmldata.IXmlconfig _xmlconfig, CancellationToken token, int TimeOver = 5)
        {
            double lowvolate = voltage * 1000 / Convert.ToDouble(_xmlconfig.GetAddNodeValue("Abs"));

            return(await SettindVolate(lowvolate, _communicationProtocol, _xmlconfig, token));
        }
Ejemplo n.º 4
0
        public async Task <bool> SetVolatedata(double voltage, ICommunicationProtocol _communicationProtocol, Xmldata.IXmlconfig _xmlconfig, CancellationToken token, int TimeOver = 5)
        {
            // await _communicationProtocol.SwitchThincness(true, _communicationProtocol);
            double needdouble = Convert.ToDouble(_xmlconfig.GetAddNodeValue("UpvolateNeeddouble"));
            await _communicationProtocol.ThicknessAdjustable(true);

            await Task.Delay(100); int i = 0;

            while (Math.Abs(voltage - (await _communicationProtocol.ReadStataThree(token)).AVolate) >= 8)
            {
                token.ThrowIfCancellationRequested();

                double currentvolate = (await _communicationProtocol.ReadStataThree(token)).AVolate;
                double ClickTime     = (voltage - currentvolate) / 8;
                if (ClickTime >= 1)
                {
                    await _communicationProtocol.SetTestPra(TestKind.ControlsVolateUP, (byte)ClickTime, token);
                }
                if (ClickTime <= -1)
                {
                    var tf = await _communicationProtocol.SetTestPra(TestKind.ControlsVolateDown, (byte)Math.Abs(ClickTime), token);
                }
            }
            //await _communicationProtocol.SwitchThincness(false, _communicationProtocol);
            await _communicationProtocol.ThicknessAdjustable(false);

            while (Math.Abs(voltage - (await _communicationProtocol.ReadStataThree(token)).AVolate) < 8)
            {
                token.ThrowIfCancellationRequested();
                if (Math.Abs(voltage - (await _communicationProtocol.ReadStataThree(token)).AVolate) / voltage > needdouble)
                {
                    double ClickTime = (voltage - (await _communicationProtocol.ReadStataThree(token)).AVolate) / 1;
                    if (ClickTime >= 1)
                    {
                        await _communicationProtocol.SetTestPra(TestKind.ControlsVolateUP, (byte)ClickTime, token);
                    }
                    if (ClickTime <= -1)
                    {
                        await _communicationProtocol.SetTestPra(TestKind.ControlsVolateDown, (byte)Math.Abs(ClickTime), token);
                    }
                }
                else
                {
                    break;
                }
            }
            //if (Math.Abs(voltage - (await _communicationProtocol.ReadStataThree(token)).AVolate) / voltage > needdouble)
            //{
            //    token.ThrowIfCancellationRequested();

            //    if (++i > TimeOver)
            //        return false;
            //    goto herep;
            //}
            return(true);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        public async Task DownVolateZero(ICommunicationProtocol _communicationProtocol, Xmldata.IXmlconfig _xmlconfig, CancellationToken token)
        {
            await ControlsPowerStata(true, _communicationProtocol, token);

            await _communicationProtocol.ThicknessAdjustable(true);

            await _communicationProtocol.SetTestPra(TestKind.ControlsVolateDown, 5, token);

            while (true)
            {
                newst : var data = await _communicationProtocol.ReadStataThree(token);

                token.ThrowIfCancellationRequested();
                if (data.Checked)
                {
                    if (data.AVolate > 5)
                    {
                        await _communicationProtocol.SetTestPra(TestKind.ControlsVolateDown, 2, token);
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    goto newst;
                }
            }

            //byte num = (byte)((await _communicationProtocol.GetCgfVolateDouble()) * 1000 / Convert.ToDouble(_xmlconfig.GetAddNodeValue("Abs")) + 2);
            //await _communicationProtocol.SetTestPra(TestKind.ControlsVolateDown, num);
        }