Exemplo n.º 1
0
        // 线程名/流程名/设备ID, 忽略返回值

        protected int do_New(clsFaim3 v_faim3, DAL_CommData v_dao_comm, string vflowName)
        {
            _faim3    = v_faim3;
            _dao_comm = v_dao_comm;
            // 无流程名, 则取类名
            _flowName = (string.IsNullOrEmpty(vflowName)) ? this.GetType().Name : vflowName;
            #region                                         // dict_Threads 线程池

            if (_faim3.dict_Threads.ContainsKey(_flowName)) // 存在key
            {
                FACC.F_Log.Debug_1("do_New()", string.Format("--->>>> {0}流程/设备存在", _flowName));
                return(-1);                  //
            }
            clsThread _en = new clsThread(); // 线程消息
            _en.Info          = new clsThreadInfo();
            _en.Name          = _flowName;
            _en.Info.flowName = _flowName;
            // 专用线程代理   dict_Threads.Add
            _en.Del = new System.Threading.ThreadStart(do_Sub_While); // 实例化代理

            _faim3.dict_Threads.Add(_flowName, _en);
            #endregion
            F_Log.Debug_1("do_New()", string.Format("初始化 流程:{0}", _flowName));
            return(0);
        }
Exemplo n.º 2
0
        bool doPartA(clsFaim3 v_faim3, DAL_CommData v_dao_comm, string vflowName)
        {
            string  _cls_Name = "DAL_PartA";
            clsLogs _logs     = new clsLogs();
            clsFlow _flow     = v_faim3.dict_Flow[vflowName];
            string  _currCase = _flow.nextCase;

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

            if ((_en_State.Times > 0))                                                            // 逻辑模型: 执行次数至少有一次, 如 <1, 则不执行AR(),  只执行判断, 以实现流程在等待联动消息的逻辑
            {
                F_Delegate.delCasePartA_R _doPartA = _dao_comm.dict_Methods.doPartA_R[_currCase]; // 通过代理, 从步骤集中取出一个步骤, 执行其方法()
                //
                _logs.No   = v_faim3.dict_CaseState[_currCase].No;
                _logs.Name = _currCase;
                _flow.RunLog.Add(_logs);
                _doPartA(v_faim3, v_dao_comm);
                // AR
                // Delay
                if ((_en_State.Delay > -1))//
                {
                    Thread.Sleep(_en_State.Delay);
                }
                //
            }
            if (string.IsNullOrEmpty(_en_State.No))//逻辑模型:  无BT报警号 检测的步骤, 只执行 AR(), 不执行AR(), 实现两个 AR() 串联(直通)的逻辑
            {
                doGet_NextCase(_faim3, ref _flow, _currCase);
            }
            else
            {
                // 逻辑模型:  无BT报警号 无报警延时, 只执行 AR(), 不执行AR(), 实现两个 AR() 串联(直通)的逻辑
                string _testCase = (_currCase + F_Const.fix_CaseT);
                if (_flow.nextCase == _flow.currCase)
                {
                    _flow.alartCase = _currCase;
                    _flow.nextCase  = _testCase; // ==> Test  当前流程名 + _T
                    F_Log.Debug_1(_cls_Name, String.Format("取到 测试步骤名:{0}", _flow.nextCase));
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        // 文件名 / 命名空间 / 类名
        static T doCreateInstance_byFile <T>(string vFn, string nsName, string clsName)
        {
            string _fn = vFn;

            _fn = do_GetFullFileName(_fn);
            if (!File.Exists(vFn))
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("--->>>> 02 不存在 文件_{0}", vFn));
                return(default(T));
            }
            string _name = nsName + "." + clsName;

            return(do_CreateInstance_byFile <T>(_name, _fn));
        }
Exemplo n.º 4
0
        static string do_GetFullFileName(string vFn)
        {
            string _rec = vFn;

            if (!vFn.Contains(":"))
            {
                _rec = AppDomain.CurrentDomain.BaseDirectory + vFn;
            }
            if (!File.Exists(vFn))
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("--->>>> 03 不存在 文件_{0}", vFn));
                return(null);
            }
            return(_rec);
        }
