コード例 #1
0
ファイル: RdcMethod.cs プロジェクト: ZQuanLi/Test
        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 + "服务成功");
            }
        }
コード例 #2
0
ファイル: RdcMethod.cs プロジェクト: ZQuanLi/Test
        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);
            }
        }
コード例 #3
0
ファイル: RdcMethod.cs プロジェクト: ZQuanLi/Test
        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);
        }
コード例 #4
0
ファイル: RdcMethod.cs プロジェクト: ZQuanLi/Test
        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);
        }