FrmOutputEquip.cs 31.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.CompilerServices;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices;
using OnlineStore.DeviceLibrary;
using log4net;
using System.Reflection;
using UserFromControl;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;


namespace OnlineStore.AutoCountClient
{
    internal partial class FrmOutputEquip : FrmEquipBase
    {
        private bool IsLoad = false;
        private OutputEquip equipBean;

        public event resetButtonClickdelegate resetButtonClick;
        public delegate void resetButtonClickdelegate();
        internal FrmOutputEquip(OutputEquip moveEquip)
        {
            equipBase = moveEquip;
            this.equipBean = moveEquip;
            Control.CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
            LoadIOList();
        }
        private void FrmStoreIOStatus_Load(object sender, EventArgs e)
        {
            IOManager.DIValue(IO_Type.O_ELine_InStop, 3);
            axisMoveControl1.LoadData(equipBean, new AxisBean[] { equipBean.MoveXAxis, equipBean.MoveZAxis, equipBean.LabelXAxis, equipBean.LabelYAxis, equipBean.LabelZAxis, equipBean.LabelRAxis, equipBean.BatchAxis });


            chbDebug.Checked = equipBean.IsDebug;
            chbPrint.Checked = ConfigAppSettings.GetIntValue(Setting_Init.NeedPrintLabel).Equals(1);
            chbStickingPos.Checked = ConfigAppSettings.GetIntValue(Setting_Init.StickingPosJudgment).Equals(1);
            lblStoreStatus.Text = RobotBase.GetRunStr(equipBean.runStatus);
            lblThisSta.Text = equipBean.WarnMsg;
            lblName.Text = equipBean.Name;
            comInP.SelectedIndex = 0;
            comTP.SelectedIndex = 0;
            LoadPoint();
            IsLoad = true;
        }

        private void LoadPoint()
        {
            cmbSizeList.Items.Clear();
            cmbSizeList.Items.Add("0=默认位置");
            foreach (int heigth in RobotManager.GetTrayList())
            {
                cmbSizeList.Items.Add(heigth);
            }
            cmbSizeList.SelectedIndex = 0;
            comWidth.SelectedIndex = 0;

            txtBp1.Text = equipBean.Config.BatchAxisP1.ToString();
            txtBP2.Text = equipBean.Config.BatchAxisP2.ToString();
            txtBP3.Text = equipBean.Config.BatchAxisP3.ToString();


            txtMXP1.Text = equipBean.Config.MoveX_P1.ToString();
            txtMXP2.Text = equipBean.Config.GetMoveXP2(0).ToString();
            txtMXP3.Text = equipBean.Config.MoveX_P3.ToString();

            txtMZP1.Text = equipBean.Config.MoveZ_P1.ToString();
            txtMZP2.Text = equipBean.Config.GetMoveZP2(0).ToString();
            txtMZP3.Text = equipBean.Config.GetMoveZP3(0).ToString();

            txtXP1.Text = equipBean.Config.LabelX_P1.ToString();
            txtXP2.Text = equipBean.Config.LabelX_P2.ToString();
            txtXP3.Text = equipBean.Config.LabelX_P3.ToString();

            txtYP1.Text = equipBean.Config.LabelY_P1.ToString();
            txtYP2.Text = equipBean.Config.LabelY_P2.ToString();
            txtYP3.Text = equipBean.Config.LabelY_P3.ToString();
            txtYP4.Text = equipBean.Config.LabelY_P4.ToString();
            txtYP5.Text = equipBean.Config.LabelY_P5.ToString();

            txtZP1.Text = equipBean.Config.LabelZ_P1.ToString();
            txtZP2.Text = equipBean.Config.LabelZ_P2.ToString();
            txtZP3.Text = equipBean.Config.LabelZ_P3.ToString();
            txtZP4.Text = equipBean.Config.LabelZ_P4.ToString();

            txtRP1.Text = equipBean.Config.LabelR_P1.ToString();
            txtRP2.Text = equipBean.Config.LabelR_P2.ToString();
            txtRP3.Text = equipBean.Config.LabelR_P3.ToString();
            txtRP4.Text = equipBean.Config.LabelR_P4.ToString();
        }

