void do_End_Flow(clsThreadInfo _ti, System.Diagnostics.Stopwatch _tmr, string vFlowId) { // _flow _flow.lastCase = _flow.currCase; if (_flow.eState == eWF_State.Running) { _flow.eState = eWF_State.End; } _dao_comm_set_arr_str800();// 消息 arr_str[0][800 + _flowNo] // _ti _ti.allowWhile = eSwitch.No; _ti.allowBusiness = eSwitch.No; _ti.cnt_heart = -1; // _tmr _tmr.Stop(); //结束计时 #region // 日志 // _log1 clsLogs _logs = new clsLogs(); _logs.No = _flow.currCase; _logs.Name = _flow.currCase + "_结束 *** "; _flow.RunLog.Add(_logs); // _log 2 FACC.F_Log.Debug_1(this.GetType().Name, String.Format("--- 流程:{0} 结束, 状态:{1} ---", vFlowId, _flow.eState.ToString())); #endregion }
protected override void do_While(string vFlowId) { clsFlow _flow = _faim3.dict_Flow[vFlowId]; int _currAxisNum = 0; string _sndStr = ""; _currCMD = _CMD_Read01; _ref_i = _devNo * _faim3.sect_iDev; // 偏移 _ref_s = _devNo * _faim3.sect_sDev + _faim3.sect_sDev_start; // 偏移 #region // 流程条件 clsThreadInfo _ti = _faim3.dict_Threads[vFlowId].Info; _ti.sleep = Convert.ToInt32(_faim3.dict_DevCards[_devNo].thDelay); _ti.allowBusiness = eSwitch.No; System.Diagnostics.Stopwatch _tmr = do_th_Name_pre(_ti); // 流程条件 _ti.allowWhile = eSwitch.On; //控制流程之1, 若为 false 则会 break流程 #endregion while (((int)_ti.allowWhile == (int)eSwitch.On)) { if (_faim3.isEmergency > 0) { _flow.eState = eWF_State.Emergency; break; } if (!do_allowBusiness(_ti)) { continue; // 流程信息 1 } long _trm_begin = _tmr.ElapsedMilliseconds; // 毫秒 if (_RunState == eRunState.isSend) { _RunState = eRunState.doSend; continue; } // 自动方式 if (string.IsNullOrEmpty(_CMD)) // 根据命令名, 取协议字符串, 填入 arr_str, 写发送长度(触发) { _CMD = _faim3.Comm_Data.arr_str[0][_ref_s]; } if (!string.IsNullOrEmpty(_CMD)) { // 发命令, 要准备命令名 和 轴号 _ti.caseName = _CMD; //_sndStr = _bo_protocol.doProtocol_01(-1, _CMD, _devNo); _faim3.Comm_Data.arr_str[0][_ref_s] = ""; _CMD = ""; } else { if (_currCMD == _CMD_Read02) // 完成一轮 { _currCMD = _CMD_Read01; _currAxisNum++; // 下一轴号 if (_currAxisNum > MaxAxisNum) { _currAxisNum = 0; // 轴号0-15 } } else if (_currCMD == _CMD_Read01) { _currCMD = _CMD_Read02; // } _ti.caseName = _currCMD; } //_sndStr = _bo_protocol.doProtocol_01(_currAxisNum, _currCMD, _devNo);// _faim3.dict_CmdFormats[_currCMD]; _RunState = eRunState.doLoop; System.Threading.Thread.Sleep(1); if (_RunState == eRunState.doLoop) { do_Send(_sndStr); } _RunState = eRunState.Free; do_end_CalcTimer(_ti, _tmr, _trm_begin); // 流程信息2 if (_RunState == eRunState.isSend) { _RunState = eRunState.doSend; continue; } System.Threading.Thread.Sleep(_ti.sleep); } doClearState(_ti); _tmr.Stop(); //结束计时 }
protected override void do_While(string vFlowId) { clsFlow _flow = _faim3.dict_Flow[vFlowId]; _currCMD = _CMD01_Read; _ref_i = _devNo * _faim3.sect_iDev; // 偏移 _ref_s = _devNo * _faim3.sect_sDev + _faim3.sect_sDev_start; // 偏移 #region // 流程条件 clsThreadInfo _ti = _faim3.dict_Threads[vFlowId].Info; _ti.sleep = Convert.ToInt32(_faim3.dict_DevCards[_devNo].thDelay); //[10]); _ti.allowBusiness = eSwitch.No; System.Diagnostics.Stopwatch _tmr = do_th_Name_pre(_ti); // 流程条件 _ti.allowWhile = eSwitch.On; //控制流程之1, 若为 false 则会 break流程 #endregion while (((int)_ti.allowWhile == (int)eSwitch.On)) { if (_faim3.isEmergency > 0) { _flow.eState = eWF_State.Emergency; break; } if (!do_allowBusiness(_ti)) { continue; // 流程信息 1 } long _trm_begin = _tmr.ElapsedMilliseconds; // 毫秒 if (_RunState == eRunState.isSend) { _RunState = eRunState.doSend; continue; } #region // 自动方式, 发其它指令 if (_faim3.Comm_Data.bt_out[0][_ref_i + 64] > 0) // 根据命令名, 取协议 { /* * _LLine = _faim3.Comm_Data.bt_out[0][_ref_i + _faim3.dict_KV["LLine"]] * _Value = _faim3.Comm_Data.bt_out[0][_ref_i + _LLine) '从大数据取出数据 */ _ti.caseName = "Send"; //_ret = DO_WriteLine(_CardNumber, _Port, _LLine, _Value) _device.Send(); _faim3.Comm_Data.bt_out[0][_ref_i + 64] = 0; } #endregion else { _RunState = eRunState.doLoop; System.Threading.Thread.Sleep(1); if (_RunState == eRunState.doLoop) { _ti.caseName = _CMD01_Read; // _ret = DI_ReadPort(_CardNumber, _Port, _Value) _device._cmdName = _CMD02_Read; // 循环 _device.Send_Receive(); } _RunState = eRunState.Free; } // 接收后处理 do_end_CalcTimer(_ti, _tmr, _trm_begin); // 流程信息2 if (_RunState == eRunState.isSend) { _RunState = eRunState.doSend; continue; } System.Threading.Thread.Sleep(_ti.sleep); } doClearState(_ti); _tmr.Stop(); //结束计时 }
protected override void do_While(string vFlowId) { //int _loc = 0; _bl = true; #region // _flow 初始化 _flow.currCase = _flow.firstCase; // 恢复 第1步 _flow.alartCase = _flow.firstCase; // 恢复 //if (_faim3.dict_CaseState.ContainsKey(_flow.alartCase)) //{ clsCaseState _caseState = _faim3.dict_CaseState[_flow.alartCase]; _caseState.beginMode = eCaseFlag.Next; _caseState.endMode = eCaseFlag.Next; //} _flow.nextCase = _flow.firstCase; _flow.lastCase = "Free"; _flow.stepCase = "Free"; // 初始化单步的步骤名 _flow.breakSkipCase = ""; // 断点无效的步骤名 _flow.times += 1; // 累加, 显示流程 启动的次数 _flow.Tag = ""; _flow.NGtimes = 0; #endregion #region // 日志 1 2 F_Log.Debug_1(this.GetType().Name, String.Format("*** 流程开始:{0}.{1}, 状态:{2}, 计数:{3} ***", vFlowId, _flow.currCase, _flow.eState.ToString(), _flow.times)); // 日志 2 clsLogs _logs2 = new clsLogs(); _logs2.No = _flow.currCase; _logs2.Name = "*** " + _flow.currCase + " _开始"; _flow.RunLog.Add(_logs2); // 累加, 内存日志 #endregion #region // 流程条件 clsThreadInfo _ti = _faim3.dict_Threads[vFlowId].Info; _ti.allowWhile = eSwitch.Yes; //控制流程之1, 线程终止 false _ti.allowBusiness = eSwitch.No; // 控制流程之2 业务等待/暂停 System.Diagnostics.Stopwatch _tmr = do_th_Name_pre(_ti); // 计时 #endregion _faim3.dict_Threads[_flowName].Info.tmr_real = 0; // 当前步骤 实际占用总时长 #region // while while (((int)_ti.allowWhile == (int)eSwitch.Yes)) // 允许线程运行 1 { #region // break // 急停 if (_faim3.isEmergency > 0) { _flow.eState = eWF_State.Emergency; _ti.allowWhile = eSwitch.No; _ti.allowBusiness = eSwitch.No; break; } // 最后一步 if (_flow.nextCase.ToUpper() == "FREE") { break;// 结束流程 } #endregion #region // continue // 暂停 if (!do_allowBusiness(_ti)) //_flow.eState = eWF_State.Wait; { continue; // 线程延时+ 业务是否允许 流程信息 2 } if (do_NG_hasTimes()) { continue; //_flow.currCase } #endregion // 显示执行后的 curr //_dao_comm_set_arr_str800(); //string _caseName_old = _flow.currCase; clsCaseState _caseState_old = _faim3.dict_CaseState[_flow.alartCase]; _flow.currCase = _flow.nextCase; // 准备执行下一步, 即将下一步设为当前步骤 if (_flow.currCase.EndsWith(F_Const.fix_CaseT)) // “_T”, 测试步骤 { } else { _flow.alartCase = _flow.currCase; // 非测试步骤 clsCaseState _caseState_new = _faim3.dict_CaseState[_flow.alartCase]; if (_caseState_new.beginMode == eCaseFlag.Free) { _caseState_new.beginMode = _caseState_old.endMode; } //if (_caseName_old.EndsWith(F_Const.fix_CaseT)) // “_T”, 测试步骤 // _caseState_new.beginMode = eCaseFlag.TT; //else } //_dao_comm_set_arr_str800(); // 指定预执行的 curr do_WaitBreak(); do_WaitStep(); _flow.caseTimes++; // 累加, 显示步骤 通过的次数 // 状态为运行中 _flow.eState = eWF_State.Running; long _trm_begin = _tmr.ElapsedMilliseconds; // 毫秒 _ti.caseName = _flow.currCase; if (_dao_comm.dict_Methods.doCase.ContainsKey(_flow.currCase)) // 条件:Case名存在,XX() 或 XX_T() { if (!_flow.currCase.EndsWith(F_Const.fix_CaseT)) // 条件:无“_T”, 则新步骤开始, 先找到该配置文档的行号 { _ti.cnt_business++; // Case完成数 // 发消息, 上一步骤信息和本步骤位置 doGet_CmdLineStart(_flow.currCase, ref _faim3); // 预处理 分解Case的各语法结构 } #region // 流程代码 代理1 Switch & Select Case F_Delegate.delCase _delCase = _dao_comm.dict_Methods.doCase[_flow.currCase]; //通过代理, 从步骤集中取出一个步骤, 执行其方法() _delCase(_dao_comm, _flow.FlowName); // 执行步骤 do_end_CalcTimer(_ti, _tmr, _trm_begin); // 流程信息2 #endregion if (_flow.Delay > -1) { System.Threading.Thread.Sleep(_flow.Delay); } } else // 结束 flow { _ti.allowWhile = eSwitch.Off; // 控制流程之2 , 步骤名不存在 无方法 _flow.eState = eWF_State.End; FACC.F_Log.Debug_1(this.GetType().Name, String.Format("--->>>> 无 步骤 :{0}.{1}->{2} - 状态:{3}, 计数:{4} ", vFlowId, _flow.lastCase, _flow.currCase, _flow.eState.ToString(), _flow.times)); } } #endregion do_End_Flow(_ti, _tmr, vFlowId); }
protected override void do_While(string vFlowId) { clsFlow _flow = _faim3.dict_Flow[vFlowId]; int _currAxisIdx = 0; // 当前轴下标号 _ref_i = _faim3.sect_iDev * _devNo; // 偏移 _ref_s = _faim3.sect_sDev * _devNo + _faim3.sect_sDev_start; // 偏移 _currCMD = _CMD01_Read_status; string _sndStr = ""; #region // 流程条件 clsThreadInfo _ti = _faim3.dict_Threads[vFlowId].Info; _ti.sleep = _faim3.dict_DevCards[_devNo].thDelay; // [10] _ti.allowBusiness = eSwitch.No; System.Diagnostics.Stopwatch _tmr = do_th_Name_pre(_ti); // 流程条件 _ti.allowWhile = eSwitch.On; //控制流程之1, 若为 false 则会 break流程 #endregion while (((int)_ti.allowWhile == (int)eSwitch.On)) { if (_faim3.isEmergency > 0) { _flow.eState = eWF_State.Emergency; break; } if (!do_allowBusiness(_ti)) { continue; // 流程信息 1 } long _trm_begin = _tmr.ElapsedMilliseconds; // 毫秒 if (_RunState == eRunState.isSend) { _RunState = eRunState.doSend; continue; } #region // 自动方式, 发其它指令 if (string.IsNullOrEmpty(_CMD)) // 根据命令名, 取协议字符串, 填入 arr_str, 写发送长度(触发) { _sndStr = _faim3.Comm_Data.arr_str[0][_ref_s]; // XX XX XX XX XX } if (!string.IsNullOrEmpty(_CMD)) { _ti.caseName = _CMD; _faim3.Comm_Data.arr_str[0][_ref_s] = ""; _CMD = ""; } #endregion else { #region // 交替,2 个命令和轴号 if (_currCMD == _CMD02_Read_input) // 完成一轮 { _currCMD = _CMD01_Read_status; _currAxisIdx++; // 下一轴号 if (_currAxisIdx >= _lstAxisId.Count) { _currAxisIdx = 0; // 轴号 } } else if (_currCMD == _CMD01_Read_status) { _currCMD = _CMD02_Read_input; // } #endregion _ti.caseName = _currCMD; clsProtocol._204C(_faim3, _dao_comm, _currCMD, _lstAxisId[_currAxisIdx].ToString(), _devNo); } _RunState = eRunState.doLoop; System.Threading.Thread.Sleep(1); if (_RunState == eRunState.doLoop) { } _RunState = eRunState.Free; do_end_CalcTimer(_ti, _tmr, _trm_begin); // 流程信息2 if (_RunState == eRunState.isSend) { _RunState = eRunState.doSend; continue; } System.Threading.Thread.Sleep(_ti.sleep); } doClearState(_ti); _tmr.Stop(); //结束计时 }