Exemple #1
0
        private void start()
        {
            if (string.IsNullOrEmpty(ip) || DataPort == 0)
            {
                throw new Exception("地址或端口不能为空");
            }

            if (this.Handle != null)
            {
                RdcFunc.RDC_StopRun(this.Handle.Value);
                RdcFunc.RDC_Close(this.Handle.Value);
            }
            //
            //RdcVar = new RdcFunc.RDC_VarOk(resultVar); //放到业务层上去
            //打开端口
            this.Handle = RdcFunc.RDC_Open(ip, DataPort, RdcVar, 0);
            //开启监听
            //返回值:RDC_OK = 0,RDC_ERR = 1,RDC_ISRUN = 2,RDC_ERRHANDLE = 3
            //RdcFunc.RDC_AddVar(RdcHelper.Handle.Value, "R1001_4710.1AA1.Ua", 2);
            int rest = RdcFunc.RDC_StartRun(this.Handle.Value);

            if (rest != 0)
            {
                throw new Exception("Ip:" + ip + ":" + DataPort + "开启监听错误返回值:" + rest);
            }
            else
            {
                FileLog.WriteLog("启动IOServic:" + ip + ":" + DataPort + "服务成功");
            }
        }
Exemple #2
0
        private static void start()
        {
            if (string.IsNullOrEmpty(ip) || DataPort == 0)
            {
                throw new Exception("地址或端口不能为空");
            }

            if (RdcMethod.Handle != null)
            {
                RdcFunc.RDC_StopRun(RdcMethod.Handle.Value);
                RdcFunc.RDC_Close(RdcMethod.Handle.Value);
            }
            //
            //RdcVar = new RdcFunc.RDC_VarOk(resultVar); //放到业务层上去
            //打开端口
            RdcMethod.Handle = RdcFunc.RDC_Open(ip, DataPort, RdcVar, 0);
            //开启监听
            //返回值:RDC_OK = 0,RDC_ERR = 1,RDC_ISRUN = 2,RDC_ERRHANDLE = 3
            //RdcFunc.RDC_AddVar(RdcHelper.Handle.Value, "R1001_4710.1AA1.Ua", 2);
            int rest = RdcFunc.RDC_StartRun(RdcMethod.Handle.Value);

            if (rest != 0)
            {
                throw new Exception("开启监听错误:" + rest);
            }
        }
Exemple #3
0
        public bool Close()
        {
            int rst = -1;

            if (this.Handle != null)
            {
                rst = RdcFunc.RDC_StopRun(this.Handle.Value);
                rst = RdcFunc.RDC_Close(this.Handle.Value);
            }
            this.Handle = null;
            return(rst == 0 ? true : false);
        }
Exemple #4
0
        public static bool Close()
        {
            int rst = -1;

            if (RdcMethod.Handle != null)
            {
                rst = RdcFunc.RDC_StopRun(RdcMethod.Handle.Value);
                rst = RdcFunc.RDC_Close(RdcMethod.Handle.Value);
            }
            RdcMethod.Handle = null;
            return(rst == 0 ? true : false);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }