Beispiel #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);
        }
Beispiel #2
0
        // 恢复/停止 指定的流程 的业务

        void set_Business_OnOff(string vflowName, eSwitch allowDoBusiness)
        {
            if (string.IsNullOrEmpty(vflowName))
            {
                return;
            }
            if (!_faim3.dict_Threads.ContainsKey(vflowName))
            {
                FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("--->>>>! 线程没有启动 2:{0}", vflowName));
                return;
            }
            if ((int)allowDoBusiness != (int)eSwitch.Yes)
            {
                _faim3.dict_Threads[vflowName].Info.allowBusiness = eSwitch.Close;
            }
            else
            {
                _faim3.dict_Threads[vflowName].Info.allowBusiness = eSwitch.Yes;
                clsFlow _flow = _faim3.dict_Flow[vflowName];
                // 无效
                _flow.isStepBy      = false;          // 单步1
                _flow.stepCase      = "";             // 单步2
                _flow.breakSkipCase = _flow.currCase; // 断点
                _flow.isStepLine    = false;          // 单行1
                _flow.caseLineIdx   = -1;             // 单行2
            }
            FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("流程:{0}-->{1}", vflowName, allowDoBusiness.ToString()));
        }
Beispiel #3
0
        int do_InitData()
        {
            //'从类名取编号
            _clsName = this.GetType().Name;
            int _idx = _clsName.LastIndexOf('_');// InStrRev(_clsName, "_");

            //if (_idx > 0) _idx += 1;
            _caseFix  = _clsName.Substring(_idx, _clsName.Length - _idx); //'提取 编号位
            _caseName = _flowName + _caseFix;                             //' 步骤/方法名 = 流/线程名 + _编号
            if (!_faim3.dict_CaseAlarm.ContainsKey(_caseName))
            {
                FACC.F_Log.Debug_1(_clsName, String.Format("--->>>> 初始化失败-10: {0} 报警对象不存在(dict_CaseAlarm)", _caseName));
                return(-10);
            }
            //_testBits = _faim3.dict_CaseAlarm[_caseName].testBits;
            clsFlow _flow = _faim3.dict_Flow[_flowName];

            if (!_flow.dictCases.ContainsKey(_caseName))
            {
                FACC.F_Log.Debug_1(_clsName, String.Format("--->>>> 初始化失败-20: {0} 步骤对象 不存在(dictCases)", _caseName));
                return(-20);
            }
            _otherCase = _flow.dictCases[_caseName].otherCase;
            return(0);
        }
Beispiel #4
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);
        }
Beispiel #5
0
 protected bool do_allowBusiness(clsThreadInfo vTheadInfo)
 {
     vTheadInfo.cnt_heart++;   // 心跳
     System.Threading.Thread.Sleep(vTheadInfo.sleep);
     if ((int)vTheadInfo.allowBusiness == (int)eSwitch.No)
     {
         clsFlow _flow = _faim3.dict_Flow[_flowName];
         _flow.eState = eWF_State.Wait;
         return(false); // 未允许运行流程/业务  business
     }
     return(true);
 }
Beispiel #6
0
 // 执行指定的 流程
 public void doRunFlow(string vflowName)
 {
     if (string.IsNullOrEmpty(vflowName))
     {
         return;
     }
     if (!_faim3.dict_Threads.ContainsKey(vflowName))
     {
         clsFlow _flow = _faim3.dict_Flow[vflowName];
         if (_flow.nextCase.ToUpper() != "FREE")// 存在
         {
             clsTool_ASM.doCreateInstance(_faim3, _dao_comm, vflowName);
         }
     }
     doRunFlow(vflowName);
 }
Beispiel #7
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";
            }
        }
Beispiel #8
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);
            }
        }
Beispiel #9
0
        // 1逐行 2单步 3断点 续运行

        void doRunMode(string vflowName, int runMode)
        {
            if (string.IsNullOrEmpty(vflowName))
            {
                return;
            }
            clsFlow _flow = _faim3.dict_Flow[vflowName];

            _flow.stepCase      = "";           // 单步2
            _flow.caseLineIdx   = -1;           // 单行2
            _flow.isStepLine    = runMode == 1; // 单行1
            _flow.isStepBy      = runMode == 2; // 单步1
            _flow.breakSkipCase = "";           // _flow.currCase; // 断点
            if (_faim3.dict_Threads.ContainsKey(vflowName))
            {
                //if (!_faim3.dict_Threads[vflowName].Info.allowDoBusi)
                _faim3.dict_Threads[vflowName].Info.allowBusiness = eSwitch.Yes;
            }
        }
Beispiel #10
0
 static void _do_WaitLine(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, eWF_State vStopState, int vCaseLineIdx)
 {
     #region // 是“行步进”调试
     clsFlow _flow = _faim3.dict_Flow[_flowName];
     if (!_flow.isStepLine)
     {
         return;                    // 是“行步进”调试
     }
     clsDevTestBits _line = _faim3.lst_DevTestBits[vCaseLineIdx];
     if (_line.isDebug == 1) /*#*/             // cfgDev_testBits #
     {
         if (_faim3.dict_KV["isDebug"] != "1") // 非 debug 状态下,不运行 debug 行  cfgDev_Cards.xls
         {
             return;
         }
     }
     _flow.caseLineIdx = vCaseLineIdx;
     while (_flow.caseLineIdx == vCaseLineIdx)//
     {
         if (_faim3.isEmergency > 0)
         {
             break;  // 急停
         }
         if (_flow.eState == eWF_State.End || _flow.eState == eWF_State.Wait)
         {
             break;
         }
         if (_flow.eState != vStopState)
         {
             _flow.eState = vStopState;                                            //
             _dao_comm_set_arr_str800(_faim3, _dao_comm, _flowName, vCaseLineIdx); // “行步进”消息  arr_str[0][800 + _flowIdx]
         }
         System.Threading.Thread.Sleep(100);
     }
     _flow.eState = eWF_State.Running;  //
     #endregion
 }
Beispiel #11
0
        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();                //结束计时
        }
