Пример #1
0
        public void open()
        {
            #region 加载出对应的设备传感器集合
            string strFactoryId = "G01";
            AddressSets = DataLogHelper.GetPLCAddressSets(strFactoryId, _typeStr);
            #endregion
            //定义需要读取的寄存器数量
            Wrapper.RegCount = Convert.ToInt16(AddressSets.Count());

            Wrapper.Connect();
            try
            {
                _thread = new Thread(Receive)
                {
                    Name = _id.ToString()
                };
                _thread.Start();
                _status    = "服务连接中";
                _isRunning = true;

                ConnectSocketServer();
            }
            catch (Exception ex)
            {
                string errorStr = "[" + _name + "]" + "服务连接失败!" + ex.Message;
                MessageBox.Show(errorStr, "出错了", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }