public void InitClient() { try { _proxyFactory = null; _proxyFactory = new ProxyFactory(this); _cmmCtrl = _proxyFactory.GetCmmControl(CmmSvrConfig); _partConfigService = _proxyFactory.GetPartConfigService(CmmSvrConfig); _IsInitialed = _cmmCtrl.IsInitialed(); // 返回服务器端是否初始化 _connected = true; if (_IsInitialed) { State = ClientState.CS_Idle; string cmmError = string.Format($"三坐标{CmmSvrConfig.ServerID} 初始化成功"); ClientUICommon.RefreshCmmEventLog(cmmError); } else { State = ClientState.CS_InitError; // string cmmError = string.Format($"三坐标{CmmSvrConfig.ServerID}没有初始化"); ClientUICommon.RefreshCmmEventLog(cmmError); } } catch (Exception ex) { _IsInitialed = false; // 初始化不成功 //string cmmError = string.Format($"三坐标{CmmSvrConfig.ServerID} 连接错误"); //_connected = false; //ClientUICommon.RefreshCmmEventLog(cmmError); //State = ClientState.CS_ConnectError; ReportConnectError(ex); } }
/// <summary> /// 获取控制代理端口 /// </summary> /// <param name="_machineId">机器号</param> /// <param name="_ipAddress">IP地址</param> /// <returns></returns> public ICmmControl GetCmmControl(CmmServerConfig csInfo) { //int servicePort = 8000 + clientInfo._machineId; // 端口 string serviceUri = @"net.tcp://" + csInfo.HostIPAddress + ":" + csInfo.ControlPost.ToString() + @"/cmmcontrolservice"; ICmmControl cmmControl = null; cmmControl = CmmControlFactory.CreateChannel(new EndpointAddress(serviceUri)); // 连接回调事件 cmmControl.ConnectWFEvents(); return(cmmControl); }