Przeglądaj źródła

"=====特殊版本:为波兰工厂由于DHA抄写失败而作的临时解决方案。"

This reverts commit 7a8e3938e2174567542aff0904e2f6bf635606cf.
sat23 3 lat temu
rodzic
commit
b45dafafd2

+ 3 - 0
SCBC Factory Tools/Models/StructList.cs

@@ -196,6 +196,9 @@ namespace MOKA_Factory_Tools
         /// 单位:毫秒
         /// </summary>
         public int NextCommandWaitTime { get; set; } = 100;
+        #region 波兰工厂临时解决方案;
+        public int CheckDHAWaitTime { get; set; } = 8000;
+        #endregion
     }
 
     public class KeyInfo

+ 11 - 0
SCBC Factory Tools/Views/Main.cs

@@ -720,6 +720,17 @@ namespace MOKA_Factory_Tools
                     functionSetting1.NextCommandWaitTime = SerialCMD.NextCommandWaitTime = jObject["NextCommandWaitTime"].Value<int>();
                 }
 
+                #region 波兰工厂临时解决方案
+                if (jObject["CheckDHAWaitTime"] == null)
+                {
+                    SaveJsonConfig("CheckDHAWaitTime", functionSetting1.CheckDHAWaitTime);
+                }
+                else
+                {
+                    functionSetting1.CheckDHAWaitTime = jObject["CheckDHAWaitTime"].Value<int>();
+                }
+                #endregion
+
                 foreach (var ss in jObject["Channel"])  //遍历Channel
                 {
                     Dictionary<string, string> ChannelValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(ss.ToString());

+ 107 - 1
SCBC Factory Tools/Views/OperationPanel.cs

@@ -37,7 +37,7 @@ namespace MOKA_Factory_Tools
         KeyInfo keyInfo = new KeyInfo();
         FireTVKey fireTVKey = new FireTVKey();
         bool preloadNow;
-        string SN;
+        string SN = "";
         string orderNow;
         Main mainform;
         int usingTime = 0;
@@ -46,6 +46,7 @@ namespace MOKA_Factory_Tools
         Thread WritekeyThread;
         string availableCount = "unknow";
 
+        public string PSN = "";
 
         //删除界面指针委托
         public delegate void DisplayUpdateDelegate(IntPtr intPtr);
@@ -708,12 +709,88 @@ namespace MOKA_Factory_Tools
         {
             if (e.KeyCode == Keys.Enter)
             {
+#if true
+                #region 波兰工厂临时解决方案
+                // 获取条码前缀;
+                string strSN = SNText.Text;
+                SNText.Text = "";
+                SNText.Enabled = false;
+                if (strSN.StartsWith(orderNow))
+                {
+                    if (SN.Length == 17)
+                    {
+                        MessageBox.Show("FSN already has, please scan PSN", "Error", MessageBoxButtons.OK);
+                        SNText.Enabled = true;
+                        return;
+                    }
+
+                    if (strSN.Length != 17)
+                    {
+                        MessageBox.Show("The length of FSN is wrong!", "Error", MessageBoxButtons.OK);
+                        SNText.Enabled = true;
+                        return;
+                    }
+
+                    SN = strSN;
+                    if (PSN.Length != 17)
+                    {
+                        SNText.Enabled = true;
+                        return;
+                    }
+
+                    SNText.Enabled = true;
+                }
+                else if (strSN.StartsWith("B"))
+                {
+                    if (PSN.Length == 17)
+                    {
+                        MessageBox.Show("PSN already has, please scan FSN", "Error", MessageBoxButtons.OK);
+                        SNText.Enabled = true;
+                        return;
+                    }
+
+                    if (strSN.Length != 17)
+                    {
+                        MessageBox.Show("The length of PSN is wrong", "Error", MessageBoxButtons.OK);
+                        SNText.Enabled = true;
+                        return;
+                    }
+
+                    PSN = strSN;
+                    if (SN.Length != 17)
+                    {
+                        SNText.Enabled = true;
+                        return;
+                    }
+
+                    SNText.Enabled = true;
+                }
+                else
+                {
+                    MessageBox.Show("Unknown barcode type=" + strSN, "Error", MessageBoxButtons.OK);
+                    SNText.Enabled = true;
+                    return;
+                }
+
+                if (PSN.Length == 0 || SN.Length == 0)
+                {
+                    SNText.Enabled = true;
+                    return;
+                }
+                keyInfo = new KeyInfo();
+                FocusMark = false;
+                SNKeyDownEven(this.Handle);
+                SetInitialStatus();
+                SNText.Enabled = false;
+                #endregion 波兰工厂临时解决方案
+#else
                 keyInfo = new KeyInfo();
                 FocusMark = false;
                 SNKeyDownEven(this.Handle);
                 SetInitialStatus();
                 SN = SNText.Text;
                 SNText.Enabled = false;
+#endif
                 if (FunctionSettingNow.BarcodeLimit)
                 {
                     if (SN.Length != FunctionSettingNow.BarcodeLength || !SN.StartsWith(FunctionSettingNow.BarcodeKeyword))
@@ -1569,11 +1646,18 @@ namespace MOKA_Factory_Tools
                     byte[] result_psn;
                     byte[] data_psn;
                     string error_psn;
+#if true // 波兰工厂临时解决方案;
+                    if (PSN.Length == 17)
+                    {
+                        if (CommonMethod.GetFireTVDsn(midListNow.host, orderNow, Encoding.ASCII.GetString(data), SN, PSN, out string dsn, out error_psn, errorDBNow))
+                        {
+#else
                     if (SerialCMD.ReadFireTVPSN(TVPort, out result_psn, out data_psn, out error_psn, SerailDelay))
                     {
                         string psn = Encoding.ASCII.GetString(data_psn);
                         if (CommonMethod.GetFireTVDsn(midListNow.host, orderNow, Encoding.ASCII.GetString(data), SN, psn, out string dsn, out error_psn, errorDBNow))
                         {
+#endif
                             keyInfo.DSN = dsn;
                             if (!CommonMethod.IsNumberAndWord(keyInfo.DSN))
                             {
@@ -4457,6 +4541,25 @@ namespace MOKA_Factory_Tools
                 }
             }
 
+#region 波兰工厂临时功能-抄写所有Key后执行Trigger和Check指令;
+            Log.WriteInfoLog("Start to Trigger DHA...");
+            if ( SerialCMD.TriggerDHA(TVPort, out result, out data, out error, SerailDelay) )
+            {
+                Thread.Sleep(FunctionSettingNow.CheckDHAWaitTime);
+                Log.WriteInfoLog("Start to Check DHA...");
+                if ( !SerialCMD.CheckDHA(TVPort, out result, out data, out error, SerailDelay) )
+                {
+                    MessageBox.Show("Check DHA Fail!");
+                    goto end;
+                }
+            }
+            else
+            {
+                MessageBox.Show("Trigger DHA Fail!");
+                goto end;
+            }
+#endregion
+
             //数据上传
             if (midListNow.host == "LocalPC" && !preloadNow)
             {
@@ -4587,6 +4690,9 @@ namespace MOKA_Factory_Tools
             EnableText(SNText);
             EnableButton(BtnClickstart);
             SN = "";
+            #region 波兰工厂临时解决方案;
+            PSN = "";
+			#endregion
         }
 
         /// <summary>