FrmPrintLabel.cs 4.4 KB
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;
using CodeLibrary;

namespace OnlineStore.XLRStore
{
    internal partial class FrmPrintLabel : FrmBase
    {
        private bool IsLoad = false;

        private PrintLabelBean moveBean;
        internal FrmPrintLabel(PrintLabelBean moveEquip)
        {
            this.moveBean = moveEquip;
            Control.CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (!this.Visible)
                {
                    return;
                }
                lblWarnMsg.Text = moveBean.WarnMsg;
                lblCurrInfo.Text = moveBean.GetMoveStr();
                string text = "\r\n" + moveBean.MoveInfo.MoveType + "_" + moveBean.MoveInfo.MoveStep;
                lblAgvInfo.Text = text;
            }
            catch (Exception ex)
            {
                LogUtil.error(moveBean.Name + "界面定时器出错:", ex);
            }

        }

        private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
        {
            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 FrmStoreIOStatus_Load(object sender, EventArgs e)
        {
            lblWarnMsg.Text = moveBean.WarnMsg;
            lblCurrInfo.Text = moveBean.GetMoveStr();
            // lblAgvInfo.Text = "AGV " + moveBean.Config.AgvName + " :" + AgvClient.GetAction(moveBean.Config.AgvName);
            IsLoad = true;
        }



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

        private void button1_Click(object sender, EventArgs e)
        {
            if (BufferDataManager.LabelInfo != null)
            {
                int startp = BufferDataManager.LabelInfo.GetPosType();
                if (startp.Equals(1))
                {
                    button2_Click(null,null);   
                }
                else
                {
                    button3_Click(null, null);
                }
                LogUtil.info($"手动清除贴标缓存:{BufferDataManager.LabelInfo.ToStr()}");
                CodeManager.DelImg(Name, BufferDataManager.LabelInfo?.LabelParam.BitmapFilename);
                BufferDataManager.LabelInfo = null;
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (BufferDataManager.AOutStoreInfo != null)
            {
                BufferDataManager.AOutStoreInfo.Labeled = false;
                LogUtil.info($"手动清除A下贴标标记:{BufferDataManager.AOutStoreInfo.ToStr()}");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (BufferDataManager.BOutStoreInfo != null)
            {
                BufferDataManager.BOutStoreInfo.Labeled = false;
                LogUtil.info($"手动清除B下贴标标记:{BufferDataManager.BOutStoreInfo.ToStr()}");
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            moveBean.Reset();
        }


        //private void btnScanTest_Click(object sender, EventArgs e)
        //{
        //    if (!IsLoad)
        //    {
        //        return;
        //    }
        //    string camera = moveBean.Config.CameraName;
        //    List<string> LastCodeList = CodeManager.CameraScan(camera, moveBean.Name.Trim() + "测试");
        //    string msg = CodeManager.ProcessCode(LastCodeList);
        //    LogUtil.info(moveBean.Name + "[" + camera + "]扫码测试结果:\r\n" + msg);
        //    MessageBox.Show(moveBean.Name + "[" + camera + "]扫码测试结果:" + msg);

        //}

    }

}