public static void DoWork(ref TestingWorkerSender sender) { DoMeasurement(ref sender.MeasurementItems[sender.CurrentItemIndex], sender.Transformer, sender.job); sender.StatusText = sender.MeasurementItems[sender.CurrentItemIndex].stateText; if (sender.CurrentItemIndex >= sender.MeasurementItems.Length) { TestFunction.Closecurrent(0); } }
/// <summary> /// 筛选测试反馈中最终输出结果的数组的结果文本 /// </summary> /// <param name="sender">测试传递结构</param> /// <returns>最终输出结果文本的数组</returns> public static string[] getFinalResultsText(TestingWorkerSender sender) { List <string> strlist = new List <string>(); foreach (MeasurementItemStruct m in sender.MeasurementItems) { if ((m != null) && ((m.failed) || (m.completed == true)) && (m.Function != MeasurementFunction.Description)) { strlist.Add(m.ResultText); } } return(strlist.ToArray()); }
// static TestingWorkUtility() { } /// <summary> /// 筛选测试反馈中最终输出结果的数组 /// </summary> /// <param name="sender">测试传递结构</param> /// <returns>最终输出结果的数组</returns> public static MeasurementResult[] getFinalResults(TestingWorkerSender sender) { List <MeasurementResult> list = new List <MeasurementResult>(); foreach (MeasurementItemStruct m in sender.MeasurementItems) { if ((m != null) && ((m.failed) || (m.completed == true))) { list.Add(m.Result); } } return(list.ToArray()); }
public static TestingWorkerSender FromDatabaseRows(int testID) { TestingWorkerSender sender = new TestingWorkerSender(); var rows = WorkingSets.local.TestResults.Select("testid = '" + testID.ToString() + "'"); if (rows.Length > 0) { sender.Transformer = WorkingSets.local.getTransformer((int)rows[0]["transformerid"]); sender.job = WorkingSets.local.getJob((int)rows[0]["mj_id"]); List <MeasurementItemStruct> mlist = new List <MeasurementItemStruct>(); MeasurementItemStruct m; foreach (var row in rows) { m = new MeasurementItemStruct((MeasurementFunction)((int)row["function"])) { Winding = new WindingType((int)row["windingtype"]), Terimal = WindingTerimal.FromList((List <int>) (new SCEEC.Converter.GenericListTypeConverter <int>().ConvertFrom((string)row["terimal"]))), WindingConfig = (TransformerWindingConfigName)(int)row["windingconfig"], TapLabel = ((string)row["taplabel"]).Split(';'), Text = (string)row["text"], failed = (bool)row["failed"], completed = (bool)row["completed"] }; List <SCEEC.Numerics.PhysicalVariable> pvList = new List <Numerics.PhysicalVariable>(); for (int i = 0; i < 9; i++) { string pvstr = (string)row["result_pv" + (i + 1).ToString()]; if (pvstr.Length > 0) { pvList.Add(SCEEC.Numerics.NumericsConverter.Text2Value(pvstr)); } else { i = 9; } } m.Result = new MeasurementResult( m.Function, pvList.ToArray(), MeasurementItemStruct.Bytes2Shorts(Convert.FromBase64String((string)row["waves"])), readyToTrigger: false, processing: false); mlist.Add(m); } sender.MeasurementItems = mlist.ToArray(); } return(sender); }
public TestingWorkerSender getTestResults(string s) { var rows = TestResults.Select("function = " + ((int)MeasurementFunction.Information).ToString()); int testid = 0; bool valid = false; foreach (var r in rows) { var ji = JobInformation.FromString((string)r["waves"]); if ((ji.testingName + "(" + ji.testingTime.ToString("yyyy-MM-dd") + ")") == s) { testid = (int)r["testid"]; valid = true; } } if (!valid) { throw new Exception("测试结果查找为空"); } rows = TestResults.Select("testid = " + testid.ToString()); if (rows.Length <= 0) { throw new Exception("测试结果导出出错"); } var tws = new TestingWorkerSender(); tws.job = getJob((int)rows[0]["mj_id"]); tws.Transformer = getTransformer((int)rows[0]["transformerid"]); tws.ProgressPercent = 100; tws.CurrentItemIndex = 0; List <MeasurementItemStruct> mis = new List <MeasurementItemStruct>(); foreach (var r in rows) { if ((int)r["function"] != (int)MeasurementFunction.Information) { mis.Add(MeasurementItemStruct.FromDataRow(r)); } else { tws.job.Information = JobInformation.FromString((string)r["waves"]); } } tws.MeasurementItems = mis.ToArray(); return(tws); }
//重做 failed 试验 //D型做三次的问题 public static void DoWork(ref TestingWorkerSender sender) { if (WorkingSets.local.IsCancer) { sender.MeasurementItems[sender.CurrentItemIndex].completed = false; sender.MeasurementItems[sender.CurrentItemIndex].failed = false; sender.MeasurementItems[sender.CurrentItemIndex].state = 0; // sender.CurrentItemIndex = sender.CurrentItemIndex - 1; WorkingSets.local.IsCancer = false; } // sender.MeasurementItems[sender.CurrentItemIndex].state = 0; DoMeasurement(ref sender.MeasurementItems[sender.CurrentItemIndex], sender.Transformer, sender.job, sender); sender.StatusText = sender.MeasurementItems[sender.CurrentItemIndex].stateText; if (sender.CurrentItemIndex >= sender.MeasurementItems.Length) { TestFunction.Closecurrent(0); } }
public static bool CancalWork(ref TestingWorkerSender sender) { if (sender.MeasurementItems[sender.CurrentItemIndex].Function == MeasurementFunction.DCResistance || sender.MeasurementItems[sender.CurrentItemIndex].Function == MeasurementFunction.OLTCSwitchingCharacter) { if (true == TZ3310.ShutDownOutCurrent(0)) { string[] OutData = TZ3310.ReadTestData(Parameter.TestKind.读取放电数据); if (OutData != null) { if (OutData[0] == "2") { sender.StatusText = "放电完成"; return(true); } else { sender.StatusText = "正在放电中..."; return(false); } } } else { sender.StatusText = "关闭电流输出失败"; return(false); } } else { if (true == TZ3310.InterRuptMe(Parameter.CommanTest.仪器复位)) { sender.StatusText = "仪器复位成功"; return(true); } else { return(false); } } return(false); }
public System.Data.DataRow ToDataRowAddIndex(TestingWorkerSender sender) { var jobInfo = sender.job; System.Data.DataRow row = WorkingSets.local.TestResults.NewRow(); row["testjobindex"] = sender.CurrentItemIndex; row["testname"] = jobInfo.Information.testingName; row["testid"] = jobInfo.Information.GetHashCode(); row["transformerid"] = jobInfo.Transformer.ID; row["mj_id"] = jobInfo.id; //row["testname"] = row["function"] = (int)Function; row["windingtype"] = (int)Winding; if (Terimal != null) { if (Terimal.Length == 2) { row["terimal"] = ((int)Terimal[0]).ToString() + ";" + ((int)Terimal[1]).ToString(); } else if (Terimal.Length == 1) { row["terimal"] = ((int)Terimal[0]).ToString(); } else { row["terimal"] = string.Empty; } } try { row["windingconfig"] = (int)WindingConfig; } catch { } if (TapLabel != null) { if (TapLabel.Length == 2) { row["taplabel"] = TapLabel[0] + ";" + TapLabel[1]; } else if (TapLabel.Length == 1) { row["taplabel"] = TapLabel[0]; } else { row["taplabel"] = string.Empty; } } if (Text != null) { row["text"] = Text; } row["failed"] = failed; row["completed"] = completed; if (result != null && result.values != null) { for (int i = 0; i < result.values.Length; i++) { if (result.values[i] != null) { var pv = result.values[i]; try { row["result_pv" + (i + 1).ToString()] = pv.OriginText; } catch { } } } row["recordtime"] = result.recordTime; if (result.waves != null) { if (result.waves != null && result.waves.Length > 0) { try { row["waves"] = System.Convert.ToBase64String(Array2Bytes(result.waves)); } catch { } } } } return(row); }
public static bool CancelWork(ref TestingWorkerSender sender) { return(TestFunction.CancalWork(ref sender)); }
public static bool CancalWork(ref TestingWorkerSender sender) { try { if (sender.MeasurementItems[sender.CurrentItemIndex].Function == MeasurementFunction.DCResistance) { if (!Fd) { Thread.Sleep(150); TZ3310.InterRuptMe(Parameter.CommanTest.模拟按键中断测量); Thread.Sleep(150); TZ3310.ShutDownOutCurrent(0); Fd = true; } string[] tpd = TZ3310.ReadTestData(Parameter.TestKind.读取放电数据); if (tpd != null && tpd[0] == "2") { sender.StatusText = "放电完成"; Fd = false; return(true); } else { // sender.StatusText = "正在放电..."; return(false); } } if (sender.MeasurementItems[sender.CurrentItemIndex].Function == MeasurementFunction.OLTCSwitchingCharacter) { if (!Fd) { Thread.Sleep(150); TZ3310.InterRuptMe(Parameter.CommanTest.模拟按键中断测量); Thread.Sleep(150); TZ3310.ShutDownOutCurrent(0); Fd = true; } string[] tpd = TZ3310.ReadTestData(Parameter.TestKind.读取放电数据); if (tpd[0] == "2") { sender.StatusText = "放电完成"; Fd = false; return(true); } else { return(false); } } else { Thread.Sleep(150); TZ3310.InterRuptMe(Parameter.CommanTest.模拟按键中断测量); return(true); } } catch { sender.MeasurementItems[sender.CurrentItemIndex].stateText = "放电失败,正在尝试重新连接"; if (!TZ3310.CommunicationQuery(0x00)) { Thread.Sleep(2000); sender.MeasurementItems[sender.CurrentItemIndex].stateText = "重新连接失败"; } return(false); } }
public static void DCResistance(ref MeasurementItemStruct mi, Transformer transformer, JobList Job, TestingWorkerSender sender) { //string p = (1.1 + i / 10) + " kV"; //string q = tempp.ToString("f1") + " A"; //tempp += 0.1; //string w = (3.3 + i) + " Ω"; //var p1 = new PhysicalVariable[] { p, q, w }; //var p2 = new PhysicalVariable[] { p, q, w }; //var p3 = new PhysicalVariable[] { p, q, w }; //mi.Result = MeasurementResult.NewDCResistanceResult(mi, p1, p2, p3, false); //i++; //if (i > 100) //{ // mi.completed = true; // mi.failed = true; // mi.stateText = "测量人为中断"; // i = 0; //} //Thread.Sleep(200); if (mi.Terimal != null) { Parameter.ZldzStation Dcposition; if (mi.Winding == WindingType.HV) { Dcposition = Parameter.ZldzStation.高压全部 + (((int)mi.Terimal[0]) % 4);//1 // mi.WindingConfig = GetWindConfig(sender.MeasurementItems[sender.CurrentItemIndex + 1], transformer); } else if (mi.Winding == WindingType.MV) { Dcposition = Parameter.ZldzStation.中压全部 + (((int)mi.Terimal[0]) % 4);//5 } else { if (!Job.DCResistance.ZcEnable) { Dcposition = Parameter.ZldzStation.低压全部 + (((int)mi.Terimal[0]) % 4);//9 } else { Dcposition = Parameter.ZldzStation.注磁抵押 + (((int)mi.Terimal[0]) % 4);//9 } } switch (mi.state) { case 0: if (mi.Winding == WindingType.HV) { mi.WindingConfig = transformer.WindingConfig.HV; } else if (mi.Winding == WindingType.MV) { mi.WindingConfig = transformer.WindingConfig.MV; } else { if (transformer.WindingNum == 2) { mi.WindingConfig = transformer.WindingConfig.MV; } else { mi.WindingConfig = transformer.WindingConfig.LV; } } Thread.Sleep(2000); byte[] TestKindData = TZ3310.SetPraZldz((Parameter.ZldzWindingKind)mi.WindingConfig, Dcposition, GetParameter.GetPraDCResistanceCurrentSpa(mi, Job), 0); Thread.Sleep(100); TZ3310.StartTest(TestKindData); WorkingSets.local.TestDCI = false; WorkingSets.local.IsEnablestable = true; mi.stateText = "正在开始" + mi.Winding + "直流电阻中..."; Thread.Sleep(4000); mi.state++; break; case 1: string[] Recbuffer = TZ3310.ReadTestData(Parameter.TestKind.直流电阻); Thread.Sleep(150); if (Recbuffer != null) { if (Recbuffer[Recbuffer.Length - 1] == "0") { PhysicalVariable[] Voltage = { NumericsConverter.Text2Value(Recbuffer[0]), NumericsConverter.Text2Value(Recbuffer[3]), NumericsConverter.Text2Value(Recbuffer[6]) }; PhysicalVariable[] Current = { NumericsConverter.Text2Value(Recbuffer[1]), NumericsConverter.Text2Value(Recbuffer[4]), NumericsConverter.Text2Value(Recbuffer[7]) }; PhysicalVariable[] Resistance = { NumericsConverter.Text2Value(Recbuffer[2]), NumericsConverter.Text2Value(Recbuffer[5]), NumericsConverter.Text2Value(Recbuffer[8]) }; mi.Result = MeasurementResult.NewDCResistanceResult(mi, Voltage, Current, Resistance, false); mi.state++; //测量结束数据需要确定 mi.stateText = "等待确认" + mi.Winding + "直流电阻稳定中..."; //临时 WorkingSets.local.IsVisible = true; WorkingSets.local.IsVisible1 = true; } else if (Recbuffer[Recbuffer.Length - 1] == "1") { mi.state++; } else { mi.failed = true; mi.completed = true; mi.stateText = mi.Winding + "错误类型:" + Recbuffer[0].ToString(); } } break; case 2: string[] Recbuffer1 = TZ3310.ReadTestData(Parameter.TestKind.直流电阻); Thread.Sleep(150); if (Recbuffer1 != null) { if (Recbuffer1[Recbuffer1.Length - 1] == "0") { PhysicalVariable[] Voltage = { NumericsConverter.Text2Value(Recbuffer1[0]), NumericsConverter.Text2Value(Recbuffer1[3]), NumericsConverter.Text2Value(Recbuffer1[6]) }; PhysicalVariable[] Current = { NumericsConverter.Text2Value(Recbuffer1[1]), NumericsConverter.Text2Value(Recbuffer1[4]), NumericsConverter.Text2Value(Recbuffer1[7]) }; PhysicalVariable[] Resistance = { NumericsConverter.Text2Value(Recbuffer1[2]), NumericsConverter.Text2Value(Recbuffer1[5]), NumericsConverter.Text2Value(Recbuffer1[8]) }; mi.Result = MeasurementResult.NewDCResistanceResult(mi, Voltage, Current, Resistance, false); if (WorkingSets.local.IsStable == true) { WorkingSets.local.IsStable = false; mi.Result = MeasurementResult.NewDCResistanceResult(mi, Voltage, Current, Resistance, true); TZ3310.InterRuptMe(Parameter.CommanTest.判断直流电阻稳定状态); mi.stateText = "确定" + mi.Winding + "直流电阻稳定成功"; mi.state++; } } else if (Recbuffer1[Recbuffer1.Length - 1] == "1") { mi.state++; } else { mi.stateText = mi.Winding + "错误类型:" + Recbuffer1[0].ToString(); mi.failed = true; mi.completed = true; } } break; case 3: string[] Recbuffer2 = TZ3310.ReadTestData(Parameter.TestKind.直流电阻); if (Recbuffer2 != null) { if (Recbuffer2[Recbuffer2.Length - 1] == "1") { if (sender.MeasurementItems.Length != (sender.CurrentItemIndex + 1)) { var miNext = sender.MeasurementItems[sender.CurrentItemIndex + 1]; if (miNext.Terimal != null && mi.Function == miNext.Function && mi.Terimal[0] == miNext.Terimal[0] && mi.Terimal[1] == miNext.Terimal[1] && mi.Winding == miNext.Winding && mi.WindingConfig == GetWindConfig(miNext, transformer)) { //不需要放电 mi.stateText = "直流电阻" + mi.Winding + ":" + mi.Terimal[0] + "-" + mi.Terimal[1] + "测试完成"; mi.completed = true; } else { //需要放电的 TZ3310.ShutDownOutCurrent(0); mi.state++; } } else { //为最后一项 mi.stateText = mi.Winding + "直流电阻正在放电..."; TZ3310.ShutDownOutCurrent(0); mi.state++; } } else { mi.failed = true; mi.completed = true; mi.stateText = mi.Winding + "错误类型:" + Recbuffer2[0].ToString(); //临时 } } break; case 4: string[] readdata = TZ3310.ReadTestData(Parameter.TestKind.读取放电数据); if (readdata[0] == "2") { mi.stateText = mi.Winding + "直流电阻放电完成"; mi.completed = true; } break; } } else { switch (mi.state) { case 0: if (mi.Winding == WindingType.HV) { mi.WindingConfig = transformer.WindingConfig.HV; } else if (mi.Winding == WindingType.MV) { mi.WindingConfig = transformer.WindingConfig.MV; } else { if (transformer.PhaseNum == 2) { mi.WindingConfig = transformer.WindingConfig.MV; } else { mi.WindingConfig = transformer.WindingConfig.LV; } } WorkingSets.local.TestDCI = false; WorkingSets.local.IsEnablestable = true; byte[] TestKindData = TZ3310.SetPraZldz((Parameter.ZldzWindingKind)mi.WindingConfig, mi.Winding.TozldzStation(Job), GetParameter.GetPraDCResistanceCurrentSpa(mi, Job), 0); Thread.Sleep(100); if (TZ3310.StartTest(TestKindData)) { mi.stateText = "正在测试" + mi.Winding.TozldzStation(Job) + "直流电阻中..."; mi.state++; } Thread.Sleep(4000); break; case 1: string[] Recbuffer = TZ3310.ReadTestData(Parameter.TestKind.直流电阻); Thread.Sleep(150); if (Recbuffer != null) { if (Recbuffer[Recbuffer.Length - 1] == "0") { PhysicalVariable[] Voltage = { Recbuffer[0], Recbuffer[3], Recbuffer[6] }; PhysicalVariable[] Current = { Recbuffer[1], Recbuffer[4], Recbuffer[7] }; PhysicalVariable[] Resistance = { Recbuffer[2], Recbuffer[5], Recbuffer[8] }; mi.Result = MeasurementResult.NewDCResistanceResult(mi, Voltage, Current, Resistance, false); mi.state++; mi.stateText = "等待确定" + mi.Winding + "直流电阻稳定中..."; WorkingSets.local.IsVisible = true; WorkingSets.local.IsVisible1 = true; } else if (Recbuffer[Recbuffer.Length - 1] == "1") { mi.state++; } else { mi.failed = true; mi.completed = true; mi.stateText = mi.Winding + "错误类型:" + Recbuffer[0].ToString(); } } break; case 2: string[] Recbuffer1 = TZ3310.ReadTestData(Parameter.TestKind.直流电阻); if (Recbuffer1 != null) { if (Recbuffer1[Recbuffer1.Length - 1] == "0") { PhysicalVariable[] Voltage = { Recbuffer1[0], Recbuffer1[3], Recbuffer1[6] }; PhysicalVariable[] Current = { Recbuffer1[1], Recbuffer1[4], Recbuffer1[7] }; PhysicalVariable[] Resistance = { Recbuffer1[2], Recbuffer1[5], Recbuffer1[8] }; mi.Result = MeasurementResult.NewDCResistanceResult(mi, Voltage, Current, Resistance, false); if (WorkingSets.local.IsStable == true) { WorkingSets.local.IsStable = false; mi.Result = MeasurementResult.NewDCResistanceResult(mi, Voltage, Current, Resistance, true); TZ3310.InterRuptMe(Parameter.CommanTest.判断直流电阻稳定状态); mi.stateText = "确定" + mi.Winding + "直流电阻稳定成功"; mi.state++; } } else if (Recbuffer1[Recbuffer1.Length - 1] == "1") { mi.state++; } else { mi.failed = true; mi.completed = true; mi.stateText = mi.Winding + "错误类型:" + Recbuffer1[0].ToString(); } } break; case 3: string[] Recbuffer2 = TZ3310.ReadTestData(Parameter.TestKind.直流电阻); if (Recbuffer2 != null) { if (Recbuffer2[Recbuffer2.Length - 1] == "1") { if (sender.MeasurementItems.Length != (sender.CurrentItemIndex + 1)) { var miNext = sender.MeasurementItems[sender.CurrentItemIndex + 1]; if (mi.Function == miNext.Function && mi.Winding == miNext.Winding && mi.WindingConfig == GetWindConfig(miNext, transformer)) { //不需要放电 mi.stateText = "直流电阻" + mi.Winding + "测试完成"; mi.completed = true; } else { //需要放电的 TZ3310.ShutDownOutCurrent(0); mi.state++; } } else { //为最后一项 mi.stateText = mi.Winding + "直流电阻测试完成"; TZ3310.ShutDownOutCurrent(0); mi.state++; } } else { mi.failed = true; mi.completed = true; mi.stateText = mi.Winding + "错误类型:" + Recbuffer2[0].ToString(); //临时 } } Thread.Sleep(1000); break; case 4: string[] readdata = TZ3310.ReadTestData(Parameter.TestKind.读取放电数据); if (readdata[0] == "2") { mi.stateText = mi.Winding + "直流电阻放电完成"; mi.completed = true; } break; } } }
public static MeasurementResult DoMeasurement(ref MeasurementItemStruct mi, Transformer transformer, JobList Job, TestingWorkerSender sender) { switch (mi.Function) { case MeasurementFunction.DCInsulation: TestFunction.DoDCInsulation(ref mi, transformer, Job); break; case MeasurementFunction.Capacitance: TestFunction.Capacitance(ref mi, transformer, Job); break; case MeasurementFunction.DCResistance: //直流电阻 TestFunction.DCResistance(ref mi, transformer, Job, sender); break; case MeasurementFunction.BushingDCInsulation: TestFunction.BushingDCInsulation(ref mi, transformer, Job); break; case MeasurementFunction.BushingCapacitance: TestFunction.BushingCapacitance(ref mi, transformer, Job); break; case MeasurementFunction.OLTCSwitchingCharacter: TestFunction.OLTCSwitchingCharacter(ref mi, transformer, Job); break; case MeasurementFunction.Information: TestFunction.Information(ref mi, transformer, Job); break; case MeasurementFunction.DCCharge: //充电 break; case MeasurementFunction.Coreinsulation: //充电 TestFunction.Coredci(ref mi, transformer, Job); break; case MeasurementFunction.Leakagecurrent: //充电 TestFunction.Losscurrent(ref mi, transformer, Job); break; case MeasurementFunction.Shortcircuitimpedance: //充电 TestFunction.Shortvolate(ref mi, transformer, Job); break; case MeasurementFunction.Description: mi.completed = true; break; } return(null); }