Exemple #1
0
 private void Keyb_OutVolateData(string cn)
 {
     if (ISHAVEDY)
     {
         if (!ISHAVEVOLATE)
         {
             if (time.Text == "")
             {
                 time.Text = "60";
             }
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             mv.ListboxItemsources.Add("持续时间  :" + time.Text + ":" + "  耐    压:" + need);
             ISHAVEVOLATE = true;
         }
         else
         {
             if (time.Text == "")
             {
                 time.Text = "60";
             }
             mv.ListboxItemsources.RemoveAt(mv.ListboxItemsources.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             mv.ListboxItemsources.Add("持续时间  :" + time.Text + ":" + "耐   压 :" + need);
         }
     }
 }
Exemple #2
0
 private void pF_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int a = System.Text.RegularExpressions.Regex.Matches(ResultTextBox.Text, @"V").Count;
         if (a == 0)
         {
             ResultTextBox.Text += "V";
         }
         PhysicalVariable tpd = NumericsConverter.Text2Value(ResultTextBox.Text);
         if (Flag == 1)
         {
             OutCnData(NumericsConverter.Value2Text((double)tpd.value, 4, -13, "", SCEEC.Numerics.Quantities.QuantityName.Voltage));
         }
         if (Flag == 2)
         {
             OutVolateData(NumericsConverter.Value2Text((double)tpd.value, 4, -13, "", SCEEC.Numerics.Quantities.QuantityName.Voltage));
         }
         if (Flag == 3)
         {
             OutDYData(NumericsConverter.Value2Text((double)tpd.value, 4, -13, "", SCEEC.Numerics.Quantities.QuantityName.Voltage));
         }
         if (Flag == 4)
         {
             OutProjectVolate(NumericsConverter.Value2Text((double)tpd.value, 4, -13, "", SCEEC.Numerics.Quantities.QuantityName.Voltage));
         }
         this.Close();
     }
     catch
     {
         ShowHide("输出数据格式出错");
     }
 }
Exemple #3
0
 // private bool ISHAVEVOLATE = false;
 private void Keyb_OutDYData(string cn)
 {
     if (!ISHAVEDY)
     {
         PhysicalVariable need = NumericsConverter.Text2Value(cn);
         mv.ListboxItemsources.Add("待测电晕  :" + need);
         ISHAVEDY = true;
     }
     else
     {
         if (ISHAVEVOLATE)
         {
             string[] b = mv.ListboxItemsources.ToArray();
             mv.ListboxItemsources.RemoveAt(mv.ListboxItemsources.Count - 1);
             mv.ListboxItemsources.RemoveAt(mv.ListboxItemsources.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             mv.ListboxItemsources.Add("待测电晕  :" + need);
             mv.ListboxItemsources.Add(b[b.Length - 1]);
         }
         else
         {
             mv.ListboxItemsources.RemoveAt(mv.ListboxItemsources.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             mv.ListboxItemsources.Add("待测电晕  :" + need);
         }
     }
 }
Exemple #4
0
        private void Keyb_OutCnTanData(string cntan)
        {
            CnTanButton.Content = cntan;
            PhysicalVariable need = NumericsConverter.Text2Value(cntan);

            Models.AutoStateStatic.SState.AGn = need;
        }
Exemple #5
0
 private void Keyb_OutCnData(string cn)
 {
     if (ISHAVEDY)
     {
         if (!ISHAVEVOLATE)
         {
             string[] a = mv.ListboxItemsources.ToArray();
             mv.ListboxItemsources.RemoveAt(mv.ListboxItemsources.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             mv.ListboxItemsources.Add("待测电压  :" + need);
             mv.ListboxItemsources.Add(a[a.Length - 1]);
         }
         else
         {
             string[] a = mv.ListboxItemsources.ToArray();
             mv.ListboxItemsources.RemoveAt(mv.ListboxItemsources.Count - 1);
             mv.ListboxItemsources.RemoveAt(mv.ListboxItemsources.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             mv.ListboxItemsources.Add("待测电压  :" + need);
             mv.ListboxItemsources.Add(a[a.Length - 2]);
             mv.ListboxItemsources.Add(a[a.Length - 1]);
         }
     }
     else
     {
         PhysicalVariable need = NumericsConverter.Text2Value(cn);
         mv.ListboxItemsources.Add("待测电压  :" + need);
     }
 }
Exemple #6
0
 public static void AddEleVolate(FourTestResult AllTestResult,
                                 PhysicalVariable v1, PhysicalVariable v2, PhysicalVariable v3, PhysicalVariable v4,
                                 int h1, int h2, int h3, int h4)
 {
     if (AllTestResult.PanelEnable)
     {
         AllTestResult.Panel1EleYAndVolate.EleVolate = v1;
         AllTestResult.Panel1EleYAndVolate.HodeTime  = h1;
     }
     if (AllTestResult.Pane2Enable)
     {
         AllTestResult.Panel2EleYAndVolate.EleVolate = v2;
         AllTestResult.Panel2EleYAndVolate.HodeTime  = h2;
     }
     if (AllTestResult.Pane3Enable)
     {
         AllTestResult.Panel3EleYAndVolate.EleVolate = v3;
         AllTestResult.Panel3EleYAndVolate.HodeTime  = h3;
     }
     if (AllTestResult.Pane4Enable)
     {
         AllTestResult.Panel4EleYAndVolate.EleVolate = v4;
         AllTestResult.Panel4EleYAndVolate.HodeTime  = h4;
     }
 }
 private void Keyb_OutCnData(string cn)
 {
     if (ISHAVEDY)
     {
         if (!ISHAVEVOLATE)
         {
             string[] a = (this.DataContext as MainWindowModel).ProjectVolate.ToArray();
             (this.DataContext as MainWindowModel).ProjectVolate.RemoveAt((this.DataContext as MainWindowModel).ProjectVolate.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             (this.DataContext as MainWindowModel).ProjectVolate.Add("待测电压  :" + need);
             (this.DataContext as MainWindowModel).ProjectVolate.Add(a[a.Length - 1]);
         }
         else
         {
             string[] a = (this.DataContext as MainWindowModel).ProjectVolate.ToArray();
             (this.DataContext as MainWindowModel).ProjectVolate.RemoveAt((this.DataContext as MainWindowModel).ProjectVolate.Count - 1);
             (this.DataContext as MainWindowModel).ProjectVolate.RemoveAt((this.DataContext as MainWindowModel).ProjectVolate.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             (this.DataContext as MainWindowModel).ProjectVolate.Add("待测电压  :" + need);
             (this.DataContext as MainWindowModel).ProjectVolate.Add(a[a.Length - 2]);
             (this.DataContext as MainWindowModel).ProjectVolate.Add(a[a.Length - 1]);
         }
     }
     else
     {
         PhysicalVariable need = NumericsConverter.Text2Value(cn);
         (this.DataContext as MainWindowModel).ProjectVolate.Add("待测电压  :" + need);
     }
 }
        private void Confire_click(object sender, RoutedEventArgs e)
        {
            PhysicalVariable tpd = NumericsConverter.Text2Value(ResultTextBox.Text);

            //  NumericsConverter.Value2Text(tpd,4,percentage:true);
            OutCnTanData(NumericsConverter.Value2Text(tpd, percentage: true));
            this.Close();
        }
Exemple #9
0
        public static void BushingDCInsulation(ref MeasurementItemStruct mi, Transformer transformer, JobList Job)
        {
            Parameter.JYDZstation position;
            if (mi.Winding == WindingType.HV)
            {
                position = Parameter.JYDZstation.高压套管A + (((int)mi.Terimal[0] + 3) % 4);
            }
            else
            {
                position = Parameter.JYDZstation.中压套管A + (((int)mi.Terimal[0] + 3) % 4);
            }
            switch (mi.state)
            {
            case 0:
                byte[] TestKindData = TZ3310.SetPraJydz(position, GetParameter.GetPraBushingDCInsulationVoltage(Job), 50, GetParameter.GetPraDCInsulationResistance(Job), GetParameter.GetPraDCInsulationAbsorptionRatio(Job), 0);
                Thread.Sleep(100);
                TZ3310.StartTest(TestKindData);
                mi.stateText = "正在测试" + position.ToString() + "末屏中...";
                mi.state++;
                Thread.Sleep(4000);
                break;

            case 1:
                string[] Recbuffer = TZ3310.ReadTestData(Parameter.TestKind.绝缘电阻);
                Thread.Sleep(150);

                if (Recbuffer != null)
                {
                    PhysicalVariable[] Volate = new PhysicalVariable[1];

                    if (Recbuffer[Recbuffer.Length - 1] == "0")
                    {
                        mi.Result = MeasurementResult.NewBushingDCInsulationResult(mi, NumericsConverter.Text2Value(Recbuffer[0]), NumericsConverter.Text2Value(Recbuffer[1]),
                                                                                   NumericsConverter.Text2Value(Recbuffer[2]), null, false);
                    }
                    else if (Recbuffer[Recbuffer.Length - 1] == "1")
                    {
                        mi.Result = MeasurementResult.NewBushingDCInsulationResult(mi, Volate[0], NumericsConverter.Text2Value(Recbuffer[0]),
                                                                                   NumericsConverter.Text2Value(Recbuffer[1]), NumericsConverter.Text2Value(Recbuffer[2]), true);
                        mi.state++;
                        mi.completed = true;
                        mi.stateText = position.ToString() + "末屏测试完成";
                    }
                    else
                    {
                        mi.failed    = true;
                        mi.completed = true;
                        mi.stateText = mi.Winding + "错误类型:" + Recbuffer[0];
                    }
                }
                break;
            }
        }
Exemple #10
0
        public static void DoDCInsulation(ref MeasurementItemStruct mi, Transformer transformer, JobList Job)
        {
            switch (mi.state)
            {
            case 0:
                byte[] TestKindData;
                if (!transformer.Coupling || mi.Winding == WindingType.LV)
                {
                    TestKindData = TZ3310.SetPraJydz(mi.Winding.ToJYDZstation(), GetParameter.GetPraDCInsulationVoltage(Job), 50, GetParameter.GetPraDCInsulationResistance(Job), GetParameter.GetPraDCInsulationAbsorptionRatio(Job), 0);
                }
                else
                {
                    TestKindData = TZ3310.SetPraJydz(Parameter.JYDZstation.高中绕组, GetParameter.GetPraDCInsulationVoltage(Job), 50, GetParameter.GetPraDCInsulationResistance(Job), GetParameter.GetPraDCInsulationAbsorptionRatio(Job), 0);
                }
                Thread.Sleep(100);
                TZ3310.StartTest(TestKindData);
                mi.stateText = "开始测量" + mi.Winding + "绝缘电阻中...";
                mi.state++;
                Thread.Sleep(4000);
                break;

            case 1:
                string[] Recbuffer = TZ3310.ReadTestData(Parameter.TestKind.绝缘电阻);
                if (Recbuffer != null)
                {
                    PhysicalVariable[] Volate = new PhysicalVariable[1];
                    if (Recbuffer[Recbuffer.Length - 1] == "0")
                    {
                        mi.Result = MeasurementResult.NewDCInsulationResult(mi, NumericsConverter.Text2Value(Recbuffer[0]), NumericsConverter.Text2Value(Recbuffer[1]),
                                                                            NumericsConverter.Text2Value(Recbuffer[2]), null, false);
                        Volate[0] = NumericsConverter.Text2Value(Recbuffer[0]);
                    }

                    else if (Recbuffer[Recbuffer.Length - 1] == "1")
                    {
                        mi.Result = MeasurementResult.NewDCInsulationResult(mi, Volate[0], NumericsConverter.Text2Value(Recbuffer[0]),
                                                                            NumericsConverter.Text2Value(Recbuffer[1]), NumericsConverter.Text2Value(Recbuffer[2]), true);
                        mi.completed = true;
                        mi.stateText = "读取" + mi.Winding + "绝缘电阻结果成功";
                    }
                    else
                    {
                        mi.failed    = true;
                        mi.completed = true;
                        mi.stateText = mi.Winding + "错误类型:" + Recbuffer[0];
                    }
                }
                break;
            }
        }
Exemple #11
0
        private string calcDF(PhysicalVariable AGx)
        {
            double tan = Math.Tan(pnv(AGx.value) - pnv(AGn.value));

            if (Math.Abs(tan) < 0.0000005)
            {
                return("0.000%");
            }
            if ((tan < 1e24) && (tan > -1e24))
            {
                return(NumericsConverter.Value2Text(tan, 4, -5, "", SCEEC.Numerics.Quantities.QuantityName.None, percentage: true).Trim());
            }
            else
            {
                return("NaN");
            }
        }
Exemple #12
0
 private void nF_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int a = System.Text.RegularExpressions.Regex.Matches(ResultTextBox.Text, @"F").Count;
         if (a == 0)
         {
             ResultTextBox.Text += "nF";
         }
         PhysicalVariable tpd = NumericsConverter.Text2Value(ResultTextBox.Text);
         OutCnData(NumericsConverter.Value2Text((double)tpd.value, 4, -13, "", SCEEC.Numerics.Quantities.QuantityName.Capacitance));
         this.Close();
     }
     catch
     {
         throw new Exception("结果值出错");
     }
 }
 private void Keyb_OutVolateData(string cn)
 {
     if (ISHAVEDY)
     {
         if (!ISHAVEVOLATE)
         {
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             (this.DataContext as MainWindowModel).ProjectVolate.Add("持续时间:" + Timecombobox.SelectedIndex.ToString() + ":" + "  耐 压:" + need);
             ISHAVEVOLATE = true;
         }
         else
         {
             (this.DataContext as MainWindowModel).ProjectVolate.RemoveAt((this.DataContext as MainWindowModel).ProjectVolate.Count - 1);
             PhysicalVariable need = NumericsConverter.Text2Value(cn);
             (this.DataContext as MainWindowModel).ProjectVolate.Add("持续时间:" + Timecombobox.SelectedIndex.ToString() + ":" + "耐 压 :" + need);
         }
     }
 }
Exemple #14
0
 public static void AddEleY(FourTestResult AllTestResult,
                            PhysicalVariable eley1, PhysicalVariable eley2, PhysicalVariable eley3, PhysicalVariable eley4)
 {
     if (AllTestResult.PanelEnable)
     {
         AllTestResult.Panel1EleYAndVolate.EleY = eley1;
     }
     if (AllTestResult.Pane2Enable)
     {
         AllTestResult.Panel2EleYAndVolate.EleY = eley2;
     }
     if (AllTestResult.Pane3Enable)
     {
         AllTestResult.Panel3EleYAndVolate.EleY = eley3;
     }
     if (AllTestResult.Pane4Enable)
     {
         AllTestResult.Panel4EleYAndVolate.EleY = eley4;
     }
 }
Exemple #15
0
        private PhysicalVariable calcCap(PhysicalVariable Ix, PhysicalVariable AGx)
        {
            double angle = pnv(AGx.value);
            double ratio = pnv(Ix.value) / pnv(In.value);
            double zn    = pnv(Cn.value) / Math.Cos(pnv(AGn.value));
            double z     = zn * ratio;
            double cp    = z * Math.Cos(angle);
            double rp    = z * Math.Sin(angle);
            double tan   = Math.Tan(pnv(AGx.value) - pnv(AGn.value));
            double cs    = cp * (1 + tan * tan);

            if ((cs < 1e24) && (cs > -1e24))
            {
                return(NumericsConverter.Value2Text(cs, 4, -13, "", SCEEC.Numerics.Quantities.QuantityName.Capacitance));
            }
            else
            {
                return("NaN");
            }
        }
Exemple #16
0
        private string calcPower(PhysicalVariable Ix, PhysicalVariable AGx)
        {
            double angle = pnv(AGx.value);
            double ratio = pnv(Ix.value) / pnv(In.value);
            double zn    = pnv(Cn.value) / Math.Cos(pnv(AGn.value));
            double z     = zn * ratio;
            double cp    = z * Math.Cos(angle);
            double rp    = z * Math.Sin(angle);
            double tan   = Math.Tan(pnv(AGx.value) - pnv(AGn.value));
            double rs    = cp * (tan * tan) / (1 + tan * tan);
            double i     = pnv(Ix.value);
            double p     = i * i * rs;

            if ((p < 1e24) && (p > -1e24))
            {
                return(NumericsConverter.Value2Text(p, 4, -3, "", SCEEC.Numerics.Quantities.QuantityName.Power));
            }
            else
            {
                return("NaN");
            }
        }
Exemple #17
0
        private string calcVolt(PhysicalVariable Freq, PhysicalVariable C, PhysicalVariable I)
        {
            double freq = pnv(Freq.value);
            double c    = pnv(C.value);
            double i    = pnv(I.value);

            if (freq < 1.0)
            {
                return("0 V");
            }
            if (c < 1e-13)
            {
                return("NaN");
            }
            if (i < 1e-9)
            {
                return("0 V");
            }
            double v = i / (2 * Math.PI * freq * c);

            return(NumericsConverter.Value2Text(v, 4, -1, "", SCEEC.Numerics.Quantities.QuantityName.Voltage));
        }
Exemple #18
0
 /// <summary>
 /// 填充TCP接受的数据信息到数据源
 /// </summary>
 /// <param name="ListboxItemsources">数据源</param>
 /// <param name="SysData">TCP接受的数据</param>
 public static ObservableCollection <string> FillListBoxTip(ObservableCollection <string> ListboxItemsources, byte[] SysData)
 {
     ThreadPool.QueueUserWorkItem(delegate
     {
         SynchronizationContext.SetSynchronizationContext(new
                                                          System.Windows.Threading.DispatcherSynchronizationContext(Application.Current.Dispatcher));
         SynchronizationContext.Current.Post(async pl =>
         {
             ListboxItemsources.Add("远程数据显示\t\n若需要手动测量\t\n请设置电晕和耐压");
             var a = StaticClass.GetDataForTcpAutoTest(SysData);
             foreach (var b in a.NeedTestList)
             {
                 PhysicalVariable tpd = NumericsConverter.Text2Value(b.ToString() + "V");
                 ListboxItemsources.Add("待测电压  :" + tpd);
             }
             PhysicalVariable eley      = NumericsConverter.Text2Value(a.EleY.ToString() + "V");
             PhysicalVariable elevolate = NumericsConverter.Text2Value(a.EleVolate.ToString() + "V");
             ListboxItemsources.Add("待测电晕  :" + eley);
             ListboxItemsources.Add("持续时间  :" + a.HideTime.ToString() + ":" + "  耐    压:" + elevolate);
         }, null);
     });
     return(ListboxItemsources);
 }
 /// <summary>
 /// 创建测量结果(绕组绝缘电阻项目)
 /// </summary>
 /// <param name="testingItem">测量项目</param>
 /// <param name="voltage">电压</param>
 /// <param name="resistance">电阻</param>
 /// <param name="absorption">吸收比</param>
 /// <param name="polarization">极化指数</param>
 /// <param name="isOutputResult">是否为最终输出结果</param
 /// <returns>测量结果</returns>
 public static MeasurementResult NewDCInsulationResult(MeasurementItemStruct testingItem, PhysicalVariable voltage, PhysicalVariable resistance, PhysicalVariable absorption, PhysicalVariable polarization, bool isOutputResult)
 {
     if ((testingItem == null) || (testingItem.Function != MeasurementFunction.DCInsulation))
     {
         throw new ArgumentException("测试结果与测试项目不符");
     }
     //if ((voltage == null) || (voltage.PhysicalVariableType != Numerics.Quantities.QuantityName.Voltage)) throw new ArgumentException("电压参数错误");
     //if ((resistance == null) || (resistance.PhysicalVariableType != Numerics.Quantities.QuantityName.Resistance)) throw new ArgumentException("电阻参数错误");
     return(new MeasurementResult(MeasurementFunction.DCInsulation, new PhysicalVariable[4] {
         voltage, resistance, absorption, polarization
     }, !isOutputResult));
 }
 /// <summary>
 /// 创建测量结果(套管电容量及介质损耗项目)
 /// </summary>
 /// <param name="testingItem">测量项目</param>
 /// <param name="voltage">电压</param>
 /// <param name="capacitance">电容量</param>
 /// <param name="tanDelta">介质损耗</param>
 /// <param name="frequency">频率</param>
 /// <param name="isOutputResult">是否为最终输出结果</param>
 /// <returns>测量结果</returns>
 public static MeasurementResult NewBushingCapacitanceResult(MeasurementItemStruct testingItem, PhysicalVariable voltage, PhysicalVariable capacitance, PhysicalVariable tanDelta, PhysicalVariable frequency, PhysicalVariable current, bool isOutputResult)
 {
     if ((testingItem == null) || (testingItem.Function != MeasurementFunction.BushingCapacitance))
     {
         throw new ArgumentException("测试结果与测试项目不符");
     }
     //if ((voltage == null) || (voltage.PhysicalVariableType != Numerics.Quantities.QuantityName.Voltage)) throw new ArgumentException("电压参数错误");
     //if ((capacitance == null) || (capacitance.PhysicalVariableType != Numerics.Quantities.QuantityName.Capacitance)) throw new ArgumentException("电容参数错误");
     //if (isOutputResult && ((tanDelta == null) || (tanDelta.PhysicalVariableType != Numerics.Quantities.QuantityName.None))) throw new ArgumentException("介损参数错误");
     //if (!isOutputResult && ((frequency == null) || (frequency.PhysicalVariableType != Numerics.Quantities.QuantityName.Frequency))) throw new ArgumentException("介损参数错误");
     return(new MeasurementResult(MeasurementFunction.BushingCapacitance, new PhysicalVariable[5] {
         frequency, voltage, capacitance, tanDelta, current
     }, !isOutputResult));
 }
Exemple #21
0
        //public static void StartEleY(bool IsTcpTestting,bool IsCompleteVolateTest,bool IsEnable, byte[] SysData, ObservableCollection<string> ListboxItemsources,
        //    ObservableCollection<string> TestResultMeassge)
        //{
        //    Models.SysAutoTestResult sys = new SysAutoTestResult();
        //    if (IsTcpTestting)
        //        sys = StaticClass.GetDataForTcpAutoTest(SysData);
        //    else
        //    {
        //        sys = GetSys(ListboxItemsources);
        //    }
        //    if (IsCompleteVolateTest)
        //    {
        //        //  SetVolate(sys.EleY);
        //        int p = 0;
        //        bool IsEnd = false;
        //        Models.AutoStateStatic.SState.TestText.Add("电晕  :" + sys.EleY.ToString() + "V" + ":\t正在升压中...");
        //        STAMethod(TestResultMeassge);
        //        while (!IsEnable)
        //        {
        //            p++;
        //            Thread.Sleep(100);
        //            if (p > 5)
        //            {
        //                Models.AutoStateStatic.SState.TestText.RemoveAt(AutoStateStatic.SState.TestText.Count - 1);
        //                Models.AutoStateStatic.SState.TestText.Add("电晕  :" + sys.EleY.ToString() + "V" + ":\t升压超时");
        //                STAMethod(TestResultMeassge);
        //                ThreadPool.QueueUserWorkItem(delegate
        //                {
        //                    SynchronizationContext.SetSynchronizationContext(new
        //                    System.Windows.Threading.DispatcherSynchronizationContext(Application.Current.Dispatcher));
        //                    SynchronizationContext.Current.Post(async pl =>
        //                    {
        //                        if (sys.IsVolate)
        //                        {
        //                            StaticClass.ShowELEYANDVOLATe(Views.EleOrVolate.Volate);
        //                            if (AutoStateStatic.SState.IsStartVolate == true)
        //                                await Task.Factory.StartNew(StartVolate);
        //                            else
        //                                AutoStateStatic.SState.IsStartVolate = false;
        //                        }
        //                        else
        //                        {
        //                            IsTcpTestting = false;
        //                        }
        //                    }, null);
        //                });
        //                IsEnd = true;
        //                break;
        //            }
        //        }
        //        if (!IsEnd)
        //        {
        //            AutoStateStatic.SState.TestText.RemoveAt(AutoStateStatic.SState.TestText.Count - 1);
        //            AutoStateStatic.SState.TestText.Add("电晕  :" + sys.EleY.ToString() + "V" + ":\t升压完成");
        //            STAMethod(TestResultMeassge);
        //            ThreadPool.QueueUserWorkItem(delegate
        //            {
        //                SynchronizationContext.SetSynchronizationContext(new
        //                System.Windows.Threading.DispatcherSynchronizationContext(Application.Current.Dispatcher));
        //                SynchronizationContext.Current.Post(async pl =>
        //                {
        //                    Views.Qualified q = new Views.Qualified
        //                    {
        //                        WindowStartupLocation = WindowStartupLocation.CenterScreen
        //                    };
        //                    q.ShowDialog();
        //                    StaticClass.ShowELEYANDVOLATe(Views.EleOrVolate.Volate);
        //                    if (AutoStateStatic.SState.IsStartVolate == true)
        //                        await Task.Factory.StartNew(StartVolate);
        //                    else
        //                        AutoStateStatic.SState.IsStartVolate = false;
        //                }, null);
        //            });
        //        }
        //    }

        //}

        public static void StartVolate(bool IsTcpTestting, bool IsCompleteEleTest, bool IsEnable, PhysicalVariable HVVoltage, byte[] SysData, ObservableCollection <string> ListboxItemsources,
                                       ObservableCollection <string> TestResultMeassge)
        {
            Models.SysAutoTestResult sys = new SysAutoTestResult();
            if (IsTcpTestting)
            {
                sys = StaticClass.GetDataForTcpAutoTest(SysData);
            }
            else
            {
                sys = GetSys(ListboxItemsources);
            }
            if (IsCompleteEleTest)
            {
                //  SetVolate(sys.EleVolate);
                int  p     = 0;
                bool IsEnd = false;
                Models.AutoStateStatic.SState.TestText.Add("耐压  :" + sys.EleVolate.ToString() + "V" + ":\t正在升压中...");
                STAMethod(TestResultMeassge);
                while (!IsEnable)
                {
                    p++;
                    Thread.Sleep(100);
                    float maxvalue = 0;
                    float actvalue = 0;
                    if (p > 5)
                    {
                        if (Math.Abs((float)HVVoltage.value - sys.EleVolate) < maxvalue)
                        {
                            actvalue = (float)HVVoltage.value;
                        }
                        AutoStateStatic.SState.TestText.RemoveAt(AutoStateStatic.SState.TestText.Count - 1);
                        AutoStateStatic.SState.TestText.Add("耐压  :" + actvalue.ToString() + "V" + ":\t未升到耐压值");
                        STAMethod(TestResultMeassge);
                        IsEnd         = true;
                        IsTcpTestting = false;
                        break;
                    }
                }
                if (!IsEnd)
                {
                    AutoStateStatic.SState.TestText.RemoveAt(AutoStateStatic.SState.TestText.Count - 1);
                    AutoStateStatic.SState.TestText.Add("耐压  :" + sys.EleVolate.ToString() + "V" + ":\t升压完成");
                    STAMethod(TestResultMeassge);
                    int   c         = 0;
                    float MaxVolate = 0;
                    #region
                    while (true)
                    {
                        Models.AutoStateStatic.SState.TestText.Add("当前电压: " + HVVoltage + "\t\n正在持续耐压中...");
                        STAMethod(TestResultMeassge);
                        if (c < sys.HideTime * 2)
                        {
                            if (StaticClass.IsOk((float)HVVoltage.value, sys.EleVolate))
                            {
                                float tempdata = Math.Abs(sys.EleVolate - (float)HVVoltage.value);
                                if (tempdata > MaxVolate)
                                {
                                    MaxVolate = tempdata;
                                    AutoStateStatic.SState.MaxEqualVolate = sys.EleVolate;
                                }
                                Thread.Sleep(500);
                                c++;
                            }
                            else
                            {
                                Thread.Sleep(500);
                                c++;
                                continue;
                            }
                        }
                        else
                        {
                            if (((float)AutoStateStatic.SState.NoSame / (float)AutoStateStatic.SState.AllNum) >= 0.80f)
                            {
                                Models.AutoStateStatic.SState.TestText.Add("耐压实验已完成  耐压结果: 不合格");
                                STAMethod(TestResultMeassge);
                                AutoStateStatic.SState.NaiVolate       = false; //耐压是否合格
                                AutoStateStatic.SState.CompeleteVolate = true;  //是否完成耐压
                                IsTcpTestting = false;
                                break;
                            }
                            else
                            {
                                Models.AutoStateStatic.SState.TestText.Add("耐压实验已完成  耐压结果: 合格");
                                STAMethod(TestResultMeassge);
                                AutoStateStatic.SState.NaiVolate       = true; //耐压是否合格
                                AutoStateStatic.SState.CompeleteVolate = true; //是否完成耐压
                                IsTcpTestting = false;
                                break;
                            }
                        }
                    }
                    #endregion
                }
            }
        }
Exemple #22
0
        public static byte[] Getbytesdata(FourTestResult fs, Int16 ImageID)
        {
            List <byte> rel = new List <byte>();

            rel.AddRange(new byte[] { 0xdd, 0x0a, (byte)fs.NeedTestNum });
            if (fs.PanelEnable)
            {
                foreach (var a in fs.Panel1Result)
                {
                    PhysicalVariable cn   = a.Cn;
                    PhysicalVariable cnt  = a.CnTan;
                    byte[]           cnf  = BitConverter.GetBytes((float)cn.value);
                    byte[]           cntf = BitConverter.GetBytes((float)cnt.value);
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                }
                if (Models.AutoStateStatic.SState.Quality)
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel1EleYAndVolate.EleY.value));
                    rel.Add(0x01);
                    rel.Add(0x01
                            );
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel1EleYAndVolate.EleY.value));
                    rel.Add(0x00);
                    rel.Add(0x01);
                }
                rel.AddRange(BitConverter.GetBytes((float)fs.Panel1EleYAndVolate.EleVolate.value));
                rel.Add((byte)fs.Panel1EleYAndVolate.HodeTime);
                rel.Add(0x02);
            }
            if (fs.Pane2Enable)
            {
                foreach (var a in fs.Panel2Result)
                {
                    PhysicalVariable cn   = a.Cn;
                    PhysicalVariable cnt  = a.CnTan;
                    byte[]           cnf  = BitConverter.GetBytes((float)cn.value);
                    byte[]           cntf = BitConverter.GetBytes((float)cnt.value);
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                }
                if (Models.AutoStateStatic.SState.Quality)
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel2EleYAndVolate.EleY.value));
                    rel.Add(0x01);
                    rel.Add(0x01);
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel2EleYAndVolate.EleY.value));
                    rel.Add(0x00);
                    rel.Add(0x01);
                }
                rel.AddRange(BitConverter.GetBytes((float)fs.Panel2EleYAndVolate.EleVolate.value));
                rel.Add((byte)fs.Panel2EleYAndVolate.HodeTime);
                rel.Add(0x02);
            }
            if (fs.Pane3Enable)
            {
                foreach (var a in fs.Panel3Result)
                {
                    PhysicalVariable cn   = a.Cn;
                    PhysicalVariable cnt  = a.CnTan;
                    byte[]           cnf  = BitConverter.GetBytes((float)cn.value);
                    byte[]           cntf = BitConverter.GetBytes((float)cnt.value);
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                }
                if (Models.AutoStateStatic.SState.Quality)
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel3EleYAndVolate.EleY.value));
                    rel.Add(0x01);
                    rel.Add(0x01);
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel3EleYAndVolate.EleY.value));
                    rel.Add(0x00);
                    rel.Add(0x01);
                }
                rel.AddRange(BitConverter.GetBytes((float)fs.Panel3EleYAndVolate.EleVolate.value));
                rel.Add((byte)fs.Panel3EleYAndVolate.HodeTime);
                rel.Add(0x02);
            }
            if (fs.Pane4Enable)
            {
                foreach (var a in fs.Panel4Result)
                {
                    PhysicalVariable cn   = a.Cn;
                    PhysicalVariable cnt  = a.CnTan;
                    byte[]           cnf  = BitConverter.GetBytes((float)cn.value);
                    byte[]           cntf = BitConverter.GetBytes((float)cnt.value);
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                }
                if (Models.AutoStateStatic.SState.Quality)
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel4EleYAndVolate.EleY.value));
                    rel.Add(0x01);
                    rel.Add(0x01);
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)fs.Panel4EleYAndVolate.EleY.value));
                    rel.Add(0x00);
                    rel.Add(0x01);
                }
                rel.AddRange(BitConverter.GetBytes((float)fs.Panel4EleYAndVolate.EleVolate.value));
                rel.Add((byte)fs.Panel4EleYAndVolate.HodeTime);
                rel.Add(0x02);
            }
            return(rel.ToArray());
        }
