Explorar o código

读取仪器数据修改

callm hai 3 meses
pai
achega
ca2b152b55

+ 2 - 2
FileWatcher/AutoAnalysisXml.cs

@@ -104,7 +104,7 @@ namespace FileWatcher
             {
                 if (Master.Text == DB.Rows[i]["ma_user"].ToString())
                 {
-                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=HUAG;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YYCW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
                     dh = new DataHelper();
                 }
             }
@@ -142,7 +142,7 @@ namespace FileWatcher
             {
                 if (Master.Text == DB.Rows[i]["ma_user"].ToString())
                 {
-                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=HUAG;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YYCW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
                     dh = new DataHelper();
                     LogicHandler.dh = new DataHelper();
                 }

+ 51 - 12
FileWatcher/AutoMakeQTY.cs

@@ -5,15 +5,11 @@ using System.Data;
 using System.IO;
 using System.Threading;
 using System.Windows.Forms;
-using System.Xml;
 using System.Text;
 using System.Net;
 using System.Net.Sockets;
-using System.Text.RegularExpressions;
 using System.IO.Ports;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement;
-using System.Windows.Media.Media3D;
-using System.Runtime.InteropServices;
+using System.Linq.Expressions;
 
 namespace FileWatcher
 {
@@ -65,8 +61,48 @@ namespace FileWatcher
             BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
 
+        private int Val(char Expression)
+        {
+            if (Expression >= '1' && Expression <= '9')
+            {
+                return unchecked((int)Expression) - 48;
+            }
+            return 0;
+        }
+
         private void Form1_Load(object sender, EventArgs e)
         {
+
+            byte[] b2 = new byte[4];
+            float f2;
+            string tmp_b2 = "43666AEC";
+
+            tmp_b2 = tmp_b2.Replace(" ", "");//删除字符串中间的空格
+
+            if (tmp_b2.Length != 8)
+            {
+                //判断输入字符串的长度是否合适
+                MessageBox.Show("输入Byte长度错误,为连续8位4个字节,高位为0的补齐0");
+            }
+            else
+            {
+                //将收到的字符串分成4个字节,这4个字节是字符串的形式
+                string tmp_char1 = tmp_b2.Substring(0, 2);
+                string tmp_char2 = tmp_b2.Substring(2, 2);
+                string tmp_char3 = tmp_b2.Substring(4, 2);
+                string tmp_char4 = tmp_b2.Substring(6, 2);
+                //将4字节的字符串格式转换成16进制的byte格式
+                b2[3] = Convert.ToByte(tmp_char1, 16);
+                b2[2] = Convert.ToByte(tmp_char2, 16);
+                b2[1] = Convert.ToByte(tmp_char3, 16);
+                b2[0] = Convert.ToByte(tmp_char4, 16);
+
+                //将16进制byte转换成浮点数格式
+                f2 = BitConverter.ToSingle(b2, 0);
+                Console.WriteLine(Convert.ToString(f2)); ;
+            }
+
+
             CheckForIllegalCrossThreadCalls = false;
             FormBorderStyle = FormBorderStyle.FixedSingle;
             serialPort1.DataReceived += SerialPort1_DataReceived;
@@ -90,11 +126,11 @@ namespace FileWatcher
                 Type.Text = BaseUtil.GetCacheData("Type").ToString();
                 ComPort.Text = BaseUtil.GetCacheData("ComPort").ToString();
                 BaudRate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
+                li_code.Text = BaseUtil.GetCacheData("Line").ToString();
             }
             catch (Exception ex) { MessageBox.Show(ex.Message); }
-
-
         }
+
         double lastqty = 0;
         private void SerialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
         {
@@ -134,7 +170,7 @@ namespace FileWatcher
                     string ma_endqty = dh.getFieldDataByCondition("make", "nvl(ma_endqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
                     dh.ExecuteSql("update make set ma_endqty=nvl(ma_endqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
                     dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode)" +
-                             "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "'),'" + li_code.Text + "'", "insert");
+                             "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "')", "insert");
                 }
                 lastqty = qty;
             }
@@ -170,6 +206,7 @@ namespace FileWatcher
             BaseUtil.SetCacheData("Type", Type.Text);
             BaseUtil.SetCacheData("ComPort", ComPort.Text);
             BaseUtil.SetCacheData("BaudRate", BaudRate.Text);
+            BaseUtil.SetCacheData("Line", li_code.Text);
             if (!dh.CheckExist("Make", "ma_code='" + ma_code.Text + "'"))
             {
                 OperateResult.AppendText("工单号不能为空\n");
@@ -194,6 +231,7 @@ namespace FileWatcher
                 serialPort1.PortName = ComPort.Text;
                 serialPort1.BaudRate = int.Parse(BaudRate.Text);
                 serialPort1.Open();
+                Timer.Start();
             }
             catch (Exception mes)
             {
@@ -202,9 +240,7 @@ namespace FileWatcher
                 else
                     OperateResult.AppendText(">>" + mes.Message + "\n");
             }
-
             OperateResult.AppendText("开始执行监控\n");
-            Timer.Start();
         }
 
         private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
