// private void DoDiTask(int id) { if (DiCntMdStp >= 99) { ResStr01 = "Failed"; ProcessView(new ListViewData() { Ch = Ref_IO_Mod.Ch, Step = DiCntMdStp.ToString(), Result = ResStr01 }); FailCnt++; s1.Abort(); DiCntMdStp = 0; mainTaskStp++; } else if (DiCntMdStp > 3 && DiCntMdStp < 99) { ResStr01 = "Passed"; mainTaskStp++; s1.Abort(); Thread.Sleep(50); OutputDO(0); //initail APAX Do out 0 ProcessView(new ListViewData() { Ch = Ref_IO_Mod.Ch, Step = ProcessStep, Result = ResStr01 }); DiCntMdStp = 0; } else if (DiCntMdStp == 3)//判斷Fq val Modbus status >=99 (4x01) 約99/10=9.9hz up { Thread.Sleep(200); MBData01 = ReadFreqVal(di_id_offset + Ref_IO_Mod.Ch).ToString(); ProcessView(new ListViewData() { Ch = Ref_IO_Mod.Ch, Step = DiCntMdStp.ToString(), RowData = "Check Mds equal 10hz , read 4x = " + MBData01 }); //GetDeviceItems(id); //getTxtbox[0].Text = IOitem.Val.ToString(); if (ReadFreqVal(di_id_offset + Ref_IO_Mod.Ch) >= 99) { DiCntMdStp++; } else { DiCntMdStp = 99; } } else if (DiCntMdStp == 2)//Out APAX5070 DO High Low =10hz(delay 40ms) { ProcessView(new ListViewData() { Ch = Ref_IO_Mod.Ch, Step = DiCntMdStp.ToString(), RowData = "Out5070 DO from H to L for 10hz" }); s1 = new Thread(FrqOut); s1.Start(); DiCntMdStp++; } else if (DiCntMdStp == 1)//切換到Fq mode, chk cnt/fq =0 cntotherwise break { GetDeviceItems(id); //md 0=DI, md 1=counter, md 2=L to H ,md 3=H to L, md 4=f IOitem.Md = 4; //Fq mode ADAM6KReqService.UpdateIOConfig(IOitem); if (ReadClrCntVal(di_id_offset + Ref_IO_Mod.Ch)) { DiCntMdStp++; } else { DiCntMdStp = 99; } } else if (DiCntMdStp == 0)//initial, clr cnt value, stop cnt, DO to L { ResStr01 = MBData01 = ""; ClrDiCntVal(); SetDiCntStart(0); //set cnt to Stop //OutData01 = OutputDO(0); //initail APAX Do out 0 OutputDO(0); //initail APAX Do out 0 DiCntMdStp++; } }