Exemplo n.º 1
0
        static string _dao_comm_set_msg(clsFaim3 _faim3, string _flowName, int caseLineIdx, ref int _loc)
        {
            string         _msg       = "";
            clsFlow        _flow      = _faim3.dict_Flow[_flowName];
            clsCaseState   _caseState = _faim3.dict_CaseState[_flow.alartCase];
            clsDevTestBits _line      = _faim3.lst_DevTestBits[caseLineIdx];

            foreach (var item in _faim3.dict_Flow)
            {
                if (item.Key == _flowName)// 流程名 转 流程号
                {
                    // 0当前步骤, 1流程名, 1流程状态/步骤, 3行号, 4命令语句:5变量名=6值 7.转入模式 8.转出模式
                    _msg = string.Format("{0} {1} {2} {3} {4}{5} {6} {7} {8} {9}",
                                         _flow.currCase,
                                         _flowName,
                                         _flow.eState.ToString(),
                                         caseLineIdx,
                                         _line.isDebug == 1 ? "#" : ".",
                                         _line.IfType,
                                         _line.vName,
                                         _line.HL,
                                         _caseState.beginMode,
                                         _caseState.endMode
                                         );
                    break;
                }
                _loc++;
            }
            return(_msg);
        }
Exemplo n.º 2
0
        bool doPartA(clsFaim3 v_faim3, DAL_CommData v_dao_comm, string vflowName)
        {
            string  _cls_Name = "DAL_PartA";
            clsLogs _logs     = new clsLogs();
            clsFlow _flow     = v_faim3.dict_Flow[vflowName];
            string  _currCase = _flow.nextCase;

            F_Log.Debug_1(_cls_Name, String.Format("流程:{0}: 步骤:{1}",
                                                   vflowName, _currCase));
            _flow.alartCase = _currCase;
            if (!v_faim3.dict_CaseState.ContainsKey(_currCase))
            {
                //'A: 步骤.txt 文件中没有注册该步骤参数
                _logs.No   = v_faim3.dict_CaseState[_currCase].No;
                _logs.Name = (_currCase + "_没注册 步骤");
                _flow.RunLog.Add(_logs);
                F_Log.Debug_1(_cls_Name, string.Format("--->>>> 没注册 流程:{0}: 步骤:{1}", vflowName, _currCase));
                return(true);
            }
            clsCaseState _en_State = v_faim3.dict_CaseState[_currCase];

            if ((_en_State.Times > 0))                                                            // 逻辑模型: 执行次数至少有一次, 如 <1, 则不执行AR(),  只执行判断, 以实现流程在等待联动消息的逻辑
            {
                F_Delegate.delCasePartA_R _doPartA = _dao_comm.dict_Methods.doPartA_R[_currCase]; // 通过代理, 从步骤集中取出一个步骤, 执行其方法()
                //
                _logs.No   = v_faim3.dict_CaseState[_currCase].No;
                _logs.Name = _currCase;
                _flow.RunLog.Add(_logs);
                _doPartA(v_faim3, v_dao_comm);
                // AR
                // Delay
                if ((_en_State.Delay > -1))//
                {
                    Thread.Sleep(_en_State.Delay);
                }
                //
            }
            if (string.IsNullOrEmpty(_en_State.No))//逻辑模型:  无BT报警号 检测的步骤, 只执行 AR(), 不执行AR(), 实现两个 AR() 串联(直通)的逻辑
            {
                doGet_NextCase(_faim3, ref _flow, _currCase);
            }
            else
            {
                // 逻辑模型:  无BT报警号 无报警延时, 只执行 AR(), 不执行AR(), 实现两个 AR() 串联(直通)的逻辑
                string _testCase = (_currCase + F_Const.fix_CaseT);
                if (_flow.nextCase == _flow.currCase)
                {
                    _flow.alartCase = _currCase;
                    _flow.nextCase  = _testCase; // ==> Test  当前流程名 + _T
                    F_Log.Debug_1(_cls_Name, String.Format("取到 测试步骤名:{0}", _flow.nextCase));
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        //protected void btOUT(int vDevNo, int vBit)
        //{
        //    doSend(_faim3, vDevNo, vBit, (eHL)(vBit > 0 ? 1 : 0), _sect_iDev);
        //}
        //'计划中取下一流程名, 用于一步延时后进行下一步
        //'直接以值正(1)/负(0)决定输出1/0  _do2_AR(_devNo, 6, eSwitch.On)
        //protected void doSend(int vDevNo, int vBit, eHL val)
        //{
        //    btOUT(_faim3, vDevNo, vBit, val, _sect_iDev);
        //}
        //'直接以位置正(1)/负(0)决定输出1/0  _do2_AR(_devNo, -6)
        public static void doGet_NextCase(clsFaim3 _faim3, ref clsFlow _flow, string vCaseName)
        {
            string _alartCase = _flow.alartCase;
            //if (_faim3.dict_CaseState.ContainsKey(_alartCase)) return;  //
            clsCaseState _caseState = _faim3.dict_CaseState[_alartCase];

            if (_flow.dictCases.ContainsKey(vCaseName))
            {
                _caseState.endMode = eCaseFlag.Next;
                _flow.nextCase     = _flow.dictCases[vCaseName].nextCase;
            }
            else// '流程结束
            {
                F_Log.Debug_1("DAL_Part", String.Format("--->>>> {0} 没有指定下一个步骤名", vCaseName));
                _caseState.endMode = eCaseFlag.Exist;
                _flow.nextCase     = "Free";
            }
        }
Exemplo n.º 4
0
        static void _dao_comm_set_arr_str800(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, int caseLineIdx)
        {
            int     _loc  = 0;
            string  _msg  = "";
            clsFlow _flow = _faim3.dict_Flow[_flowName];

            if (!_flow.isStepLine)
            {
                return;                    // 是“行步进”调试
            }
            clsCaseState _caseState = _faim3.dict_CaseState[_flow.alartCase];

            _msg = _dao_comm_set_msg(_faim3, _flowName, caseLineIdx, ref _loc);
            if (!string.IsNullOrEmpty(_msg))
            {
                _dao_comm.set_arr_str(_loc + 800, _msg);
            }
        }
Exemplo n.º 5
0
        static void __NG(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, string _caseName)
        {
            if (_flowName == "DAL_Buttons")
            {
                return;
            }
            clsFlow _flow      = _faim3.dict_Flow[_flowName];
            string  _alartCase = _flow.alartCase;
            //if (!_faim3.dict_CaseState.ContainsKey(_alartCase)) return;  //
            clsCaseState _caseState = _faim3.dict_CaseState[_alartCase];
            Dictionary <string, clsCaseChildInfo> _dictCaseChildInfo = _caseState.dict_CaseChildInfo;

            if (!_dictCaseChildInfo.ContainsKey(_NG_D))
            {
                return; // 指定步骤无此部份指令
            }
            int _lineStart = _dictCaseChildInfo[_NG_D].lineStart;

            if (_lineStart < 0)
            {
                return;                  // 条件:没有指定的结构块起始行号
            }
            _do_WaitLine(_faim3, _dao_comm, _flowName, eWF_State.JMP, _lineStart);
            if (_faim3.isEmergency > 0)
            {
                return;
            }
            #region // 开始执行

            clsDevTestBits _line = _faim3.lst_DevTestBits[_lineStart];
            if (_line.isDebug == 1)                   /*#*/
            {
                if (_faim3.dict_KV["isDebug"] != "1") // 非 debug 状态下,不运行 debug 行  cfgDev_Cards.xls
                {
                    return;
                }
            }
            //string _line_vName = _line.vName;
            if (_flow.dictCases.ContainsKey(_line.vName) ||
                _line.vName.ToUpper().Trim() == "NEXT" ||
                _line.vName.ToUpper().Trim() == "NEXTCASE") // 5. 转向目标正确
            {
                _flow.Tag = "GOTO_NG";                      //  设NG跳转标志
                if (_flow.NGtimes == 0)                     // 首次,初始设次数
                {
                    _flow.NGtimes = Convert.ToInt32(string.IsNullOrEmpty(_line.HL) ? "1" : _line.HL);
                }

                if (_flow.NGtimes < 2) // 到NG次数, 则转向
                {
                    _flow.NGtimes      = 0;
                    _caseState.endMode = eCaseFlag.NG;
                    if (_line.vName.ToUpper().Trim() == "NEXT" ||
                        _line.vName.ToUpper().Trim() == "NEXTCASE")            // 转向下一步骤 NestCase 的第一行号
                    {
                        _flow.nextCase = _flow.dictCases[_alartCase].nextCase; // 设跳转步骤名
                    }
                    else
                    {
                        _flow.nextCase = _line.vName;
                    }
                }
                else
                {
                    _flow.NGtimes--;
                }
            }
            else// '流程结束
            {
                F_Log.Debug_1("NG", String.Format("--->>>> {0} NG指定之步骤名不存在", _line.vName));
                _caseState.endMode = eCaseFlag.Exist;
                _flow.nextCase     = "Free";
            }
            #endregion
            _line.times++;   // 此行使用的次数
        }
Exemplo n.º 6
0
        void doPartB(clsFaim3 v_faim3, DAL_CommData v_dao_comm, string vflowName)
        {
            string       _cls_Name  = "DAL_PartB";
            clsFlow      _flow      = v_faim3.dict_Flow[vflowName];
            string       _alartCase = _flow.alartCase;//取流程名, 无后缀
            clsCaseState _caseState = _faim3.dict_CaseState[_alartCase];
            clsCaseAlarm _enAlarm   = v_faim3.dict_CaseAlarm[_alartCase];

            _enAlarm.OnAlarm += new FaimDelegate.delAlarm(_enAlarm_OnAlarm);
            //
            if ((_enAlarm.maxDelay1 == -1))//逻辑模型 maxDelay1 = -1  不进行测试
            {
                doGet_NextCase(_faim3, ref _flow, _alartCase);
                FACC.F_Log.Debug_1(_clsName, string.Format("逻辑模型 maxDelay1 = -1  不进行测试:{0}", _alartCase));
                return;
            }
            // 带后缀的 方法 名, 只在 dict_Methods.doCase 中

            F_Delegate.delCasePartB_T _doPartB_T = _dao_comm.dict_Methods.doPartB_T[_alartCase];
            bool _bl_BT = true;

            _bl_BT = (_bl_BT & _doPartB_T(v_faim3, v_dao_comm));     // 测试 TEST
            if ((_flow.Tag == "GOTO_ABS" || _flow.Tag == "GOTO_NG")) //
            {
                _flow.Tag      = "";
                _flow.stepCase = _flow.currCase;
                return;
            }
            else if ((_flow.Tag == "GOTO_OTHER"))//
            {
                _flow.Tag = "";
                List <string> _otherCase = _flow.dictCases[_alartCase].otherCase;
                if (_otherCase.Contains(_alartCase))// 若 自定义列表包括了当前步骤名, 如何处理???
                {
                    return;
                }
            }
            else if ((_flow.Tag == "ALAR_ON_NG"))
            {
                _flow.Tag         = "";
                _enAlarm.AlarmDrv = eSwitch.On;
                _enAlarm.AlarmIs  = true;  // OnAlarm(this);
                //
                return;
            }
            else if ((_flow.Tag == "ALAR_OFF_NG"))//
            {
                _flow.Tag         = "";
                _enAlarm.AlarmDrv = eSwitch.Off;
                //
                _enAlarm.AlarmIs = false;   // OnAlarm(this);
                return;
            }
            //
            if ((_bl_BT && !_enAlarm.AlarmIs))//
            {
                //
                _caseState.Result = "";
                _enAlarm.DelayT1  = 0;
                _enAlarm.DelayT2  = 0;
                _flow.NGtimes     = 0;
                doGet_NextCase(_faim3, ref _flow, _alartCase);
                F_Log.Debug_1(_cls_Name, (_alartCase + " BT(1)"));
            }
            else
            {
                //
                if (!_enAlarm.AlarmIs)// 没报警
                {
                    //
                    _enAlarm.DelayT1++;
                    if (_enAlarm.DelayT1 > _enAlarm.maxDelay1)//  第一圈
                    {
                        _enAlarm.DelayT1 = 0;
                        _enAlarm.DelayT2++;
                        if (_enAlarm.DelayT2 > _enAlarm.maxDelay2)// 第二圈 时间到
                        {
                            _enAlarm.DelayT2 = 0;
                            if (_enAlarm.maxDelay2 == 0)//
                            {
                                if (_flow.dictCases.ContainsKey(_alartCase))
                                {
                                    _caseState.endMode = eCaseFlag.NG;
                                    _flow.nextCase     = v_faim3.dict_CaseAlarm[_alartCase].excpCase;
                                }
                                else
                                {
                                    F_Log.Debug_1(_cls_Name, string.Format("--->>>> {0} 没有指定下一个方法名", _alartCase));
                                    _caseState.endMode = eCaseFlag.Exist;
                                    _flow.nextCase     = "Free";//流程结束
                                }
                                return;
                            }
                            else if (_enAlarm.maxDelay2 > 0)
                            {
                                _enAlarm.AlarmIs  = true;
                                _enAlarm.AlarmDrv = eSwitch.On;// 报警灯亮
                                //
                            }
                        }
                    }
                }
                else if (_enAlarm.AlarmIs)//
                {
                    //
                    if (!string.IsNullOrEmpty(_enAlarm.dlgMessage))//
                    {
                        string _title = (_enAlarm.RemarkA + ",请确认忽略异常!");
                        if ((_enAlarm.dlgMessage.Length > 6))
                        {
                            _title = _enAlarm.dlgMessage;
                        }
                        //
                        DialogResult _dlg = MessageBox.Show(_enAlarm.dlgMessage, "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                        if ((_dlg == DialogResult.OK))//逻辑模型:  人工出口, 有报警 忽略异常
                        {
                            //
                            F_Delegate.delCasePartB_R _doPart_BR = v_dao_comm.dict_Methods.doPartB_R[_alartCase];
                            //  测试 RUN
                            _doPart_BR(v_faim3, v_dao_comm);
                            //
                            System.Threading.Thread.Sleep(_enAlarm.DelayB);
                            if (_flow.dictCases.ContainsKey(_alartCase))
                            {
                                _caseState.endMode = eCaseFlag.NG;
                                _flow.nextCase     = v_faim3.dict_CaseAlarm[_alartCase].excpCase;
                            }
                            else
                            {
                                F_Log.Debug_1(_cls_Name, string.Format("--->>>> {0} 没有指定下一个方法名", _alartCase));
                                _caseState.endMode = eCaseFlag.Exist;
                                _flow.nextCase     = "Free";//流程结束
                            }
                            _enAlarm.AlarmIs  = false;
                            _enAlarm.AlarmDrv = eSwitch.Off;//报警灯灭
                        }
                    }
                    else if (_bl_BT)//逻辑模型:  成功出口, 有报警
                    {
                        _caseState.Result = "";
                        _enAlarm.DelayT1  = 0;
                        _enAlarm.DelayT2  = 0;
                        _flow.NGtimes     = 0;
                        _enAlarm.AlarmIs  = false;
                        _enAlarm.AlarmDrv = eSwitch.Off;//报警灯灭
                        doGet_NextCase(_faim3, ref _flow, _alartCase);
                        F_Log.Debug_1(_cls_Name, (_alartCase + " BT(2)"));
                    }
                }
            }
            return;
        }
Exemplo n.º 7
0
        // _PART_CMD("PARTA")  "PARTC"
        static void _PART_CMD(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, string _caseName, string PartName)
        {
            #region                                    // 条件
            clsFlow      _flow      = _faim3.dict_Flow[_flowName];
            string       _alartCase = _flow.alartCase; // _caseName 可能后带有 _T 标记
            clsCaseState _caseState = _faim3.dict_CaseState[_alartCase];
            Dictionary <string, clsCaseChildInfo> _dictCaseChildInfo =
                _caseState.dict_CaseChildInfo;
            if (!_dictCaseChildInfo.ContainsKey(PartName))
            {
                return; // 条件:指定步骤无此部份指令
            }
            int _lineStart = _dictCaseChildInfo[PartName].lineStart;
            if (_lineStart < 0)
            {
                return;                  // 条件:没有指定的结构块起始行号
            }
            int _lineEnd = _dictCaseChildInfo[PartName].lineEnd;
            if (_lineEnd < 0)   // 只有一行时
            {
                _lineEnd = _lineStart;
            }
            #endregion

            // "DIM.GOTO.ADD.DEC.INC.OUT.OUT_A.OUT_T.OUT_AOK.OUT_TOK"
            for (int i = _lineStart; i <= _lineEnd; i++) // 文档对象驱动
            {
                #region                                  // for
                if (_faim3.isEmergency > 0)
                {
                    break; // 急停
                }
                #region    // 忽略 CODE isDebug #
                clsDevTestBits _line = _faim3.lst_DevTestBits[i];
                if (_line.Remark.ToUpper().StartsWith("CODE"))
                {
                    continue;                                             //条件:文档行指定为以代码实现
                }
                if (F_CaseSub._CMD_NULL.Contains(_line.IfType.ToUpper())) // 占位行
                {
                    continue;
                }

                if (_line.isDebug == 1) /*#*/             // cfgDev_testBits #
                {
                    if (_faim3.dict_KV["isDebug"] != "1") // 非 debug 状态下,不运行 debug 行  cfgDev_Cards.xls
                    {
                        continue;
                    }
                }
                #endregion

                #region // 暂停别
                eWF_State _state = eWF_State.Free;
                #region // 可置于 vName 列的指令
                string _IfType = _line.vName.ToUpper();
                switch (_IfType)
                {
                case "SLEEP":
                case "DELAY":
                case "WAIT":                                               // WAIT 2
                case "TIMW":                                               // WAIT 2
                    _state = eWF_State.Sleep;
                    _do_WaitLine(_faim3, _dao_comm, _flowName, _state, i); //
                    break;

                case "GOTO":
                case "JMP":
                case "NEXT":
                case "NEXTCASE":
                    _state = eWF_State.JMP;
                    _do_WaitLine(_faim3, _dao_comm, _flowName, _state, i);     //
                    break;
                }
                #endregion
                #region                       // 可置于 IfType 列的指令
                if (_state == eWF_State.Free) //
                {
                    _IfType = _line.IfType.ToUpper();
                    switch (_IfType)    // IfType
                    {
                    case "SLEEP":
                    case "DELAY":
                    case "TIMW":                                               // WAIT 1
                        _state = eWF_State.Sleep;
                        _do_WaitLine(_faim3, _dao_comm, _flowName, _state, i); //
                        break;

                    case "GOTO":
                    case "JMP":
                    case "NEXT":
                    case "NEXTCASE":
                        _state = eWF_State.JMP;
                        _do_WaitLine(_faim3, _dao_comm, _flowName, _state, i);     //
                        break;

                    case "ADD":
                    case "SUB":
                    case "INC":
                    case "DEC":
                        _state = eWF_State.Math;
                        _do_WaitLine(_faim3, _dao_comm, _flowName, _state, i);     //
                        break;

                    case "OUT":
                    case "SEND":
                    case "MBUS":
                    case "CONN":
                        _state = eWF_State.Send;
                        _do_WaitLine(_faim3, _dao_comm, _flowName, _state, i);     //
                        break;

                    default:                                                           // 其它
                        _do_WaitLine(_faim3, _dao_comm, _flowName, eWF_State.Line, i); //
                        break;
                    }
                }
                #endregion
                #endregion

                if (_faim3.isEmergency > 0)
                {
                    break;                                                              // 急停
                }
                #region                                                                 // 开始执行
                System.Diagnostics.Stopwatch _tmr = new System.Diagnostics.Stopwatch(); //实例化一个计时器
                _tmr.Start();
                long _trm_begin = _tmr.ElapsedMilliseconds;                             // 毫秒


                #region                                                              // TITL TBNO
                string _str_1 = "  ";                                                // 值 vName
                string _str_2 = "  ";                                                // 值 HL

                int _val_1 = 0;                                                      // 值: vName
                int _val_2 = F_TransCalc._Get_Value_2(_faim3, _line.HL, ref _str_2); // 值: HL
                int _val_3 = 0;                                                      // 值: Reset
                int _bit   = -1;                                                     // 位
                if ("TITL" == _line.IfType.ToUpper() ||                              // 流程步骤名
                    "TITLE" == _line.IfType.ToUpper())
                {
                    _caseState.Remark = _line.vName.Trim();
                    //continue;
                }
                else if ("TBNO" == _line.IfType.ToUpper())  // 设置当前使用的表号
                {
                    _flow.tableNo = Convert.ToInt32(_line.vName.Trim());
                    //continue;
                }
                #endregion

                #region                                       // SLEEP DELAY TIMW WAIT
                else if ("SLEEP" == _line.IfType.ToUpper() || // IfType
                         "DELAY" == _line.IfType.ToUpper() ||
                         "TIMW" == _line.IfType.ToUpper() ||
                         "WAIT" == _line.IfType.ToUpper() ||
                         "SLEEP" == _line.vName.ToUpper() ||        // vName
                         "DELAY" == _line.vName.ToUpper() ||
                         "TIMW" == _line.vName.ToUpper() ||
                         "WAIT" == _line.vName.ToUpper())
                {
                    System.Threading.Thread.Sleep(_val_2);
                }
                #endregion

                #region                                                           // 设备 _204C: A_ST A_IO LOAD HOME STOP EMG MOVA MOVR MOVL MOVI ARCR ARCA STAT INPUT
                else if (clsProtocol.doExistCmd_204(_line.IfType.ToUpper()) > -1) // 指令
                {
                    int _devNo = -1;                                              //设备号
                    if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                    {
                        clsDevFunction _df = _faim3.dict_DevFunction[_line.vName]; //
                        _devNo = _df.devNo;                                        //设备号
                    }
                    else
                    {
                        _devNo = clsProtocol.do_GetDevNo(_faim3, _line.vName);
                    }
                    if (_devNo > -1)  // Send
                    {
                        clsProtocol._204C(_faim3, _dao_comm, _line.IfType, _line.HL, _devNo);
                    }
                }
                #endregion

                #region // ADD SUB INC DEC
                else if ("ADD" == _line.IfType.ToUpper() || "ADD" == _line.vName.ToUpper())
                {
                    _do_math(_faim3, _line, _val_2);
                }
                else if ("SUB" == _line.IfType.ToUpper() || "SUB" == _line.vName.ToUpper())
                {
                    _do_math(_faim3, _line, -_val_2);
                }
                else if ("INC" == _line.IfType.ToUpper() || "INC" == _line.vName.ToUpper())
                {
                    _do_math(_faim3, _line, 1);
                }
                else if ("DEC" == _line.IfType.ToUpper() || "DEC" == _line.vName.ToUpper())
                {
                    _do_math(_faim3, _line, -1);
                }
                #endregion

                #region                                                     // CONN
                else if (_line.IfType.ToUpper().StartsWith("CONN"))         // 设备连接
                {
                    _val_1 = F_TransCalc._Get_Value_2(_faim3, _line.vName); // 值: vName
                    int _ref_i_len = _faim3.sect_iDev * _val_1 + _faim3.snd_iLen;
                    // out
                    _faim3.Comm_Data.bt_out[0][_ref_i_len] = -99; //
                    if (_val_2 > 0)
                    {
                        _dao_comm.set_bt_out(_ref_i_len, (int)eSwitch.Connect);     // bt_out[164]=-100
                    }
                    else
                    {
                        _dao_comm.set_bt_out(_ref_i_len, (int)eSwitch.Disconnect);  // bt_out[164]=-200
                    }
                }
                #endregion

                #region //  BTOF BTON TEXT TBSE LET  DIM
                else if (_line.IfType.ToUpper().StartsWith("BTOF"))
                {
                    #region // dict_DevFunction
                    if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                    {
                        // '0devNo      1driverName     2Remark         3ioIdx      4Off|On     5varName    6Index          registerId	Enabled	9CardName
                        clsDevFunction _df = _faim3.dict_DevFunction[_line.vName]; //
                        _bit = _faim3.sect_iDev * _df.devNo + _df.Index;           //内存位

                        if (_df.varName.ToUpper() == "BT_OUT")
                        {
                            if (_faim3.Comm_Data.bt_out[0][_bit] >= (int)Math.Pow(2, _val_2))
                            {
                                _faim3.Comm_Data.bt_out[0][_bit] = _faim3.Comm_Data.bt_out[0][_bit] & ~(int)Math.Pow(2, _val_2);//输出电位
                            }
                        }
                        else if (_df.varName.ToUpper() == "BT_IN")
                        {
                            if (_faim3.Comm_Data.bt_in[0][_bit] >= (int)Math.Pow(2, _val_2))
                            {
                                _faim3.Comm_Data.bt_in[0][_bit] = _faim3.Comm_Data.bt_in[0][_bit] & ~(int)Math.Pow(2, _val_2);//输出电位
                            }
                        }
                    }
                    #endregion
                }
                else if (_line.IfType.ToUpper().StartsWith("BTON"))
                {
                    #region // dict_DevFunction
                    if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                    {
                        clsDevFunction _df = _faim3.dict_DevFunction[_line.vName];                                          //
                        _bit = _faim3.sect_iDev * _df.devNo + _df.Index;                                                    //内存位
                        if (_df.varName.ToUpper() == "BT_OUT")                                                              // 5 varName
                        {
                            _faim3.Comm_Data.bt_out[0][_bit] = _faim3.Comm_Data.bt_out[0][_bit] | (int)Math.Pow(2, _val_2); //输出电位
                        }
                    }
                    else if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                    {
                        clsDevFunction _df = _faim3.dict_DevFunction[_line.vName];                                        //
                        _bit = _faim3.sect_iDev * _df.devNo + _df.Index;                                                  //内存位
                        if (_df.varName.ToUpper() == "BT_IN")                                                             // 5 varName
                        {
                            _faim3.Comm_Data.bt_in[0][_bit] = _faim3.Comm_Data.bt_in[0][_bit] | (int)Math.Pow(2, _val_2); //输出电位
                        }
                    }
                    #endregion
                }
                else if (_line.IfType.ToUpper().StartsWith("TEXT"))         // 全局字符串变量赋值
                {
                    _val_1 = F_TransCalc._Get_Value_2(_faim3, _line.vName); // 行号 键

                    if (_faim3.ui_buffer.Count > _val_1)
                    {
                        _faim3.ui_buffer[_val_1] = _str_2;
                    }
                }
                else if (_line.IfType.ToUpper().StartsWith("DIM"))
                {
                    #region // dict_DevFunction  BT_OUT BT_IN MODBUS ARR_INT_REG
                    if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                    {
                        clsDevFunction _df    = _faim3.dict_DevFunction[_line.vName]; //
                        int            _devNo = _df.devNo;                            //设备号
                        int            _ref_i = _faim3.sect_iDev * _devNo;
                        _bit = _ref_i + _df.Index;                                    //内存位
                        if (_df.varName.ToUpper() == "BT_OUT")
                        {
                            _faim3.Comm_Data.bt_out[0][_bit] = _val_2;//
                        }
                        else if (_df.varName.ToUpper() == "BT_IN" || _df.varName.ToUpper() == "MODBUS")
                        {
                            _faim3.Comm_Data.bt_in[0][_bit] = _val_2;//
                        }
                        else if (_df.varName.ToUpper() == "ARR_INT")
                        {
                            _faim3.Comm_Data.arr_int[_bit] = _val_2;//
                        }
                        else if (_df.varName.ToUpper() == "ARR_INT_REG")
                        {
                            _faim3.Comm_Data.arr_int_reg[_bit] = _val_2;//
                        }
                        else if (_df.varName.ToUpper() == "ARR_STR")
                        {
                            _faim3.Comm_Data.arr_str[0][_bit] = _str_2;//
                        }
                    }
                    #endregion
                    #region // _dim_dict 动态变量 dim[Feeder05_unLink] <== Value
                    else if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        _bit = _faim3._dim_dict[_line.vName]; // 内存位
                        _faim3._dim[_bit] = _val_2;           // 直接设置, 用以联动
                    }
                    #endregion
                    #region // 变量
                    else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                             _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                    {
                        F_TransCalc.doSetValue_byName(_faim3, _line.vName, _val_2);
                    }
                    #endregion
                    else
                    {
                        _val_1 = F_TransCalc._Get_Value_2(_faim3, _line.vName);
                        _faim3.Comm_Data.arr_int[_val_1] = _val_2;//
                    }
                }
                else if (_line.IfType.ToUpper().StartsWith("TBSE"))                         // 给指定的表单元赋值
                {
                    _val_3 = F_TransCalc._Get_Value_2(_faim3, _line.Reset);                 // 行号 键

                    if (_faim3.dict_CommonInfo.ContainsKey(_val_3) || _flow.tableNo == 0)   // 0.dict_CommonInfo
                    {
                        #region                                                             //dict_CommonInfo   val_01/val_02/val_03/arr_01/arr_02/arr_03
                        _val_1 = F_TransCalc._Get_Value_2(_faim3, _line.vName, ref _str_1); // 列


                        switch (_str_1)
                        {
                        case "val_01":
                            _faim3.dict_CommonInfo[_val_3].val_01 = _line.HL.Split(' ')[0];
                            break;

                        case "val_02":
                            _faim3.dict_CommonInfo[_val_3].val_02 = _line.HL.Split(' ')[0];
                            break;

                        case "val_03":
                            _faim3.dict_CommonInfo[_val_3].val_03 = _line.HL.Split(' ')[0];
                            break;

                        case "arr_01":
                            _faim3.dict_CommonInfo[_val_3].arr_1 = _line.HL;
                            break;

                        case "arr_02":
                            _faim3.dict_CommonInfo[_val_3].arr_2 = _line.HL;
                            break;

                        case "arr_03":
                            _faim3.dict_CommonInfo[_val_3].arr_3 = _line.HL;
                            break;
                        }
                        #endregion
                    }
                    else if (_faim3.dict_Modbus.ContainsKey(_val_3) || _flow.tableNo == 1)  // 1.dict_Modbus
                    {
                        #region                                                             //dict_Modbus   Loc_No/Name/transFlag/propFlag/Length/unitFlag/functionCode/Address/val01/val02/val03/val04
                        _val_1 = F_TransCalc._Get_Value_2(_faim3, _line.vName, ref _str_1); // 列


                        switch (_str_1)
                        {
                        case "Name":
                            _faim3.dict_Modbus[_val_3].Name = _line.HL;
                            break;

                        case "transFlag":
                            _faim3.dict_Modbus[_val_3].transFlag = _line.HL;
                            break;

                        case "propFlag":
                            _faim3.dict_Modbus[_val_3].propFlag = _line.HL;
                            break;

                        case "Length":
                            _faim3.dict_Modbus[_val_3].Length = _line.HL;
                            break;

                        case "unitFlag":
                            _faim3.dict_Modbus[_val_3].unitFlag = _line.HL;
                            break;

                        case "functionCode":
                            _faim3.dict_Modbus[_val_3].functionCode = _line.HL;
                            break;

                        case "Address":
                            _faim3.dict_Modbus[_val_3].Address = _line.HL;
                            break;

                        case "val01":
                            _faim3.dict_Modbus[_val_3].val01 = _line.HL;
                            break;

                        case "val02":
                            _faim3.dict_Modbus[_val_3].val02 = _line.HL;
                            break;

                        case "val03":
                            _faim3.dict_Modbus[_val_3].val03 = _line.HL;
                            break;

                        case "val04":
                            _faim3.dict_Modbus[_val_3].val04 = _line.HL;
                            break;
                        }
                        #endregion
                    }
                    else if (_faim3.dict_PointInfo.ContainsKey(_val_3) || _flow.tableNo == 2) // 2.dict_PointInfo
                    {
                        #region                                                               // dict_PointInfo   Loc_No/m_Id/Axis_Id/Distance/Max_Speed/Acc/Dcl/Remark
                        _val_1 = F_TransCalc._Get_Value_2(_faim3, _line.vName, ref _str_1);   // 列
                        //_val_2 = F_TransCalc._Get_Value_2(_faim3, _line.HL, ref _str_2); // 列
                        switch (_str_1)
                        {
                        case "Axis_Id":
                            _faim3.dict_PointInfo[_val_3].Axis_Id = _val_2;
                            break;

                        case "Distance":
                            _faim3.dict_PointInfo[_val_3].Distance = _val_2;
                            break;

                        case "Max_Speed":
                            _faim3.dict_PointInfo[_val_3].Max_Speed = _val_2;
                            break;

                        case "Acc":
                            _faim3.dict_PointInfo[_val_3].Acc = _val_2;
                            break;

                        case "Dcl":
                            _faim3.dict_PointInfo[_val_3].Dcl = _val_2;
                            break;

                        case "Remark":
                            _faim3.dict_PointInfo[_val_3].Remark = _line.HL;
                            break;
                        }
                        #endregion
                    }
                }
                #endregion

                #region                                           // IF
                else if (_line.IfType.ToUpper().StartsWith("IF")) // IF_XX
                {
                    bool _result = do_Compare(_faim3, _line);
                    if (!_result)                                                    // 为假,则跳
                    {
                        if (_faim3.dict_CaseState[_caseName].dict_IF.ContainsKey(i)) // 取跳转到 ELSE 的位置,正好转到ELSE 的下一位置
                        {
                            i = _faim3.dict_CaseState[_caseName].dict_IF[i];
                        }
                    }
                }
                else if ("ELSE" == _line.IfType.ToUpper())                         // ELSE
                {
                    if (_faim3.dict_CaseState[_caseName].dict_ELSE.ContainsKey(i)) // 取跳转到 ENDIF  位置
                    {
                        i = _faim3.dict_CaseState[_caseName].dict_ELSE[i];
                    }
                    continue;
                }
                else if ("ENDIF" == _line.IfType.ToUpper() ||
                         "EDIF" == _line.IfType.ToUpper())// ENDIF   EDIF
                {
                    continue;
                }
                #endregion

                #region                                               // WHILE
                else if (_line.IfType.ToUpper().StartsWith("WHIL") || // WHIL WHIL_XX WHILE WHILE_XX
                         _line.IfType.ToUpper().StartsWith("DW"))     // DWXX DW_XX
                {
                    bool _result = do_Compare(_faim3, _line);
                    if (!_result)                                                       // 为假,则跳
                    {
                        if (_faim3.dict_CaseState[_caseName].dict_WHILE.ContainsKey(i)) // 跳出 取跳转到 LOOP 的位置
                        {
                            i = _faim3.dict_CaseState[_caseName].dict_WHILE[i];
                        }
                    }
                }
                else if ("LEAV" == _line.IfType.ToUpper() ||
                         "BREAK" == _line.IfType.ToUpper())                         // LEAV/Break
                {
                    if (_faim3.dict_CaseState[_caseName].dict_WHILE.ContainsKey(i)) // 跳出 取跳转到 LOOP 的位置



                    {
                        i = _faim3.dict_CaseState[_caseName].dict_WHILE[i];
                    }
                }
                else if ("LOOP" == _line.IfType.ToUpper() ||                       // LOOP/EDDO
                         "EDDO" == _line.IfType.ToUpper() ||
                         "ITER" == _line.IfType.ToUpper())                         //  ITER/Continue
                {
                    if (_faim3.dict_CaseState[_caseName].dict_LOOP.ContainsKey(i)) // 循环 取跳转到 WHILE 的上一位置
                    {
                        i = _faim3.dict_CaseState[_caseName].dict_LOOP[i] - 1;
                    }
                    continue;
                }
                #endregion

                #region                                        // GOTO JMP NEXT
                else if ("NEXT" == _line.IfType.ToUpper() ||
                         "NEXTCASE" == _line.IfType.ToUpper()) // 程序控制
                {
                    _flow.Tag = "GOTO_ABS";                    // 设绝对跳转标志



                    _caseState.endMode = eCaseFlag.Goto;
                    _flow.nextCase     = _flow.dictCases[_alartCase].nextCase; // 设跳转步骤名
                    _line.times++;                                             // 此行使用的次数



                    _line.tmr = (int)(_tmr.ElapsedMilliseconds - _trm_begin);  // 本次流程完成用时
                    _faim3.dict_Threads[_flowName].Info.tmr_real += _line.tmr; // 当前步骤 累加 实际占用总时长 += 每语句使用的时间
                    break;
                }
                else if ("GOTO" == _line.IfType.ToUpper() ||
                         "JMP" == _line.IfType.ToUpper()) // 程序控制 GOTO NEXTCASE
                {
                    if (_faim3.dict_CaseState[_caseName].dict_TAG.ContainsKey(_line.vName.Trim()))
                    {
                        i = _faim3.dict_CaseState[_caseName].dict_TAG[_line.vName.Trim()];  // 转向当前的步骤的既定标记
                    }
                    else
                    {
                        _flow.Tag = "GOTO_ABS";// 设绝对跳转标志



                        _caseState.endMode = eCaseFlag.Goto;
                        if (_line.vName.ToUpper().Trim() == "NEXT" ||
                            _line.vName.ToUpper().Trim() == "NEXTCASE")            // 转向下一步骤 NestCase 的第一行号
                        {
                            _flow.nextCase = _flow.dictCases[_alartCase].nextCase; // 设跳转步骤名
                        }
                        else
                        {
                            _flow.nextCase = _line.vName; // 设跳转步骤名
                        }
                        _line.times++;                    // 此行使用的次数



                        _line.tmr = (int)(_tmr.ElapsedMilliseconds - _trm_begin);  // 本次流程完成用时
                        _faim3.dict_Threads[_flowName].Info.tmr_real += _line.tmr; // 当前步骤 累加 实际占用总时长 += 每语句使用的时间
                    }
                    break;
                }
                #endregion

                #region                                    // EXIT TAG
                else if ("EXIT" == _line.IfType.ToUpper()) // 任务管理
                {
                    _flow.nextCase = "Free";
                }
                else if ("TAG" == _line.IfType.ToUpper())// 程序控制
                {
                    break;
                }
                #endregion

                #region // CALL PROC ENDP 子程序



                else if (_line.IfType.ToUpper().StartsWith("CALL") ||
                         _line.IfType.ToUpper().StartsWith("EXSR"))                                 // CALL/EXSR 取跳转到 进入 PROC 的位置
                {
                    if (_faim3.dict_CaseState[_caseName].dict_PROC.ContainsKey(_line.vName.Trim())) // vName
                    {
                        _faim3.dict_CaseState[_caseName].lst_PROC.Insert(0, i);
                        i = _faim3.dict_CaseState[_caseName].dict_PROC[_line.vName.Trim()];
                    }
                }
                else if (_line.IfType.ToUpper().StartsWith("PROC") ||
                         _line.IfType.ToUpper().StartsWith("BGSR"))                           // PROC/ BGSR 跳出 取跳转到 ENDP 的位置
                {
                    if (_faim3.dict_CaseState[_caseName].dict_PROC.ContainsKey(i.ToString())) // 跳出 取跳转到 ENDP 的位置
                    {
                        i = _faim3.dict_CaseState[_caseName].dict_PROC[i.ToString()];
                    }
                }
                else if (_line.IfType.ToUpper().StartsWith("EDSR") || // 跳出 取跳转到 进入 PROC 的位置
                         _line.IfType.ToUpper().StartsWith("RETU") || //
                         _line.IfType.ToUpper().StartsWith("ENDP"))   //
                {
                    if (_faim3.dict_CaseState[_caseName].lst_PROC.Count > 0)
                    {
                        i = _faim3.dict_CaseState[_caseName].lst_PROC[0];
                        _faim3.dict_CaseState[_caseName].lst_PROC.RemoveAt(0);
                    }
                }
                #endregion

                #region // OUT SEND MBUS
                else if (_line.IfType.ToUpper().StartsWith("MBUS"))
                {
                    #region                                                 // MBUS     ,5  ,保留     ,*Loc
                    // clsModBus _en = _faim3.dict_Modbus[_val_2];
                    _val_3 = F_TransCalc._Get_Value_2(_faim3, _line.Reset); // 文档的值: 数值


                    List <byte> _lst = clsModBus._getModbusFix(_faim3, _val_3);

                    int _devNo_1 = Convert.ToInt32(_line.vName);//设备号


                    int _ref_1i = _faim3.sect_iDev * _devNo_1;
                    int _ref_1s = _faim3.sect_sDev * _devNo_1 + _faim3.sect_sDev_start;

                    string _val = BitConverter.ToString(_lst.ToArray()).Replace("-", " ");

                    // ---发出消息 条件:1.bt_out  2._devNo   3.snd_iLen
                    _faim3._sss[_ref_1s] = _val;                                 //
                    //_dao_comm.set_arr_str(_ref_1s, _val);  //
                    _faim3.Comm_Data.bt_out[0][_ref_1i + _faim3.snd_iLen] = -99; //
                    _dao_comm.set_bt_out(_ref_1i + _faim3.snd_iLen, _lst.Count); //
                    #endregion



                    #region // <64 byte
                    //for (int _t = 0; _t < _lst.Count; _t++)
                    //{
                    //    _faim3.Comm_Data.bt_out[0][_t] = _lst[_t]; // 输出
                    //}

                    //// ---发出消息 条件:1.bt_out  2._devNo   3.snd_iLen
                    //_faim3.Comm_Data.bt_out[0][_ref_1i + _faim3.snd_iLen] = -99;    //
                    //_dao_comm.set_bt_out(_ref_1i + _faim3.snd_iLen, _lst.Count);  //
                    #endregion
                }
                else if (_line.IfType.ToUpper().StartsWith("OUT") ||
                         _line.IfType.ToUpper().StartsWith("SEND"))
                {
                    if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                    {
                        #region                                                    // OUT
                        clsDevFunction _df = _faim3.dict_DevFunction[_line.vName]; //
                        if (_df.varName.ToUpper() == "BT_OUT")
                        {
                            int _devNo_1 = _df.devNo;//设备号


                            int _ref_1i = _faim3.sect_iDev * _devNo_1;
                            //int _ref_1s = _faim3.sect_sDev * _devNo_1 + _faim3.sect_sDev_start;
                            _bit = _ref_1i + _df.Index;//内存位



                            // 特殊 vName ==> driverName ==> _df.ioIdx ==> LLine
                            _faim3.Comm_Data.bt_out[0][_ref_1i + Convert.ToInt32(_faim3.dict_KV["LLine"])] = _df.ioIdx;
                            // HL ==> _val_2 => Value
                            _faim3.Comm_Data.bt_out[0][_ref_1i + Convert.ToInt32(_faim3.dict_KV["Value"])] = _val_2;
                            //通用 bt_out[_df.Index]-->_df.ioIdx  _val_2-->H/L
                            _faim3.Comm_Data.bt_out[0][_bit] = _val_2; // 输出电位  bt_out[106]=6   bt_out[6]= 9>0

                            // --- 发出消息 条件:1.bt_out  2._devNo   3.snd_iLen
                            _faim3.Comm_Data.bt_out[0][_ref_1i + _faim3.snd_iLen] = -99; //
                            _dao_comm.set_bt_out(_ref_1i + _faim3.snd_iLen, _bit);       // bt_out[164]=6
                        }
                        #endregion
                    }
                    else if (_faim3.dict_CmdFormats.ContainsKey(_line.vName))
                    {
                        #region                                            // 协议表 字符串 Ascii码 snd_sLen=1
                        int _devNo_1 = clsProtocol.getSendData(_faim3, i); // 返回待发送数据的 设备号



                        int _ref_1i = _faim3.sect_iDev * _devNo_1;
                        int _ref_1s = _faim3.sect_sDev * _devNo_1 + _faim3.sect_sDev_start; // 设发送数据的长度, 发送的是字符域的数据



                        // 发出消息 条件:1.bt_out  2._devNo   3.snd_iLen
                        _faim3.Comm_Data.bt_out[0][_ref_1i + _faim3.snd_iLen] = -99;
                        _dao_comm.set_bt_out(_ref_1i + _faim3.snd_iLen, 1);
                        #endregion
                    }
                    else if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        // _sss  [0 ~ 200] 区域
                        #region                               // _dim_dict 动态变量 dim[Feeder05_unLink] <== _line.HL
                        _bit = _faim3._dim_dict[_line.vName]; // 内存位



                        if (_str_2 == "    ")
                        {
                            _faim3._dim[_bit] = _val_2;  // 值    直接设置, 用以联动
                        }
                        else
                        {
                            _faim3._sss[_bit] = _str_2;  // 字符串
                        }
                        #endregion
                    }
                    else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                             _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                    {
                        // 空 大数据
                    }
                }
                #endregion

                _line.times++;                                             // 当前行使用的次数
                _line.tmr = (int)(_tmr.ElapsedMilliseconds - _trm_begin);  // 当前行完成用时

                _faim3.dict_Threads[_flowName].Info.tmr_real += _line.tmr; // 当前步骤 累加 实际占用总时长 += 每语句使用的时间
                #endregion                                                 // 开始执行

                #endregion                                                 // for
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        static void _TEST_2(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, string _caseName, ref bool _vbl)
        {
            if (_flowName == "DAL_Buttons")
            {
                _vbl = true;
                return;
            }
            bool         _mybl      = true;
            clsFlow      _flow      = _faim3.dict_Flow[_flowName];
            string       _alartCase = _flow.alartCase;
            clsCaseState _caseState = _faim3.dict_CaseState[_alartCase];
            Dictionary <string, clsCaseChildInfo> _dictCaseChildInfo =
                _caseState.dict_CaseChildInfo;
            string PartName = _TESTB;// "TESTB";
            string _IfType  = _CMD_TEST;

            #region                                        // 指定步骤无此部份指令
            if (!_dictCaseChildInfo.ContainsKey(PartName)) // 条件:指定步骤无此部份指令
            {
                _vbl = _mybl;
                return;
            }
            #endregion
            int _lineStart = _dictCaseChildInfo[PartName].lineStart;  // 起始行号
            if (_lineStart < 0)
            {
                return;                                          // 条件:没有指定的结构块起始行号
            }
            int _lineEnd = _dictCaseChildInfo[PartName].lineEnd; // 终止行号
            if (_lineEnd < 0)                                    // 只有一行时
            {
                _lineEnd = _lineStart;
            }
            for (int i = _lineStart; i <= _lineEnd; i++) // 文档对象驱动
            {
                if (_faim3.isEmergency > 0)
                {
                    break; // 急停
                }
                #region    // for
                clsDevTestBits _line = _faim3.lst_DevTestBits[i];
                if (_line.Remark.ToUpper().StartsWith("CODE") ||
                    _line.IfType.ToUpper() == "NG")
                {
                    continue;                                             //条件:文档行指定为以代码实现
                }
                if (F_CaseSub._CMD_NULL.Contains(_line.IfType.ToUpper())) // 占位行
                {
                    continue;
                }
                if (_line.isDebug == 1)                   /*#*/
                {
                    if (_faim3.dict_KV["isDebug"] != "1") // 非 debug 状态下,不运行 debug 行  cfgDev_Cards.xls
                    {
                        continue;
                    }
                }
                _do_WaitLine(_faim3, _dao_comm, _flowName, eWF_State.Test, i);// 单步
                if (_faim3.isEmergency > 0)
                {
                    break;                                      // 急停
                }
                if (_flow.isStepPass || _faim3.isStepPass != 0) // 步骤直通
                {
                    _mybl = true;
                    continue;
                }
                #region                                                                 // 开始执行
                _line = _faim3.lst_DevTestBits[i];
                System.Diagnostics.Stopwatch _tmr = new System.Diagnostics.Stopwatch(); //实例化一个计时器
                _tmr.Start();
                long   _trm_begin = _tmr.ElapsedMilliseconds;                           // 毫秒
                int    _bit       = -1;                                                 // 位
                int    _val_1     = -1;
                string _str_2     = "   ";
                int    _val_2     = F_TransCalc._Get_Value_2(_faim3, _line.HL, ref _str_2);
                int    _val_3     = -1;
                if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                {
                    #region                                                    // dict_DevFunction IO口定义 vName : 4D_GS, 6RS_0302, 6D_ER, 6D_RP
                    clsDevFunction _df = _faim3.dict_DevFunction[_line.vName]; //
                    _bit = _faim3.sect_iDev * _df.devNo + _df.Index;           // 内存位
                    int _ref_1i = -1;
                    int _ref_1s = -1;
                    switch (_df.varName.ToUpper())
                    {
                    // MODBUS
                    case "MODBUS":
                        _ref_1i = _faim3.sect_iDev * _df.devNo;
                        _bit    = _faim3.sect_iDev * _df.devNo + _df.Index;
                        // 取比较值

                        _val_1 = _faim3.Comm_Data.bt_in[0][_bit];
                        break;

                    // 74X
                    case "BT_IN":
                        _ref_1i = _faim3.sect_iDev * _df.devNo;
                        _ref_1s = _faim3.sect_sDev * _df.devNo + _faim3.sect_sDev_start;
                        _faim3.Comm_Data.bt_out[0][_ref_1i + Convert.ToInt32(_faim3.dict_KV["LLine"])] = _df.ioIdx;
                        _bit = _faim3.sect_iDev * _df.devNo + _df.ioIdx;
                        // 发出消息 条件:1.bt_out  2._devNo   3.snd_iLen
                        _faim3.Comm_Data.bt_out[0][_ref_1i + _faim3.snd_iLen + 1] = -99;
                        _dao_comm.set_bt_out(_ref_1i + _faim3.snd_iLen + 1, _bit);      // bt_in[164]=6  DI_R1:DI_ReadLine
                        // 取比较值

                        _val_1 = _faim3.Comm_Data.bt_in[0][_bit];
                        break;

                    case "BT_OUT":
                        _ref_1i = _faim3.sect_iDev * _df.devNo;
                        _bit    = _faim3.sect_iDev * _df.devNo + _df.Index;
                        // 取比较值
                        _val_1 = _faim3.Comm_Data.bt_out[0][_bit];
                        break;

                    // 204C
                    case "A_ST":
                    case "A_IO":
                        clsProtocol._204C(_faim3, _dao_comm, _df.varName, _df.ioIdx.ToString(), _df.devNo); // 发出自定义命令
                        _val_1 = _faim3.Comm_Data.bt_in[0][_bit];                                           // 取出值, 可能多次才能取到
                        break;

                    // RS485
                    case "ReadPos":
                    case "ReadStatus":
                    case "READPOS":
                    case "READSTATUS":
                        // 发出命令
                        int _devNo_1 = clsProtocol.getSendData(_faim3, i);
                        _ref_1i = _faim3.sect_iDev * _devNo_1;
                        _ref_1s = _faim3.sect_sDev * _devNo_1 + _faim3.sect_sDev_start;
                        // 发出消息 条件:1.bt_out  2._devNo   3.snd_iLen
                        _faim3.Comm_Data.bt_out[0][_ref_1i + _faim3.snd_iLen] = -99;
                        _dao_comm.set_bt_out(_ref_1i + _faim3.snd_iLen, 1);
                        //
                        _val_3 = F_TransCalc._Get_Value_2(_faim3, _line.Reset);
                        _val_1 = _faim3.Comm_Data.bt_in[0][_bit];     // 取出值, 可能多次才能取到
                        break;
                    }
                    #endregion
                }
                else if (_faim3._dim_dict.ContainsKey(_line.vName))
                {
                    #region                                 // _dim_dict  动态变量
                    _bit   = _faim3._dim_dict[_line.vName]; // 自定义名为下标, 分配地址, 寻址
                    _val_1 = _faim3._dim[_bit];
                    #endregion
                }
                else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                         _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                {
                    #region // _FAIM3 大数据
                    _bit   = 1;
                    _val_1 = Convert.ToInt32(F_TransCalc.doGetValue_byName(_faim3, _line.vName));
                    #endregion
                }
                _line.times++;                                             // 此行使用的次数
                _line.tmr = (int)(_tmr.ElapsedMilliseconds - _trm_begin);  // 本次流程完成用时
                _faim3.dict_Threads[_flowName].Info.tmr_real += _line.tmr; // 当前步骤 实际占用总时长 += 每语句使用的时间
                // TEST
                if (_bit > -1)
                {
                    if (_flow.isStepLine || _flow.isStepLine)
                    {
                        int _loc = 0;
                        foreach (var item in _faim3.dict_Flow)
                        {
                            if (item.Key == _flowName)// 流程名 转 流程号
                            {
                                string _msg = string.Format("TEST {0} {1} {2} {3} {4} {5}",
                                                            _flow.currCase,
                                                            _flowName,
                                                            _bit,
                                                            _val_1,
                                                            _line.IfType,
                                                            _val_2
                                                            );
                                _dao_comm.set_arr_str(_loc + 800, _msg);
                                break;
                            }
                            _loc++;
                        }
                    }
                    #region // 测试 AND
                    if (_line.IfType == "EQ_AND" || _line.IfType == "AND_EQ" || _line.IfType == "EQ")
                    {
                        _mybl = _mybl && (_val_1 == _val_2);//
                    }
                    else if (_line.IfType == "NE_AND" || _line.IfType == "AND_NE" || _line.IfType == "NE")
                    {
                        _mybl = _mybl && (_val_1 != _val_2);//
                    }
                    else if (_line.IfType == "GT_AND" || _line.IfType == "AND_GT" || _line.IfType == "GT")
                    {
                        _mybl = _mybl && (_val_1 > _val_2);//
                    }
                    else if (_line.IfType == "GE_AND" || _line.IfType == "AND_GE" || _line.IfType == "GE")
                    {
                        _mybl = _mybl && (_val_1 >= _val_2);//
                    }
                    else if (_line.IfType == "LT_AND" || _line.IfType == "AND_LT" || _line.IfType == "LT")
                    {
                        _mybl = _mybl && (_val_1 < _val_2);//
                    }
                    else if (_line.IfType == "LE_AND" || _line.IfType == "AND_LE" || _line.IfType == "LE")
                    {
                        _mybl = _mybl && (_val_1 <= _val_2); //
                    }
                    #endregion                               // 测试 AND
                    #region                                  // BIT BITN
                    else if (_line.IfType == "BIT")          // 为高有效
                    {
                        // _val_2= 5; Math.Pow(2, _val_2) = 32.0 = 0x20 = 0010 0000
                        if (_val_2 < 0)
                        {
                            _val_2 = 0;
                        }
                        bool _rb = false;
                        if (_val_1 > -1)
                        {
                            _rb = (_val_1 & (int)Math.Pow(2, _val_2)) == Math.Pow(2, _val_2);
                        }
                        else
                        {
                            _rb = false;
                        }
                        _mybl = _mybl && _rb;        //
                    }
                    else if (_line.IfType == "BITN") // 为低有效
                    {
                        if (_val_2 < 0)
                        {
                            _val_2 = 0;
                        }
                        bool _rb = false;
                        if (_val_1 > -1)
                        {
                            _rb = (_val_1 & (int)Math.Pow(2, _val_2)) != Math.Pow(2, _val_2);
                        }
                        else
                        {
                            _rb = false;
                        }
                        _mybl = _mybl && (_rb);//
                    }
                    #endregion
                    #region // 测试 OR
                    else if (_line.IfType == "EQ_OR" || _line.IfType == "OR_EQ")
                    {
                        _mybl = _mybl || (_val_1 == _val_2);//
                        if (_mybl)
                        {
                            break;
                        }
                    }
                    else if (_line.IfType == "NE_OR" || _line.IfType == "OR_NE")
                    {
                        _mybl = _mybl || (_val_1 != _val_2);//
                        if (_mybl)
                        {
                            break;
                        }
                    }
                    else if (_line.IfType == "GT_OR" || _line.IfType == "OR_GT")
                    {
                        _mybl = _mybl || (_val_1 > _val_2);//
                        if (_mybl)
                        {
                            break;
                        }
                    }
                    else if (_line.IfType == "GE_OR" || _line.IfType == "OR_GE")
                    {
                        _mybl = _mybl || (_val_1 >= _val_2);//
                        if (_mybl)
                        {
                            break;
                        }
                    }
                    else if (_line.IfType == "LT_OR" || _line.IfType == "OR_LT")
                    {
                        _mybl = _mybl || (_val_1 < _val_2);//
                        if (_mybl)
                        {
                            break;
                        }
                    }
                    else if (_line.IfType == "LE_OR" || _line.IfType == "OR_LE")
                    {
                        _mybl = _mybl || (_val_1 <= _val_2);//
                        if (_mybl)
                        {
                            break;
                        }
                    }
                    #endregion        // 测试 OR
                }
                #endregion            // 开始执行
                #endregion            // for
            }
            _flow.isStepPass = false; // 取消直通
            _vbl             = _mybl;
            return;
        }