Exemplo n.º 5
0
        //protected void btOUT(int vDevNo, int vBit)
        //{
        //    doSend(_faim3, vDevNo, vBit, (eHL)(vBit > 0 ? 1 : 0), _sect_iDev);
        //}
        //'计划中取下一流程名, 用于一步延时后进行下一步
        //'直接以值正(1)/负(0)决定输出1/0  _do2_AR(_devNo, 6, eSwitch.On)
        //protected void doSend(int vDevNo, int vBit, eHL val)
        //{
        //    btOUT(_faim3, vDevNo, vBit, val, _sect_iDev);
        //}
        //'直接以位置正(1)/负(0)决定输出1/0  _do2_AR(_devNo, -6)
        public static void doGet_NextCase(clsFaim3 _faim3, ref clsFlow _flow, string vCaseName)
        {
            string _alartCase = _flow.alartCase;
            //if (_faim3.dict_CaseState.ContainsKey(_alartCase)) return;  //
            clsCaseState _caseState = _faim3.dict_CaseState[_alartCase];

            if (_flow.dictCases.ContainsKey(vCaseName))
            {
                _caseState.endMode = eCaseFlag.Next;
                _flow.nextCase     = _flow.dictCases[vCaseName].nextCase;
            }
            else// '流程结束
            {
                F_Log.Debug_1("DAL_Part", String.Format("--->>>> {0} 没有指定下一个步骤名", vCaseName));
                _caseState.endMode = eCaseFlag.Exist;
                _flow.nextCase     = "Free";
            }
        }
Exemplo n.º 6
0
        // from : file  命名空间.类名 / faim3 / dao / new(形参:用户类名)
        static T do_CreateInstance_byName_Para <T>(string vName, clsFaim3 v_faim3, DAL_CommData v_dao_comm, string userClassName)
        {
            object obj = null;
            Type   vT  = Type.GetType(vName);

            obj = Activator.CreateInstance(
                vT,
                new object[] { v_faim3, v_dao_comm, userClassName });
            T _en = (T)obj;//

            if (_en == null)
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("--->>>> 04 未创建对象_{0} {1}", vName, userClassName));
            }
            else
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("成功创建对象_{0}", _en.GetType().Name));
            }
            return(_en);
        }
Exemplo n.º 7
0
        static T do_CreateInstance <T>(
            string vFn, string vName,
            clsFaim3 vFaim3, string userClassName)
        {
            if (!File.Exists(vFn))
            {
                return(default(T));
            }
            byte[]   _buf = File.ReadAllBytes(vFn);
            Assembly _asm = Assembly.Load(_buf);

            //Assembly _asm = Assembly.LoadFrom(vFile);
            object obj = null;

            if (string.IsNullOrEmpty(userClassName))
            {
                obj = _asm.CreateInstance(vName, false);
            }
            else
            {
                Type vT = Type.GetType(vName);
                obj = Activator.CreateInstance(
                    vT,
                    new object[] { vFaim3, userClassName });
            }
            T _en = (T)obj;//

            if (_en == null)
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("!! 未创建对象_{0}", vName));
            }
            else
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("成功创建对象_{0}", _en.GetType().Name));
            }

            return(_en);
        }
Exemplo n.º 8
0
        // 文件名.命名空间 / 类名
        static T do_CreateInstance_byFile <T>(string vName, string vFn)
        {
            if (!File.Exists(vFn))
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("--->>>> 05 文件不存在_{0}{1}", vName, vFn));
                return(default(T));
            }
            byte[]   _buf = File.ReadAllBytes(vFn);
            Assembly _asm = Assembly.Load(_buf);
            object   obj  = null;

            obj = _asm.CreateInstance(vName, false);
            T _en = (T)obj;//

            if (_en == null)
            {
                F_Log.Debug_1("clsTool_ASM", string.Format("--->>>> 06 未创建对象_{0}{1}", vName, vFn));
                System.Windows.Forms.MessageBox.Show(string.Format("--->>>> 06 未创建对象_{0}{1}", vName, vFn));
            }
            //else
            //    F_Log.Debug_1("clsTool_ASM", string.Format("成功创建对象_{0}", _en.GetType().Name));
            return(_en);
        }