@@ -250,8 +286,11 @@ namespace FileWatcher
 
         private void Timer_Tick(object sender, EventArgs e)
         {
-            byte[] data = HexStringToBytes("01 03 00 01 00 06 94 08");
-            serialPort1.Write(data, 0, data.Length);
+            if (serialPort1.IsOpen)
+            {
+                byte[] data = HexStringToBytes("01 03 00 01 00 06 94 08");
+                serialPort1.Write(data, 0, data.Length);
+            }
         }
 
         private void AutoStart_CheckedChanged(object sender, EventArgs e)

+ 346 - 0
FileWatcher/AutoMakeQTYRZ.Designer.cs

@@ -0,0 +1,346 @@
+namespace FileWatcher
+{
+    partial class AutoMakeQTYRZ
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.components = new System.ComponentModel.Container();
+            this.XmlWatcher = new System.IO.FileSystemWatcher();
+            this.XmlFolder = new System.Windows.Forms.FolderBrowserDialog();
+            this.StartWatch = new System.Windows.Forms.Button();
+            this.StopWatch = new System.Windows.Forms.Button();
+            this.OperateResult = new System.Windows.Forms.RichTextBox();
+            this.Clean = new System.Windows.Forms.Button();
+            this.MakeCode_lable = new System.Windows.Forms.Label();
+            this.Timer = new System.Windows.Forms.Timer(this.components);
+            this.ATEFile = new System.IO.FileSystemWatcher();
+            this.Type = new System.Windows.Forms.ComboBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.AutoStart = new System.Windows.Forms.CheckBox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.BaudRate = new System.Windows.Forms.TextBox();
+            this.NowQTY = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.ComPort = new FileWatcher.SerialPortCombox();
+            this.li_code = new FileWatcher.SearchTextBox();
+            this.label5 = new System.Windows.Forms.Label();
+            this.ma_code = new FileWatcher.SearchTextBox();
+            this.GetData = new System.Windows.Forms.Button();
+            ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.ATEFile)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // XmlWatcher
+            // 
+            this.XmlWatcher.EnableRaisingEvents = true;
+            this.XmlWatcher.Filter = "*.log";
+            this.XmlWatcher.SynchronizingObject = this;
+            // 
+            // StartWatch
+            // 
+            this.StartWatch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.StartWatch.Location = new System.Drawing.Point(290, 557);
+            this.StartWatch.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.StartWatch.Name = "StartWatch";
+            this.StartWatch.Size = new System.Drawing.Size(128, 56);
+            this.StartWatch.TabIndex = 0;
+            this.StartWatch.Text = "开始监控";
+            this.StartWatch.UseVisualStyleBackColor = true;
+            this.StartWatch.Click += new System.EventHandler(this.StartWatch_Click);
+            // 
+            // StopWatch
+            // 
+            this.StopWatch.Enabled = false;
+            this.StopWatch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.StopWatch.Location = new System.Drawing.Point(700, 557);
+            this.StopWatch.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.StopWatch.Name = "StopWatch";
+            this.StopWatch.Size = new System.Drawing.Size(128, 56);
+            this.StopWatch.TabIndex = 1;
+            this.StopWatch.Text = "停止监控";
+            this.StopWatch.UseVisualStyleBackColor = true;
+            this.StopWatch.Click += new System.EventHandler(this.StopWatch_Click);
+            // 
+            // OperateResult
+            // 
+            this.OperateResult.Location = new System.Drawing.Point(892, 22);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.OperateResult.Name = "OperateResult";
+            this.OperateResult.Size = new System.Drawing.Size(517, 535);
+            this.OperateResult.TabIndex = 7;
+            this.OperateResult.Text = "";
+            // 
+            // Clean
+            // 
+            this.Clean.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Clean.Location = new System.Drawing.Point(1096, 580);
+            this.Clean.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.Clean.Name = "Clean";
+            this.Clean.Size = new System.Drawing.Size(112, 48);
+            this.Clean.TabIndex = 8;
+            this.Clean.Text = "清除";
+            this.Clean.UseVisualStyleBackColor = true;
+            this.Clean.Click += new System.EventHandler(this.Clean_Click);
+            // 
+            // MakeCode_lable
+            // 
+            this.MakeCode_lable.AutoSize = true;
+            this.MakeCode_lable.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.MakeCode_lable.Location = new System.Drawing.Point(34, 220);
+            this.MakeCode_lable.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.MakeCode_lable.Name = "MakeCode_lable";
+            this.MakeCode_lable.Size = new System.Drawing.Size(104, 38);
+            this.MakeCode_lable.TabIndex = 12;
+            this.MakeCode_lable.Text = "工单号";
+            // 
+            // Timer
+            // 
+            this.Timer.Interval = 2000;
+            this.Timer.Tick += new System.EventHandler(this.Timer_Tick);
+            // 
+            // ATEFile
+            // 
+            this.ATEFile.EnableRaisingEvents = true;
+            this.ATEFile.Filter = "*.txt";
+            this.ATEFile.SynchronizingObject = this;
+            // 
+            // Type
+            // 
+            this.Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.Type.FormattingEnabled = true;
+            this.Type.Items.AddRange(new object[] {
+            "投入",
+            "产出"});
+            this.Type.Location = new System.Drawing.Point(204, 44);
+            this.Type.Name = "Type";
+            this.Type.Size = new System.Drawing.Size(436, 32);
+            this.Type.TabIndex = 18;
+            this.Type.Visible = false;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(34, 38);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(75, 38);
+            this.label1.TabIndex = 19;
+            this.label1.Text = "类型";
+            this.label1.Visible = false;
+            // 
+            // AutoStart
+            // 
+            this.AutoStart.AutoSize = true;
+            this.AutoStart.Checked = true;
+            this.AutoStart.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.AutoStart.Location = new System.Drawing.Point(678, 227);
+            this.AutoStart.Name = "AutoStart";
+            this.AutoStart.Size = new System.Drawing.Size(186, 28);
+            this.AutoStart.TabIndex = 20;
+            this.AutoStart.Text = "开机自动启动";
+            this.AutoStart.UseVisualStyleBackColor = true;
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(34, 120);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(75, 38);
+            this.label2.TabIndex = 22;
+            this.label2.Text = "串口";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label3.Location = new System.Drawing.Point(426, 120);
+            this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(104, 38);
+            this.label3.TabIndex = 23;
+            this.label3.Text = "波特率";
+            // 
+            // BaudRate
+            // 
+            this.BaudRate.Location = new System.Drawing.Point(564, 120);
+            this.BaudRate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.BaudRate.Name = "BaudRate";
+            this.BaudRate.Size = new System.Drawing.Size(146, 35);
+            this.BaudRate.TabIndex = 24;
+            // 
+            // NowQTY
+            // 
+            this.NowQTY.Location = new System.Drawing.Point(204, 373);
+            this.NowQTY.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.NowQTY.Name = "NowQTY";
+            this.NowQTY.Size = new System.Drawing.Size(146, 35);
+            this.NowQTY.TabIndex = 26;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label4.Location = new System.Drawing.Point(34, 370);
+            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(133, 38);
+            this.label4.TabIndex = 25;
+            this.label4.Text = "当前计数";
+            // 
+            // ComPort
+            // 
+            this.ComPort.Location = new System.Drawing.Point(204, 120);
+            this.ComPort.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.ComPort.Name = "ComPort";
+            this.ComPort.Size = new System.Drawing.Size(176, 40);
+            this.ComPort.TabIndex = 21;
+            // 
+            // li_code
+            // 
+            this.li_code.AllPower = null;
+            this.li_code.Caller = null;
+            this.li_code.Condition = null;
+            this.li_code.DBTitle = null;
+            this.li_code.FormName = null;
+            this.li_code.Location = new System.Drawing.Point(204, 291);
+            this.li_code.Name = "li_code";
+            this.li_code.Power = null;
+            this.li_code.ReturnData = null;
+            this.li_code.SelectField = null;
+            this.li_code.SetValueField = null;
+            this.li_code.Size = new System.Drawing.Size(436, 41);
+            this.li_code.TabIndex = 28;
+            this.li_code.TableName = null;
+            this.li_code.TextBoxEnable = false;
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label5.Location = new System.Drawing.Point(34, 291);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(82, 41);
+            this.label5.TabIndex = 27;
+            this.label5.Text = "线别";
+            // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = null;
+            this.ma_code.Caller = null;
+            this.ma_code.Condition = null;
+            this.ma_code.DBTitle = null;
+            this.ma_code.FormName = null;
+            this.ma_code.Location = new System.Drawing.Point(204, 214);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Power = null;
+            this.ma_code.ReturnData = null;
+            this.ma_code.SelectField = null;
+            this.ma_code.SetValueField = null;
+            this.ma_code.Size = new System.Drawing.Size(436, 41);
+            this.ma_code.TabIndex = 29;
+            this.ma_code.TableName = null;
+            this.ma_code.TextBoxEnable = false;
+            // 
+            // GetData
+            // 
+            this.GetData.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.GetData.Location = new System.Drawing.Point(492, 557);
+            this.GetData.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.GetData.Name = "GetData";
+            this.GetData.Size = new System.Drawing.Size(128, 56);
+            this.GetData.TabIndex = 30;
+            this.GetData.Text = "获取数据";
+            this.GetData.UseVisualStyleBackColor = true;
+            this.GetData.Click += new System.EventHandler(this.GetData_Click);
+            // 
+            // AutoMakeQTYRZ
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(1443, 640);
+            this.Controls.Add(this.GetData);
+            this.Controls.Add(this.ma_code);
+            this.Controls.Add(this.li_code);
+            this.Controls.Add(this.label5);
+            this.Controls.Add(this.NowQTY);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.BaudRate);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.ComPort);
+            this.Controls.Add(this.AutoStart);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.Type);
+            this.Controls.Add(this.MakeCode_lable);
+            this.Controls.Add(this.Clean);
+            this.Controls.Add(this.OperateResult);
+            this.Controls.Add(this.StopWatch);
+            this.Controls.Add(this.StartWatch);
+            this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.MaximizeBox = false;
+            this.Name = "AutoMakeQTYRZ";
+            this.Text = "UAS设备数据解析 2024-11-29  10:05";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
+            this.Load += new System.EventHandler(this.Form1_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.ATEFile)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.IO.FileSystemWatcher XmlWatcher;
+        private System.Windows.Forms.FolderBrowserDialog XmlFolder;
+        private System.Windows.Forms.Button StopWatch;
+        private System.Windows.Forms.Button StartWatch;
+        private System.Windows.Forms.RichTextBox OperateResult;
+        private System.Windows.Forms.Button Clean;
+        private System.Windows.Forms.Label MakeCode_lable;
+        private System.Windows.Forms.Timer Timer;
+        private System.IO.FileSystemWatcher ATEFile;
+        private System.Windows.Forms.ComboBox Type;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.CheckBox AutoStart;
+        private SerialPortCombox ComPort;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.TextBox BaudRate;
+        private System.Windows.Forms.TextBox NowQTY;
+        private System.Windows.Forms.Label label4;
+        private SearchTextBox li_code;
+        private System.Windows.Forms.Label label5;
+        private SearchTextBox ma_code;
+        private System.Windows.Forms.Button GetData;
+    }
+}
+