        private void LoadIOList()
        {
            int maxCount = 16;
            int roleindex = 0;
            this.tableLayoutPanel1.RowStyles.Clear();
            this.tableLayoutPanel1.RowCount = maxCount;
            this.tableLayoutPanel3.RowStyles.Clear();
            this.tableLayoutPanel3.RowCount = maxCount;
            int i = 0;
            foreach (ConfigIO ioValue in equipBean.Config.DIList.Values)
            {
                IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
                if (i >= maxCount)
                {
                    this.tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
                    this.tableLayoutPanel3.Controls.Add(control, 0, roleindex - maxCount);
                }
                else
                {
                    this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
                    this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
                }
                roleindex++;
                i++;
                DIControlList.Add(ioValue.ProName, control);
            }

            tableLayoutPanel2.RowStyles.Clear();
            this.tableLayoutPanel2.RowCount = maxCount;
            this.tableLayoutPanel4.RowStyles.Clear();
            this.tableLayoutPanel4.RowCount = maxCount;
            roleindex = 0;
            i = 0;
            foreach (ConfigIO ioValue in equipBean.Config.DOList.Values)
            {
                IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
                control.Click += Control_Click;
                if (i >= maxCount)
                {
                    this.tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
                    this.tableLayoutPanel4.Controls.Add(control, 0, roleindex - maxCount);
                }
                else
                {
                    this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
                    this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
                }
                roleindex++;
                i++;
                DOControlList.Add(ioValue.ProName, control);
            }
            this.SuspendLayout();    //此处为不闪屏,一定要有的! 

            cmbWriteIO.DataSource = new List<ConfigIO>(equipBean.Config.DOList.Values);
            cmbWriteIO.ValueMember = "ProName";
            cmbWriteIO.DisplayMember = "DisplayStr";

        }
        private void Control_Click(object sender, EventArgs e)
        {
            IOTextControl control = (IOTextControl)sender;
            string name = control.Name.Substring(3, control.Name.Length - 3);
            List<string> keyList = new List<string>(DOControlList.Keys);
            int index = keyList.IndexOf(name);
            if (index >= 0)
            {
                cmbWriteIO.SelectedIndex = index;
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (!this.Visible)
                {
                    return;
                }
                if (this.Visible)
                {
                    ReadIOList();
                    ReadBtnDO();
                }
                chbMoveStop.Checked = equipBean.MoveStop;
                if (equipBean.runStatus > RobotRunStatus.Wait)
                {
                    lblName.BackColor = Color.Green;
                    if (btnStart.Enabled)
                    {
                        FormStatus(true);
                    }
                }
                else
                {
                    lblName.BackColor = System.Drawing.Color.DodgerBlue;
                    if (!btnStart.Enabled)
                    {
                        FormStatus(false);
                    }
                }
                lblAgvInfo.Text = "AGV-" + equipBean.Config.AgvInName + " 状态:" + AgvClient.GetAction(equipBean.Config.AgvInName).ToString() +
                    "\t            AGV-" + equipBean.Config.AgvOutName + " 状态:" + AgvClient.GetAction(equipBean.Config.AgvOutName).ToString() + "";

                lblMoveInfo.Text = equipBean.GetMoveStr();
                // string canOut = LineManager.Line.CanOutStore(equipBean.DeviceID) ? "可出库":"不可出库" ;
                lblStoreStatus.Text = RobotBase.GetRunStr(equipBean.runStatus);
                lblThisSta.Text = equipBean.WarnMsg;

            }
            catch (Exception ex)
            {
                LogUtil.error(equipBean.Name + "界面定时器出错:" + ex.ToString());
            }

        }

