瀏覽代碼

save comlex verison

Robert 4 年之前
父節點
當前提交
841ad9bb2f

+ 1 - 0
AwInitilizer/App.xaml.cs

@@ -42,6 +42,7 @@ namespace AwInitilizer
             base.OnExit(e);
 
             var stopResult = SajetConnect.SajetTransClose();
+            Environment.Exit(0);
         }
     }
 }

+ 10 - 2
AwInitilizer/MainWindow.xaml.cs

@@ -364,7 +364,14 @@ namespace AwInitilizer
 
                 foreach(var procedureLog in procedureList[procedureIndex].LogPair)
                 {
-                    logPairs.Add(procedureLog.Key, procedureLog.Value);
+                    if (logPairs.ContainsKey(procedureLog.Key))
+                    {
+                        logPairs[procedureLog.Key] = procedureLog.Value;
+                    }
+                    else
+                    {
+                        logPairs.Add(procedureLog.Key, procedureLog.Value);
+                    }
                 }
 
                 if (!result)
@@ -558,8 +565,9 @@ namespace AwInitilizer
             List<ProcedureBase> procedures = new List<ProcedureBase>();
 
             //init intilize procedure list
-            procedures.Add(new ButtonStatusCheckPorcedure());
+            
             procedures.Add(new BasicInfoUpdateProcedure());
+            procedures.Add(new ButtonStatusCheckPorcedure());
             procedures.Add(new FourGenModuleCheckProcedure());
             for (int firemwareIndex = 0; firemwareIndex < ViewModel.FirmwareUpdateModels.Count ; firemwareIndex++)
             {

+ 3 - 3
AwInitilizer/Procedure/ButtonStatusCheckPorcedure.cs

@@ -31,13 +31,13 @@ namespace AwInitilizer.Procedure
             //wait restart
             Logger.Print("Waiting response..");
 
-            bool response = false;
+            object response = false;
             int pollinfCnt = 0;
             for (pollinfCnt = 0; pollinfCnt < 14; pollinfCnt++)
             {
                 await Task.Delay(TimeSpan.FromSeconds(30));
-                response = await CheckAllIdel();
-                if (response)
+                response = await GetButtonStatus();
+                if (response!=null)
                     break;
             }
 

+ 1 - 54
AwInitilizer/Procedure/FirmwareUpdateProcedure.cs

@@ -10,7 +10,6 @@ using System.IO;
 using System.Linq;
 using System.Net;
 using System.Text;
-using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Web;
 using System.Windows.Ink;
@@ -66,7 +65,7 @@ namespace AwInitilizer.Procedure
                 for (pollinfCnt = 0; pollinfCnt < 14; pollinfCnt++)
                 {
                     await Task.Delay(TimeSpan.FromSeconds(30));
-                    response = await CheckAllIdel();
+                    response = await ChekCsuBootCompelete();
                     if (response)
                         break;
                 }
@@ -180,58 +179,6 @@ namespace AwInitilizer.Procedure
             }
         }
 
-        private async Task<bool> CheckAllIdel()
-        {
-            try
-            {
-                using (WebClient webClient = new WebClient())
-                {
-                    NameValueCollection parameters = new NameValueCollection();
-                    parameters.Add("opt", "2");
-                    webClient.QueryString = parameters;
-
-                    using (Stream stream = await webClient.OpenReadTaskAsync($"https://{ServerIpAddress}/get_query_action.php"))
-                    // 使用 StreamReader 讀取 stream 內的字元
-                    using (StreamReader reader = new StreamReader(stream))
-                    {
-                        // 將 StreamReader 所讀到的字元轉為 string
-                        string request = reader.ReadToEnd();
-                        InfoLog += $"get status respons:\n{request}\n";
-                        LogPair.Add($"EvseStatus", request);
-                        Regex rx = new Regex("(SystemStatus)\\\": (\\d)");
-                        var matches = rx.Matches(request);
-                        bool isAllPassed = true;
-                        for (int matchIndex = 0; matchIndex < matches.Count; matchIndex++)
-                        {
-                            var match = matches[matchIndex];
-                            if (match.Groups.Count != 3)
-                            {
-                                InfoLog += $"Connector {matchIndex} status string mismatched\n";
-                                Logger.Print($"Connector {matchIndex} status string mismatched", isError: true);
-                                isAllPassed = false;
-                            }
-                            else
-                            {
-                                if (match.Groups[2].Value != "1")
-                                {
-                                    InfoLog += $"Connector {matchIndex} status not Idel\n";
-                                    Logger.Print($"Connector {matchIndex} status not Idel", isError: true);
-                                    isAllPassed = false;
-                                }
-                            }
-                        }
-
-                        return isAllPassed;
-                    }
-                }
-                return true;
-            }
-            catch (Exception e)
-            {
-                return false;
-            }
-        }
-
         internal async Task<bool> Uploadfiremware(string fileName)
         {
             try

+ 52 - 0
AwInitilizer/Procedure/ProcedureBase.cs

@@ -1,11 +1,15 @@
 using AwInitilizer.Assist;
 using AwInitilizer.Interface;
 using AwInitilizer.Model;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.IO;
 using System.Linq;
 using System.Net.Sockets;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 
 namespace AwInitilizer.Procedure
@@ -77,6 +81,54 @@ namespace AwInitilizer.Procedure
             return true;
         }
 
+        internal async Task<bool> ChekCsuBootCompelete()
+        {
+            await Task.Delay(TimeSpan.FromMinutes(2));
+            try
+            {
+                using (WebClientTimeout webClient = new WebClientTimeout())
+                {
+                    NameValueCollection parameters = new NameValueCollection();
+                    parameters.Add("opt", "2");
+                    webClient.QueryString = parameters;
+
+                    using (Stream stream = await webClient.OpenReadTaskAsync($"https://{ServerIpAddress}/get_query_action.php"))
+                    // 使用 StreamReader 讀取 stream 內的字元
+                    using (StreamReader reader = new StreamReader(stream))
+                    {
+                        // 將 StreamReader 所讀到的字元轉為 string
+                        string request = reader.ReadToEnd();
+                        Regex rx = new Regex("(SystemStatus)\\\": ([0-9]*)");
+                        var matches = rx.Matches(request);
+                        bool isAllPassed = true;
+                        for (int matchIndex = 0; matchIndex < matches.Count; matchIndex++)
+                        {
+                            var match = matches[matchIndex];
+                            if (match.Groups.Count != 3)
+                            {
+                                isAllPassed = false;
+                                break;
+                            }
+                            else
+                            {
+                                if (match.Groups[2].Value != "1")
+                                {
+                                    isAllPassed = false;
+                                    break;
+                                }
+                            }
+                        }
+
+                        return isAllPassed;
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                return false;
+            }
+        }
+
         private void Dispose()
         {
             if(serialPortocol!=null)