private void Btn_End_Click(object sender, EventArgs e) { string ret = Itri2Fanuc.SamplingCancel(); ret = Itri2Fanuc.SamplingEnd(); if (ret.Equals("EW_OK")) { Smplsw.Close(); Smplsw.Dispose(); timer1.Enabled = false; //timer2.Enabled = false; TB_ConStatus.Text = "Sampling end"; Btn_Start.Enabled = true; Btn_End.Enabled = false; } }
private void Btn_Connect_Click(object sender, EventArgs e) { if (Btn_Connect.Text == "Connect") { string ip = TB_IP.Text; ushort port = ushort.Parse(TB_Port.Text); int timeout = 2; string ret = Itri2Fanuc.Connect(ip, port, timeout); if (ret == "EW_OK") { TB_ConStatus.Text = "Connect"; Btn_Connect.Text = "DisConnect"; TB_ConStatus.BackColor = Color.Green; Btn_Set.Enabled = true; Btn_Delete.Enabled = true; Btn_Start.Enabled = true; Btn_RdPrm.Enabled = true; Btn_WrPrm.Enabled = true; Btn_UploadCode.Enabled = true; Btn_DownloadCode.Enabled = true; Btn_FrqResStart.Enabled = true; TB_IP.Enabled = false; TB_Port.Enabled = false; mts.GetHndl(Itri2Fanuc); } else { MessageBox.Show("Connect failed:" + ret, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (Btn_Connect.Text == "DisConnect") { Itri2Fanuc.SamplingCancel(); Itri2Fanuc.SamplingEnd(); string ret = Itri2Fanuc.DisConnect(); if (ret == "EW_OK") { Inertial(); } } }