        private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
        {
            // KNDAIManager.NeedShow = false;
            try
            {
                if (this.timer1.Enabled)
                {
                    this.timer1.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, "Exception(异常)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogUtil.error("", ex);
            }
        }
        private void btnOpenDo_Click(object sender, EventArgs e)
        {
            WriteDO(IO_VALUE.HIGH);
        }
        private void btnWriteSingleDO_Click(object sender, EventArgs e)
        {
            WriteDO(IO_VALUE.LOW);
        }
        private void WriteDO(IO_VALUE value)
        {
            string deviceName = txtDoName.Text;
            int index = FormUtil.GetIntValue(txtDOIndex);
            //   IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
            int time = FormUtil.GetIntValue(txtWriteTime);
            int slaveId = FormUtil.GetIntValue(txtSlaveId);
            if (time > 0)
            {
                IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
            }
            else
            {
                IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
            }
        }
        private ConfigIO GetSelectDO()
        {
            string text = cmbWriteIO.SelectedValue.ToString();
            if (equipBean.Config.DOList.ContainsKey(text))
            {
                ConfigIO io = equipBean.Config.DOList[text];
                return io;
            }
            return null;
        }
        IOTextControl selectControl = null;
        private void cmbWriteIO_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbWriteIO.SelectedIndex >= 0)
            {
                ConfigIO io = GetSelectDO();
                if (io != null)
                {
                    // txtIp.Text = io.DeviceName;
                    txtDOIndex.Text = io.GetIOAddr().ToString();
                    txtDoName.Text = io.IO_IP;
                    txtSlaveId.Text = io.SlaveID.ToString();
                    IOTextControl newControl = DOControlList[io.ProName];
                    if (selectControl != null) { selectControl.BorderStyle = BorderStyle.None; }
                    newControl.BorderStyle = BorderStyle.FixedSingle;
                    selectControl = newControl;
                    lablIoIP.Text = io.IO_IP + "_" + io.GetIOAddr().ToString();
                }
            }
        }


        private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            e.DrawBackground();
            e.DrawFocusRectangle();
            if (cmbWriteIO.Items.Count > e.Index)
            {
                ConfigIO io = (ConfigIO)cmbWriteIO.Items[e.Index];
                e.Graphics.DrawString(io.DisplayStr, e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
            }
        }

        private void btnReadIO_Click(object sender, EventArgs e)
        {
            ReadIOList();
        }

        internal override void FormStatus(bool isStart)
        {
            btnStart.Enabled = true;
            btnStop.Enabled = true;
            if (isStart)
            {
                btnStart.Text = "复位";
            }
            else
            {
                btnStart.Text = "启动调试";
            }
            btnOutStore.Enabled = isStart;
        }

        private void FrmIOStatus_Shown(object sender, EventArgs e)
        {
            LoadDOBtn(groupBox5);
            timer1.Start();
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            StartDebug(btnStart);
            resetButtonClick?.Invoke();
        }
        private void btnStop_Click(object sender, EventArgs e)
        {
            StopRun(btnStop);
        }

