FrmSendWire.cs 3.9 KB
using log4net; 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using URSoldering.Common;
using URSoldering.DeviceLibrary;
using URSoldering.LoadCSVLibrary;

namespace URSoldering.Client
{
    public partial class FrmSendWire : FrmBase
    {
        public FrmSendWire()
        {
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
        }

        public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
        }

        private void btnStopSend_Click(object sender, EventArgs e)
        {
            SendWireManager.StopSend();
        }
        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);
            if (!IsHandleCreated)
            {
                this.Close();
            }
        }

        private void formStatus(bool isOpen)
        {
            btnSetSold.Enabled = isOpen;
            btnOpenSold.Enabled = !isOpen;
            btnCloseSold.Enabled = isOpen;
            btnStartSend.Enabled = isOpen; 
            btnStartSend.Enabled = isOpen;
            btnStartBack.Enabled = isOpen; 
            btnReadError.Enabled = isOpen;
        }
        private void btnOpenSold_Click(object sender, EventArgs e)
        {
            if (SendWireManager.Init(WeldRobotBean.RobotConfig.JBC_SendWire_Port))
            {
                formStatus(true);
            }
            else
            {
                MessageBox.Show("打开送丝机失败!");
            }
        }

        private void btnCloseSold_Click(object sender, EventArgs e)
        {
            SendWireManager.Release();
            formStatus(false);
        }

        private void btnSetSold_Click(object sender, EventArgs e)
        {
            int speed = FormUtil.GetIntValue(txtSpeed);
            int length = FormUtil.GetIntValue(txtLength);
            SendWireManager.setLength(length);
            SendWireManager.setSpeed(speed);
        }
         
        private void btnCloseForm_Click(object sender, EventArgs e)
        {
            this.Close();
        } 
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (RobotBean.KNDIOValue(IO_Type.SuddenStop_Single).Equals(IO_VALUE.LOW))
            {
                lblMsg.Text = "急停未开";
            }
            else
            {
                lblMsg.Text = "";
            }
        }

        private void btnReadError_Click(object sender, EventArgs e)
        {
            int error = SendWireManager.ReadPortError();
            txtPortError.Text = error.ToString(); 
        }

        private void btnStartSend_Click(object sender, EventArgs e)
        {
            SendWireManager.StartFSend();
        }

        private void btnStartBack_Click(object sender, EventArgs e)
        {
            SendWireManager.StartBSend();
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            SendWireManager.StopSend();
        }

        private void FrmSendWire_Load(object sender, EventArgs e)
        {
            txtSoldingCom.Text = WeldRobotBean.RobotConfig.JBC_SendWire_Port;
            if (SendWireManager.IsRun)
            {
                formStatus(true);
            }
            else
            {
                formStatus(false);
            }
        }

        private void btnReadError_Click_1(object sender, EventArgs e)
        {
            int value = SendWireManager.ReadPortError();
            txtPortError.Text = value.ToString();
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            SendWireManager.Reset();
        }
         

    }
}