浏览代码

增加弹窗

WIN-GH9CEESPLTB\Administrator 1 月之前
父节点
当前提交
36bb5da70f

+ 12 - 0
MainForm/ClassFile/Inovance_EIP.cs

@@ -218,6 +218,18 @@ namespace EIP_Protocol
         public OP30_DataSet_t mesData;
         public OP30_DataSet_t mesData;
         public IoT_DataSet_t iotData;
         public IoT_DataSet_t iotData;
         public OP30_TestData_t testData;
         public OP30_TestData_t testData;
+        public OP30_OtherData otherData;
+
+    }
+
+    public struct OP30_OtherData
+    {
+        [MarshalAs(UnmanagedType.I4)]
+        public int ChangeA;                              //左工位 0:取消换胶 1:换胶弹窗  2:扫码完成
+
+        [MarshalAs(UnmanagedType.I4)]
+        public int ChangeB;                             //右工位 0:取消换胶 1:换胶弹窗  2:扫码完成
+
     }
     }
 
 
     [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]
     [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]

+ 7 - 0
MainForm/FaForm/Dialog_BandBarode_S1.cs

@@ -15,6 +15,13 @@ using SqlSugar;
 
 
 namespace MainForm.FaForm
 namespace MainForm.FaForm
 {
 {
+    /// <summary>
+    /// 1.弹窗     plc ==>pc cmdParam=1
+    /// 2.扫码后   pc ==>plc cmdParam=2
+    /// 3.plc确认绑定 plc ==>pc cmdParam=3
+    /// 4.绑定成功 pc ==>plc cmdParam=4
+    /// 5.绑定失败 pc ==>plc cmdParam=5
+    /// </summary>
     public partial class Dialog_BandBarode_S1 : Form
     public partial class Dialog_BandBarode_S1 : Form
     {
     {
         public static bool isNoClose { get; set; }=false;
         public static bool isNoClose { get; set; }=false;

+ 169 - 4
MainForm/FaForm/Dialog_MaterialVerify_S1.Designer.cs

@@ -33,12 +33,177 @@ namespace MainForm.FaForm
         /// </summary>
         /// </summary>
         private void InitializeComponent()
         private void InitializeComponent()
         {
         {
-            this.components = new Container();
-            this.AutoScaleMode = AutoScaleMode.Font;
-            this.ClientSize = new Size(800, 450);
-            this.Text = "Dialog_MaterialVerify_S1";
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.groupBox2 = new System.Windows.Forms.GroupBox();
+            this.ErrorLab = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.Barcode = new System.Windows.Forms.TextBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.Station = new System.Windows.Forms.TextBox();
+            this.Type = new System.Windows.Forms.TextBox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.SN = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.groupBox1.SuspendLayout();
+            this.groupBox2.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // groupBox1
+            // 
+            this.groupBox1.Controls.Add(this.label4);
+            this.groupBox1.Controls.Add(this.SN);
+            this.groupBox1.Controls.Add(this.label2);
+            this.groupBox1.Controls.Add(this.Type);
+            this.groupBox1.Controls.Add(this.Station);
+            this.groupBox1.Controls.Add(this.label1);
+            this.groupBox1.Location = new System.Drawing.Point(33, 22);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(649, 183);
+            this.groupBox1.TabIndex = 0;
+            this.groupBox1.TabStop = false;
+            this.groupBox1.Text = "辅耗材信息";
+            // 
+            // groupBox2
+            // 
+            this.groupBox2.Controls.Add(this.ErrorLab);
+            this.groupBox2.Controls.Add(this.label3);
+            this.groupBox2.Controls.Add(this.Barcode);
+            this.groupBox2.Location = new System.Drawing.Point(33, 235);
+            this.groupBox2.Name = "groupBox2";
+            this.groupBox2.Size = new System.Drawing.Size(649, 92);
+            this.groupBox2.TabIndex = 12;
+            this.groupBox2.TabStop = false;
+            this.groupBox2.Text = "扫码区域";
+            // 
+            // ErrorLab
+            // 
+            this.ErrorLab.AutoSize = true;
+            this.ErrorLab.ForeColor = System.Drawing.Color.Red;
+            this.ErrorLab.Location = new System.Drawing.Point(184, 55);
+            this.ErrorLab.Name = "ErrorLab";
+            this.ErrorLab.Size = new System.Drawing.Size(0, 18);
+            this.ErrorLab.TabIndex = 7;
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(81, 27);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(62, 18);
+            this.label3.TabIndex = 6;
+            this.label3.Text = "二维码";
+            // 
+            // Barcode
+            // 
+            this.Barcode.Location = new System.Drawing.Point(187, 24);
+            this.Barcode.Name = "Barcode";
+            this.Barcode.Size = new System.Drawing.Size(280, 28);
+            this.Barcode.TabIndex = 5;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(99, 39);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(44, 18);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "工位";
+            // 
+            // Station
+            // 
+            this.Station.Location = new System.Drawing.Point(187, 36);
+            this.Station.Name = "Station";
+            this.Station.Size = new System.Drawing.Size(280, 28);
+            this.Station.TabIndex = 8;
+            // 
+            // Type
+            // 
+            this.Type.Location = new System.Drawing.Point(187, 77);
+            this.Type.Name = "Type";
+            this.Type.Size = new System.Drawing.Size(280, 28);
+            this.Type.TabIndex = 9;
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(63, 80);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(80, 18);
+            this.label2.TabIndex = 10;
+            this.label2.Text = "耗材类型";
+            // 
+            // SN
+            // 
+            this.SN.Location = new System.Drawing.Point(187, 120);
+            this.SN.Name = "SN";
+            this.SN.Size = new System.Drawing.Size(280, 28);
+            this.SN.TabIndex = 11;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(63, 123);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(80, 18);
+            this.label4.TabIndex = 12;
+            this.label4.Text = "耗材SN码";
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(390, 355);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(87, 36);
+            this.button1.TabIndex = 13;
+            this.button1.Text = "取消";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(237, 355);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(87, 36);
+            this.button2.TabIndex = 14;
+            this.button2.Text = "确认";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // Dialog_MaterialVerify_S1
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(718, 419);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Controls.Add(this.groupBox2);
+            this.Controls.Add(this.groupBox1);
+            this.Name = "Dialog_MaterialVerify_S1";
+            this.Text = "辅耗材上料";
+            this.Load += new System.EventHandler(this.Dialog_MaterialVerify_S1_Load);
+            this.groupBox1.ResumeLayout(false);
+            this.groupBox1.PerformLayout();
+            this.groupBox2.ResumeLayout(false);
+            this.groupBox2.PerformLayout();
+            this.ResumeLayout(false);
+
         }
         }
 
 
         #endregion
         #endregion
+
+        private GroupBox groupBox1;
+        private GroupBox groupBox2;
+        private Label ErrorLab;
+        private Label label3;
+        private TextBox Barcode;
+        private Label label1;
+        private TextBox Station;
+        private Label label2;
+        private TextBox Type;
+        private Label label4;
+        private TextBox SN;
+        private Button button1;
+        private Button button2;
     }
     }
 }
 }

