private void button2_Click(object sender, EventArgs e) { try { DialogResult MsgBoxResult = MessageBox.Show("确定要更新任务?", //对话框的显示内容 "操作提示", //对话框的标题 MessageBoxButtons.YesNo, //定义对话框的按钮,这里定义了YSE和NO两个按钮 MessageBoxIcon.Question, //定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号 MessageBoxDefaultButton.Button2); //定义对话框的按钮式样 //decimal sortgroupno1 = decimal.Parse(ConfigurationManager.AppSettings["Group1"].ToString()); //decimal sortgroupno2 = decimal.Parse(ConfigurationManager.AppSettings["Group2"].ToString()); if (MsgBoxResult == DialogResult.Yes) { if (textBox1.Text.Equals("")) { MessageBox.Show("请输入机械手任务号"); return; } else { String from = textBox1.Text; String to = textBox2.Text; decimal taskState = 10; if (textBox2.Text == "") { to = from; } if (Convert.ToDecimal(textBox1.Text) > Convert.ToDecimal(textBox2.Text)) //防止任务号输反 { from = to; } if (radioButton2.Checked) { taskState = 15; } else if (radioButton3.Checked) { taskState = 20; } decimal dFrom = decimal.Parse(from); decimal tFrom = decimal.Parse(to); ////////////////////////////////////////////////////////////////////////////////// var machineList = InBoundService.GetListByUtasknumTotasknum(dFrom, tFrom); foreach (var item in machineList) { if (taskState == 20) { InBoundService.UpdateMachineInOut(item.UNIONTASKNUM ?? 0, (groupNo - 1) * 22 + cbTroughNum.SelectedIndex + 1); } TaskService.UpdateMachine(item.UNIONTASKNUM ?? 0, (groupNo - 1) * 22 + cbTroughNum.SelectedIndex + 1, taskState); } ////////////////////////////////////////////////////////////////////////////////之前机制 //for (decimal i = dFrom; i <= tFrom; i++)//i 机械手任务号 //{ // if (taskState == 20) // { // InBoundService.UpdateMachineInOut(i, (groupNo - 1) * 22 + cbTroughNum.SelectedIndex + 1); // } // TaskService.UpdateMachine(i, (groupNo - 1) * 22 + cbTroughNum.SelectedIndex + 1, taskState); //} button1_Click(null, null); } } } catch (Exception ex) { MessageBox.Show("错误信息:" + ex.Message); } }
public void OnDataChange(int Group, int[] clientId, object[] values) { if (Group != 23) { for (int i = 0; i < clientId.Length; i++) { //第五位 读写标志位 if (clientId[i] == 5) { if (int.Parse(values[i].ToString()) == 2) { updateListBox("读到第" + ((groupNo - 1) * 22 + Group) + "号机械手写入标志位2"); writeLog.Write("读到第" + ((groupNo - 1) * 22 + Group) + "号机械手写入标志位2"); while (!isInit) { Thread.Sleep(100); } //if (tempList.Count > 0) //{ // List<String> temp = getKey(((groupNo - 1) * 22 + Group) + ""); // if (temp != null) // { //if (!groupBool[Group - 1]) //{ // Thread.Sleep(100); // groupBool[Group - 1] = true; //} //foreach (var item in temp) //{ if (groupList[Group - 1].ReadD(3) != null && groupList[Group - 1].ReadD(3).ToString() != "0") { String item = groupList[Group - 1].ReadD(3).ToString(); //任务号 updateListBox(item + ":" + ((groupNo - 1) * 22 + Group) + " 已接收"); writeLog.Write(((groupNo - 1) * 22 + Group) + "号机械手已接收:" + item + "号任务"); TaskService.UpdateMachineSec(decimal.Parse(item), ((groupNo - 1) * 22 + Group) + ""); removeKey(((groupNo - 1) * 22 + Group) + ""); } // } //} // removeKey(Group + ""); //} sendTask(((groupNo - 1) * 22 + Group) + "", groupList[Group - 1]); } // break; } else if (clientId[i] == 1)//第一位:任务完成标志位 { if (decimal.Parse(values[i].ToString()) != 0) { writeLog.Write((((groupNo - 1) * 22 + Group) + "号机械手已完成:" + decimal.Parse(values[i].ToString()) + "号任务")); updateListBox((decimal.Parse(values[i].ToString()) + ":" + ((groupNo - 1) * 22 + Group) + " 已完成任务")); InBoundService.UpdateMachineInOut(decimal.Parse(values[i].ToString()), ((groupNo - 1) * 22 + Group)); TaskService.UpdateMachineFinished(decimal.Parse(values[i].ToString()), ((groupNo - 1) * 22 + Group) + ""); } } } } else { for (int i = 0; i < clientId.Length; i++) { //if (clientId[i] == 1) //{ //if (int.Parse(values[i].ToString()) != 0) //{ String temp = Convert.ToString(int.Parse(values[i].ToString()), 2); //WriteErr(1, clientId[i], temp, groupNo); //alarms.fileOper.Write(temp, new AlarmsFileModel { DeviceNo = clientId[i].ToString() }); alarms.WriteErrWithCheck(1, clientId[i], temp, groupNo); //} //} } } }