/// <summary> /// 连接机床网络 /// </summary> /// <param name="ipr"> /// 机床ip /// </param> /// <param name="ipl"> /// 本地ip /// </param> /// <param name="port"> /// 机床端口 /// </param> /// <returns> /// true:连接成功 /// false:连接失败 /// </returns> public static int start_connect(string ipr, string ipl, UInt16 port) { ipnl = ipl; ipnr = ipr; portn = port; int ret; // 初始化 ret = Api.HNC_NetInit(ipnl, 9090, "DataC"); if (ret != 0) { //MessageBox.Show("初始化失败"); return(1); } // 连接 ret = Api.HNC_NetConnect(ipnr, portn); Thread.Sleep(10); // 检测是否已连接 if (Api.HNC_NetIsConnect(ipnr, portn) == 0) { iscon = true; return(0); } else { return(2); } }
/// <summary> /// 连接机床网络 /// </summary> /// <param name="ipr"> /// 机床ip /// </param> /// <param name="ipl"> /// 本地ip /// </param> /// <param name="port"> /// 机床端口 /// </param> /// <returns> /// true:连接成功 /// false:连接失败 /// </returns> public static bool start_connect(string ipr, string ipl, UInt16 port) { ipnl = ipl; ipnr = ipr; portn = port; int ret; // 初始化 ret = Api.HNC_NetInit(ipnl, 9090, "NCVM"); if (ret != 0) { MessageBox.Show("初始化失败"); } // 连接 ret = Api.HNC_NetConnect(ipnr, portn); Thread.Sleep(10); // 检测是否已连接 if (Api.HNC_NetIsConnect(ipnr, portn) == 0) { iscon = true; } return(iscon); }
// 初始化 private void Form1_Load(object sender, EventArgs e) { ShowMsgBox(HncApi.HNC_NetInit(GetLocalIpAddr(), localPort) == 0 ? true : false, "Initializing "); AddCombox(); abbScanner(); // ABB 扫描 }
public int InitNet(String ip, UInt16 port) { lock (_lock) { if (_smplSet != null) { return(0); } Int32 ret = HncApi.HNC_NetInit(ip, port); if (ret == 0 && _smplSet == null) { _smplSet = new SampleSet(); _smplSet.ReadSamplConfigFile(); _SmpCollector = new SamplDatacollector(); _EvtCollector = new EventDataCollector(); _SmpCollector.Start(); _EvtCollector.Start(); } return(ret); } }
private void Form1_Load(object sender, EventArgs e) { ShowMsgBox(HncApi.HNC_NetInit(GetLocalIpAddr(), localPort) == 0 ? true : false, "初始化"); }
private void IpInitialize() { ShowMsgBox(HncApi.HNC_NetInit(GetLocalIpAddr(), localPort) == 0 ? true : false, " 本地IP初始化 "); }