FrmFeedingEquip.cs 24.8 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
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.AssemblyLine
{
    public partial class FrmFeedingEquip : FrmBase
    {
        private bool IsLoad = false;
        private string portName = "";
        private short SlvAddr = 0;
        private FeedingEquip feedEquip;
        public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        public FrmFeedingEquip(FeedingEquip moveEquip)
        {
            this.feedEquip = moveEquip;
            Control.CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
            LoadIOList();
        }
        Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>();
        Dictionary<string, IOTextControl> DOControlList = new Dictionary<string, IOTextControl>();
        private void LoadIOList()
        {
            int roleindex = 0;
            this.tableLayoutPanel1.RowStyles.Clear();
            this.tableLayoutPanel1.RowCount = feedEquip.Config.DIList.Count;
            foreach (ConfigIO ioValue in feedEquip.Config.DIList.Values)
            {
                this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
                IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
                this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
                roleindex++;
                DIControlList.Add(ioValue.ProName, control);
            }

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

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

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (!this.Visible)
                {
                    return;
                }
                if (chbAutoRead.Checked && this.Visible)
                {
                    ReadIOList();
                    lblTrayNum.Text = "托盘编码:" + TrayManager.GetNum(feedEquip.DeviceID);
                } 
               
                string canOut = LineManager.Line.CanOutStore(feedEquip.DeviceID) ? "可出库":"不可出库" ;
                lblStoreStatus.Text = KTK_Store.GetRunStr(feedEquip.lineStatus, feedEquip.runStatus)+"("+canOut+")";
                lblThisSta.Text = feedEquip.WarnMsg;
                string text = "";
                List<InOutParam> ps = new List<InOutParam>(feedEquip.waitInStoreList);
                if (ps.Count > 0)
                {
                    text = "等待入库列表:\r";
                    foreach (InOutParam param in ps)
                    {
                        text += param.ToStr() + "\r";
                    }
                }
                if (!lblInstoreList.Text.Equals(text))
                {
                    lblInstoreList.Text = text;
                }
            }catch(Exception ex)
            {
                LogUtil.error(feedEquip.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(LOGGER, ex.StackTrace);
            }
        }
        private void btnWriteSingleDO_Click(object sender, EventArgs e)
        {
            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 (feedEquip.Config.DOList.ContainsKey(text))
            {
                ConfigIO io = feedEquip.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.DeviceName;
                    txtSlaveId.Text = io.SlaveID.ToString();
                    IOTextControl newControl = DOControlList[io.ProName];
                    if (selectControl != null) { selectControl.BackColor = Color.White; }
                    newControl.BackColor = Color.SkyBlue;
                    selectControl = newControl;
                }
            }
        }


        private void FrmStoreIOStatus_Load(object sender, EventArgs e)
        {
            chbDebug.Checked = feedEquip.IsDebug;
            if (feedEquip.UpdownUseAxis)
            { 
                portName = feedEquip.Config.UpDown_Axis.DeviceName;
                SlvAddr = feedEquip.Config.UpDown_Axis.GetAxisValue();
                txtAxisDeviceName.Text = portName;
                txtSlaveId.Text = SlvAddr.ToString();
                comboBox1.Items.Clear();
                comboBox1.Items.Add(feedEquip.Config.UpDown_Axis.Explain);
                comboBox1.SelectedIndex = 0;
                
                txtAxisValue.Text = SlvAddr.ToString();
            }
            else
            {
                tabControl1.TabPages.Remove(tabPage2);
            }

            cmbSizeList.Items.Clear();
            cmbSizeList.Items.Add("0=默认位置");
            for(int i = 8; i <= 48; i = i + 4)
            {
                cmbSizeList.Items.Add(i.ToString());
            }
            cmbSizeList.SelectedIndex = 0;
            lblStoreStatus.Text = KTK_Store.GetRunStr(feedEquip.lineStatus, feedEquip.runStatus);
            lblThisSta.Text = feedEquip.WarnMsg;
            txtP1.Text = feedEquip.Config.UpDownAxisP1.ToString();
            IsLoad = true;
        }

        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();
        }

        private void ReadIOList()
        {
            foreach (string key in DIControlList.Keys)
            {
                IOTextControl control = DIControlList[key];
                int iov = (int)IOManager.IOValue(key, feedEquip.DeviceID);
                if (iov != control.IOValue)
                {
                    control.IOValue = iov;
                    control.ShowData();
                }
            }
            foreach (string key in this.DOControlList.Keys)
            {
                IOTextControl control = DOControlList[key];
                int iov = (int)IOManager.DOValue(key, feedEquip.DeviceID);
                if (iov != control.IOValue)
                {
                    control.IOValue = iov;
                    control.ShowData();
                }
            }

        }

        private void btnReadAllDi_Click(object sender, EventArgs e)
        {
            string deviceName = txtDoName.Text;
            IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
            int time = FormUtil.GetIntValue(txtWriteTime);
            int slaveId = FormUtil.GetIntValue(txtSlaveId);
            IOManager.instance.ReadAllDI(deviceName, (byte)slaveId);
        }

        public void FormStatus(bool isStart)
        {
            btnStart.Enabled = !isStart;
            btnStop.Enabled = true;
            btnReset.Enabled = isStart;
            btnInStore.Enabled = isStart;
            btnOutStore.Enabled = isStart;
        }

        private void btnReadAllDo_Click(object sender, EventArgs e)
        {
            string deviceName = txtDoName.Text;

            IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
            int time = FormUtil.GetIntValue(txtWriteTime);
            int slaveId = FormUtil.GetIntValue(txtSlaveId);
            IOManager.instance.ReadAllDO(deviceName, (byte)slaveId );
        }


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

        private void btnStart_Click(object sender, EventArgs e)
        {
            if (feedEquip.runStatus.Equals(LineRunStatus.Wait))
            {
                bool result = feedEquip.StartDebugRun();
                if (result)
                {
                    FormStatus(true);
                }
            }
        }

        private void chbDebug_CheckedChanged(object sender, EventArgs e)
        {
            if (!IsLoad)
            {
                return;
            }

            if (chbDebug.Checked)
            {
                if (!feedEquip.IsDebug)
                {
                    DialogResult result = MessageBox.Show("是否切换到调试状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (result.Equals(DialogResult.Yes))
                    {
                        feedEquip.IsDebug = true;
                        feedEquip.Config.IsDebug = 1; 
                        LineManager.SaveFeedingEquipConfig(feedEquip.Config);
                        feedEquip.ChangeDebug();
                        LogUtil.info(feedEquip.Name+ "用户切换到调试状态 ");
                    }
                }
            }
            else
            {
                if (feedEquip.IsDebug)
                {
                    DialogResult result = MessageBox.Show("是否切换到正常工作状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (result.Equals(DialogResult.Yes))
                    {
                        feedEquip.IsDebug = false;
                        feedEquip.Config.IsDebug = 0;
                        LineManager.SaveFeedingEquipConfig(feedEquip.Config);
                        feedEquip.ChangeDebug();
                        LogUtil.info(feedEquip.Name + "用户切换到正常工作状态 ");
                    }
                }
            }
        }

        private void btnOutStore_Click(object sender, EventArgs e)
        {
            if (feedEquip.runStatus .Equals(LineRunStatus.Runing))
            { 
                feedEquip.StartOutStoreMove(new InOutParam( ));
            }
            else
            {
                MessageBox.Show("未启动或不在空闲中,无法入库测试!");
            }
        }

        private void btnInStore_Click(object sender, EventArgs e)
        {
            if (feedEquip.runStatus.Equals(LineRunStatus.Runing))
            {
                feedEquip.StartInStoreMove(new InOutParam());
            }
            else
            {
                MessageBox.Show("未启动或不在空闲中,无法入库测试!");
            }
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            try
            {
                feedEquip.StopMove();
            }
            catch (Exception ex)
            {
                LogUtil.error( "出错:" + ex.StackTrace);
            }
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            if (feedEquip.runStatus>(LineRunStatus.Wait))
            {
                feedEquip.Reset();
            }
        }
        private void btnStop1Up_Click(object sender, EventArgs e)
        {
            if (btnStop1Up.Text.Equals("阻挡气缸1下降"))
            { 
                feedEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
                btnStop1Up.Text = "阻挡气缸1上升";
                btnStop1Up.BackColor = Color.Aqua;
            }
            else
            { 
                feedEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
                btnStop1Up.Text = "阻挡气缸1下降";
                btnStop1Up.BackColor = Color.White;
            }
        } 
        private void btnStop2Up_Click(object sender, EventArgs e)
        {
            if (btnStop2Up.Text.Equals("阻挡气缸2下降"))
            {
                feedEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
                btnStop2Up.Text = "阻挡气缸2上升";
                btnStop2Up.BackColor = Color.Aqua;
            }
            else
            {
                feedEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
                btnStop2Up.Text = "阻挡气缸2下降";
                btnStop2Up.BackColor = Color.White;
            } 
        } 
        private void btnTopUp_Click(object sender, EventArgs e)
        { 
            if (btnTopUp.Text.Equals("顶升气缸上升"))
            {
                feedEquip.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
                btnTopUp.Text = "顶升气缸下降";
                btnTopUp.BackColor = Color.Aqua;
            }
            else
            {
                feedEquip.CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
                btnTopUp.Text = "顶升气缸上升";
                btnTopUp.BackColor = Color.SkyBlue;
            }
        }
    
        private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
        {
            if (btnBeforeAfterBefore.Text.Equals("前后气缸前进"))
            {
                feedEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
                btnBeforeAfterBefore.Text = "前后气缸后退";
                btnBeforeAfterBefore.BackColor = Color.Aqua;
            }
            else
            {
                feedEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
                btnBeforeAfterBefore.Text = "前后气缸前进";
                btnBeforeAfterBefore.BackColor = Color.SkyBlue;
            }
        } 
        private void btnUpDownUp_Click(object sender, EventArgs e)
        {
            if (btnUpDownUp.Text.Equals("上下气缸上升"))
            {
                feedEquip.CylinderMove(null, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
                btnUpDownUp.Text = "上下气缸下降";
                btnUpDownUp.BackColor = Color.Aqua;
            }
            else
            {
                feedEquip.CylinderMove(null, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
                btnUpDownUp.Text = "上下气缸上升";
                btnUpDownUp.BackColor = Color.SkyBlue;
            }
        } 
        private void btnClampSlack_Click(object sender, EventArgs e)
        {
            if (btnClampSlack.Text.Equals("夹料气缸夹紧"))
            {
                feedEquip.CylinderMove(null, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
                btnClampSlack.Text = "夹料气缸放松";
                btnClampSlack.BackColor = Color.Aqua;
            }
            else
            {
                feedEquip.CylinderMove(null, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
                btnClampSlack.Text = "夹料气缸夹紧";
                btnClampSlack.BackColor = Color.SkyBlue;
            }
        } 
        private void btnOpenAxis_Click(object sender, EventArgs e)
        {
            string portName = txtAxisDeviceName.Text;
            short SlvAddr = FormUtil.GetShortValue(txtAxisValue);
            LogUtil.info("点击【打开伺服】,端口号【" + portName + "】地址【" + SlvAddr + "】 ");
            ACServerManager.OpenPort(portName);
          

            ACServerManager.AlarmClear(portName, SlvAddr);
            Thread.Sleep(100);
            ACServerManager.ServoOn(portName, SlvAddr);
        }

        private void btnCloseAxis_Click(object sender, EventArgs e)
        { 
            LogUtil.info("点击【关闭伺服】,端口号【" + portName + "】地址【" + SlvAddr + "】 ");
            ACServerManager.ServoOff(portName, SlvAddr);
        }

        private void btnAxisAMove_Click(object sender, EventArgs e)
        {  
            int position = FormUtil.GetIntValue(txtAPosition);
            int speed = FormUtil.GetIntValue(txtASpeed); 
            LogUtil.info("点击【绝对运动】,端口号【" + portName + "】地址【" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
            ACServerManager.AbsMove(portName, SlvAddr, position, speed);
        }

        private void btnAxisRMove_Click(object sender, EventArgs e)
        { 
            int position = FormUtil.GetIntValue(txtAPosition);
            int speed = FormUtil.GetIntValue(txtASpeed);  
            LogUtil.info("点击【相对运动】,端口号【" + portName + "】地址【" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
            ACServerManager.RelMove(portName, SlvAddr, position, speed);
        }

        private void btnAxisVMove_Click(object sender, EventArgs e)
        {  
            int speed = FormUtil.GetIntValue(txtASpeed);
          
            LogUtil.info("点击【匀速运动】,端口号【" + portName + "】地址【" + SlvAddr + "】 速度【" + speed + "】");
            ACServerManager.SpeedMove(portName, SlvAddr, speed);
        }

        private void btnAxisStop_Click(object sender, EventArgs e)
        { 
            LogUtil.info("点击【停止运动】,端口号【" + portName + "】地址【" + SlvAddr + "】 ");
            ACServerManager.SuddenStop(portName, SlvAddr);
        }

        private void btnComAlarmClear_Click(object sender, EventArgs e)
        { 
            LogUtil.info("点击【清理报警】,端口号【" + portName + "】地址【" + SlvAddr + "】 ");
            ACServerManager.AlarmClear(portName, SlvAddr);
            Thread.Sleep(100);
            ACServerManager.ServoOn(portName, SlvAddr);
        }

        private void btnAxisReturnHome_Click(object sender, EventArgs e)
        { 
            int speed = FormUtil.GetIntValue(txtASpeed);
            LogUtil.info("点击【原点返回】,端口号【" + portName + "】地址【" + SlvAddr + "】 速度【" + speed + "】");
            ACServerManager.HomeMove(portName, SlvAddr, speed);
        }

        private void btnGetAlarm_Click(object sender, EventArgs e)
        {
            int value = ACServerManager.GetAlarmStatus(portName, SlvAddr);
            this.txtAlarmStatus.Text = value.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int value = ACServerManager.GetBusyStatus(portName, SlvAddr);
            this.txtBusyStatus.Text = value.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int value = ACServerManager.GetHomeEndStatus(portName, SlvAddr);
            this.txtHomeStatus.Text = value.ToString();
        }

        private void btnReadHomeSingle_Click(object sender, EventArgs e)
        { 
            int value = ACServerManager.GetHomeSingle(portName, SlvAddr);
            this.txtHomeSingle.Text = value.ToString();
        }

        private void btnReadPosition_Click(object sender, EventArgs e)
        {
            lblOutPulse.Text= ACServerManager.GetTargetPosition(portName, SlvAddr).ToString();
            lblCountPulse.Text = ACServerManager.GetActualtPosition(portName, SlvAddr).ToString();
        } 
        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) { }
            txtSizePosition.Text = feedEquip.Config.GetUpdownPosition(size).ToString();
            txtBoxP.Text = feedEquip.Config.GetUpdownBoxPosition(size).ToString();
            btnMoveto.Text = size + "寸移栽位置 :";
           btnBoxP.Text= size + "寸料仓门口位置 :";
            // btnMoveto.Text = "尺寸" + size + "对应位置:";
        }

        private void btnMoveto_Click(object sender, EventArgs e)
        {
            int position = FormUtil.GetIntValue(txtSizePosition);
            if (position != -1)
            { 
                int speed = feedEquip.Config.UpdownAxis_DownSpeed;
                LogUtil.info("点击【移栽位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
                ACServerManager.AbsMove(portName, SlvAddr, position, speed);
            }
        }

        private void btnAxisOn_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            feedEquip.RunAxis(false);
            this.Enabled = true;
            LogUtil.info("伺服运转ON完成");
        }

        private void btnAxisOff_Click(object sender, EventArgs e)
        { 
            feedEquip.CloseAxis();
            LogUtil.info("伺服运转OFF完成");
        }

        private void btnCloseAll_Click(object sender, EventArgs e)
        {
            IOManager.instance.CloseAllDO();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int position = FormUtil.GetIntValue(txtP1);
            if (position != -1)
            {
                int speed =feedEquip.Config.UpdownAxis_P1Speed;
                LogUtil.info("点击【P1点测试】, 位置【" + position + "】速度【" + speed + "】");
                ACServerManager.AbsMove(portName, SlvAddr, position, speed);
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            int p1Position = FormUtil.GetIntValue(txtP1);
            feedEquip.Config.UpDownAxisP1 = p1Position;

            int size = 0;
            try { size = Convert.ToInt32(cmbSizeList.Text); } catch (Exception ex) { }
            int sizePosition = FormUtil.GetIntValue(txtSizePosition);
            int sizeBoxP = FormUtil.GetIntValue(txtBoxP);
            feedEquip.Config.UpdateUpdownPositon(size, sizePosition);
            feedEquip.Config.UpdateUpdownBoxPositon(size, sizeBoxP);
            LineManager.SaveFeedingEquipConfig(feedEquip.Config);
            MessageBox.Show("保存成功!");
        }

        private void btnBoxP_Click(object sender, EventArgs e)
        {
            int position = FormUtil.GetIntValue(txtBoxP);
            if (position != -1)
            {
                int speed = feedEquip.Config.UpdownAxis_DownSpeed;
                LogUtil.info("点击【料仓门口下降位置】,料盘高度【" + cmbSizeList.Text + "】 位置【" + position + "】速度【" + speed + "】");
                ACServerManager.AbsMove(portName, SlvAddr, position, speed);
            }
        }
    }
     
}