Beispiel #12
0
        // 输出
        static void _OUT_X_old(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, string _caseName, string vIfType)
        {
            string  _IfType    = vIfType + ".GOTO.ADD.DEC.INC.";
            clsFlow _flow      = _faim3.dict_Flow[_flowName];
            string  _alartCase = _flow.alartCase;
            Dictionary <string, clsCaseChildInfo> _dictCaseChildInfo =
                _faim3.dict_CaseState[_alartCase].dict_CaseChildInfo;

            if (!_dictCaseChildInfo.ContainsKey(vIfType))
            {
                return;                                             // 条件:指定步骤无此部份指令
            }
            int _lineStart = _dictCaseChildInfo[vIfType].lineStart; // 起始行号

            if (_lineStart < 0)
            {
                return; // 条件:没有指定的结构块起始行号
            }
            clsDevTestBits _line = _faim3.lst_DevTestBits[_lineStart];

            if (_line.flowCase != _caseName)
            {
                return; // 条件:顺序执行时, 如步骤名不对, 则结束当前结构
            }
            if (!_IfType.Contains(_line.IfType.ToUpper() + "."))
            {
                return;                                                     //条件:没有结构块指定的命令
            }
            int _cnt_break = 0;                                             // 计数器

            for (int i = _lineStart; i < _faim3.lst_DevTestBits.Count; i++) // 文档对象驱动
            {
                if (_faim3.isEmergency > 0)
                {
                    break;
                }
                #region // for
                _line = _faim3.lst_DevTestBits[i];
                if (_line.Remark.ToUpper().StartsWith("CODE"))
                {
                    continue;                                                        //条件:文档行指定为以代码实现
                }
                if (!(_line.isDebug == 1 /*#*/ && _faim3.dict_KV["isDebug"] == "1")) // 在 debug 状态下,才运行 debug 行  cfgKV.ini
                {
                    continue;
                }
                if (_line.flowCase != _caseName)
                {
                    break; // 条件:顺序执行时, 如步骤名不对, 则结束当前结构
                }
                if (!_IfType.Contains(_line.IfType.ToUpper() + "."))
                {
                    break; //条件:没有结构块指定的命令
                }
                #region    // 开始执行

                _do_WaitLine(_faim3, _dao_comm, _flowName, eWF_State.Line, i);
                System.Diagnostics.Stopwatch _tmr = new System.Diagnostics.Stopwatch(); //实例化一个计时器
                _tmr.Start();
                long _trm_begin = _tmr.ElapsedMilliseconds;                             // 毫秒

                int _bit = -1;                                                          // 位

                int _val_2 = F_TransCalc._Get_Value_2(_faim3, _line.HL);
                if ("SLEEP" == _line.vName.ToUpper()) // 必须作为第一判断
                {
                    System.Threading.Thread.Sleep(_val_2);
                }
                #region // GOTO ADD DEC INC
                else if ("GOTO" == _line.IfType.ToUpper())
                {
                    _flow.nextCase = _line.vName;
                }
                else if ("ADD" == _line.IfType.ToUpper())
                {
                    if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        #region                               // _dim_dict 动态变量

                        _bit = _faim3._dim_dict[_line.vName]; // 内存位 自定义名为下标, 分配地址, 寻址
                        _faim3._dim[_bit] += _val_2;          // 直接设置, 用以联动     dim[Feeder05_unLink] = Value
                        #endregion
                    }
                }
                else if ("DEC" == _line.IfType.ToUpper())
                {
                    if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        #region                               // _dim_dict 动态变量

                        _bit = _faim3._dim_dict[_line.vName]; // 内存位 自定义名为下标, 分配地址, 寻址
                        _faim3._dim[_bit] -= _val_2;          // 直接设置, 用以联动     dim[Feeder05_unLink] = Value
                        #endregion
                    }
                }
                else if ("INC" == _line.IfType.ToUpper())
                {
                    if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        #region                               // _dim_dict 动态变量

                        _bit = _faim3._dim_dict[_line.vName]; // 内存位 自定义名为下标, 分配地址, 寻址
                        _faim3._dim[_bit] += 1;               // 直接设置, 用以联动     dim[Feeder05_unLink] = Value
                        #endregion
                    }
                }
                #endregion
                else if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                {
                    #region                                                       // 输出 OUT IO 类

                    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")
                    {
                        // 特殊 vName ==> driverName ==> _df.ioIdx ==> LLine
                        _faim3.Comm_Data.bt_out[0][_ref_i + Convert.ToInt32(_faim3.dict_KV["LLine"])] = _df.ioIdx;
                        // HL ==> _val_2 => Value
                        _faim3.Comm_Data.bt_out[0][_ref_i + 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_lenLoc
                        _faim3.Comm_Data.bt_out[0][_faim3.sect_idev * _devNo + _faim3.snd_lenLoc] = -1; //
                        _dao_comm.set_bt_out(_faim3.sect_idev * _devNo + _faim3.snd_lenLoc, _bit);      // bt_out[164]=6
                    }
                    #endregion
                }
                else if (_faim3.dict_CmdFormat.ContainsKey(_line.vName))
                {
                    #region // 输出 OUT 协议类


                    clsProtocol _protocol = new clsProtocol(_faim3, _dao_comm);
                    // 返回待发送数据的绝对位置
                    int _ret = _protocol.getSendData(_line.vName, _val_2, _line.HL);
                    // 设发送数据的长度, 发送的是字符域的数据
                    //int _ref_s = _faim3.sect_sDev_start + _faim3.sect_sDev * _ret;
                    //_faim3._sss[_ref_s + _faim3.snd_slen] = "0";
                    //_dao_comm.set_arr_str(_ref_s + _faim3.snd_slen, "1");
                    // 发送

                    _dao_comm.set_arr_str(_ret, "1");
                    #endregion
                }
                else if (_faim3._dim_dict.ContainsKey(_line.vName))
                {
                    #region                               // _dim_dict 动态变量 dim[Feeder05_unLink] <== Value
                    _bit = _faim3._dim_dict[_line.vName]; // 内存位

                    _faim3._dim[_bit] = _val_2;           // 直接设置, 用以联动
                    #endregion
                }
                else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                         _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                {
                    // 大数据 空
                }
                else if (_cnt_break > 0)  // 截断
                {
                    break;
                }
                #endregion
                _cnt_break++;
                _line.times++;                                             // 此行使用的次数

                _line.tmr = (int)(_tmr.ElapsedMilliseconds - _trm_begin);  // 本次流程完成用时
                _faim3.dict_Threads[_flowName].Info.tmr_real += _line.tmr; // 当前步骤 实际占用总时长 += 每语句使用的时间
                #endregion
            }
        }
Beispiel #13
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;
        }
Beispiel #14
0
        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();                //结束计时
        }
