Exemplo n.º 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 + "服务成功");
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }