コード例 #1
0
ファイル: RdcMethod.cs プロジェクト: ZQuanLi/Test
        private bool addVar(List <string> Tags)
        {
            Thread.Sleep(250);
            int rst = RdcFunc.RDC_StopRun(this.Handle.Value);

            if (rst != 0)
            {
                FileLog.WriteLog("停止客户端监控错误:" + rst);
                return(false);
            }
            Thread.Sleep(250);
            int  nDataType = 2;/*默认是2*/
            bool exits     = false;

            /*增加监听的变量*/
            foreach (string tag in Tags)
            {
                rst = RdcFunc.RDC_AddVar(this.Handle.Value, tag, nDataType);
                if (rst == 0)
                {
                    exits = true;
                    //msg = "正在监听...";
                    //Yada.Public.FileLog.WriteLog("变量:" + tag+"监视成功");
                }
                else if (rst == 1)
                {
                    FileLog.WriteLog("变量:" + tag + "监听错误errorcode:" + rst);
                }
                else if (rst == 2)
                {
                    exits = true;
                    //msg = "监听进行中...";
                }
                else if (rst == 3)
                {
                    FileLog.WriteLog("变量:" + tag + "连接接口错误errorcode:" + rst);
                }
                else
                {
                    FileLog.WriteLog("变量:" + tag + "监听未知错误errorcode:" + rst);
                }
            }
            int  i      = 0;
            bool isPass = false;

            while (++i <= 3 && exits == true)
            {
                Thread.Sleep(250);
                rst = RdcFunc.RDC_StartRun(this.Handle.Value);
                if (rst != 0)
                {
                    FileLog.WriteLog("IP:" + this.ip + ":" + this.DataPort + "第" + i.ToString() + "次重新启动Rdc监控错误返回值:" + rst);
                    continue;
                    //return false;
                }
                else
                {
                    isPass = true;
                    break;
                }
            }
            return(isPass);
        }
コード例 #2
0
ファイル: RdcMethod.cs プロジェクト: ZQuanLi/Test
        private static bool addVar(List <string> Tags)
        {
            Thread.Sleep(250);
            int rst = RdcFunc.RDC_StopRun(RdcMethod.Handle.Value);

            if (rst != 0)
            {
                FileLog.WriteLog("停止客户端监控错误:" + rst);
                return(false);
            }
            Thread.Sleep(250);
            int  nDataType = 2;/*默认是2*/
            bool exits     = false;

            /*增加监听的变量*/
            foreach (string tag in Tags)
            {
                rst = RdcFunc.RDC_AddVar(RdcMethod.Handle.Value, tag, nDataType);
                if (rst == 0)
                {
                    exits = true;
                    //msg = "正在监听...";
                    //Yada.Public.FileLog.WriteLog("变量:" + tag+"监视成功");
                }
                else if (rst == 1)
                {
                    FileLog.WriteLog("变量:" + tag + "监听错误errorcode:" + rst);
                }
                else if (rst == 2)
                {
                    exits = true;
                    //msg = "监听进行中...";
                }
                else if (rst == 3)
                {
                    FileLog.WriteLog("变量:" + tag + "连接接口错误errorcode:" + rst);
                }
                else
                {
                    FileLog.WriteLog("变量:" + tag + "监听未知错误errorcode:" + rst);
                }
            }
            int i = 0;

            while (i < 3 && exits == true)
            {
                ++i;
                Thread.Sleep(250);
                rst = RdcFunc.RDC_StartRun(RdcMethod.Handle.Value);
                if (rst != 0)
                {
                    FileLog.WriteLog("第" + i.ToString() + "重新启动客户端监控错误:" + rst);
                    return(false);
                }
                else
                {
                    break;
                }
            }
            return(true);
        }