示例#1
0
        } = 3;                                            //
        #region 客户端管理器初始化
        public void Initialize()
        {
            // 导入client
            string path = Path.Combine(PathManager.Instance.GetSettingsPath(), ClientConfigFileName);

            if (File.Exists(path))
            {
                LoadClientFromXmlFile(path);
            }
            else
            {
                _cmmSvrConfigs = new List <CmmServerConfig>();
            }
            // 循环初始化client
            foreach (var config in CmmSvrConfigs)
            {
                CmmClient client = new CmmClient(config);
                client.IsActived = true;
                //client.InitClient(); //
                // 更新UI界面
                ClientUICommon.AddCmmToView(config, client.State);

                _cmmClients.Add(client);
            }
            // 设置心跳信号
            PlcClient.Instance.DisconnectEvent += Plc_DisconnectEvent;
            PlcClient.Instance.ReconnectEvent  += Plc_ReconnectEvent;
            _heartbeatTimer.Start();
        }
示例#2
0
 /// <summary>
 /// 添加客户端
 /// </summary>
 /// <param name="csConf"></param>
 /// <returns>返回false表示客户端已存在,返回true添加成功</returns>
 public bool AddClient(CmmServerConfig csConf)
 {
     // 判断机器是否已经存在
     if (_cmmSvrConfigs.Where(cl => cl.HostIPAddress.Equals(csConf.HostIPAddress)).Count() == 0 && _cmmSvrConfigs.Where(cl => cl.ServerID == csConf.ServerID).Count() == 0)
     {
         _cmmSvrConfigs.Add(csConf); //  添加机器配置信息
         CmmClient client = new CmmClient(csConf);
         client.IsActived = true;
         //client.InitClient(); // 添加client时不做初始化
         _cmmClients.Add(client);
         //
         ClientUICommon.AddCmmToView(csConf, client.State);
         return(true);
     }
     return(false);
 }
示例#3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //PathConfig ptcnf = new PathConfig();
            PathManager.Instance.RootPath         = @"D:\clientPathRoot";
            PathManager.Instance.PartProgramsPath = @"Progs";
            PathManager.Instance.BladesPath       = @"blades";
            PathManager.Instance.ReportsPath      = @"Results";
            //PathManager.Instance.Configration = ptcnf;

            PartConfig prcnf = new PartConfig();

            prcnf.PartID       = "TestPart";
            prcnf.ProgFileName = "1.prg";
            prcnf.FlvFileName  = "blade5.flv";
            prcnf.NormFileName = "blade5.nom";
            prcnf.TolFileName  = "blade5.tol";
            PartConfigManager.Instance.InitPartConfigManager(/*@"d:\clientPathRoot\parts.xml"*/);
            PartConfigManager.Instance.AddPartConfig(prcnf);
            PartConfigManager.Instance.SavePartConfigToXml(@"d:\clientPathRoot\parts.xml");
            _cmmClient = new CmmClient(serverCnf);
            _cmmClient.InitClient();
        }