Exemple #23
0
        public static byte[] GetTcpResult(MeasureResult result)
        {
            List <byte> rel = new List <byte>();

            rel.AddRange(new byte[] { 0xdd, 0x0a, (byte)result.TestNum });
            if (result.PanelOneEnable)
            {
                foreach (var item in result.PanelResultOne.Volatepointresult)
                {
                    PhysicalVariable cn       = item.Cn;
                    PhysicalVariable cnTan    = item.CnTan;
                    PhysicalVariable cnVolate = item.Volate;
                    byte[]           cnf      = new byte[4];
                    byte[]           cntf     = new byte[4];
                    byte[]           cntv     = new byte[4];
                    if (cn == null || cn.value == null)
                    {
                        cnf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cnf = BitConverter.GetBytes((float)cn.value);
                    }
                    if (cnTan == null || cnTan.value == null)
                    {
                        cntf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntf = BitConverter.GetBytes((float)cnTan.value);
                    }

                    if (cnVolate == null || cnVolate.value == null)
                    {
                        cntv = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntv = BitConverter.GetBytes((float)cnVolate.value);
                    }
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                    rel.AddRange(cntv);
                }
                if (result.PanelResultOne.DYVolate == null || result.PanelResultOne.DYVolate.value == null)
                {
                    // rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultOne.DYVolate.value));
                    rel.Add(TrueOrFalse(result.PanelResultOne.DyQuatity));
                    rel.Add(0x01);
                    rel.Add(0x01);
                }

                if (result.PanelResultOne.KeepVolated == null || result.PanelResultOne.KeepVolated.value == null)
                {
                    //rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultOne.KeepVolated.value));
                    rel.Add((byte)result.PanelResultOne.KeepTimed);
                    rel.Add(0x02);
                    rel.Add(0x02);
                }
            }
            if (result.PanelTwoEnable)
            {
                foreach (var item in result.PanelResultTwo.Volatepointresult)
                {
                    PhysicalVariable cn       = item.Cn;
                    PhysicalVariable cnTan    = item.CnTan;
                    PhysicalVariable cnVolate = item.Volate;
                    byte[]           cnf      = new byte[4];
                    byte[]           cntf     = new byte[4];
                    byte[]           cntv     = new byte[4];
                    if (cn == null || cn.value == null)
                    {
                        cnf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cnf = BitConverter.GetBytes((float)cn.value);
                    }
                    if (cnTan == null || cnTan.value == null)
                    {
                        cntf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntf = BitConverter.GetBytes((float)cnTan.value);
                    }

                    if (cnVolate == null || cnVolate.value == null)
                    {
                        cntv = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntv = BitConverter.GetBytes((float)cnVolate.value);
                    }
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                    rel.AddRange(cntv);
                }
                if (result.PanelResultTwo.DYVolate == null || result.PanelResultTwo.DYVolate.value == null)
                {
                    //  rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultTwo.DYVolate.value));
                    rel.Add(TrueOrFalse(result.PanelResultTwo.DyQuatity));
                    rel.Add(0x01);
                    rel.Add(0x01);
                }

                if (result.PanelResultTwo.KeepVolated == null || result.PanelResultTwo.KeepVolated.value == null)
                {
                    // rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultTwo.KeepVolated.value));
                    rel.Add((byte)result.PanelResultTwo.KeepTimed);
                    rel.Add(0x02);
                    rel.Add(0x02);
                }
            }
            if (result.PanelThreeEnable)
            {
                foreach (var item in result.PanelResultThree.Volatepointresult)
                {
                    PhysicalVariable cn       = item.Cn;
                    PhysicalVariable cnTan    = item.CnTan;
                    PhysicalVariable cnVolate = item.Volate;
                    byte[]           cnf      = new byte[4];
                    byte[]           cntf     = new byte[4];
                    byte[]           cntv     = new byte[4];
                    if (cn == null || cn.value == null)
                    {
                        cnf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cnf = BitConverter.GetBytes((float)cn.value);
                    }
                    if (cnTan == null || cnTan.value == null)
                    {
                        cntf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntf = BitConverter.GetBytes((float)cnTan.value);
                    }

                    if (cnVolate == null || cnVolate.value == null)
                    {
                        cntv = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntv = BitConverter.GetBytes((float)cnVolate.value);
                    }
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                    rel.AddRange(cntv);
                }
                if (result.PanelResultThree.DYVolate == null || result.PanelResultThree.DYVolate.value == null)
                {
                    //rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultThree.DYVolate.value));
                    rel.Add(TrueOrFalse(result.PanelResultThree.DyQuatity));
                    rel.Add(0x01);
                    rel.Add(0x01);
                }


                if (result.PanelResultThree.KeepVolated == null || result.PanelResultThree.KeepVolated.value == null)
                {
                    // rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultThree.KeepVolated.value));
                    rel.Add((byte)result.PanelResultThree.KeepTimed);
                    rel.Add(0x02);
                    rel.Add(0x02);
                }
            }
            if (result.PanelFourEnable)
            {
                foreach (var item in result.PanelResultFour.Volatepointresult)
                {
                    PhysicalVariable cn       = item.Cn;
                    PhysicalVariable cnTan    = item.CnTan;
                    PhysicalVariable cnVolate = item.Volate;
                    byte[]           cnf      = new byte[4];
                    byte[]           cntf     = new byte[4];
                    byte[]           cntv     = new byte[4];
                    if (cn == null || cn.value == null)
                    {
                        cnf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cnf = BitConverter.GetBytes((float)cn.value);
                    }
                    if (cnTan == null || cnTan.value == null)
                    {
                        cntf = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntf = BitConverter.GetBytes((float)cnTan.value);
                    }

                    if (cnVolate == null || cnVolate.value == null)
                    {
                        cntv = new byte[] { 0x00, 0x00, 0x00, 0x00 };
                    }
                    else
                    {
                        cntv = BitConverter.GetBytes((float)cnVolate.value);
                    }
                    rel.AddRange(cnf);
                    rel.AddRange(cntf);
                    rel.AddRange(cntv);
                }
                if (result.PanelResultFour.DYVolate == null || result.PanelResultFour.DYVolate.value == null)
                {
                    //rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultFour.DYVolate.value));
                    rel.Add(TrueOrFalse(result.PanelResultFour.DyQuatity));
                    rel.Add(0x01);
                    rel.Add(0x01);
                }

                if (result.PanelResultFour.KeepVolated == null || result.PanelResultFour.KeepVolated.value == null)
                {
                    // rel.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                }
                else
                {
                    rel.AddRange(BitConverter.GetBytes((float)result.PanelResultFour.KeepVolated.value));
                    rel.Add((byte)result.PanelResultFour.KeepTimed);
                    rel.Add(0x02);
                    rel.Add(0x02);
                }
            }
            //rel.Add(result.Fre);
            //rel.AddRange(BitConverter.GetBytes(result.TestSpeed));
            return(rel.ToArray());
        }
Exemple #24
0
        //读取测量数据
        /// <summary>
        /// 读取测量数据和数据的处理
        /// </summary>
        /// <param name="testkind">测试类型</param>
        /// <returns>回复解析完成的数据</returns>
        public string[] ReadTestData(Parameter.TestKind testkind)
        {
            if (testkind == Parameter.TestKind.介质损耗)
            {
                //string[] RetData = new string[5];
                byte[] SendComman = { 0x12 };
                byte[] RecBuffer  = new byte[31];
                sc.SendCommand(SendComman, ref RecBuffer, 50);

                if (RecBuffer[0] == 0xfa)
                {
                    string[] RetData = new string[5];
                    RetData[0] = RecBuffer[1].ToString();
                    PhysicalVariable pv = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(2).Take(7).ToArray()));
                    RetData[1] = pv.ToString();
                    PhysicalVariable pv1 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(9).Take(7).ToArray()));
                    RetData[2] = pv1.ToString();
                    PhysicalVariable pv2 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(16).Take(7).ToArray()));
                    RetData[3] = pv2.ToString();
                    RetData[4] = "0";
                    return(RetData);
                }
                if (RecBuffer[0] == 0xff)
                {
                    string[]         RetData = new string[5];
                    PhysicalVariable pv      = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(2).Take(7).ToArray()));
                    RetData[0] = pv.ToString();
                    PhysicalVariable pv1 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(9).Take(7).ToArray()));
                    RetData[1] = pv1.ToString();
                    PhysicalVariable pv2 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(16).Take(7).ToArray()) + "%");
                    RetData[2] = pv2.ToString(percentage: true, positiveSign: true);
                    PhysicalVariable pv3 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(23).Take(7).ToArray()));
                    RetData[3] = pv3.ToString();
                    RetData[4] = "1";

                    return(RetData);
                }
                if (RecBuffer[0] == 0xee)
                {
                    string[] Rd = new string[1];
                    Rd[0] = TestErrDC(RecBuffer[1].ToString());
                    return(Rd);//错误类型
                }
            }
            if (testkind == Parameter.TestKind.直流电阻)
            {
                byte[] Sendbuffer = { 0x32 };
                byte[] RecBuffer  = new byte[75];
                try
                {
                    sc.SendCommand(Sendbuffer, ref RecBuffer, 10);
                    //if (CheckData(RecData) == RecData[74])
                    //{
                    if (RecBuffer[0] == 0xfa)
                    {
                        string[] RetData = new string[10];
                        RetData[0] = Encoding.ASCII.GetString(RecBuffer.Skip(2).Take(8).ToArray());
                        PhysicalVariable pv = NumericsConverter.Text2Value(RetData[0]);
                        RetData[0] = pv.ToString();
                        RetData[1] = Encoding.ASCII.GetString(RecBuffer.Skip(10).Take(8).ToArray());
                        PhysicalVariable pv1 = NumericsConverter.Text2Value(RetData[1]);
                        RetData[1] = pv1.ToString();
                        RetData[2] = Encoding.ASCII.GetString(RecBuffer.Skip(18).Take(8).ToArray()).Replace("$", "Ω");
                        PhysicalVariable pv2 = NumericsConverter.Text2Value(RetData[2]);
                        RetData[2] = pv2.ToString();

                        RetData[3] = Encoding.ASCII.GetString(RecBuffer.Skip(26).Take(8).ToArray());
                        PhysicalVariable pv3 = NumericsConverter.Text2Value(RetData[3]);
                        RetData[3] = pv3.ToString();

                        RetData[4] = Encoding.ASCII.GetString(RecBuffer.Skip(34).Take(8).ToArray());
                        PhysicalVariable pv4 = NumericsConverter.Text2Value(RetData[4]);
                        RetData[4] = pv4.ToString();
                        RetData[5] = Encoding.ASCII.GetString(RecBuffer.Skip(42).Take(8).ToArray()).Replace("$", "Ω");
                        PhysicalVariable pv5 = NumericsConverter.Text2Value(RetData[5]);
                        RetData[5] = pv5.ToString();

                        RetData[6] = Encoding.ASCII.GetString(RecBuffer.Skip(50).Take(8).ToArray());
                        PhysicalVariable pv6 = NumericsConverter.Text2Value(RetData[6]);
                        RetData[6] = pv6.ToString();

                        RetData[7] = Encoding.ASCII.GetString(RecBuffer.Skip(58).Take(8).ToArray());
                        PhysicalVariable pv7 = NumericsConverter.Text2Value(RetData[7]);
                        RetData[7] = pv7.ToString();
                        RetData[8] = Encoding.ASCII.GetString(RecBuffer.Skip(66).Take(8).ToArray()).Replace("$", "Ω");
                        PhysicalVariable pv8 = NumericsConverter.Text2Value(RetData[8]);
                        RetData[8] = pv8.ToString();

                        RetData[9] = "0";
                        return(RetData);
                    }
                    else if (RecBuffer[0] == 0xff)
                    {
                        string[] RetData = new string[10];
                        RetData[0] = Encoding.ASCII.GetString(RecBuffer.Skip(2).Take(8).ToArray());
                        PhysicalVariable pv = NumericsConverter.Text2Value(RetData[0]);
                        RetData[0] = pv.ToString();
                        RetData[1] = Encoding.ASCII.GetString(RecBuffer.Skip(10).Take(8).ToArray());
                        PhysicalVariable pv1 = NumericsConverter.Text2Value(RetData[1]);
                        RetData[1] = pv1.ToString();
                        RetData[2] = Encoding.ASCII.GetString(RecBuffer.Skip(18).Take(8).ToArray()).Replace("$", "Ω");
                        PhysicalVariable pv2 = NumericsConverter.Text2Value(RetData[2]);
                        RetData[2] = pv2.ToString();
                        RetData[3] = Encoding.ASCII.GetString(RecBuffer.Skip(26).Take(8).ToArray());
                        PhysicalVariable pv3 = NumericsConverter.Text2Value(RetData[3]);
                        RetData[3] = pv3.ToString();
                        RetData[4] = Encoding.ASCII.GetString(RecBuffer.Skip(34).Take(8).ToArray());
                        PhysicalVariable pv4 = NumericsConverter.Text2Value(RetData[4]);
                        RetData[4] = pv4.ToString();
                        RetData[5] = Encoding.ASCII.GetString(RecBuffer.Skip(42).Take(8).ToArray()).Replace("$", "Ω");
                        PhysicalVariable pv5 = NumericsConverter.Text2Value(RetData[5]);
                        RetData[5] = pv5.ToString();
                        RetData[6] = Encoding.ASCII.GetString(RecBuffer.Skip(50).Take(8).ToArray());
                        PhysicalVariable pv6 = NumericsConverter.Text2Value(RetData[6]);
                        RetData[6] = pv6.ToString();
                        RetData[7] = Encoding.ASCII.GetString(RecBuffer.Skip(58).Take(8).ToArray());
                        PhysicalVariable pv7 = NumericsConverter.Text2Value(RetData[7]);
                        RetData[7] = pv7.ToString();
                        RetData[8] = Encoding.ASCII.GetString(RecBuffer.Skip(66).Take(8).ToArray()).Replace("$", "Ω");
                        PhysicalVariable pv8 = NumericsConverter.Text2Value(RetData[8]);
                        RetData[8] = pv8.ToString();
                        RetData[9] = "1";

                        return(RetData);
                    }
                    else if (RecBuffer[0] == 0xee)
                    {
                        string[] Rd = new string[1];
                        Rd[0] = TestErr(RecBuffer[1].ToString());
                        return(Rd);//错误类型
                    }
                    //}
                }
                catch
                {
                }
            }
            if (testkind == Parameter.TestKind.绝缘电阻)
            {
                byte[] SendComman = { 0x22 };
                byte[] RecData    = new byte[18];
                //  float[] RetData = new float[4];

                sc.SendCommand(SendComman, ref RecData, 50);

                if (CheckData(RecData) == RecData[17])
                {
                    if (RecData[0] == 0xfa)
                    {
                        string[] RetData = new string[4];

                        PhysicalVariable pv = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(1).Take(5).ToArray()) + "V");
                        RetData[0] = pv.ToString();
                        string TempData = Encoding.ASCII.GetString(RecData.Skip(6).Take(7).ToArray()).Replace("$", "Ω");
                        if (TempData.IndexOf('Ω') < 0)
                        {
                            TempData += "Ω";
                        }
                        PhysicalVariable pv1 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(6).Take(7).ToArray()).Replace("$", "Ω"));
                        RetData[1] = pv1.ToString();
                        PhysicalVariable pv2 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(13).Take(4).ToArray()));
                        RetData[2] = pv2.ToString();
                        RetData[3] = "0";
                        return(RetData);
                    }
                    if (RecData[0] == 0xff)
                    {
                        string[] RetData  = new string[4];
                        string   TempData = Encoding.ASCII.GetString(RecData.Skip(1).Take(7).ToArray()).Replace("$", "Ω");
                        if (TempData.IndexOf('Ω') < 0)
                        {
                            TempData += "Ω";
                        }
                        PhysicalVariable pv = NumericsConverter.Text2Value(TempData);
                        RetData[0] = pv.ToString();

                        PhysicalVariable pv1 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(8).Take(4).ToArray()));
                        RetData[1] = pv1.ToString();
                        PhysicalVariable pv2 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(12).Take(4).ToArray()));
                        RetData[2] = pv2.ToString();
                        RetData[3] = "1";

                        return(RetData);
                    }
                    if (RecData[0] == 0xee)
                    {
                        string[] Rd = new string[1];
                        Rd[0] = TestErrDC(RecData[1].ToString());

                        return(Rd);//错误类型
                    }
                }

                else
                {
                }
            }
            if (testkind == Parameter.TestKind.载分接)
            {
                byte[] RecBuffer = new byte[51];
                // float[] RetData = new float[7];
                byte[] SendComman = { 0x42 };
                sc.SendCommand(SendComman, ref RecBuffer, 50);
                if (RecBuffer[0] == 0xfa)
                {
                    string[] RetData = new string[7];
                    RetData[0] = RecBuffer[1].ToString();
                    PhysicalVariable pv = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(2).Take(8).ToArray()));
                    RetData[1] = pv.ToString();
                    PhysicalVariable pv1 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(10).Take(8).ToArray()));
                    RetData[2] = pv1.ToString();
                    PhysicalVariable pv2 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(18).Take(8).ToArray()));
                    RetData[3] = pv2.ToString();
                    PhysicalVariable pv3 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(26).Take(8).ToArray()));
                    RetData[4] = pv3.ToString();
                    PhysicalVariable pv4 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(34).Take(8).ToArray()));
                    RetData[5] = pv4.ToString();
                    PhysicalVariable pv5 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(42).Take(8).ToArray()));
                    RetData[6] = pv5.ToString();
                    return(RetData);
                }
                else if (RecBuffer[0] == 0xff && RecBuffer[1] == 0xff)
                {
                    string[]         RetData = new string[6];
                    PhysicalVariable pv      = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(2).Take(8).ToArray()));
                    RetData[0] = pv.ToString();
                    PhysicalVariable pv1 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(10).Take(8).ToArray()));
                    RetData[1] = pv1.ToString();
                    PhysicalVariable pv2 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(18).Take(8).ToArray()));
                    RetData[2] = pv2.ToString();
                    PhysicalVariable pv3 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(26).Take(8).ToArray()));
                    RetData[3] = pv3.ToString();
                    PhysicalVariable pv4 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(34).Take(8).ToArray()));
                    RetData[4] = pv4.ToString();
                    PhysicalVariable pv5 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecBuffer.Skip(42).Take(8).ToArray()));
                    RetData[5] = pv5.ToString();
                    return(RetData);
                }
                else if (RecBuffer[0] == 0xee)
                {
                    string[] Rd = new string[1];

                    Rd[0] = TestErr(RecBuffer[1].ToString());
                    return(Rd);//错误类型
                }
                else
                {
                    return(null);
                }
            }
            if (testkind == Parameter.TestKind.读取放电数据)
            {
                byte[] RecData = new byte[26];
                // float[] RetData = new float[4];
                byte[] SendComman = { 0x3e };
                if (sc.SendCommand(SendComman, ref RecData, 50) >= 0)
                {
                    string[] RetData = new string[4];
                    bool     Success;
                    RetData[0] = RecData[0].ToString();
                    PhysicalVariable pv = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(1).Take(8).ToArray()), out Success);
                    if (Success)
                    {
                        RetData[1] = pv.ToString();
                    }
                    else
                    {
                        RetData[1] = Encoding.ASCII.GetString(RecData.Skip(1).Take(8).ToArray());
                    }
                    PhysicalVariable pv1 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(9).Take(8).ToArray()), out Success);
                    if (Success)
                    {
                        RetData[2] = pv1.ToString();
                    }
                    else
                    {
                        RetData[2] = Encoding.ASCII.GetString(RecData.Skip(9).Take(8).ToArray());
                    }
                    PhysicalVariable pv2 = NumericsConverter.Text2Value(Encoding.ASCII.GetString(RecData.Skip(17).Take(8).ToArray()), out Success);
                    if (Success)
                    {
                        RetData[3] = pv2.ToString();
                    }
                    else
                    {
                        RetData[3] = Encoding.ASCII.GetString(RecData.Skip(17).Take(8).ToArray());
                    }

                    return(RetData);
                }
            }
            return(null);
        }
        private void Recor_Click(object sender, RoutedEventArgs e)
        {
            #region 设置基础值
            double VolateD = 0;
            string Volate  = "0V";
            try
            {
                if (AutoStateStatic.SState.mv.HVVoltage.ToString() != "NaN")
                {
                    Volate = mv.HVVoltage.ToString();
                    PhysicalVariable a = NumericsConverter.Text2Value(Volate);
                    VolateD = (double)a.value;
                }
            }
            catch
            {
            }
            var Fre  = mv.HVFrequency.ToString();
            var Time = DateTime.Now.ToString();

            float Cn      = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Capacitance1).value;
            var   Current = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Current1).value;
            var   Tan     = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.DissipationFactor1).value;

            var Cn2      = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Capacitance2).value;
            var Current2 = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Current2).value;
            var Tan2     = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.DissipationFactor2).value;

            var Cn3      = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Capacitance3).value;
            var Current3 = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Current3).value;
            var Tan3     = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.DissipationFactor3).value;

            var Cn4      = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Capacitance4).value;
            var Current4 = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.Current4).value;
            var Tan4     = (float)NumericsConverter.Text2Value(AutoStateStatic.SState.mv.DissipationFactor4).value;
            if (Com1.SelectedIndex == 0)
            {
                XVolate.Add(Volate);

                if (Com2.SelectedIndex == 0)
                {
                    YVolateAndCn.Add(Cn);
                    YVolateAndCn2.Add(Cn2);
                    YVolateAndCn3.Add(Cn3);
                    YVolateAndCn4.Add(Cn4);

                    mv.SetChartObserver(YVolateAndCn.ToArray(), XVolate, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndCn2.ToArray(), XVolate, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndCn3.ToArray(), XVolate, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndCn4.ToArray(), XVolate, ChartPannel.Channel4);
                }
                else if (Com2.SelectedIndex == 1)
                {
                    YVolateAndCurrent.Add((double)Current);
                    YVolateAndCurrent2.Add((double)Current2);
                    YVolateAndCurrent3.Add((double)Current3);
                    YVolateAndCurrent4.Add((double)Current4);
                    mv.SetChartObserver(YVolateAndCurrent.ToArray(), XVolate, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndCurrent2.ToArray(), XVolate, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndCurrent3.ToArray(), XVolate, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndCurrent4.ToArray(), XVolate, ChartPannel.Channel4);
                }
                else if (Com2.SelectedIndex == 2)
                {
                    YVolateAndTan.Add((double)Tan);
                    YVolateAndTan2.Add((double)Tan2);
                    YVolateAndTan3.Add((double)Tan3);
                    YVolateAndTan4.Add((double)Tan4);
                    mv.SetChartObserver(YVolateAndTan.ToArray(), XVolate, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndTan2.ToArray(), XVolate, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndTan3.ToArray(), XVolate, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndTan4.ToArray(), XVolate, ChartPannel.Channel4);
                }
            }
            if (Com1.SelectedIndex == 1)
            {
                XFre.Add(Fre);
                if (Com2.SelectedIndex == 0)
                {
                    YVolateAndCn.Add((double)Cn);
                    YVolateAndCn2.Add((double)Cn2);
                    YVolateAndCn3.Add((double)Cn3);
                    YVolateAndCn4.Add((double)Cn4);
                    mv.SetChartObserver(YVolateAndCn.ToArray(), XFre, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndCn2.ToArray(), XFre, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndCn3.ToArray(), XFre, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndCn4.ToArray(), XFre, ChartPannel.Channel4);
                }
                else if (Com2.SelectedIndex == 1)
                {
                    YVolateAndCurrent.Add((double)Current);
                    YVolateAndCurrent2.Add((double)Current2);
                    YVolateAndCurrent3.Add((double)Current3);
                    YVolateAndCurrent4.Add((double)Current4);
                    mv.SetChartObserver(YVolateAndCurrent.ToArray(), XFre, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndCurrent2.ToArray(), XFre, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndCurrent3.ToArray(), XFre, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndCurrent4.ToArray(), XFre, ChartPannel.Channel4);
                }
                else
                {
                    YVolateAndTan.Add((double)Tan);
                    YVolateAndTan2.Add((double)Tan2);
                    YVolateAndTan3.Add((double)Tan3);
                    YVolateAndTan4.Add((double)Tan4);
                    mv.SetChartObserver(YVolateAndTan.ToArray(), XFre, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndTan2.ToArray(), XFre, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndTan3.ToArray(), XFre, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndTan4.ToArray(), XFre, ChartPannel.Channel4);
                }
            }
            if (Com1.SelectedIndex == 2)
            {
                XFre.Add(Time);
                if (Com2.SelectedIndex == 0)
                {
                    YVolateAndCn.Add((double)VolateD);
                    YVolateAndCn2.Add((double)VolateD);
                    YVolateAndCn3.Add((double)VolateD);
                    YVolateAndCn4.Add((double)VolateD);
                    mv.SetChartObserver(YVolateAndCn.ToArray(), XTime, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndCn2.ToArray(), XTime, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndCn3.ToArray(), XTime, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndCn4.ToArray(), XTime, ChartPannel.Channel4);
                }
                else if (Com2.SelectedIndex == 1)
                {
                    YVolateAndCurrent.Add((double)Current);
                    YVolateAndCurrent2.Add((double)Current2);
                    YVolateAndCurrent3.Add((double)Current3);
                    YVolateAndCurrent4.Add((double)Current4);
                    mv.SetChartObserver(YVolateAndCurrent.ToArray(), XTime, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndCurrent2.ToArray(), XTime, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndCurrent3.ToArray(), XTime, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndCurrent4.ToArray(), XTime, ChartPannel.Channel4);
                }
                else
                {
                    YVolateAndTan.Add((double)Tan);
                    YVolateAndTan2.Add((double)Tan2);
                    YVolateAndTan3.Add((double)Tan3);
                    YVolateAndTan4.Add((double)Tan4);
                    mv.SetChartObserver(YVolateAndTan.ToArray(), XTime, ChartPannel.Channel1);
                    mv.SetChartObserver(YVolateAndTan2.ToArray(), XTime, ChartPannel.Channel2);
                    mv.SetChartObserver(YVolateAndTan3.ToArray(), XTime, ChartPannel.Channel3);
                    mv.SetChartObserver(YVolateAndTan4.ToArray(), XTime, ChartPannel.Channel4);
                }
            }
            #endregion
        }
        public static void OLTCSwitchingCharacter(ref MeasurementItemStruct mi, Transformer transformer, JobList Job)
        {
            Parameter.YzfjStation yzfjStation;
            if (mi.Winding == WindingType.HV)
            {
                yzfjStation = Parameter.YzfjStation.高压侧;
            }
            else
            {
                yzfjStation = Parameter.YzfjStation.中压侧;
            }
            switch (mi.state)
            {
            case 0:
                byte[] TestKindData = TZ3310.SetPraYzfj((Parameter.YzfjWindingKind)mi.WindingConfig, yzfjStation, Parameter.yzfjTap._1To_2, Parameter.YzfjCurrent._1_A, 5, 5, 0);
                Thread.Sleep(100);
                TZ3310.StartTest(TestKindData);
                mi.stateText = "正在测试" + mi.Winding + "有载分接中...";
                mi.state++;
                Thread.Sleep(4000);
                break;

            case 1:
                string[] Recbuffer = TZ3310.ReadTestData(Parameter.TestKind.载分接);
                if (Recbuffer != null)
                {
                    bool ReadforT;
                    if (Recbuffer[0] == "1")
                    {
                        ReadforT = true;
                    }
                    else
                    {
                        ReadforT = false;
                    }
                    if (Recbuffer.Length == 7)
                    {
                        PhysicalVariable[] Voltage   = { NumericsConverter.Text2Value(Recbuffer[1]), NumericsConverter.Text2Value(Recbuffer[3]), NumericsConverter.Text2Value(Recbuffer[5]) };  //135
                        PhysicalVariable[] current   = { NumericsConverter.Text2Value(Recbuffer[2]), NumericsConverter.Text2Value(Recbuffer[4]), NumericsConverter.Text2Value(Recbuffer[6]) };  //246
                        PhysicalVariable[] Resistans = new PhysicalVariable[3];
                        Resistans[0] = NumericsConverter.Text2Value("0.005");
                        Resistans[1] = NumericsConverter.Text2Value("0.005");
                        Resistans[2] = NumericsConverter.Text2Value("0.005");
                        mi.Result    = MeasurementResult.NewOLTCSwitchingCharacterResult(mi, Voltage, current, Resistans, null, ReadforT, false);
                        mi.stateText = "读取" + mi.Winding + "有载分接充电中...";
                        if (ReadforT)    //可以触发
                        {
                            mi.stateText = mi.Winding + "有载分接等待触发。。。";
                            Thread.Sleep(500);
                            mi.state++;
                        }
                    }
                    else
                    {
                        //  mi.failed = true;
                        mi.completed = true;
                        mi.stateText = "充电时错误:" + Recbuffer[0].ToString();
                    }
                }
                break;

            case 2:
                string[] Recbuffer1 = TZ3310.ReadTestData(Parameter.TestKind.载分接);
                if (Recbuffer1 != null)
                {
                    bool ReadforR;
                    if (Recbuffer1[0] == "2")
                    {
                        ReadforR = true;
                    }
                    else
                    {
                        ReadforR = false;
                    }
                    if (Recbuffer1.Length == 7)
                    {
                        PhysicalVariable[] Voltage = { NumericsConverter.Text2Value(Recbuffer1[1]), NumericsConverter.Text2Value(Recbuffer1[3]), NumericsConverter.Text2Value(Recbuffer1[5]) }; //135
                        PhysicalVariable[] current = { NumericsConverter.Text2Value(Recbuffer1[2]), NumericsConverter.Text2Value(Recbuffer1[4]), NumericsConverter.Text2Value(Recbuffer1[6]) }; //246
                        if (ReadforR)                                                                                                                                                           //触发成功
                        {
                            mi.Result = MeasurementResult.NewOLTCSwitchingCharacterResult(mi, Voltage, current, new PhysicalVariable[3], null, ReadforR, true);

                            mi.stateText = "读取" + mi.Winding + "触发成功";
                            mi.state++;
                        }
                    }

                    else if (Recbuffer1.Length == 1)
                    {
                        // mi.failed = true;
                        mi.completed = true;
                        mi.stateText = mi.Winding + "错误类型:" + Recbuffer1[0].ToString();
                    }
                }
                break;

            case 3:

                mi.stateText = "正在读取波形中。。。";
                Thread.Sleep(8000);
                mi.state++;
                break;

            case 4:
                var Waveform = TZ3310.GetWaveFormData;    //5s
                if (Waveform != null)
                {
                    mi.Result = MeasurementResult.NewOLTCSwitchingCharacterResult(mi, new PhysicalVariable[3], new PhysicalVariable[3],
                                                                                  new PhysicalVariable[3], Waveform, false, true);
                    mi.state++;
                    WorkingSets.local.WaveFormSwicth = Waveform;
                    Thread.Sleep(50);
                    WorkingSets.local.ShowWaveForm = true;
                    mi.stateText = mi.Winding + "波形读取完成";
                }
                else
                {
                    // mi.state++;
                    //    mi.failed = true;
                    mi.completed = true;
                    mi.stateText = mi.Winding + "未读取到波形";
                }
                break;

            case 5:
                mi.completed = true;
                break;
            }
        }