private void AddClientView(CmmServerConfig arg1, ClientState arg2) { ClientUICommon.syncContext.Post(o => { CmmDataRecord cmmRecord = new CmmDataRecord(arg1, true, arg2); cmmRecordList.Add(cmmRecord); }, null); }
/// <summary> /// </summary> /// <param name="cmmSvrConfig">服务器配置,包括IP地址,端口号等</param> public CmmClient(CmmServerConfig cmmSvrConfig) { CmmSvrConfig = cmmSvrConfig; State = ClientState.CS_None; _connected = false; PlcClient.Instance.DisconnectEvent += Plc_DisconnectEvent; PlcClient.Instance.ReconnectEvent += Plc_ReconnectEvent; }
public Form1() { InitializeComponent(); serverCnf = new CmmServerConfig(); serverCnf.HostIPAddress = "localhost"; serverCnf.ControlPost = 6666; serverCnf.PartConfigPost = 7777; serverCnf.ServerID = 1; }
public IPartConfigService GetPartConfigService(CmmServerConfig clientInfo) { //int servicePort = 9000 + clientInfo._machineId; // 端口 string serviceUri = @"net.tcp://" + clientInfo.HostIPAddress + ":" + clientInfo.PartConfigPost.ToString() + @"/partconfigservice"; IPartConfigService fileServiceProxy = null; fileServiceProxy = PartConfigServiceFactory.CreateChannel(new EndpointAddress(serviceUri)); return(fileServiceProxy); }
public CmmDataRecord(CmmServerConfig conf, bool active, ClientState state) { IsActived = active; ServerID = conf.ServerID; ServerName = "三坐标 " + ServerID.ToString(); IPAddress = conf.HostIPAddress; _state = state; IsFault = (state == ClientState.CS_Error) ? true : false; //State = cmmStateInfo[state]; }
/// <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); }
private void addCmmTsb_Click(object sender, EventArgs e) { CmmForm cf = new CmmForm(); if (cf.ShowDialog() == DialogResult.OK) { CmmServerConfig csConf = new CmmServerConfig(); csConf.HostIPAddress = cf.IpAddress; csConf.ServerID = cf.ServerID; if (!ClientManager.Instance.AddClient(csConf)) { MessageBox.Show("测量机已存在."); } } }
/// <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); }