        private void chbDebug_CheckedChanged(object sender, EventArgs e)
        {
            if (!IsLoad)
            {
                return;
            }
            if (!chbDebug.Checked.Equals(equipBean.IsDebug))
            {
                bool IsDebug = chbDebug.Checked;
                string tarStr = IsDebug ? "调试状态" : "非调试状态";

                DialogResult result = MessageBox.Show("确定切换到" + tarStr, "调试状态更改确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (result.Equals(DialogResult.Yes))
                {
                    equipBean.IsDebug = IsDebug;
                    equipBean.Config.IsDebug = IsDebug ? 1 : 0;
                    RobotManager.SaveOutputConfig(equipBean.Config);
                    equipBean.ChangeDebug(IsDebug);
                    LogUtil.info(equipBean.Name + "用户切换 调试状态 =" + IsDebug);
                }
            }
        }

        private void btnOutStore_Click(object sender, EventArgs e)
        {
            if (equipBean.runStatus.Equals(RobotRunStatus.Runing))
            {
                if (equipBean.IOValue(IO_Type.Out_TrayCheck).Equals(IO_VALUE.HIGH) && equipBean.IOValue(IO_Type.X_OLine_Run).Equals(IO_VALUE.LOW))
                {
                    WorkParam param = new WorkParam();
                    param.IsTest = true;
                    if (comTP.SelectedIndex.Equals(1))
                    {
                        param.IsNgReel = true;
                    }
                    else
                    {
                        param = new WorkParam(1, 1, "", 8, 7, true);
                    }
                    LogUtil.info(equipBean.Name + "点击:取放料测试");
                    equipBean.StartWorking(param);
                }
                else
                {
                    if (equipBean.IOValue(IO_Type.Out_TrayCheck).Equals(IO_VALUE.LOW))
                    {
                        MessageBox.Show("XRay出口未检测到料盘,取放料测试 失败");
                    }
                    else
                    {
                        MessageBox.Show("XRay出口皮带还在转动中,取放料测试 失败");
                    }
                }
            }
            else
            {
                MessageBox.Show("未启动或不在空闲中,取放料测试 失败");
            }
        }
        private void btnCloseAll_Click(object sender, EventArgs e)
        {
            foreach (Control con in groupBox5.Controls)
            {
                if (con is Button)
                {
                    con.BackColor = BackColor = Color.White;
                }
            }
            foreach (ConfigIO io in equipBase.baseConfig.DOList.Values)
            {
                IOManager.instance.WriteSingleDO(io.IO_IP, io.SlaveID, io.GetIOAddr(), IO_VALUE.LOW);
            }
        }

        private void cmbSizeList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbSizeList.SelectedIndex < 0)
            {
                return;
            }