Exemplo n.º 9
0
        static void __NG(clsFaim3 _faim3, DAL_CommData _dao_comm, string _flowName, string _caseName)
        {
            if (_flowName == "DAL_Buttons")
            {
                return;
            }
            clsFlow _flow      = _faim3.dict_Flow[_flowName];
            string  _alartCase = _flow.alartCase;
            //if (!_faim3.dict_CaseState.ContainsKey(_alartCase)) return;  //
            clsCaseState _caseState = _faim3.dict_CaseState[_alartCase];
            Dictionary <string, clsCaseChildInfo> _dictCaseChildInfo = _caseState.dict_CaseChildInfo;

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

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

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

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

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

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

            _bl_BT = (_bl_BT & _doPartB_T(v_faim3, v_dao_comm));     // 测试 TEST
            if ((_flow.Tag == "GOTO_ABS" || _flow.Tag == "GOTO_NG")) //
            {
                _flow.Tag      = "";
                _flow.stepCase = _flow.currCase;
                return;
            }
            else if ((_flow.Tag == "GOTO_OTHER"))//
            {
                _flow.Tag = "";
                List <string> _otherCase = _flow.dictCases[_alartCase].otherCase;
                if (_otherCase.Contains(_alartCase))// 若 自定义列表包括了当前步骤名, 如何处理???
                {
                    return;
                }
            }
            else if ((_flow.Tag == "ALAR_ON_NG"))
            {
                _flow.Tag         = "";
                _enAlarm.AlarmDrv = eSwitch.On;
                _enAlarm.AlarmIs  = true;  // OnAlarm(this);
                //
                return;
            }
            else if ((_flow.Tag == "ALAR_OFF_NG"))//
            {
                _flow.Tag         = "";
                _enAlarm.AlarmDrv = eSwitch.Off;
                //
                _enAlarm.AlarmIs = false;   // OnAlarm(this);
                return;
            }
            //
            if ((_bl_BT && !_enAlarm.AlarmIs))//
            {
                //
                _caseState.Result = "";
                _enAlarm.DelayT1  = 0;
                _enAlarm.DelayT2  = 0;
                _flow.NGtimes     = 0;
                doGet_NextCase(_faim3, ref _flow, _alartCase);
                F_Log.Debug_1(_cls_Name, (_alartCase + " BT(1)"));
            }
            else
            {
                //
                if (!_enAlarm.AlarmIs)// 没报警
                {
                    //
                    _enAlarm.DelayT1++;
                    if (_enAlarm.DelayT1 > _enAlarm.maxDelay1)//  第一圈
                    {
                        _enAlarm.DelayT1 = 0;
                        _enAlarm.DelayT2++;
                        if (_enAlarm.DelayT2 > _enAlarm.maxDelay2)// 第二圈 时间到
                        {
                            _enAlarm.DelayT2 = 0;
                            if (_enAlarm.maxDelay2 == 0)//
                            {
                                if (_flow.dictCases.ContainsKey(_alartCase))
                                {
                                    _caseState.endMode = eCaseFlag.NG;
                                    _flow.nextCase     = v_faim3.dict_CaseAlarm[_alartCase].excpCase;
                                }
                                else
                                {
                                    F_Log.Debug_1(_cls_Name, string.Format("--->>>> {0} 没有指定下一个方法名", _alartCase));
                                    _caseState.endMode = eCaseFlag.Exist;
                                    _flow.nextCase     = "Free";//流程结束
                                }
                                return;
                            }
                            else if (_enAlarm.maxDelay2 > 0)
                            {
                                _enAlarm.AlarmIs  = true;
                                _enAlarm.AlarmDrv = eSwitch.On;// 报警灯亮
                                //
                            }
                        }
                    }
                }
                else if (_enAlarm.AlarmIs)//
                {
                    //
                    if (!string.IsNullOrEmpty(_enAlarm.dlgMessage))//
                    {
                        string _title = (_enAlarm.RemarkA + ",请确认忽略异常!");
                        if ((_enAlarm.dlgMessage.Length > 6))
                        {
                            _title = _enAlarm.dlgMessage;
                        }
                        //
                        DialogResult _dlg = MessageBox.Show(_enAlarm.dlgMessage, "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                        if ((_dlg == DialogResult.OK))//逻辑模型:  人工出口, 有报警 忽略异常
                        {
                            //
                            F_Delegate.delCasePartB_R _doPart_BR = v_dao_comm.dict_Methods.doPartB_R[_alartCase];
                            //  测试 RUN
                            _doPart_BR(v_faim3, v_dao_comm);
                            //
                            System.Threading.Thread.Sleep(_enAlarm.DelayB);
                            if (_flow.dictCases.ContainsKey(_alartCase))
                            {
                                _caseState.endMode = eCaseFlag.NG;
                                _flow.nextCase     = v_faim3.dict_CaseAlarm[_alartCase].excpCase;
                            }
                            else
                            {
                                F_Log.Debug_1(_cls_Name, string.Format("--->>>> {0} 没有指定下一个方法名", _alartCase));
                                _caseState.endMode = eCaseFlag.Exist;
                                _flow.nextCase     = "Free";//流程结束
                            }
                            _enAlarm.AlarmIs  = false;
                            _enAlarm.AlarmDrv = eSwitch.Off;//报警灯灭
                        }
                    }
                    else if (_bl_BT)//逻辑模型:  成功出口, 有报警
                    {
                        _caseState.Result = "";
                        _enAlarm.DelayT1  = 0;
                        _enAlarm.DelayT2  = 0;
                        _flow.NGtimes     = 0;
                        _enAlarm.AlarmIs  = false;
                        _enAlarm.AlarmDrv = eSwitch.Off;//报警灯灭
                        doGet_NextCase(_faim3, ref _flow, _alartCase);
                        F_Log.Debug_1(_cls_Name, (_alartCase + " BT(2)"));
                    }
                }
            }
            return;
        }
Exemplo n.º 11
0
        static int getSendData(clsFaim3 _faim3, string vCmdName, string vHL, string vReset)
        {
            int _devNo = -1;

            if (_faim3.dict_CmdFormats.ContainsKey(vCmdName))
            {
                _devNo = Convert.ToInt32(_faim3.dict_CmdFormats[vCmdName].devNo);//[0] cfgCmdFormat.xls
            }
            else if (_faim3.dict_DevFunction.ContainsKey(vCmdName))
            {
                _devNo   = _faim3.dict_DevFunction[vCmdName].devNo;//[0] cfgDev_Function.xls
                vCmdName = _faim3.dict_DevFunction[vCmdName].varName;
            }
            else
            {
                F_Log.Error_4("clsProtocol.getSendData()",
                              string.Format(" --->>>> 此命令不存在 {0} {1} {2}", vCmdName, vHL, vReset));
                return(-1); //没有此命令 模板
            }
            int           _ref_1i    = _faim3.sect_iDev * _devNo;
            int           _ref_1s    = _faim3.sect_sDev * _devNo + _faim3.sect_sDev_start;
            string        _str_HL    = "   ";
            string        _str_Reset = "   ";
            int           _val_HL    = F_TransCalc._Get_Value_2(_faim3, vHL, ref _str_HL);
            int           _val_Reset = F_TransCalc._Get_Value_2(_faim3, vReset, ref _str_Reset);
            clsCommonInfo _en        = null;

            if (_val_Reset > 0)
            {
                if (_faim3.dict_CommonInfo.ContainsKey(_val_Reset)) // 可能是表值 tb_CommonInfo.xls
                {
                    _en = _faim3.dict_CommonInfo[_val_Reset];
                }
            }

            switch ((eDeviceName)_devNo)
            {
            case eDeviceName.RS485_6:
                #region          // RS485_6
                if (_en != null) // 有表值 tb_CommonInfo.xls
                {
                    #region      // SeekHome Home_Dir
                    switch (vCmdName)
                    {
                    case "SeekHome":
                        SeekHome _SeekHome = _faim3._SeekHome;
                        _SeekHome.v02.OutputNum = F_Parse._ConverToInt(clsFaim3.StringFormat(_faim3, _en.val_01));
                        _SeekHome.v03.Condition = F_Parse._ConverToInt(clsFaim3.StringFormat(_faim3, _en.val_02));
                        break;

                    case "Home_Dir":
                        Home_Dir _Home_Dir = _faim3._Home_Dir;
                        _Home_Dir.v02.Acc      = F_Parse._ConverToDouble(clsFaim3.StringFormat(_faim3, _en.val_01));
                        _Home_Dir.v03.Dec      = F_Parse._ConverToInt(clsFaim3.StringFormat(_faim3, _en.val_02));
                        _Home_Dir.v04.Vel      = F_Parse._ConverToDouble(clsFaim3.StringFormat(_faim3, _en.val_03));
                        _Home_Dir.v05.Location = F_Parse._ConverTofloat(clsFaim3.StringFormat(_faim3, _en.arr_01[0]));
                        _Home_Dir.v06.Location = F_Parse._ConverTofloat(clsFaim3.StringFormat(_faim3, _en.arr_01[1]));
                        break;
                    }
                    #endregion
                }
                clsProt485 _485 = new clsProt485(_faim3);
                _485.Out_Ready(vCmdName, _val_HL);       // 485 对象
                break;

                #endregion
            case eDeviceName.TCP_5:
            case eDeviceName.TCP_8:
            case eDeviceName.TCP_9:
                string _Format2 = _faim3.dict_CmdFormats[vCmdName].Format;    //[2]; 模板
                //clsRobot_AZ _az = new clsRobot_AZ(_faim3);
                List <string> _lstPara = new List <string>();
                if (_val_HL != -999)
                {
                    // $GetVariable,{0}&CrLf
                    if (!string.IsNullOrEmpty(vHL))
                    {
                        _lstPara.Add(vHL);
                    }
                }
                else if (_str_HL != "   ")
                {
                    if (!string.IsNullOrEmpty(vHL))
                    {
                        _lstPara.Add(_str_HL);
                    }
                }
                if (_en != null)     // 有表值

                {
                    // J Point {0} {1} {2} {3}
                    if (!string.IsNullOrEmpty(_en.val_01))
                    {
                        _lstPara.Add(clsFaim3.StringFormat(_faim3, _en.val_01));
                    }
                    if (!string.IsNullOrEmpty(_en.val_02))
                    {
                        _lstPara.Add(clsFaim3.StringFormat(_faim3, _en.val_02));
                    }
                    if (!string.IsNullOrEmpty(_en.val_03))
                    {
                        _lstPara.Add(clsFaim3.StringFormat(_faim3, _en.val_03));
                    }
                    if (!string.IsNullOrEmpty(_en.arr_1))
                    {
                        _lstPara.Add(clsFaim3.StringFormat(_faim3, _en.arr_1));
                    }
                    if (!string.IsNullOrEmpty(_en.arr_2))
                    {
                        _lstPara.Add(clsFaim3.StringFormat(_faim3, _en.arr_2));
                    }
                    if (!string.IsNullOrEmpty(_en.arr_3))
                    {
                        _lstPara.Add(clsFaim3.StringFormat(_faim3, _en.arr_3));
                    }
                }
                _faim3._sss[_ref_1s] = "";      // 非标准二进制字节码



                string _cmd = F_TransCalc.StringFormat(_Format2, _lstPara);
                _faim3._sss[_ref_1s + _faim3.snd_sAsc] = _cmd;         //

                string _Echo4 = _faim3.dict_CmdFormats[vCmdName].Echo; //[4]; 反馈
                _faim3._sss[_ref_1s + _faim3.test_sLoc] = _Echo4;

                break;
            }
            return(_devNo);
        }
Exemplo n.º 12
0
        protected override void do_While(string vFlowId)
        {
            //int _loc = 0;
            _bl = true;
            #region                            // _flow 初始化

            _flow.currCase = _flow.firstCase;  // 恢复 第1步

            _flow.alartCase = _flow.firstCase; // 恢复
            //if (_faim3.dict_CaseState.ContainsKey(_flow.alartCase))
            //{
            clsCaseState _caseState = _faim3.dict_CaseState[_flow.alartCase];
            _caseState.beginMode = eCaseFlag.Next;
            _caseState.endMode   = eCaseFlag.Next;
            //}
            _flow.nextCase = _flow.firstCase;
            _flow.lastCase = "Free";
            _flow.stepCase = "Free";  // 初始化单步的步骤名

            _flow.breakSkipCase = ""; // 断点无效的步骤名
            _flow.times        += 1;  // 累加, 显示流程 启动的次数

            _flow.Tag     = "";
            _flow.NGtimes = 0;
            #endregion
            #region // 日志 1 2
            F_Log.Debug_1(this.GetType().Name, String.Format("*** 流程开始:{0}.{1}, 状态:{2}, 计数:{3} ***",
                                                             vFlowId,
                                                             _flow.currCase,
                                                             _flow.eState.ToString(),
                                                             _flow.times));
            // 日志 2
            clsLogs _logs2 = new clsLogs();
            _logs2.No   = _flow.currCase;
            _logs2.Name = "*** " + _flow.currCase + " _开始";
            _flow.RunLog.Add(_logs2);                                // 累加, 内存日志
            #endregion
            #region                                                  // 流程条件
            clsThreadInfo _ti = _faim3.dict_Threads[vFlowId].Info;
            _ti.allowWhile    = eSwitch.Yes;                         //控制流程之1, 线程终止  false
            _ti.allowBusiness = eSwitch.No;                          // 控制流程之2 业务等待/暂停
            System.Diagnostics.Stopwatch _tmr = do_th_Name_pre(_ti); // 计时
            #endregion
            _faim3.dict_Threads[_flowName].Info.tmr_real = 0;        // 当前步骤 实际占用总时长



            #region                                           // while
            while (((int)_ti.allowWhile == (int)eSwitch.Yes)) // 允许线程运行 1
            {
                #region                                       // break
                // 急停
                if (_faim3.isEmergency > 0)
                {
                    _flow.eState      = eWF_State.Emergency;
                    _ti.allowWhile    = eSwitch.No;
                    _ti.allowBusiness = eSwitch.No;
                    break;
                }
                // 最后一步


                if (_flow.nextCase.ToUpper() == "FREE")
                {
                    break;// 结束流程
                }
                #endregion
                #region                     // continue
                // 暂停
                if (!do_allowBusiness(_ti)) //_flow.eState = eWF_State.Wait;
                {
                    continue;               // 线程延时+ 业务是否允许 流程信息 2
                }
                if (do_NG_hasTimes())
                {
                    continue; //_flow.currCase
                }
                #endregion
                // 显示执行后的 curr
                //_dao_comm_set_arr_str800();
                //string _caseName_old = _flow.currCase;
                clsCaseState _caseState_old = _faim3.dict_CaseState[_flow.alartCase];
                _flow.currCase = _flow.nextCase;  // 准备执行下一步, 即将下一步设为当前步骤


                if (_flow.currCase.EndsWith(F_Const.fix_CaseT)) // “_T”, 测试步骤
                {
                }
                else
                {
                    _flow.alartCase = _flow.currCase; // 非测试步骤


                    clsCaseState _caseState_new = _faim3.dict_CaseState[_flow.alartCase];
                    if (_caseState_new.beginMode == eCaseFlag.Free)
                    {
                        _caseState_new.beginMode = _caseState_old.endMode;
                    }
                    //if (_caseName_old.EndsWith(F_Const.fix_CaseT)) // “_T”, 测试步骤
                    //    _caseState_new.beginMode = eCaseFlag.TT;
                    //else
                }
                //_dao_comm_set_arr_str800();
                // 指定预执行的 curr
                do_WaitBreak();
                do_WaitStep();

                _flow.caseTimes++; // 累加, 显示步骤 通过的次数


                // 状态为运行中


                _flow.eState = eWF_State.Running;
                long _trm_begin = _tmr.ElapsedMilliseconds;                    // 毫秒
                _ti.caseName = _flow.currCase;
                if (_dao_comm.dict_Methods.doCase.ContainsKey(_flow.currCase)) // 条件:Case名存在,XX() 或 XX_T()
                {
                    if (!_flow.currCase.EndsWith(F_Const.fix_CaseT))           // 条件:无“_T”, 则新步骤开始, 先找到该配置文档的行号
                    {
                        _ti.cnt_business++;                                    // Case完成数


                        // 发消息, 上一步骤信息和本步骤位置
                        doGet_CmdLineStart(_flow.currCase, ref _faim3);                          // 预处理 分解Case的各语法结构
                    }
                    #region                                                                      // 流程代码 代理1   Switch  &  Select Case
                    F_Delegate.delCase _delCase = _dao_comm.dict_Methods.doCase[_flow.currCase]; //通过代理, 从步骤集中取出一个步骤, 执行其方法()
                    _delCase(_dao_comm, _flow.FlowName);                                         // 执行步骤
                    do_end_CalcTimer(_ti, _tmr, _trm_begin);                                     // 流程信息2
                    #endregion
                    if (_flow.Delay > -1)
                    {
                        System.Threading.Thread.Sleep(_flow.Delay);
                    }
                }
                else  // 结束 flow
                {
                    _ti.allowWhile = eSwitch.Off;               // 控制流程之2 , 步骤名不存在 无方法


                    _flow.eState = eWF_State.End;
                    FACC.F_Log.Debug_1(this.GetType().Name, String.Format("--->>>> 无 步骤 :{0}.{1}->{2} - 状态:{3}, 计数:{4} ",
                                                                          vFlowId,
                                                                          _flow.lastCase, _flow.currCase,
                                                                          _flow.eState.ToString(),
                                                                          _flow.times));
                }
            }
            #endregion
            do_End_Flow(_ti, _tmr, vFlowId);
        }
Exemplo n.º 13
0
        // 返回待发送数据的绝对位置
        public int Out_Ready(string vCmdName, int vAxisNum)
        {
            int    _ret    = 0;
            string _result = "";

            string[] _names = Enum.GetNames(typeof(eDev485));
            if (Array.IndexOf(_names, vCmdName) > -1)
            {
                #region // 参数 SimpleFormat
                //int _AxisNum = Convert.ToInt32(vAxisNum);
                _result = doSimpleToString(new SimpleFormat()
                {
                    v01_AxisNum = vAxisNum,
                    v00_cmdName = (eDev485)Enum.Parse(
                        typeof(eDev485),
                        vCmdName)
                });
                #endregion
            }
            else
            {
                #region // 对象Home_Dir OutputLine Position_Set_Pos SeekHome SetRegisterSub
                switch (vCmdName)
                {
                case "Home_Dir":
                    _faim3._Home_Dir.v01.AxisNum = vAxisNum;
                    _result = Home_Dir(_faim3._Home_Dir);
                    break;

                case "OutputLine":
                    _faim3._OutputLine.v01.AxisNum = vAxisNum;
                    _result = OutputLine(_faim3._OutputLine);
                    break;

                case "Position_Set_Pos":
                    _faim3._Position_Set_Pos.v01.AxisNum = vAxisNum;
                    _result = Position_Set_Pos(_faim3._Position_Set_Pos);
                    break;

                case "SeekHome":
                    _faim3._SeekHome.v01.AxisNum = vAxisNum;
                    _result = SeekHome(_faim3._SeekHome);
                    break;

                case "SetRegisterSub":
                    _faim3._SetRegisterSub.v01.AxisNum = vAxisNum;
                    _result = SetRegisterSub(_faim3._SetRegisterSub);
                    break;
                }
                #endregion
            }
            #region // 置预发的数据
            int _devNo = -1;
            // 设备号
            if (_faim3.dict_CmdFormats.ContainsKey(vCmdName))
            {
                _devNo = Convert.ToInt32(_faim3.dict_CmdFormats[vCmdName].devNo);//[0] cfgCmdFormat.xls
            }
            else if (_faim3.dict_DevFunction.ContainsKey(vCmdName))
            {
                _devNo = _faim3.dict_DevFunction[vCmdName].devNo;//[0] cfgDev_Function.xls
            }
            else
            {
                F_Log.Error_4("clsProt485.Out_Ready()",
                              string.Format(" --->>>> 设备号不存在 {0} vAxisNum:{1}", vCmdName, vAxisNum));
                return(-1); //没有此命令 模板
            }
            int _ref_1i = _faim3.sect_iDev * _devNo;
            int _ref_1s = _faim3.sect_sDev * _devNo + _faim3.sect_sDev_start; // 偏移位

            string[] _arr  = _result.Split('|');                              // 分解模板
            string   _send = _arr.Length > 1 ? _arr[1] : _arr[0];
            int      _crc  = F_TransCalc.doCRC(_send);                        // AA BB CC DD CRC CRC
            _send = _send + " " + F_TransCalc.doDecToHexs(_crc);
            _faim3._sss[_ref_1s] = _send;                                     // 置 数据部份
            _faim3._sss[_ref_1s + _faim3.snd_sAsc]  = "";                     // 无ASCII, 置空
            _faim3._sss[_ref_1s + _faim3.test_sLoc] = vCmdName;               // 置 发出的命令
            _faim3._sss[_ref_1s + _faim3.snd_sLen]  = "0";                    // 置 长度为空
            #endregion
            _ret = _ref_1s + _faim3.snd_sLen;
            return(_ret);
        }