diff --git a/.vs/Testrong.User.Program/v17/.suo b/.vs/Testrong.User.Program/v17/.suo index 5bb2805..b73b05a 100644 Binary files a/.vs/Testrong.User.Program/v17/.suo and b/.vs/Testrong.User.Program/v17/.suo differ diff --git a/Testrong.User.Program/UserProgram.cs b/Testrong.User.Program/UserProgram.cs index 17b1d16..4b9d976 100644 --- a/Testrong.User.Program/UserProgram.cs +++ b/Testrong.User.Program/UserProgram.cs @@ -654,6 +654,41 @@ namespace Testrong.User.Program } + + /* ----------SlotThreadLocker------------- + * int SlotNum: Current Slot Number, + * List slotList: Slot List, + * string pathFlag: Path Selector, Possible Value="Freq","CAL_Init","CAL","RINT","CAL_COM", + */ + public void SlotThreadLocker(int SlotNum, List slotList, string pathFlag) + { + string WritePath; + switch (pathFlag) + { + case "Freq": + WritePath = EXT_CAL_FREQ_PATH; + break; + case "CAL_Init": + WritePath = EXT_CAL_INIT_PATH; + break; + case "RINT": + WritePath = RINT_COMPFILE_PATH; + break; + case "CAL_COM": + WritePath = CAL_COMPFILE_PATH; + break; + default: + WritePath = EXT_CAL_PATH; + break; + } + if (SlotNum < slotList[slotList.Count - 1]) + { + StreamWriter swSignal = new StreamWriter(WritePath + SlotNum + ".flag"); //Create file flagging end of current thread + swSignal.WriteLine(); + swSignal.Flush(); + swSignal.Close(); + } + } private int GetPMUTempSensorIndex(int channel) { if ((channel >= 65 && channel <= 80) || (channel >= 97 && channel <= 112) || (channel >= 193 && channel <= 208) || (channel >= 241 && channel <= 256)) @@ -892,8 +927,7 @@ namespace Testrong.User.Program return DmmDic; } - //Write Data To File - /* + /*----------Write Data To File------------- * Variable Definition * string filename: filename * int slot: Slot Number @@ -945,7 +979,7 @@ namespace Testrong.User.Program } else if (mode == "FVMI") { - if (range == "60mA") + if (range == "60mA" || range == "1A") { sw.Write($"{ForceValue[writeLine]:F10},"); sw.Write($"{AteMeasure[writeLine]:F15},"); @@ -960,7 +994,7 @@ namespace Testrong.User.Program } else if (mode == "FIMV") { - if (range == "60mA") + if (range == "60mA" || range == "5uA") { sw.Write($"{ForceValue[writeLine]:F10},"); sw.Write($"{AteMeasure[writeLine]:F15},"); @@ -1189,13 +1223,7 @@ namespace Testrong.User.Program swResult = new StreamWriter(EXT_CAL_FREQ_PATH + "f_Result.csv", true, Encoding.UTF8); FrequencyProcess(SlotNum, swResult, EXT_CAL_FREQ_PATH, 25); swResult.Close(); - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_FREQ_PATH + SlotNum + ".flag"); - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + SlotThreadLocker(SlotNum:SlotNum,slotList:slotList,pathFlag:"Freq"); if (SlotNum == slotList[slotList.Count - 1]) { swResult.Close(); @@ -1289,13 +1317,7 @@ namespace Testrong.User.Program var isPmurUploadOK = extCaliHandle.UploadFile(context.Communicator.ServerIP, EXT_CAL_INIT_PATH + "Pmur_init.csv", FileType.pmu_r); LogRawText($"Pmu_r Status: {isPmurUploadOK}"); - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_INIT_PATH + SlotNum + ".flag"); //Create file flagging end of current thread - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL_Init"); } void Rint_FVMV_2mA_Pre(IFlowRunnerContext context, TestVersion testVersion) { @@ -1435,13 +1457,8 @@ namespace Testrong.User.Program filetime: filetime ); } - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_PATH + SlotNum + ".flag"); //Create file flagging end of current thread - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL"); swdata.Flush(); swdata.Close(); } @@ -1490,13 +1507,7 @@ namespace Testrong.User.Program var isMVUploadOK = extCaliHandle.UploadFile(context.Communicator.ServerIP, RINT_COMPFILE_PATH + context.Communicator.ServerIP + "_MV.csv", FileType.mv); LogRawText($"MV Status: {isMVUploadOK}"); - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(RINT_COMPFILE_PATH + SlotNum + ".flag"); //Create file flagging end of current thread - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "RINT"); } void Pmur_Upload(IFlowRunnerContext context) { @@ -1755,13 +1766,7 @@ namespace Testrong.User.Program Pmur.Close(); #region Thread Lock - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_PATH + SlotNum + ".flag"); //Create file flagging end of current thread - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL"); #endregion } void ExternalCalibrationReset(IFlowRunnerContext context) @@ -1812,13 +1817,7 @@ namespace Testrong.User.Program var isMIUploadOK = extCaliHandle.UploadFile(context.Communicator.ServerIP, EXT_CAL_INIT_PATH + "MI_init.csv", FileType.mi); LogRawText($"MI Status: {isMIUploadOK}"); - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_INIT_PATH + SlotNum + ".flag"); - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL_Init"); } void DmmGetResValue(IFlowRunnerContext context, TestVersion testVersion) { @@ -1923,13 +1922,8 @@ namespace Testrong.User.Program { Thread.Sleep(1); } - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_INIT_PATH + SlotNum + ".flag"); - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL_Init"); } void ExternalCalibrationCollect(IFlowRunnerContext context, TestVersion testVersion, bool isFirstTest, bool isPreCheck) { @@ -2829,13 +2823,7 @@ namespace Testrong.User.Program #endregion #region Thread Lock - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_PATH + SlotNum + ".flag"); //Create file flagging end of current thread - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL"); #endregion dmm.ResetInstrument(); @@ -2893,13 +2881,8 @@ namespace Testrong.User.Program Thread.Sleep(10); var isMIUploadOK = extCaliHandle.UploadFile(context.Communicator.ServerIP, CAL_COMPFILE_PATH + context.Communicator.ServerIP + "_MI.csv", FileType.mi); LogRawText($"MI Status: {isMIUploadOK}"); - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(CAL_COMPFILE_PATH + SlotNum + ".flag"); //Create file flagging end of current thread - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL_COM"); } void Rint_GND_FVMI_2mA(IFlowRunnerContext context) @@ -2956,21 +2939,17 @@ namespace Testrong.User.Program double Vstep = 0.0004; string filepath = "Slot" + SlotNum + "_PMU_" + "ch" + ChannelPmu[loopk] + "_" + "FVMI" + "_" + "Hi-Z" + "_" + "2mA" + ".csv"; string filename = EXT_CAL_PATH + filepath; - StreamWriter sw = new StreamWriter(filename, true, Encoding.UTF8); - sw.AutoFlush = true; - sw.Write("Tester_Name,Foo\n"); - sw.Write($"Slot_No,{SlotNum}\n"); - sw.Write($"Board_Dna,{arm_dna}\n"); - sw.Write("Channel_Type,PMU\n"); - sw.Write($"Channel_No,{ChannelPmu[loopk]}\n"); - sw.Write($"Mode,FVMI\n"); - sw.Write($"R_Load,Hi-Z\n"); - sw.Write($"R_Int,{0}\n"); - sw.Write($"R_Ext,{0}\n"); - sw.Write($"I_Range,2mA\n"); - sw.Write("V_Range,20V\n"); - sw.Write("Meas_Range,13V\n"); - sw.Write("\n"); + int ch = ChannelPmu[loopk]; + double[] AteMeasure = new double[SampliCount]; + double[] ForceValue = new double[SampliCount]; + double[] DMMValue = new double[SampliCount]; + double[] TempValue = new double[SampliCount]; + + StreamWriter sw = new StreamWriter(filename, true, Encoding.UTF8) + { + AutoFlush = true + }; + if (loopk == 0) { DelayHelper.Sleep(20); @@ -3009,6 +2988,23 @@ namespace Testrong.User.Program ForceV += Vstep; } PPMU.Force(PmuPinName, 0, PpmuMode.FVMI, PpmuIRange._2mA, VRange.Normal); + + WriteSingleFile( + filename: filename, + slot: SlotNum, + dna: arm_dna, + type: "PMU", + channel: ch, + mode: "FVMI", + rload: "Hi-Z", + extR: ExtBoard_Res, + range: "2mA", + ForceValue: ForceValue, + AteMeasure: AteMeasure, + DmmMeasure: DMMValue, + TempValue: TempValue + ); + sw.Flush(); sw.Close(); swdata.Write($"{arm_dna},"); @@ -3026,13 +3022,8 @@ namespace Testrong.User.Program swdata.Flush(); swdata.Close(); Thread.Sleep(100); - if (SlotNum < slotList[slotList.Count - 1]) - { - StreamWriter swSignal = new StreamWriter(EXT_CAL_PATH + SlotNum + ".flag"); //Create file flagging end of current thread - swSignal.WriteLine(); - swSignal.Flush(); - swSignal.Close(); - } + + SlotThreadLocker(SlotNum: SlotNum, slotList: slotList, pathFlag: "CAL"); } #endregion