+ 121 - 2
MainForm/FaForm/Dialog_MaterialVerify_S1.cs

@@ -1,12 +1,131 @@
-using System.Windows.Forms;
+using EIP_Protocol;
+using Sunny.UI;
+using System;
+using System.Collections.Generic;
+using System.Numerics;
+using System.Threading.Tasks;
+using System.Windows.Forms;
 
 
 namespace MainForm.FaForm
 namespace MainForm.FaForm
 {
 {
     public partial class Dialog_MaterialVerify_S1 : Form
     public partial class Dialog_MaterialVerify_S1 : Form
     {
     {
-        public Dialog_MaterialVerify_S1()
+        Form_Home home =new Form_Home();
+
+        int plcNo = 1;
+        string stationCode = "";
+        string stationName = "";
+        string tagBaseName = ""; //标签变量名称
+        string tagMesCommName = "mesCommToPC"; //标签变量名称
+        string tagBarsetName = "BarcodeSet";
+        (int, string) resultPLC;
+
+        OP30_MesData_t OP30PLC_MesData; //PLC的MES数据
+        OP70_MesData_t OP70PLC_MesData; //PLC的MES数据
+
+        private Timer _inputTimer;
+
+        public Dialog_MaterialVerify_S1(string Code,string Name,string tagName)
         {
         {
             InitializeComponent();
             InitializeComponent();
+            //置顶
+            this.TopMost = true;
+            // 设置窗口相对于父窗口居中
+            this.StartPosition = FormStartPosition.CenterParent;
+            this.Shown += MainForm_Shown;
+
+            stationCode = Code;
+            stationName = Name;
+            tagBaseName = tagName;
+        }
+
+        private void Dialog_MaterialVerify_S1_Load(object sender, System.EventArgs e)
+        {
+
+            home.FunsEip.Add(GlobalContext.IsUsePLCNow,
+                        new Inovance_EIP(GlobalContext.PC1Address, GlobalContext.Machine1Address)); //OP10 壳体清洁上料装备
+
+            foreach (Inovance_EIP plcEIP in home.FunsEip.Values)
+            {
+                if (plcEIP != null)
+                {
+                    try
+                    {
+                        (int, string) result = plcEIP.Connect();
+                    }
+                    catch (Exception ex)
+                    {
+                        MessageBox.Show($"PLC[{plcEIP._pcIPStr}]连接失败!失败信息:" + ex.Message,
+                            "PLC连接提示", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
+                            MessageBoxOptions.ServiceNotification);
+                    }
+                }
+            }
+            List<Task> TaskReadProcess = new List<Task>(); // 线程-触发点位(PLC)的线程
+            TaskReadProcess.Add(new Task(() => { ReadStation(); })); // 开启PLC的业务处理线程-监听PLC点位+状态
+            foreach (Task task in TaskReadProcess)
+            {
+                if (task != null)
+                    task.Start();
+            }
+        }
+
+        private void button2_Click(object sender, System.EventArgs e)
+        {
+            // 初始化定时器
+            _inputTimer = new Timer();
+            _inputTimer.Interval = 500; // 500毫秒
+            _inputTimer.Tick += InputTimer_Tick;
+        }
+
+        private void button1_Click(object sender, System.EventArgs e)
+        {
+
+        }
+
+        private void ReadStation()
+        {
+            while (true)
+            {
+                if (stationCode.Contains("30"))
+                {
+                    resultPLC = home.FunsEip[plcNo]
+                            .Read_SingleTag<OP30_MesData_t>(tagBaseName, 1, out OP30PLC_MesData, this); //读取单个结构体数据
+                }
+                if (stationCode.Contains("70"))
+                {
+                    resultPLC = home.FunsEip[plcNo]
+                            .Read_SingleTag<OP30_MesData_t>(tagBaseName, 1, out OP30PLC_MesData, this); //读取单个结构体数据
+                }
+
+                if (resultPLC.Item1 == 0)
+                {
+                  
+                }
+
+            }
         }
         }
+
+        private void MainForm_Shown(object sender, EventArgs e)
+        {
+            // 将焦点设置到 textBox1
+            Barcode.Focus();
+        }
+
+        private void InputTimer_Tick(object sender, EventArgs e)
+        {
+            // 定时器触发,表示输入已经完成
+            _inputTimer.Stop();
+            //模拟点击
+            Barcode.Focus();
+
+            string strBarcode = Barcode.Text.Trim();
+            if (!string.IsNullOrEmpty(strBarcode))
+            {
+                SN.Text = strBarcode;
+                Barcode.Text = "";
+            }
+        }
+
     }
     }
 }
 }

+ 120 - 0
MainForm/FaForm/Dialog_MaterialVerify_S1.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 8 - 0
MainForm/FaForm/Form_Home.cs

@@ -4397,6 +4397,14 @@ namespace MainForm
 
 
                         stopwatch2.Stop();
                         stopwatch2.Stop();
 
 
+                        #region 辅材上料扫码
+                        if (stPLC_MesData.Left.otherData.ChangeA == 1 || stPLC_MesData.Left.otherData.ChangeB == 1)
+                        {
+
+                        }
+
+                        #endregion
+
                         #region 左边进站
                         #region 左边进站
 
 
                         try
                         try