Beispiel #15
0
        // 赋值

        static void _LET_X_old(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, string _caseName, string vIfType)
        {
            clsFlow _flow = _faim3.dict_Flow[_flowName];

            #region // 条件
            Dictionary <string, clsCaseChildInfo> _dictCaseChildInfo =
                _faim3.dict_CaseState[_flow.alartCase].dict_CaseChildInfo;
            // string vIfType = "Line";
            if (!_dictCaseChildInfo.ContainsKey(vIfType))
            {
                return;
            }
            int    _lineStart = _dictCaseChildInfo[vIfType].lineStart; // 起始行号
            string _IfType    = vIfType + ".GOTO.ADD.DEC.INC.";
            if (_lineStart < 0)
            {
                return;                                  // 条件:没有指定的结构块起始行号
            }
            clsDevTestBits _line = _faim3.lst_DevTestBits[_lineStart];
            if (_line.flowCase != _caseName)
            {
                return;                              // 条件:顺序执行时, 如步骤名不对, 则结束当前结构
            }
            if (!_IfType.Contains(_line.IfType.ToUpper() + "."))
            {
                return;                                                 //条件:没有结构块指定的命令
            }
            #endregion

            int _cnt_break = 0;                                             // 计数器

            for (int i = _lineStart; i < _faim3.lst_DevTestBits.Count; i++) // 文档对象驱动
            {
                if (_faim3.isEmergency > 0)
                {
                    break;
                }
                #region // for
                _line = _faim3.lst_DevTestBits[i];
                if (_line.Remark.ToUpper().StartsWith("CODE"))
                {
                    continue;                                               //条件:文档行指定为以代码实现
                }
                if (_line.flowCase != _caseName)
                {
                    break;                              // 条件:顺序执行时, 如步骤名不对, 则结束当前结构
                }
                if (!_IfType.Contains(_line.IfType.ToUpper() + "."))
                {
                    break;                                                 //条件:没有结构块指定的命令
                }
                _do_WaitLine(_faim3, _dao_comm, _flowName, eWF_State.Line, i);
                #region // 开始执行


                System.Diagnostics.Stopwatch _tmr = new System.Diagnostics.Stopwatch(); //实例化一个计时器
                _tmr.Start();
                long _trm_begin = _tmr.ElapsedMilliseconds;                             // 毫秒

                int _bit = -1;                                                          // 位

                int _val_2 = F_TransCalc._Get_Value_2(_faim3, _line.HL);
                #region                               // SLEEP GOTO ADD DEC INC
                if ("SLEEP" == _line.vName.ToUpper()) //
                {
                    System.Threading.Thread.Sleep(_val_2);
                }
                else if ("GOTO" == _line.IfType.ToUpper())
                {
                    _flow.nextCase = _line.vName;
                }
                else if ("ADD" == _line.IfType.ToUpper())
                {
                    if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        #region                               // _dim_dict 动态变量

                        _bit = _faim3._dim_dict[_line.vName]; // 内存位 自定义名为下标, 分配地址, 寻址
                        _faim3._dim[_bit] += _val_2;          // 直接设置, 用以联动     dim[Feeder05_unLink] = Value
                        #endregion
                    }
                    else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                             _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                    {
                        int _ls = Convert.ToInt32(F_TransCalc.doGetValue_byName(_faim3, _line.vName));
                        F_TransCalc.doSetValue_byName(_faim3, _line.vName, _ls + _val_2);
                    }
                }
                else if ("DEC" == _line.IfType.ToUpper())
                {
                    if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        #region                               // _dim_dict 动态变量

                        _bit = _faim3._dim_dict[_line.vName]; // 内存位 自定义名为下标, 分配地址, 寻址
                        _faim3._dim[_bit] -= _val_2;          // 直接设置, 用以联动     dim[Feeder05_unLink] = Value
                        #endregion
                    }
                    else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                             _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                    {
                        int _ls = Convert.ToInt32(F_TransCalc.doGetValue_byName(_faim3, _line.vName));
                        F_TransCalc.doSetValue_byName(_faim3, _line.vName, _ls - _val_2);
                    }
                }
                else if ("INC" == _line.IfType.ToUpper())
                {
                    if (_faim3._dim_dict.ContainsKey(_line.vName))
                    {
                        #region                               // _dim_dict 动态变量

                        _bit = _faim3._dim_dict[_line.vName]; // 内存位 自定义名为下标, 分配地址, 寻址
                        _faim3._dim[_bit] += 1;               // 直接设置, 用以联动     dim[Feeder05_unLink] = Value
                        #endregion
                    }
                    else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                             _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                    {
                        int _ls = Convert.ToInt32(F_TransCalc.doGetValue_byName(_faim3, _line.vName));
                        F_TransCalc.doSetValue_byName(_faim3, _line.vName, _ls - 1);
                    }
                }
                #endregion
                else if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                {
                    #region                                                       // BT_OUT
                    clsDevFunction _df    = _faim3.dict_DevFunction[_line.vName]; //
                    int            _devNo = _df.devNo;                            //设备号

                    int _refIdx = _faim3.sect_idev * _devNo;
                    _bit = _refIdx + _df.Index;//内存位

                    if (_df.varName.ToUpper() == "BT_OUT")
                    {
                        _faim3.Comm_Data.bt_out[0][_bit] = _val_2;//输出电位
                    }
                    #endregion
                }
                else if (_faim3._dim_dict.ContainsKey(_line.vName))
                {
                    #region                               // _dim_dict 动态变量 dim[Feeder05_unLink] <== Value
                    _bit = _faim3._dim_dict[_line.vName]; // 内存位

                    _faim3._dim[_bit] = _val_2;           // 直接设置, 用以联动
                    #endregion
                }
                else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                         _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                {
                    F_TransCalc.doSetValue_byName(_faim3, _line.vName, _val_2);
                }
                else if (_cnt_break > 0)  // 截断
                {
                    break;
                }
                #endregion
                _cnt_break++;
                _line.times++;                                             // 此行使用的次数

                _line.tmr = (int)(_tmr.ElapsedMilliseconds - _trm_begin);  // 本次流程完成用时
                _faim3.dict_Threads[_flowName].Info.tmr_real += _line.tmr; // 当前步骤 实际占用总时长 += 每语句使用的时间
                #endregion
            }
        }
