コード例 #1
0
ファイル: Commor.cs プロジェクト: jtzhang163/Arthur
        public Result EndConnect()
        {
            var result = new Result();

            if (this.Communicator.CommType == "Serial")
            {
                result = new SerialComm().EndConnect(this);
            }
            else if (this.Communicator.CommType == "OmronFinsTcp")
            {
                result = new OmronFinsTcpComm().EndConnect(this);
            }
            else if (this.Communicator.CommType == "Ethernet")
            {
                result = new EthernetComm().EndConnect(this);
            }
            Connected = false;
            return(Result.Success);
        }
コード例 #2
0
ファイル: Commor.cs プロジェクト: jtzhang163/Arthur
        public Result Write(string addr, ushort value)
        {
            var result = Result.Success;

            if (this.Communicator.CommType == "OmronFinsTcp")
            {
                result = new OmronFinsTcpComm().Write(this, addr, value);
            }
            else
            {
                result = new Result("连接为未知类型!");
            }

            if (result.IsFailed)
            {
                LogHelper.WriteError(string.Format("给 {0} 写数据出现错误: {1}", this.Communicator.Name, result.Msg));
            }
            return(result);
        }
コード例 #3
0
ファイル: Commor.cs プロジェクト: jtzhang163/Arthur
        public Result Connect()
        {
            var result = new Result();

            if (!this.Connected)
            {
                if (this.Communicator.CommType == "Serial")
                {
                    result = new SerialComm().Connect(this);
                }
                else if (this.Communicator.CommType == "OmronFinsTcp")
                {
                    result = new OmronFinsTcpComm().Connect(this);
                }
                else if (this.Communicator.CommType == "Ethernet")
                {
                    result = new EthernetComm().Connect(this);
                }
            }

            this.Connected = result.IsSucceed;
            return(result);
        }