+ 349 - 0
FileWatcher/AutoMakeQTYRZ.cs

@@ -0,0 +1,349 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Threading;
+using System.Windows.Forms;
+using System.Xml;
+using System.Text;
+using System.Net;
+using System.Net.Sockets;
+using System.Text.RegularExpressions;
+using System.IO.Ports;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement;
+using System.Windows.Media.Media3D;
+using System.Runtime.InteropServices;
+
+namespace FileWatcher
+{
+    public partial class AutoMakeQTYRZ : Form
+    {
+
+        DataHelper dh;
+
+        DataTable dt;
+
+        DataTable DB;
+
+        /// <summary>
+        /// 用户编号
+        /// </summary>
+        string iusercode;
+        /// <summary>
+        /// 岗位资源
+        /// </summary>
+        string isource;
+
+        Thread InitDB;
+        /// 当前工序
+        /// </summary>
+        string istepcode;
+        StringBuilder sql = new StringBuilder();
+        /// <summary>
+        /// 缓存的文件
+        /// </summary>
+        public static string CachePath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/Cache.xml";
+        /// <summary>
+        /// 缓存的文件夹
+        /// </summary>
+        public static string CachePathFolder = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":/UAS_MES/XmlAnalysor/";
+
+        ftpOperater ftp = new ftpOperater();
+
+        public AutoMakeQTYRZ()
+        {
+            InitializeComponent();
+            StartPosition = FormStartPosition.CenterScreen;
+        }
+        DataTable Dbfind;
+
+        string IPAddress = "";
+        private void nr_rule_DBChange(object sender, EventArgs e)
+        {
+            Dbfind = li_code.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+        }
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            CheckForIllegalCrossThreadCalls = false;
+            FormBorderStyle = FormBorderStyle.FixedSingle;
+            serialPort1.DataReceived += SerialPort1_DataReceived;
+            InitDB = new Thread(ConnectDB);
+            //添加监控事件
+            XmlWatcher.Changed += new FileSystemEventHandler(XmlWatcher_Created);
+            //ATEFile.Changed += new FileSystemEventHandler(XmlWatcher_Created);
+            SetLoadingWindow stw = new SetLoadingWindow(InitDB, "正在启动程序");
+            stw.StartPosition = FormStartPosition.CenterScreen;
+            stw.ShowDialog();
+            List<string> CacheInf = new List<string>();
+            IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
+            for (int i = 0; i < IpEntry.AddressList.Length; i++)
+            {
+                if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
+                    IPAddress = IpEntry.AddressList[i].ToString();
+            }
+            //获取缓存信息
+            try
+            {
+                Type.Text = BaseUtil.GetCacheData("Type").ToString();
+                ComPort.Text = BaseUtil.GetCacheData("ComPort").ToString();
+                BaudRate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
+                li_code.Text = BaseUtil.GetCacheData("Line").ToString();
+            }
+            catch (Exception ex) { MessageBox.Show(ex.Message); }
+
+
+        }
+
+        private float getdata(string tmp_b2)
+        {
+            byte[] b2 = new byte[4];
+            float f2 = 0;
+
+            tmp_b2 = tmp_b2.Replace(" ", "");//删除字符串中间的空格
+            if (tmp_b2.Length != 8)
+            {
+                //判断输入字符串的长度是否合适
+                MessageBox.Show("输入Byte长度错误,为连续8位4个字节,高位为0的补齐0");
+            }
+            else
+            {
+                //将收到的字符串分成4个字节,这4个字节是字符串的形式
+                string tmp_char1 = tmp_b2.Substring(6, 2);
+                string tmp_char2 = tmp_b2.Substring(4, 2);
+                string tmp_char3 = tmp_b2.Substring(2, 2);
+                string tmp_char4 = tmp_b2.Substring(0, 2);
+                //将4字节的字符串格式转换成16进制的byte格式
+                b2[3] = Convert.ToByte(tmp_char1, 16);
+                b2[2] = Convert.ToByte(tmp_char2, 16);
+                b2[1] = Convert.ToByte(tmp_char3, 16);
+                b2[0] = Convert.ToByte(tmp_char4, 16);
+                //将16进制byte转换成浮点数格式
+                f2 = BitConverter.ToSingle(b2, 0);
+            }
+            return f2;
+        }
+
+        double lastqty = 0;
+        private void SerialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
+        {
+            int len = serialPort1.BytesToRead;
+            Byte[] readBuffer = new Byte[len];
+            serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
+            string data = BitConverter.ToString(readBuffer, 0, readBuffer.Length).Replace("-", "");
+
+            float 电压数据 = getdata(data.Substring(6, 8));
+            float 电流数据 = getdata(data.Substring(14, 8));
+            float 功率数据 = getdata(data.Substring(22, 8));
+            float 频率数据 = getdata(data.Substring(30, 8));
+            float 功率因素 = getdata(data.Substring(38, 8));
+            OperateResult.AppendText(data);
+            OperateResult.AppendText(电压数据.ToString() + "\n");
+            OperateResult.AppendText(电流数据.ToString() + "\n");
+            OperateResult.AppendText(功率数据.ToString() + "\n");
+            OperateResult.AppendText(频率数据.ToString() + "\n");
+            OperateResult.AppendText(功率因素.ToString() + "\n");
+            //如果电流是0,则下次重新获取数据
+            dh.ExecuteSql("insert into currenttest(CT_ID, CT_MAKECODE, CT_VOLTAGE, CT_CURRENT, CT_POWER, CT_FREQUENCY, CT_POWER1)" +
+                  "VALUES(currenttest_SEQ.NEXTVAL,'" + ma_code.Text + "','" + 电压数据 + "','" + 电流数据 + "','" + 功率数据 + "','"+ 频率数据 + "','"+ 功率因素 + "')", "insert");
+            if (电流数据 == 0)
+            {
+                lastqty = 1;
+            }
+            else
+            {
+                lastqty = 0;
+            }
+            if (lastqty != 0)
+            {
+                if (电流数据 == 0)
+                {
+                    lastqty = 0;
+                }
+                else
+                {
+                    lastqty = 1;
+                }
+
+              
+            }
+        }
+
+        private void ConnectDB()
+        {
+            dh = new DataHelper();
+            SystemInf.dh = dh;
+
+            ma_code.TableName = "make";
+            ma_code.SelectField = "ma_code # 工单号";
+            ma_code.FormName = Name;
+            ma_code.DBTitle = "工单查询";
+            ma_code.SetValueField = new string[] { "ma_code" };
+            ma_code.Condition = "";
+            ma_code.DbChange += nr_rule_DBChange;
+
+            li_code.TableName = "line";
+            li_code.SelectField = "li_code # 线别编号,li_name # 线别名称";
+            li_code.FormName = Name;
+            li_code.DBTitle = "线别查询";
+            li_code.SetValueField = new string[] { "li_code" };
+            li_code.Condition = "";
+            li_code.DbChange += nr_rule_DBChange;
+        }
+        SerialPort serialPort1 = new SerialPort();
+
+        private void StartWatch_Click(object sender, EventArgs e)
+        {
+            BaseUtil.SetCacheData("Type", Type.Text);
+            BaseUtil.SetCacheData("ComPort", ComPort.Text);
+            BaseUtil.SetCacheData("BaudRate", BaudRate.Text);
+            BaseUtil.SetCacheData("Line", li_code.Text);
+            if (!dh.CheckExist("Make", "ma_code='" + ma_code.Text + "'"))
+            {
+                OperateResult.AppendText("工单号不能为空\n");
+                return;
+            }
+            //if (!dh.CheckExist("line", "li_code='" + li_code.Text + "'"))
+            //{
+            //    OperateResult.AppendText("线别不能为空\n");
+            //    return;
+            //}
+            //string ExitConfirm = MessageBox.Show(this, "确认计数器是否置为0?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            //if (ExitConfirm != "Yes")
+            //{
+            //    return;
+            //}
+            //设置按钮不可点击
+            StartWatch.Enabled = false;
+            ma_code.Enabled = false;
+            StopWatch.Enabled = true;
+            try
+            {
+                serialPort1.PortName = ComPort.Text;
+                serialPort1.BaudRate = int.Parse(BaudRate.Text);
+                serialPort1.Open();
+                Timer.Start();
+            }
+            catch (Exception mes)
+            {
+                if (BaudRate.Text == "" || BaudRate.Text == "")
+                    OperateResult.AppendText(">>请先维护波特率和串口\n");
+                else
+                    OperateResult.AppendText(">>" + mes.Message + "\n");
+            }
+            OperateResult.AppendText("开始执行监控\n");
+        }
+
+        private void XmlWatcher_Created(object sender, FileSystemEventArgs e)
+        {
+            OperateResult.AppendText("文件修改:" + e.FullPath + "\n");
+            TxtHandleProcess(e.FullPath);
+        }
+
+        string nextLine;
+        private void TxtHandleProcess(string FileName)
+        {
+            List<string> badcode = new List<string>();
+            List<string> badlocation = new List<string>();
+            List<string> badprod = new List<string>();
+
+        }
+
+        private void StopWatch_Click(object sender, EventArgs e)
+        {
+            XmlWatcher.EnableRaisingEvents = false;
+            StartWatch.Enabled = true;
+            ma_code.Enabled = true;
+
+            StopWatch.Enabled = false;
+            OperateResult.AppendText("停止执行监控\n");
+        }
+
+        private void Clean_Click(object sender, EventArgs e)
+        {
+            OperateResult.Clear();
+        }
+
+        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            string ExitConfirm = MessageBox.Show(this, "确认退出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+            if (ExitConfirm != "Yes")
+            {
+                WindowState = FormWindowState.Minimized;
+                e.Cancel = true;
+            }
+        }
+
+
+        private void Timer_Tick(object sender, EventArgs e)
+        {
+            if (serialPort1.IsOpen)
+            {
+                byte[] data = HexStringToBytes("55 00 10 65");
+                serialPort1.Write(data, 0, data.Length);
+            }
+        }
+
+        private void AutoStart_CheckedChanged(object sender, EventArgs e)
+        {
+            SetAutoRun();
+        }
+        private void SetAutoRun()
+        {
+            if (AutoStart.Checked) //设置开机自启动  
+            {
+                string path = Application.ExecutablePath;
+                RegistryKey rk = Registry.LocalMachine;
+                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
+                rk2.SetValue("FileWatcher.exe", path);
+                rk2.Close();
+                rk.Close();
+            }
+            else //取消开机自启动  
+            {
+                string path = Application.ExecutablePath;
+                RegistryKey rk = Registry.LocalMachine;
+                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
+                rk2.DeleteValue("FileWatcher.exe", false);
+                rk2.Close();
+                rk.Close();
+            }
+        }
+
+        private byte[] HexStringToBytes(string hs)//十六进制字符串转byte
+        {
+            string a = hs.Replace(" ", "");
+            int bytelength = 0;
+            if (a.Length % 2 == 0)
+            {
+                bytelength = a.Length / 2;
+            }
+            else
+            {
+                bytelength = a.Length / 2 + 1;
+            }
+            byte[] b = new byte[bytelength];
+            //逐个字符变为16进制字节数据
+            for (int i = 0; i < bytelength; i++)
+            {
+                if (i == bytelength - 1)
+                {
+                    b[i] = Convert.ToByte(a.Substring(i * 2), 16);
+                }
+                else
+                {
+                    b[i] = Convert.ToByte(a.Substring(i * 2, 2), 16);
+                }
+            }
+            //按照指定编码将字节数组变为字符串
+            return b;
+        }
+
+        private void GetData_Click(object sender, EventArgs e)
+        {
+
+        }
+    }
+}