Beispiel #16
0
        // 测试变量 复位
        private static void _TEST_2_Reset(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, string _caseName)
        {
            clsFlow _flow      = _faim3.dict_Flow[_flowName];
            string  _alartCase = _flow.alartCase;
            Dictionary <string, clsCaseChildInfo> _dictCaseChildInfo =
                _faim3.dict_CaseState[_alartCase].dict_CaseChildInfo;
            string PartName = _TESTB;// "TESTB";

            if (!_dictCaseChildInfo.ContainsKey(PartName))
            {
                return;                                              // 没有此段
            }
            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 (_line.isDebug == 1)                   /*#*/
                {
                    if (_faim3.dict_KV["isDebug"] != "1") // 非 debug 状态下,不运行 debug 行  cfgDev_Cards.xls
                    {
                        continue;
                    }
                }
                if (string.IsNullOrEmpty(_line.Reset) || _line.Reset == "-")
                {
                    continue;                                                   // 无复位值
                }
                _do_WaitLine(_faim3, _dao_comm, _flowName, eWF_State.Reset, i); // 单步
                if (_faim3.isEmergency > 0)
                {
                    break;       // 急停
                }
                #region          // 开始执行
                _line = _faim3.lst_DevTestBits[i];
                int _bit   = -1; // 位
                int _val_3 = F_TransCalc._Get_Value_2(_faim3, _line.Reset);
                if (_faim3.dict_DevFunction.ContainsKey(_line.vName))
                {
                    #region                                                    // dict_DevFunction IO口定义
                    clsDevFunction _df = _faim3.dict_DevFunction[_line.vName]; //
                    _bit = _df.devNo * _faim3.sect_iDev + _df.Index;           // 内存位

                    _faim3.Comm_Data.bt_in[0][_bit] = _val_3;                  // 还原值

                    #endregion
                }
                else if (_faim3._dim_dict.ContainsKey(_line.vName))
                {
                    #region                               // _dim_dict 动态变量测试
                    _bit = _faim3._dim_dict[_line.vName]; // 内存位 自定义名为下标, 分配地址, 寻址
                    _faim3._dim[_bit] = _val_3;
                    #endregion
                }
                else if (_line.vName.ToUpper().StartsWith("_FAIM3") ||
                         _line.vName.ToUpper().StartsWith("CLSFAIM3"))
                {
                    #region // _FAIM3 大数据
                    F_TransCalc.doSetValue_byName(_faim3, _line.vName, _val_3);
                    #endregion
                }
                #endregion
                #endregion
            }
        }
