/// <summary> /// PMW端口测试 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSend_Click(object sender, EventArgs e) { Capm c = new Capm(); c.ModelType = cboModel.SelectedIndex; //型号 c.MsgType = 2; //消息类型 c.Ids = new int[] { Convert.ToInt32(txtPMWid.Value) }; c.Vals = new int[] { Convert.ToInt32(txtPMWVal.Value) }; string data = TcpManager.Client(txtIP.Text, Convert.ToInt32(txtPort.Text), getJson(c)); ExecuteResponse(data); }
/// <summary> /// 执行动作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDJ1_Click(object sender, EventArgs e) { int num = Convert.ToInt32(((Button)sender).Tag);//机号位 Capm c = new Capm(); c.ModelType = cboModel.SelectedIndex; //型号 c.MsgType = 0; //消息类型 c.Ids = new int[] { num }; c.Vals = new int[] { GetValuesByNum(num) }; string data = TcpManager.Client(txtIP.Text, Convert.ToInt32(txtPort.Text), getJson(c)); ExecuteResponse(data); }
/// <summary> /// 批量操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void grd_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 8) { int i = e.RowIndex; //执行 Capm c = new Capm(); c.ModelType = cboModel.SelectedIndex; //型号 c.MsgType = 0; //消息类型 c.Ids = new int[] { 1, 2, 3, 4, 5, 6, 7 }; c.Vals = new int[] { Convert.ToInt32(dt.Rows[i]["col1"]), Convert.ToInt32(dt.Rows[i]["col2"]), Convert.ToInt32(dt.Rows[i]["col3"]), Convert.ToInt32(dt.Rows[i]["col4"]), Convert.ToInt32(dt.Rows[i]["col5"]), Convert.ToInt32(dt.Rows[i]["col6"]), Convert.ToInt32(dt.Rows[i]["col7"]) }; string data = TcpManager.Client(txtIP.Text, Convert.ToInt32(txtPort.Text), getJson(c)); ExecuteResponse(data); } else if (e.ColumnIndex == 9) { //删除 dt.Rows.RemoveAt(e.RowIndex); grd.DataSource = dt; } else if (e.ColumnIndex == 10) { if (e.RowIndex != 0) { DataRow dr = dt.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { dr[dt.Columns[i].Caption] = dt.Rows[e.RowIndex][dt.Columns[i].Caption]; } dt.Rows.RemoveAt(e.RowIndex); dt.Rows.InsertAt(dr, e.RowIndex - 1); grd.DataSource = dt; } } }