+ 132 - 0
FileWatcher/AutoMakeQTYRZ.resx

@@ -0,0 +1,132 @@
+<?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>
+  <metadata name="XmlWatcher.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="XmlFolder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>164, 17</value>
+  </metadata>
+  <metadata name="Timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>296, 17</value>
+  </metadata>
+  <metadata name="ATEFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>435, 17</value>
+  </metadata>
+</root>

+ 7 - 7
FileWatcher/DataHelper.cs

@@ -8,14 +8,14 @@ namespace FileWatcher
 {
    public class DataHelper
     {
-        //系统默认的的连接字符串
-        //private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-        ////用户选择的数据库的连接字符串
-        //public static string DBConnectionString= "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-
-        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YD_CYZZ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.85)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+       // 系统默认的的连接字符串
+        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.6.28)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
-        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YD_CYZZ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.85)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.6.28)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+
+        //private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YD_CYZZ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.85)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        ////用户选择的数据库的连接字符串
+        //public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=YD_CYZZ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.85)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
 
         public static OracleConnection connection = null;
         OracleCommand command = null;

+ 9 - 0
FileWatcher/FileWatcher.csproj

@@ -96,6 +96,12 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AutoMakeQTYRZ.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="AutoMakeQTYRZ.Designer.cs">
+      <DependentUpon>AutoMakeQTYRZ.cs</DependentUpon>
+    </Compile>
     <Compile Include="AutoMakeQTY.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -266,6 +272,9 @@
     <Compile Include="测试记录解析DCW.Designer.cs">
       <DependentUpon>测试记录解析DCW.cs</DependentUpon>
     </Compile>
+    <EmbeddedResource Include="AutoMakeQTYRZ.resx">
+      <DependentUpon>AutoMakeQTYRZ.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="AutoMakeQTY.resx">
       <DependentUpon>AutoMakeQTY.cs</DependentUpon>
     </EmbeddedResource>

+ 1 - 1
FileWatcher/Program.cs

@@ -45,7 +45,7 @@ namespace FileWatcher
                 Application.EnableVisualStyles();
                 Application.SetCompatibleTextRenderingDefault(false);
                 if (principal.IsInRole(WindowsBuiltInRole.Administrator))
-                    Application.Run(new SOP("",""));
+                    Application.Run(new AutoMakeQTYRZ());
                 else
                 {
                     //创建启动对象