예제 #1
0
        public PLCNode(int id, string ip, int port, string typeStr, string comments, int rate, short startaddress)
        {
            _id           = id;
            _plcip        = ip;
            _port         = port;
            _typeStr      = typeStr;
            _name         = comments;
            _status       = "服务未连接";
            _rate         = rate;
            _startaddress = startaddress;

            Wrapper = ModBusWrapper.CreateInstance(Protocol.TCPIP, ip, port, startaddress);
        }
예제 #2
0
        public static ModBusWrapper CreateInstance(Protocol protocol, string strPLCServerIP, int iPLCServerPort, short startAddress)
        {
            if (_Instance == null)
            {
                switch (protocol)
                {
                case Protocol.TCPIP:
                    _Instance = new ModBusTCPIPWrapper(strPLCServerIP, iPLCServerPort, startAddress);
                    break;

                case Protocol.SerialPort:
                    _Instance = new ModBusSerialPortWrapper(strPLCServerIP, iPLCServerPort, startAddress);
                    break;

                default:
                    break;
                }
            }
            return(_Instance);
        }