Beispiel #17
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
            }
        }
Beispiel #18
0
        public static void Init_DictFlow_Dev(ref clsFaim3 _faim3, ref DAL_CommData _dao_comm)
        {
            //'0.isEnable	 1.devNo	  2.Name	 3.cardType	4.card_num	5.port	6.mode	7.BoardID	8.isDebug	9.TryConn	10.thDelay
            // PCI_7432 TCP PCI_7230 204C    RS485 RS232
            //int _idev_debug50 = 50;
            foreach (var item in _faim3.dict_DevCards)
            {
                int _devNo = item.Key;
                if (item.Value.isEnable < 1)
                {
                    continue;                            //
                }
                object _dev1_io = null;                  // 1设备
                object _dog2_io = null;                  // 2看门狗

                object _flow_3 = null;                   // 3流程
                string _Name   = item.Value.Name.Trim(); // 按类别处理

                switch (_Name)
                {
                // 如有流程则会自动打开设备
                case "RS485":
                    _dev1_io = new cls485(_faim3, _dao_comm, _devNo);
                    _dog2_io = new clsDog485(_faim3, _dao_comm, _devNo);
                    if (item.Value.thDelay > 0)        // 有流程延时参数

                    {
                        _flow_3 = new clsWhile485(_faim3, _dao_comm, _devNo.ToString());
                    }
                    break;

                case "RS232":
                    _dev1_io = new clsSP(_faim3, _dao_comm, _devNo);
                    _dog2_io = new clsDogSP(_faim3, _dao_comm, _devNo);
                    break;

                case "TCP":
                    _dev1_io = new clsTCP(_faim3, _dao_comm, _devNo);
                    _dog2_io = new clsDogTcp(_faim3, _dao_comm, _devNo);
                    if (item.Value.thDelay > 0)        // 有流程延时参数
                    {
                        _flow_3 = new clsWhileTcp(_faim3, _dao_comm, _devNo.ToString());
                    }
                    break;

                case "PCI_7230":
                    _dev1_io = new cls7230(_faim3, _dao_comm, _devNo);
                    _dog2_io = new clsDog72x(_faim3, _dao_comm, _devNo);
                    if (item.Value.thDelay > 0)        // 有流程延时参数

                    {
                        _flow_3 = new clsWhile74x(_faim3, _dao_comm, _devNo.ToString());
                    }
                    break;

                case "PCI_7432":
                    _dev1_io = new cls7432(_faim3, _dao_comm, _devNo);
                    _dog2_io = new clsDog72x(_faim3, _dao_comm, _devNo);
                    if (item.Value.thDelay > 0)        // 有流程延时参数

                    {
                        _flow_3 = new clsWhile74x(_faim3, _dao_comm, _devNo.ToString());
                    }
                    break;

                case "204C":
                    _dev1_io = new cls204C(_faim3, _dao_comm, _devNo);
                    _dog2_io = new clsDog204C(_faim3, _dao_comm, _devNo);
                    if (item.Value.thDelay > 0)        // 有流程延时参数

                    {
                        _flow_3 = new clsWhile204(_faim3, _dao_comm, _devNo.ToString());
                    }
                    break;
                }
                if (_dev1_io != null)
                {
                    // dict_DevIo 设备字典
                    if (!_dao_comm.dict_DevIo.ContainsKey(_devNo.ToString()))
                    {
                        _dao_comm.dict_DevIo.Add(_devNo.ToString(), (IFaimIO)_dev1_io);
                    }
                }
                if (_dog2_io != null)
                {
                    //dict_Flow 看门狗 流程字典
                    if (!_faim3.dict_Flow.ContainsKey("d_" + item.Value.devID)) // 使用设备ID,而不是设备号
                    {
                        clsFlow _en = new clsFlow();
                        _en.FlowName = "d_" + item.Value.devID;
                        _en.Remark   = "d_" + item.Value.devID;
                        _en.Delay    = item.Value.dogDelay;
                        _faim3.dict_Flow.Add(_en.FlowName, _en); // 加入到流程字典中
                    }
                }
                // 重复
                if (_flow_3 != null)
                {
                    // dict_Flow 流程字典
                    if (!_faim3.dict_Flow.ContainsKey(item.Value.devID))
                    {
                        clsFlow _en = new clsFlow();
                        _en.FlowName = item.Value.devID;  //  使用的是设备ID
                        _en.Remark   = item.Value.devID;
                        _en.Delay    = item.Value.thDelay;
                        _faim3.dict_Flow.Add(_en.FlowName, _en); // 加入到流程中
                    }
                }
            }
        }
Beispiel #19
0
        // 产生按钮流程及脚本

        public static void doCreateButton(ref clsFaim3 _faim3, ref DAL_CommData _dao_comm, string[] Lines)
        {
            string _btnName = "DAL_Buttons";

            #region           // clsDevTestBits
            List <clsDevTestBits> _lst = _faim3.dict_DevTestBits[_btnName];
            if (_lst != null) //
            {
                int i = 0;
                for (i = 0; i < Lines.Length; i++)
                {
                    string _cmd = Lines[i].Trim();
                    if (string.IsNullOrEmpty(_cmd))
                    {
                        continue;
                    }

                    if (_cmd.IndexOf(',') < 0)
                    {
                        _cmd = _cmd.Replace(" ", ",");
                        _cmd = _cmd.Replace(",,,", ",,"); // 不存在3个,
                    }

                    if (_cmd.IndexOf(',') > -1)
                    {
                        // 有, 按, 处理, 忽略所有的空格
                        string[] _arr_2 = _cmd.Split(',');
                        if (_arr_2.Length > 0)
                        {
                            if (_arr_2.Length > 0)
                            {
                                _lst[i].IfType = _arr_2[0].Trim();                   //  "O U T";
                            }
                            if (_arr_2.Length > 1)
                            {
                                _lst[i].vName = _arr_2[1].Trim();// "1DO_9";
                            }
                            else
                            {
                                _lst[i].vName = "";
                            }
                            if (_arr_2.Length > 2)
                            {
                                _lst[i].HL = _arr_2[2].Trim();// "1";
                            }
                            else
                            {
                                _lst[i].HL = "";
                            }
                            if (_arr_2.Length > 3)
                            {
                                _lst[i].Reset = _arr_2[3].Trim();// "1";
                            }
                            else
                            {
                                _lst[i].Reset = "";
                            }
                        }
                    }
                    else
                    {
                        string[] _arr_1 = _cmd.Split(' ');
                        if (_arr_1.Length > 0)
                        {
                            if (_arr_1.Length > 0)
                            {
                                _lst[i].IfType = _arr_1[0].Trim();//  "O U T";
                            }
                            if (_arr_1.Length > 1)
                            {
                                _lst[i].vName = _arr_1[1].Trim();// "1DO_9";
                            }
                            else
                            {
                                _lst[i].vName = "";
                            }

                            if (_arr_1.Length > 2)
                            {
                                _lst[i].HL = _arr_1[2].Trim();// "1";
                            }
                            else
                            {
                                _lst[i].HL = "";
                            }

                            if (_arr_1.Length > 3)
                            {
                                _lst[i].Reset = _arr_1[3].Trim();// "1";
                            }
                            else
                            {
                                _lst[i].Reset = "";
                            }
                        }
                    }
                }
                for (int j = i; j < _lst.Count; j++)
                {
                    _lst[j].IfType = "NOP"; //  "NOP";
                    _lst[j].vName  = "0";   // "1DO_9";
                    _lst[j].HL     = "";    // "1";
                    _lst[j].Reset  = "";    // "1";
                }
            }
            #endregion
            if (string.IsNullOrEmpty(_btnName))
            {
                return;
            }
            if (!_faim3.dict_Threads.ContainsKey(_btnName))
            {
                clsFlow _flow = _faim3.dict_Flow[_btnName];
                if (_flow.nextCase.ToUpper() != "FREE")// 已打开过

                {
                    clsTool_ASM.doCreateInstance(_faim3, _dao_comm, _btnName);
                }
            }
        }
Beispiel #20
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++;   // 此行使用的次数
        }
Beispiel #21
0
        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();                //结束计时
        }
Beispiel #22
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;
        }
Beispiel #23
0
 void Set_Flow(string vFlowName)
 {
     _flowName     = vFlowName;
     _flow         = _faim3.dict_Flow[_flowName];
     txt_flow.Text = _flow.Remark;
 }