            int size = 0;
            try { size = Convert.ToInt32(cmbSizeList.Text); } catch (Exception ex) { }
            txtMZP2.Text = equipBean.Config.GetMoveZP2(size).ToString();
            txtMZP3.Text = equipBean.Config.GetMoveZP3(size).ToString();
            btnMZP2.Text = "取料Z轴-取料点P2-" + size + "mm";
            btnMZP3.Text = "取料Z轴-放料点P3-" + size + "mm";
        }

        private void btnOpenAllAxis_Click(object sender, EventArgs e)
        {
            btnOpenAllAxis.Enabled = false;
            LogUtil.info(equipBean.Name + " 点击: " + btnOpenAllAxis.Text);
            equipBean.OpenAllAxis();
            btnOpenAllAxis.Enabled = true;
        }
        private void btnCloseAxis_Click(object sender, EventArgs e)
        {
            btnCloseAxis.Enabled = false;
            LogUtil.info(equipBean.Name + " 点击: " + btnCloseAxis.Text);
            equipBean.CloseAllAxis();
            btnCloseAxis.Enabled = true;
        }


        private void btnTakeCode_Forward_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.TakeCode_Back, IO_Type.TakeCode_Forward);
        }

        private void btnTakeCode_Back_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.TakeCode_Forward, IO_Type.TakeCode_Back);
        }

        private void btnTakeT_Clamping_Work_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.TakeT_Clamping_Relax, IO_Type.TakeT_Clamping_Work);
        }

        private void btnTakeT_Clamping_Relax_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.TakeT_Clamping_Work, IO_Type.TakeT_Clamping_Relax);
        }

        private void btnNGCylinder_Forward_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.NGCylinder_Back, IO_Type.NGCylinder_Forward);
        }

        private void btnNGCylinder_Back_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.NGCylinder_Forward, IO_Type.NGCylinder_Back);
        }

        private void btnLablePaste_Forward_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.LablePaste_Back, IO_Type.LablePaste_Forward);
        }

        private void btnLablePaste_Back_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.LablePaste_Forward, IO_Type.LablePaste_Back);
        }

        private void btnO_ELine_TopUp_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.O_ELine_TopDown, IO_Type.O_ELine_TopUp);
        }

        private void O_ELine_TopDown_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.O_ELine_TopUp, IO_Type.O_ELine_TopDown);
        }

        private void btnO_Work_LocationUp_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.O_Work_LocationDown, IO_Type.O_Work_LocationUp);
        }

        private void O_Work_LocationDown_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.O_Work_LocationUp, IO_Type.O_Work_LocationDown);
        }

        private void btnO_TrayFixed_Forward_Click(object sender, EventArgs e)
        {
            equipBean.TrayFixedFoward();
        }

        private void O_TrayFixed_Back_Click(object sender, EventArgs e)
        {
            if (equipBean.TrayFixedCanBack())
            {
                equipBean.TrayFixedBack();
            }
            else
            {
                MessageBox.Show("提升轴当前不在下降位置P2,不后退定位气缸");
            }
        }
        protected void AxisMove(AxisBean axis, TextBox txt, int targetSpeed)
        {
            int position = FormUtil.GetIntValue(txt);
            LogUtil.info("点位运动:[" + axis.AxisName + "] [" + position + "] [" + targetSpeed + "]");
            axis.AbsMove(null, position, targetSpeed);
        }
        private void btnBP1_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.BatchAxis, txtBp1, equipBean.Config.BatchAxis_P1Speed);
        }
        private void btnBP2_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.BatchAxis, txtBP2, equipBean.Config.BatchAxis_P2Speed);
        }
        private void btnBP3_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.BatchAxis, txtBP3, equipBean.Config.BatchAxis_P3Speed);
        }
        private void btnBSave_Click(object sender, EventArgs e)
        {
            LogUtil.info(equipBean.Name + " 点击: " + btnBSave.Text);
            int p1 = FormUtil.GetIntValue(txtBp1);
            int p2 = FormUtil.GetIntValue(txtBP2);
            int p3 = FormUtil.GetIntValue(txtBP3);
            equipBean.Config.BatchAxisP1 = p1;
            equipBean.Config.BatchAxisP2 = p2;
            equipBean.Config.BatchAxisP3 = p3;

            int mxp1 = FormUtil.GetIntValue(txtMXP1);
            int mxp2 = FormUtil.GetIntValue(txtMXP2);
            int mxp3 = FormUtil.GetIntValue(txtMXP3);
            int width = 0;
            try { width = Convert.ToInt32(comWidth.Text); } catch (Exception ex) { }

            int height = 0;
            try { height = Convert.ToInt32(cmbSizeList.Text); } catch (Exception ex) { }

            equipBean.Config.MoveX_P1 = mxp1;
            equipBean.Config.UpdateMoveXP2(width, mxp2);
            equipBean.Config.MoveX_P3 = mxp3;

            int mzp1 = FormUtil.GetIntValue(txtMZP1);
            int mzp2 = FormUtil.GetIntValue(txtMZP2);
            int mzp3 = FormUtil.GetIntValue(txtMZP3);
            equipBean.Config.MoveZ_P1 = mzp1;
            equipBean.Config.UpdateMoveZP2(height, mzp2);
            equipBean.Config.UpdateMoveZP3(height, mzp3);


            int xp1 = FormUtil.GetIntValue(txtXP1);
            int xp2 = FormUtil.GetIntValue(txtXP2);
            int xp3 = FormUtil.GetIntValue(txtXP3);
            equipBean.Config.LabelX_P1 = xp1;
            equipBean.Config.LabelX_P2 = xp2;
            equipBean.Config.LabelX_P3 = xp3;

            int YP1 = FormUtil.GetIntValue(txtYP1);
            int YP2 = FormUtil.GetIntValue(txtYP2);
            int YP3 = FormUtil.GetIntValue(txtYP3);
            int YP4 = FormUtil.GetIntValue(txtYP4);
            int YP5 = FormUtil.GetIntValue(txtYP5);
            equipBean.Config.LabelY_P1 = YP1;
            equipBean.Config.LabelY_P2 = YP2;
            equipBean.Config.LabelY_P3 = YP3;
            equipBean.Config.LabelY_P4 = YP4;
            equipBean.Config.LabelY_P5 = YP5;

            int ZP1 = FormUtil.GetIntValue(txtZP1);
            int ZP2 = FormUtil.GetIntValue(txtZP2);
            int ZP3 = FormUtil.GetIntValue(txtZP3);
            int ZP4 = FormUtil.GetIntValue(txtZP4);
            equipBean.Config.LabelZ_P1 = ZP1;
            equipBean.Config.LabelZ_P2 = ZP2;
            equipBean.Config.LabelZ_P3 = ZP3;
            equipBean.Config.LabelZ_P4 = ZP4;

            int RP1 = FormUtil.GetIntValue(txtRP1);
            int RP2 = FormUtil.GetIntValue(txtRP2);
            int RP3 = FormUtil.GetIntValue(txtRP3);
            int RP4 = FormUtil.GetIntValue(txtRP4);
            equipBean.Config.LabelR_P1 = RP1;
            equipBean.Config.LabelR_P2 = RP2;
            equipBean.Config.LabelR_P3 = RP3;
            equipBean.Config.LabelR_P4 = RP4;


            RobotManager.SaveOutputConfig(equipBean.Config);
            MessageBox.Show("保存成功!");

        }

        private void IoButton_Click(object sender, EventArgs e)
        {
            DoBtnClick(sender);
        }

        private void chbMoveStop_CheckedChanged(object sender, EventArgs e)
        {

            if (!IsLoad)
            {
                return;
            }
            equipBean.MoveStop = chbMoveStop.Checked;
            LogUtil.info(equipBean.Name + "用户切换是否暂停: " + equipBean.MoveStop);
        }

        private void O_WLine_TopUp_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.O_WLine_TopDown, IO_Type.O_WLine_TopUp);
        }

        private void O_WLine_TopDown_Click(object sender, EventArgs e)
        {
            equipBean.CylinderMove(null, IO_Type.O_WLine_TopUp, IO_Type.O_WLine_TopDown);
        }

        private void btnMXP1_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.MoveXAxis, txtMXP1, equipBean.Config.MoveX_P1Speed);
        }

        private void btnMXP2_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.MoveXAxis, txtMXP2, equipBean.Config.MoveX_P2Speed);
        }

        private void btnMXP3_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.MoveXAxis, txtMXP3, equipBean.Config.MoveX_P3Speed);
        }

        private void btnMZP1_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.MoveZAxis, txtMZP1, equipBean.Config.MoveZ_P1Speed);
        }

        private void btnMZP2_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.MoveZAxis, txtMZP2, equipBean.Config.MoveZ_P2Speed);
        }

        private void btnMZP3_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.MoveZAxis, txtMZP3, equipBean.Config.MoveZ_P3Speed);
        }

        private void btnXP1_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelXAxis, txtXP1, equipBean.Config.LabelX_P1Speed);
        }

        private void btnXP2_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelXAxis, txtXP2, equipBean.Config.LabelX_P2Speed);
        }

        private void btnXP3_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelXAxis, txtXP3, equipBean.Config.LabelX_P3Speed);
        }

        private void btnYP1_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelYAxis, txtYP1, equipBean.Config.LabelY_P1Speed);
        }

        private void btnYP2_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelYAxis, txtYP2, equipBean.Config.LabelY_P2Speed);
        }

        private void btnYP3_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelYAxis, txtYP3, equipBean.Config.LabelY_P3Speed);
        }
        private void btnYP4_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelYAxis, txtYP4, equipBean.Config.LabelY_P3Speed);
        }

        private void btnYP5_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelYAxis, txtYP5, equipBean.Config.LabelY_P3Speed);
        }

        private void btnZP1_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelZAxis, txtZP1, equipBean.Config.LabelZ_P1Speed);
        }

        private void btnZP2_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelZAxis, txtZP2, equipBean.Config.LabelZ_P2Speed);
        }

        private void btnZP3_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelZAxis, txtZP3, equipBean.Config.LabelZ_P3Speed);
        }

        private void btnRP1_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelRAxis, txtRP1, equipBean.Config.LabelR_P1Speed);
        }

        private void btnRP2_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelRAxis, txtRP2, equipBean.Config.LabelR_P2Speed);
        }

        private void btnRP3_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelRAxis, txtRP3, equipBean.Config.LabelR_P3Speed);
        }
        private void btnRP4_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelRAxis, txtRP4, equipBean.Config.LabelR_P3Speed);
        }
        private void comWidth_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comWidth.SelectedIndex < 0)
            {
                return;
            }

            int width = 0;
            try { width = Convert.ToInt32(comWidth.Text); } catch (Exception ex) { }
            txtMXP2.Text = equipBean.Config.GetMoveXP2(width).ToString();
            btnMXP2.Text = "取料X轴-取料点P2-" + width + "寸";
        }

        private void chbAutoSend_CheckedChanged(object sender, EventArgs e)
        {
            if (!IsLoad)
            {
                return;
            }
            if (!chbAutoSend.Checked.Equals(equipBean.AutoSendShelfOut))
            {
                bool isCheck = chbAutoSend.Checked;
                equipBean.AutoSendShelfOut = isCheck;
                LogUtil.info(equipBean.Name + "用户切换 放料完成送出料串 =" + isCheck);
            }
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            try
            {
                if (RobotManager.LastPrintStatus.Equals(Asa.PrintLabel.PrinterStatus.Print) || RobotManager.LastPrintStatus.Equals(Asa.PrintLabel.PrinterStatus.Printing))
                {
                    MessageBox.Show("正在打印中,请稍后。。。");
                    return;
                }

                LogUtil.error("点击:PrintLabel 打印标签  StartPrintLabel");
                string code = txtPrintCode.Text;
                string num = txtPringNum.Text;
                equipBean.StartPrintLabel(code, num,"test");
            }
            catch (Exception ex)
            {
                LogUtil.error("打印标签错误:" + ex.ToString());
            }
        }

        private void chbPrint_CheckedChanged(object sender, EventArgs e)
        {
            if (!IsLoad)
            {
                return;
            }
            
            bool isCheck = chbPrint.Checked;
            string v = (isCheck ? 1 : 0).ToString();
            if (ConfigAppSettings.GetValue(Setting_Init.NeedPrintLabel).Equals(v).Equals(false))
            {
                ConfigAppSettings.SaveValue(Setting_Init.NeedPrintLabel, v);
                LogUtil.info(equipBean.Name + "用户切换 启用标签打印 =" + v);
            }
        }
        private void chbStickingPos_CheckedChanged(object sender, EventArgs e)
        {
            if (!IsLoad)
            {
                return;
            }

            bool isCheck = chbStickingPos.Checked;
            string v = (isCheck ? 1 : 0).ToString();
            if (ConfigAppSettings.GetValue(Setting_Init.StickingPosJudgment).Equals(v).Equals(false))
            {
                ConfigAppSettings.SaveValue(Setting_Init.StickingPosJudgment, v);
                LogUtil.info(equipBean.Name + "用户切换 启用标签黏贴位置判断 =" + v);
            }
        }
        private void btnZP4_Click(object sender, EventArgs e)
        {
            AxisMove(equipBean.LabelZAxis, txtZP4, equipBean.Config.LabelZ_P4Speed);
        }

        private void btnShelfReset_Click(object sender, EventArgs e)
        {
            LogUtil.info(equipBean.Name + "点击:料架模块复位");
            if (equipBase.runStatus > (RobotRunStatus.Wait))
            {
                equipBean.ShelfMoveReset();
            }
        }
        private void btnMoveReset_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("请确认出口夹爪上是否有料盘,请在复位前取下. 点击确认继续", "", MessageBoxButtons.OKCancel) != DialogResult.OK)
                return;
            LogUtil.info(equipBean.Name + "点击:取放料机构复位");
            if (equipBase.runStatus > (RobotRunStatus.Wait))
            {
                equipBean.MoveReset();
                resetButtonClick?.Invoke();
            }
        }

        private void btnLabelReset_Click(object sender, EventArgs e)
        {
            LogUtil.info(equipBean.Name + "点击:贴标机构复位");
            if (equipBase.runStatus > (RobotRunStatus.Wait))
            {
                equipBean.SecMoveReset();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RobotManager.LastPrintStatus = Asa.PrintLabel.PrinterStatus.Idle;
        }
    }

}