/// <summary> /// 设置单个产品数据 /// </summary> /// <param name="idNo"></param> /// <param name="stepVal"></param> public void SetTestVal(int uutNo, CHPPara.CStepVal ItemVal) { if (this.InvokeRequired) { this.Invoke(new Action <int, CHPPara.CStepVal>(SetTestVal), uutNo, ItemVal); } else { if (ItemVal.mVal.Count != labValList[uutNo].Count) { return; } string failCode = string.Empty; for (int stepNo = 0; stepNo < labValList[uutNo].Count; stepNo++) { EStepName stepName = ItemVal.mVal[stepNo].name; double stepVal = ItemVal.mVal[stepNo].value; string stepUnit = ItemVal.mVal[stepNo].unit; string stepShow = stepVal.ToString("0.00") + stepUnit; if (stepName == EStepName.IR) { if (stepVal >= 1000) { stepShow = "UUUUUU"; } } labValList[uutNo][stepNo].Text = stepShow; if (ItemVal.mVal[stepNo].result == 0) { labValList[uutNo][stepNo].ForeColor = Color.Blue; } else { labValList[uutNo][stepNo].ForeColor = Color.Red; failCode = ItemVal.mVal[stepNo].code; } } if (ItemVal.result == 0) { labResultList[uutNo].Text = "PASS"; labResultList[uutNo].ForeColor = Color.Blue; } else { labResultList[uutNo].Text = failCode; labResultList[uutNo].ForeColor = Color.Red; } } }
/// <summary> /// 读取测试步骤设置值 /// </summary> /// <param name="stepNo"></param> /// <param name="rStepVal"></param> /// <param name="er"></param> /// <returns></returns> public bool ReadStepSetting(int stepNo, out EStepName stepName, out List <double> stepVal, out string er) { stepName = EStepName.AC; stepVal = new List <double>(); er = string.Empty; try { er = "不支持读设定步骤"; return(true); } catch (Exception ex) { er = ex.ToString(); return(false); } }
/// <summary> /// 读取测试步骤设置值 /// </summary> /// <param name="stepNo"></param> /// <param name="rStepVal"></param> /// <param name="er"></param> /// <returns></returns> public bool ReadStepSetting(int stepNo, out EStepName stepName, out List <double> stepVal, out string er) { stepName = EStepName.AC; stepVal = new List <double>(); er = string.Empty; try { string cmd = "SAF:STEP" + stepNo.ToString() + ":SET?"; string rData = string.Empty; if (!sendCmdToHP(cmd, out rData, out er)) { return(false); } string[] stepList = rData.Split(','); if (stepList.Length < 4) { er = "获取步骤数据错误:" + rData; return(false); } switch (stepList[2]) { case "AC": stepName = EStepName.AC; for (int i = 0; i < stepList.Length - 5; i++) { stepVal.Add(System.Convert.ToDouble(stepList[i + 3])); } if (stepVal.Count != CHPPara.C_ACItem.Length) { er = "获取步骤数据错误:" + rData; return(false); } stepVal[0] = stepVal[0] / 1000; //VOLTAGE stepVal[1] = stepVal[1] * 1000; //HIGHT LIMIT stepVal[2] = stepVal[2] * 1000; //LOW LIMIT stepVal[3] = stepVal[3] * 1000; //ARC LIMIT stepVal[4] = stepVal[4]; //RAMP TIME stepVal[5] = stepVal[5]; //TEST TIME stepVal[6] = stepVal[6]; //FALL TIME break; case "DC": stepName = EStepName.DC; for (int i = 0; i < stepList.Length - 5; i++) { stepVal.Add(System.Convert.ToDouble(stepList[i + 3])); } if (stepVal.Count != CHPPara.C_DCItem.Length) { er = "获取步骤数据错误:" + rData; return(false); } stepVal[0] = stepVal[0] / 1000; //VOLTAGE stepVal[1] = stepVal[1] * 1000; //HIGHT LIMIT stepVal[2] = stepVal[2] * 1000; //LOW LIMIT stepVal[3] = stepVal[3] * 1000; //ARC LIMIT stepVal[4] = stepVal[4]; //RAMP TIME stepVal[5] = stepVal[5]; //DWELL TIME stepVal[6] = stepVal[6]; //TEST TIME stepVal[7] = stepVal[7]; //FALL TIME break; case "IR": stepName = EStepName.IR; for (int i = 0; i < stepList.Length - 7; i++) { stepVal.Add(System.Convert.ToDouble(stepList[i + 3])); } if (stepVal.Count != CHPPara.C_IRItem.Length) { er = "获取步骤数据错误:" + rData; return(false); } stepVal[0] = stepVal[0] / 1000; //VOLTAGE stepVal[1] = stepVal[1] / 1000000; //LOW LIMIT stepVal[2] = stepVal[2] / 1000000; //HIGHT LIMIT stepVal[3] = stepVal[3]; //RAMP TIME stepVal[4] = stepVal[4]; //TEST TIME stepVal[5] = stepVal[5]; //FALL TIME break; case "OSC": stepName = EStepName.OSC; for (int i = 0; i < stepList.Length - 5; i++) { stepVal.Add(System.Convert.ToDouble(stepList[i + 3])); } if (stepVal.Count != CHPPara.C_OSCItem.Length) { er = "获取步骤数据错误:" + rData; return(false); } stepVal[0] = stepVal[0] * 100; //OPEN stepVal[1] = stepVal[1] * 100; //SHORT break; default: stepName = EStepName.PA; break; } return(true); } catch (Exception ex) { er = ex.ToString(); return(false); } }
/// <summary> /// 设置测试数据 /// </summary> /// <param name="stepValList"></param> public void SetTestVal(List <string> serialNo, List <CHPPara.CStepVal> stepValList) { if (this.InvokeRequired) { this.Invoke(new Action <List <string>, List <CHPPara.CStepVal> >(SetTestVal), serialNo, stepValList); } else { for (int uutNo = 0; uutNo < labValList.Length; uutNo++) { if (stepValList[uutNo].mVal.Count != labValList[uutNo].Count) { continue; } string failCode = string.Empty; for (int stepNo = 0; stepNo < labValList[uutNo].Count; stepNo++) { EStepName stepName = stepValList[uutNo].mVal[stepNo].name; double stepVal = stepValList[uutNo].mVal[stepNo].value; string stepUnit = stepValList[uutNo].mVal[stepNo].unit; string stepShow = stepVal.ToString("0.00") + stepUnit; if (stepName == EStepName.IR) { if (stepUnit == "M0hm") { if (stepVal >= 1000000) { stepShow = "UUUUUU"; } } else { if (stepVal >= 1000) { stepShow = "UUUUUU"; } } } if (serialNo[uutNo] != string.Empty) { labValList[uutNo][stepNo].Text = stepShow; if (stepValList[uutNo].mVal[stepNo].result == 0) { labValList[uutNo][stepNo].ForeColor = Color.Blue; } else { labValList[uutNo][stepNo].ForeColor = Color.Red; failCode = stepValList[uutNo].mVal[stepNo].code; } } else { labValList[uutNo][stepNo].Text = ""; labValList[uutNo][stepNo].ForeColor = Color.Black; } } if (serialNo[uutNo] != string.Empty) { if (stepValList[uutNo].result == 0) { labResultList[uutNo].Text = "PASS"; labResultList[uutNo].ForeColor = Color.Blue; } else { labResultList[uutNo].Text = failCode; labResultList[uutNo].ForeColor = Color.Red; } } else { labResultList[uutNo].Text = ""; labResultList[uutNo].ForeColor = Color.Black; } } } }
/// <summary> /// 读设置值 /// </summary> /// <param name="stepNo"></param> /// <param name="er"></param> /// <returns></returns> public bool ReadStepSetting(int stepNo, out EStepName stepName, out List <double> stepVal, out string er) { return(_devHP.ReadStepSetting(stepNo, out stepName, out stepVal, out er)); }
/// <summary> /// 读取测试结果 /// </summary> /// <param name="chan"></param> /// <param name="chanResult"></param> /// <param name="stepResult"></param> /// <param name="stepCode"></param> /// <param name="stepMode"></param> /// <param name="stepVal"></param> /// <param name="stepUnit"></param> /// <param name="er"></param> /// <returns></returns> public bool ReadResult(int chan, out int chanResult, out List <int> stepResult, out List <string> stepCode, out List <EStepName> stepMode, out List <double> stepVal, out List <string> stepUnit, out string er) { chanResult = 0; stepResult = new List <int>(); stepCode = new List <string>(); stepMode = new List <EStepName>(); stepVal = new List <double>(); stepUnit = new List <string>(); er = string.Empty; try { string cmd = "FETCh?"; string rData = string.Empty; if (!sendCmdToHP(cmd, out rData, out er)) { return(false); } string[] StepArray = rData.Split((char)32); //空格 if (StepArray.Length < _stepNum) { er = "接收数据步骤错误:" + rData; return(false); } for (int i = 0; i < StepArray.Length; i++) { string[] StrName = StepArray[i].Split(':'); string StepName = StrName[0]; //STEP1,2,3.. if (StepName.Substring(0, 4) != "STEP") { er = "测试步骤名称错误:" + rData; return(false); } string ItemName = StrName[1]; //AC,DC,IR if (!Enum.IsDefined(typeof(EStepName), ItemName)) { er = "测试项目错误:" + rData; return(false); } EStepName eItemName = (EStepName)Enum.Parse(typeof(EStepName), ItemName); string ItemVal = StrName[2]; string[] CHVals = ItemVal.Split(';'); string[] _CHVals = new string[1] { "" }; string[] CHVals2 = CHVals.Except(_CHVals).ToArray(); if (CHVals2.Length != _uutMax) { er = "测试通道数错误:" + rData; return(false); } for (int z = 0; z < CHVals2.Length; z++) //产品数据 { string[] uutVals = CHVals2[z].Split(','); if (uutVals.Length < 4) { er = "测试结果错误:" + rData; return(false); } int CH = System.Convert.ToInt32(uutVals[0]); double Volt = System.Convert.ToDouble(uutVals[1]); double value = System.Convert.ToDouble(uutVals[2]); string Result = uutVals[3]; if (chan != CH) { continue; } if (Result == "PASS") { stepResult.Add(0); stepCode.Add(Result); } else { chanResult = 1; stepResult.Add(1); stepCode.Add(Result); } stepMode.Add(eItemName); switch (eItemName) { case EStepName.AC: stepVal.Add(value); stepUnit.Add("mA"); break; case EStepName.DC: stepVal.Add(value); stepUnit.Add("mA"); break; case EStepName.IR: if (value < 1000) { stepVal.Add(value); stepUnit.Add("M0hm"); } else { stepVal.Add(value / 1000); stepUnit.Add("G0hm"); } break; case EStepName.OSC: stepVal.Add(value); stepUnit.Add("nF"); break; default: break; } } } return(true); } catch (Exception ex) { er = ex.ToString(); return(false); } }
/// <summary> /// 读取测试结果 /// </summary> /// <param name="uutMax"></param> /// <param name="stepMax"></param> /// <param name="uut"></param> /// <param name="er"></param> /// <returns></returns> public bool ReadResult(int uutMax, int stepMax, out List <CCHResult> uut, out string er) { er = string.Empty; uut = new List <CCHResult>(); try { //测试通道数据 for (int uutNo = 0; uutNo < uutMax; uutNo++) { uut.Add(new CCHResult()); for (int i = 0; i < stepMax; i++) { uut[uutNo].Step.Add(new CStepResult()); } } //获取测试结果 string cmd = "FETCh?"; string rData = string.Empty; if (!sendCmdToHP(cmd, out rData, out er)) { return(false); } string[] StepArray = rData.Split((char)32); //空格 if (StepArray.Length < stepMax) { er = "接收数据步骤错误:" + rData; return(false); } for (int i = 0; i < stepMax; i++) { string[] StrName = StepArray[i].Split(':'); string StepName = StrName[0]; //STEP1,2,3.. if (StepName.Substring(0, 4) != "STEP") { er = "测试步骤名称错误:" + rData; return(false); } string ItemName = StrName[1]; //AC,DC,IR EStepName eItemName = EStepName.AC; switch (ItemName) { case "AC": eItemName = EStepName.AC; break; case "DC": eItemName = EStepName.DC; break; case "IR": eItemName = EStepName.IR; break; case "OS": eItemName = EStepName.OSC; break; default: er = "测试项目错误:" + rData; return(false); } string ItemVal = StrName[2]; string[] CHVals = ItemVal.Split(';'); if (CHVals.Length < uutMax) { er = "测试通道数错误:" + rData; return(false); } for (int z = 0; z < uutMax; z++) //产品数据 { string[] uutVals = CHVals[z].Split(','); if (uutVals.Length < 4) { er = "测试结果错误:" + rData; return(false); } int CH = System.Convert.ToInt16(uutVals[0]); double Volt = System.Convert.ToDouble(uutVals[1]); double value = System.Convert.ToDouble(uutVals[2]); string Result = uutVals[3]; if (Result == "PASS") { uut[z].Step[i].Result = 0; uut[z].Step[i].Code = Result; } else { uut[z].Result = 1; uut[z].Step[i].Result = 1; uut[z].Step[i].Code = Result; } uut[z].Step[i].Name = eItemName; switch (eItemName) { case EStepName.AC: uut[z].Step[i].Value = value; uut[z].Step[i].Unit = "mA"; break; case EStepName.DC: uut[z].Step[i].Value = value; uut[z].Step[i].Unit = "mA"; break; case EStepName.IR: if (value < 1000) { uut[z].Step[i].Value = value; uut[z].Step[i].Unit = "M0hm"; } else { uut[z].Step[i].Value = value / 1000; uut[z].Step[i].Unit = "G0hm"; } break; case EStepName.OSC: uut[z].Step[i].Value = value; uut[z].Step[i].Unit = "nF"; break; default: uut[z].Step[i].Value = value; uut[z].Step[i].Unit = "NA"; break; } } } return(true); } catch (Exception ex) { er = ex.ToString(); return(false); } }
/// <summary> /// 设置测试项目 /// </summary> /// <param name="stepName"></param> /// <param name="itemVal"></param> /// <param name="step"></param> /// <param name="er"></param> /// <returns></returns> public static CStep IniStep(EStepName stepName, int stepNo) { try { CStep stepItem = new CStep(); stepItem.stepNo = stepNo; stepItem.name = stepName; switch (stepName) { case EStepName.AC: stepItem.des = "交流电压耐压(AC)测试"; for (int i = 0; i < C_ACItem.Length; i++) { CItem item = new CItem(); item.name = C_ACItem[i]; item.unitDes = C_ACUnit[i]; item.setVal = 0; stepItem.para.Add(item); } break; case EStepName.DC: stepItem.des = "直流电压耐压(DC)测试"; for (int i = 0; i < C_DCItem.Length; i++) { CItem item = new CItem(); item.name = C_DCItem[i]; item.unitDes = C_DCUnit[i]; item.setVal = 0; stepItem.para.Add(item); } break; case EStepName.IR: stepItem.des = "绝缘阻抗(IR)测试"; for (int i = 0; i < C_IRItem.Length; i++) { CItem item = new CItem(); item.name = C_IRItem[i]; item.unitDes = C_IRUnit[i]; item.setVal = 0; stepItem.para.Add(item); } break; case EStepName.GB: stepItem.des = "接地电阻(GB)测试"; for (int i = 0; i < C_GBItem.Length; i++) { CItem item = new CItem(); item.name = C_GBItem[i]; item.unitDes = C_GBUnit[i]; item.setVal = 0; stepItem.para.Add(item); } break; case EStepName.OSC: stepItem.des = "开短路侦测(OS)测试"; for (int i = 0; i < C_OSCItem.Length; i++) { CItem item = new CItem(); item.name = C_OSCItem[i]; item.unitDes = C_OSCUnit[i]; item.setVal = 0; stepItem.para.Add(item); } break; default: break; } return(stepItem); } catch (Exception) { return(null); } }