Browse Source

Add project files.

Robert 1 year ago
parent
commit
78115479cb

+ 6 - 0
GitVersion.yml

@@ -0,0 +1,6 @@
+assembly-versioning-scheme: MajorMinorPatch
+assembly-informational-format: '{ShortSha}'
+next-version: 1.0.2
+branches: {}
+ignore:
+  sha: []

+ 22 - 0
MesAdaptor/ISajetConnect.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public interface ISajetConnect
+    {
+        bool SajetTransStart();
+        bool SajetTransClose();
+        bool SajetTransSignIn(ref string data);
+        bool SajetTransWoCheck(ref string workOrder);
+        bool SajetTransSnCheck(ref string serialNumber);
+        bool SajetTranFinishSuccess();
+        bool SajetTranFinishFail(MesErrorCode errorCode);
+        string SajetTransRegisterHeader(string model, string header);
+        bool SajetTransReport(ValueReportDatas reportPair);
+        bool SajetTransLog(string data);
+    }
+}

+ 69 - 0
MesAdaptor/MesAdaptor.csproj

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{6B69CF23-270B-429B-A21D-AD98C2DFF678}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MesAdaptor</RootNamespace>
+    <AssemblyName>MesAdaptor</AssemblyName>
+    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="PhihongEv.Lib, Version=1.0.12.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\PhihongEv.Lib.1.0.12\lib\net40\PhihongEv.Lib.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ISajetConnect.cs" />
+    <Compile Include="MesErrorCode.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="SajectConnectSajet2.cs" />
+    <Compile Include="SajectConnectSajet.cs" />
+    <Compile Include="SajectConnectTest.cs" />
+    <Compile Include="SajetConnect.cs" />
+    <Compile Include="SajetConnectAdapter.cs" />
+    <Compile Include="SajetConnectShinewave.cs" />
+    <Compile Include="ValueReportData.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>
+    </PreBuildEvent>
+  </PropertyGroup>
+</Project>

+ 35 - 0
MesAdaptor/MesErrorCode.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public enum MesErrorCode
+    {
+        None,
+        ChargerConnectFail,
+        ModelNameUpadateFail,
+        SerilaNumberUpadateFail,
+        UtcDatetimeUpdateFail,
+        FourthGenModelVersionMismatch,
+        FourthGenSimInstartionMismatch,
+        FourthGenSimInfoMismatch,
+        WifiModeNotClient,
+        WifiRssiLow,
+        FirmwareUploadFail,
+        FirmwareUpdateTimeout,
+        FirmwareVersionCheckFail,
+        EmergencyButtonTestFail,
+        GreenButtonTestFail,
+        BlueButtonTestFail,
+        FactoryResetFail,
+
+        SetOptionsFail,
+        ProgramFail,
+        RestFail,
+        ProgramCheckFail,
+        GetCheckSumFail
+    }
+}

+ 37 - 0
MesAdaptor/Properties/AssemblyInfo.cs

@@ -0,0 +1,37 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MesAdaptor")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MesAdaptor")]
+[assembly: AssemblyCopyright("Copyright ©  2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("6b69cf23-270b-429b-a21d-ad98c2dff678")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.9.3.0")]
+[assembly: AssemblyVersion("1.9.3.0")]
+[assembly: AssemblyFileVersion("1.9.3.0")]
+[assembly: AssemblyInformationalVersion("4cf1d59")]

+ 275 - 0
MesAdaptor/SajectConnectSajet.cs

@@ -0,0 +1,275 @@
+using PhihongEv.Lib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public class SajectConnectSajet : ISajetConnect
+    {
+        private enum CMD
+        {
+            Signin = 1,
+            SnCheck = 2,
+            WoCheck = -1,
+            Report = 3,
+            Log = 4,
+            HeaderRegister = 8,
+            ValueReport = 5,
+            StringValueReport = 6,
+        }
+
+        public bool SajetTransStart() => SajetConnectAdapter.SajetTransStart();
+        public bool SajetTransClose() => SajetConnectAdapter.SajetTransClose();
+
+        private string userId = "";
+        public bool SajetTransSignIn(ref string data)
+        {
+            var attemptId = data;
+            if (SajetTransData(CMD.Signin, ref data))
+            {
+                if (string.IsNullOrEmpty(data) || data.StartsWith("NG"))
+                {
+                    userId = "";
+                    return false;
+                }
+                else
+                {
+                    userId = attemptId;
+                    return true;
+                }
+            }
+            userId = "";
+            return false;
+        }
+
+        private string WorkOrder = "";
+        public bool SajetTransWoCheck(ref string workOrder)
+        {
+            return true;
+        }
+
+        private string SN;
+        public bool SajetTransSnCheck(ref string serialNumber)
+        {
+            var attemptSN = serialNumber;
+            var msg = serialNumber;
+
+            if (SajetTransData(CMD.SnCheck, ref msg))
+            {
+                if (string.IsNullOrEmpty(msg) || msg.StartsWith("NG"))
+                {
+                    SN = "";
+                    return false;
+                }
+                else
+                {
+                    SN = attemptSN;
+                    return true;
+                }
+            }
+            SN = "";
+            return false;
+        }
+
+        public bool SajetTranFinishSuccess()
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msg = userId + ";" + SN + ";";
+
+            if (string.IsNullOrEmpty(msg))
+                return false;
+
+            msg += "OK";
+
+#if DEBUG
+            return true;
+#endif
+
+            return SajetTransData(CMD.Report, ref msg);
+        }
+
+        public bool SajetTranFinishFail(MesErrorCode errorCode)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msg = userId + ";" + SN + ";";
+
+            if (string.IsNullOrEmpty(msg))
+                return false;
+
+            msg += $"NG;{errorCode};";  //E114
+
+#if DEBUG
+            return true;
+#endif
+
+            return SajetTransData(CMD.Report, ref msg);
+        }
+
+        public string SajetTransRegisterHeader(string model, string header)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return "";
+            var msg = userId + ";";
+            msg += model + ";" + header;
+            if (SajetTransData(CMD.HeaderRegister, ref msg))
+            {
+                if (msg.StartsWith("OK"))
+                {
+                    //get codename
+                    msg = msg.Substring(3);
+                    var spaceIndex = msg.IndexOf(";");
+                    if (spaceIndex > 0)
+                    {
+                        msg = msg.Substring(0, spaceIndex);
+                    }
+                    return msg;
+                }
+                return null;
+            }
+            return null;
+        }
+
+        public bool SajetTransReport(ValueReportDatas reportPair)
+        {
+            //build header
+            Dictionary<string, int> valuePairs = new Dictionary<string, int>();
+            foreach (var data in reportPair)
+            {
+                if (int.TryParse(data.Val, out int val))
+                {
+                    valuePairs.Add(data.Key, val);
+                }
+                else if (data.Val.ToLower().Contains("fail"))
+                {
+                    valuePairs.Add(data.Key, 0);
+                }
+                else if (data.Val.ToLower().Contains("success"))
+                {
+                    valuePairs.Add(data.Key, 1);
+                }
+                else
+                {
+                    valuePairs.Add(string.Format("{0}:{1}", data.Key, data.Val), 1);
+                }
+            }
+            //register Header
+            var codePair = new Dictionary<string, string>();
+
+            string model = "";
+            if (SystemID.TryParse(SN,out var systemID))
+            {
+                model = systemID.ModelName.ToString();
+            }
+
+            foreach (var key in valuePairs.Keys)
+            {
+                var code = SajetTransRegisterHeader(model, key);
+                if (string.IsNullOrEmpty(code))
+                    continue;
+                codePair.Add(key, code);
+            }
+            //report value
+            var reportResult = SajetTransReport(valuePairs, codePair);
+            return reportResult;
+        }
+
+        public bool SajetTransReport(Dictionary<string, int> resultPair, Dictionary<string, string> codePair)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msgHeader = userId + ";" + SN;
+            string msg = "";
+
+            foreach (var result in resultPair)
+            {
+                if (codePair.Keys.Contains(result.Key))
+                {
+                    msg = string.Format("{0};{1}:{2};",msgHeader, codePair[result.Key], string.Format("{0}.00", result.Value));
+                    //msg += string.Format(";{0}:{1}", codePair[result.Key], string.Format("{0}.00", result.Value));
+                }
+                //msg += ";";
+                SajetTransData(CMD.ValueReport, ref msg);
+                //msg = userId + ";" + SN;
+            }
+            //msg += ";";
+            return true;
+        }
+
+        public bool SajetTransReport(Dictionary<string, string> resultPair, Dictionary<string, string> codePair)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msg = userId + ";" + SN;
+            foreach (var result in resultPair)
+            {
+                if (codePair.Keys.Contains(result.Key))
+                {
+                    msg += string.Format(";{0}:{1}", codePair[result.Key], string.Format("{0}.00", result.Value));
+                }
+                msg += ";";
+                SajetTransData(CMD.StringValueReport, ref msg);
+                msg = userId + ";" + SN;
+            }
+            msg += ";";
+            return true;
+        }
+
+        public bool SajetTransLog(string data)
+        {
+            return true;
+
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string prefix = userId + ";" + SN + ";";
+            while (data.Length > 0)
+            {
+                var msg = prefix;
+                int sendLength = Math.Min(250 - msg.Length, data.Length);
+                var sendString = data.Substring(0, sendLength);
+                msg += sendString;
+                if (!SajetTransData(CMD.Log, ref msg))
+                {
+                    break;
+                }
+                data = data.Substring(sendLength);
+            }
+            return data.Length == 0;
+        }
+
+        private bool SajetTransData(CMD command, ref string data)
+        {
+            return SajetConnectAdapter.SajetTransData((int)command, ref data);
+        }
+
+        private string GetSendPrefix()
+        {
+            string msg = "";
+            if (string.IsNullOrEmpty(userId))
+            {
+                return null;
+            }
+            msg = userId + ";";
+            if (string.IsNullOrEmpty(WorkOrder))
+            {
+                return null;
+            }
+            msg += WorkOrder + ";";
+            return msg;
+        }
+    }
+}

+ 283 - 0
MesAdaptor/SajectConnectSajet2.cs

@@ -0,0 +1,283 @@
+using PhihongEv.Lib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public class SajectConnectSajet2 : ISajetConnect
+    {
+        private enum CMD
+        {
+            Signin = 1,
+            SnCheck = 2,
+            Report = 3,
+            ValueReport = 4,
+        }
+
+        private readonly string _MechineCode;
+        public SajectConnectSajet2(string MechineCode)
+        {
+            if (string.IsNullOrEmpty(MechineCode))
+            {
+                throw new Exception("MechineCode cannot not be empty");
+            }
+
+            _MechineCode = MechineCode;
+        }
+
+        public bool SajetTransStart() => SajetConnectAdapter.SajetTransStart();
+        public bool SajetTransClose() => SajetConnectAdapter.SajetTransClose();
+
+        private string userId = "";
+        public bool SajetTransSignIn(ref string data)
+        {
+            var attemptId = data;
+            var msg = data + ";";
+            if (SajetTransData(CMD.Signin, ref data))
+            {
+                if (string.IsNullOrEmpty(data) || data.StartsWith("NG"))
+                {
+                    userId = "";
+                    return false;
+                }
+                else
+                {
+                    userId = attemptId;
+                    return true;
+                }
+            }
+            userId = "";
+            return false;
+        }
+
+        [Obsolete]
+        public bool SajetTransWoCheck(ref string workOrder)
+        {
+            return true;
+        }
+
+        private SystemID systemID;
+        public bool SajetTransSnCheck(ref string serialNumber)
+        {
+            if (!SystemID.TryLooseParse(serialNumber, out var id))
+            {
+                return false;
+            }
+
+            var msg = string.Format("{0};{1};;", id.ModelName.ToString(), id.ToString());
+
+            if (SajetTransData(CMD.SnCheck, ref msg))
+            {
+                if (string.IsNullOrEmpty(msg) || msg.StartsWith("NG"))
+                {
+                    systemID = null;
+                    return false;
+                }
+                systemID = id;
+                return true;
+            }
+            systemID = null;
+            return false;
+        }
+
+        //public bool SajetTransSnCheck(string partNO,string sn)
+        //{
+        //    var msg = string.Format("{0};{1};;", partNO, sn);
+
+        //    if (SajetTransData(CMD.SnCheck, ref msg))
+        //    {
+        //        if (string.IsNullOrEmpty(msg) || msg.StartsWith("NG"))
+        //        {
+        //            return false;
+        //        }
+        //        return true;
+        //    }
+        //    return false;
+        //}
+
+        public bool SajetTranFinishSuccess()
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (systemID == null)
+                return false;
+            //string msg = userId + ";" + systemID.ToString() + ";";
+            string msg = string.Format("{0};{1};{2};{3}:0;", userId, _MechineCode, systemID.ModelName.ToString(), systemID.ToString());
+
+            if (string.IsNullOrEmpty(msg))
+                return false;
+
+            return SajetTransData(CMD.Report, ref msg);
+        }
+
+        //public bool SajetTranFinishSuccess(string partNO, string sn)
+        //{
+        //    if (string.IsNullOrEmpty(userId))
+        //        return false;
+        //    //string msg = userId + ";" + systemID.ToString() + ";";
+        //    string msg = string.Format("{0};{1};{2};{3}:0;", userId, _MechineCode, partNO, sn);
+
+        //    if (string.IsNullOrEmpty(msg))
+        //        return false;
+
+        //    return SajetTransData(CMD.Report, ref msg);
+        //}
+
+        public bool SajetTranFinishFail(MesErrorCode errorCode)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (systemID == null)
+                return false;
+            //string msg = userId + ";" + systemID.ToString() + ";";
+            string msg = string.Format("{0};{1};{2};{3}:1:", userId, _MechineCode, systemID.ModelName.ToString(), systemID.ToString());
+
+            if (string.IsNullOrEmpty(msg))
+                return false;
+
+            msg += $"{GetMesCodeString(errorCode)};";  //E114
+
+            return SajetTransData(CMD.Report, ref msg);
+        }
+
+        //public bool SajetTranFinishFail(string partNO, string sn, MesErrorCode errorCode)
+        //{
+        //    if (string.IsNullOrEmpty(userId))
+        //        return false;
+        //    //string msg = userId + ";" + systemID.ToString() + ";";
+        //    string msg = string.Format("{0};{1};{2};{3}:1:", userId, _MechineCode, partNO, sn);
+
+        //    if (string.IsNullOrEmpty(msg))
+        //        return false;
+
+        //    msg += $"{errorCode};";  //E114
+
+        //    return SajetTransData(CMD.Report, ref msg);
+        //}
+
+        [Obsolete]
+        public string SajetTransRegisterHeader(string model, string header)
+        {
+            return "";
+        }
+
+        public bool SajetTransReport(ValueReportDatas reportDatas)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (systemID == null)
+                return false;
+
+            var totalResult = true;
+
+            foreach (var data in reportDatas)
+            {
+                var key = data.Key;
+                var value = data.Val;
+                var isSuccess = data.IsSuccess;
+
+                value = value.Trim();
+                var det = isSuccess ? "0" : "1";
+
+                if (string.IsNullOrEmpty(value))
+                {
+                    value = "empty";
+                }
+                else if (value.ToLower() == "fail")
+                {
+                    value = "0";
+                }
+                else if (value.ToLower() == "success")
+                {
+                    value = "1";
+                }
+
+                var msg = string.Format("{0};{1};{2};{3};{4}:{5}:{6};", userId, _MechineCode, systemID.ModelName.ToString(), systemID.ToString(), key, value, det);
+                var result = SajetTransData(CMD.ValueReport, ref msg);
+                totalResult &= result;
+            }
+            return totalResult;
+        }
+
+        //public bool SajetTransReport(string partNO, string no, Dictionary<string, string> reportPair)
+        //{
+        //    if (string.IsNullOrEmpty(userId))
+        //        return false;
+
+        //    var totalResult = true;
+        //    foreach (var pair in reportPair)
+        //    {
+        //        var msg = string.Format("{0};{1};{2};{3};{4}:{5};", userId, _MechineCode, partNO, no, pair.Key, pair.Value);
+        //        var result = SajetTransData(CMD.ValueReport, ref msg);
+        //        totalResult &= result;
+        //    }
+        //    return totalResult;
+        //}
+
+        [Obsolete]
+        public bool SajetTransReport(Dictionary<string, int> resultPair, Dictionary<string, string> codePair)
+        {
+            return true;
+        }
+
+        [Obsolete]
+        public bool SajetTransReport(Dictionary<string, string> resultPair, Dictionary<string, string> codePair)
+        {
+            return true;
+        }
+
+        [Obsolete]
+        public bool SajetTransLog(string data)
+        {
+            return true;
+        }
+
+        private bool SajetTransData(CMD command, ref string data)
+        {
+            return SajetConnectAdapter.SajetTransData((int)command, ref data);
+        }
+
+        private string GetMesCodeString(MesErrorCode mesError)
+        {
+            switch (mesError)
+            {
+                case MesErrorCode.ChargerConnectFail:
+                    return "A081";
+                case MesErrorCode.ModelNameUpadateFail:
+                    return "A082";
+                case MesErrorCode.SerilaNumberUpadateFail:
+                    return "A083";
+                case MesErrorCode.UtcDatetimeUpdateFail:
+                    return "A084";
+                case MesErrorCode.FourthGenModelVersionMismatch:
+                    return "A085";
+                case MesErrorCode.FourthGenSimInstartionMismatch:
+                    return "A086";
+                case MesErrorCode.FourthGenSimInfoMismatch:
+                    return "A087";
+                case MesErrorCode.WifiModeNotClient:
+                    return "A088";
+                case MesErrorCode.WifiRssiLow:
+                    return "A089";
+                case MesErrorCode.FirmwareUploadFail:
+                    return "A090";
+                case MesErrorCode.FirmwareUpdateTimeout:
+                    return "A091";
+                case MesErrorCode.FirmwareVersionCheckFail:
+                    return "A092";
+                case MesErrorCode.EmergencyButtonTestFail:
+                    return "A093";
+                case MesErrorCode.GreenButtonTestFail:
+                    return "A094";
+                case MesErrorCode.BlueButtonTestFail:
+                    return "A095";
+                case MesErrorCode.FactoryResetFail:
+                    return "A096";
+            }
+            return "A081";
+        }
+    }
+}

+ 31 - 0
MesAdaptor/SajectConnectTest.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public class SajectConnectTest : ISajetConnect
+    {
+        public bool SajetTranFinishFail(MesErrorCode errorCode) => true;
+
+        public bool SajetTranFinishSuccess() => true;
+
+        public bool SajetTransClose() => true;
+
+        public bool SajetTransLog(string data) => true;
+
+        public string SajetTransRegisterHeader(string model, string header) => "";
+
+        public bool SajetTransReport(ValueReportDatas reportPair) => true;
+
+        public bool SajetTransSignIn(ref string data) => true;
+
+        public bool SajetTransSnCheck(ref string serialNumber) => true;
+
+        public bool SajetTransStart() => true;
+
+        public bool SajetTransWoCheck(ref string workOrder) => true;
+    }
+}

+ 63 - 0
MesAdaptor/SajetConnect.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public enum MesType
+    {
+        none,
+        shinewave,
+        sajet,
+        sajet2,
+        test
+    }
+
+    public static class SajetConnect
+    {
+        public static ISajetConnect Instance { get; internal set; }
+
+        public static bool SajetTransStart() => Instance.SajetTransStart();
+        public static bool SajetTransClose() => Instance == null ? false : Instance.SajetTransClose();
+        public static bool SajetTransSignIn(ref string data) => Instance.SajetTransSignIn(ref data);
+        public static bool SajetTransWoCheck(ref string workOrder) => Instance.SajetTransWoCheck(ref workOrder);
+        public static bool SajetTransSnCheck(ref string serialNumber) => Instance.SajetTransSnCheck(ref serialNumber);
+        public static bool SajetTranFinishSuccess() => Instance.SajetTranFinishSuccess();
+        public static bool SajetTranFinishFail(MesErrorCode errorCode) => Instance.SajetTranFinishFail(errorCode);
+        public static string SajetTransRegisterHeader(string model, string header) => Instance.SajetTransRegisterHeader(model, header);
+        public static bool SajetTransReport(ValueReportDatas reportPair) => Instance.SajetTransReport(reportPair);
+        public static bool SajetTransLog(string data) => Instance.SajetTransLog(data);
+
+        public static void SetMes(string mesSetting = "",string mechineCode = "")
+        {
+            if (mesSetting is null)
+            {
+                SajetConnect.Instance = new SajectConnectTest();
+                return;
+            }
+            
+            mesSetting = mesSetting.ToLower();
+            switch (mesSetting)
+            {
+                case "php":
+                case "shinewave":
+                    SajetConnect.Instance = new SajetConnectShinewave();
+                    break;
+                case "phv":
+                case "sajet":
+                    SajetConnect.Instance = new SajectConnectSajet();
+                    break;
+                //case "phv":
+                case "sajet2":
+                    SajetConnect.Instance = new SajectConnectSajet2(mechineCode);
+                    break;
+                default:
+                    SajetConnect.Instance = new SajectConnectTest();
+                    break;
+            }
+        }
+    }
+}

+ 59 - 0
MesAdaptor/SajetConnectAdapter.cs

@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public static class SajetConnectAdapter
+    {
+        [DllImport("SajetConnect.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+        public static extern bool SajetTransStart();
+
+        [DllImport("SajetConnect.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+        public static extern bool SajetTransClose();
+
+        //[DllImport("SajetConnect.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+        //public static extern bool SajetTransData(int command, IntPtr data, IntPtr length);
+
+        [DllImport("SajetConnect.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+        public static extern bool SajetTransData(int command, IntPtr data, IntPtr length);
+
+        [DllImport("SajetConnect.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
+        public static extern bool SajetTransData_C(int command, out string data);
+
+        public static bool SajetTransData(int command, ref string data)
+        {
+            var idByte = Encoding.ASCII.GetBytes(data);
+            var length = idByte.Length;
+
+            var dataArrayLength = Math.Max(length, 200);
+            var dataArray = new byte[dataArrayLength];
+            Array.Copy(idByte, 0, dataArray, 0, length);
+
+            IntPtr dataIntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(dataArrayLength);
+            System.Runtime.InteropServices.Marshal.Copy(dataArray, 0, dataIntPtr, dataArray.Length);
+
+            IntPtr lengthIntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(10);
+            System.Runtime.InteropServices.Marshal.WriteInt32(lengthIntPtr, length);
+
+            var sendResult = SajetConnectAdapter.SajetTransData(command, dataIntPtr, lengthIntPtr);
+
+            var resultString1 = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(dataIntPtr);
+
+            System.Runtime.InteropServices.Marshal.Copy(dataIntPtr, dataArray, 0, dataArrayLength);
+            //System.Runtime.InteropServices.Marshal.Release(dataIntPtr);
+            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(dataIntPtr);
+
+            var readLength = System.Runtime.InteropServices.Marshal.ReadInt32(lengthIntPtr);
+            //System.Runtime.InteropServices.Marshal.Release(lengthIntPtr);
+
+            var resultString = Encoding.ASCII.GetString(dataArray);
+
+            data = resultString1.Substring(0, Math.Min(readLength, resultString1.Length));
+            return sendResult;
+        }
+    }
+}

+ 304 - 0
MesAdaptor/SajetConnectShinewave.cs

@@ -0,0 +1,304 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public class SajetConnectShinewave : ISajetConnect
+    {
+        private enum CMD
+        {
+            Signin = 1,
+            Log = 4,
+            ValueReport = 5,
+            StringValueReport = 6,
+            HeaderRegister = 8,
+            WoCheck = 14,
+            SnCheck = 15,
+            Report = 16,
+        }
+
+        public bool SajetTransStart() => SajetConnectAdapter.SajetTransStart();
+        public bool SajetTransClose() => SajetConnectAdapter.SajetTransClose();
+
+        private string userId = "";
+        public bool SajetTransSignIn(ref string data)
+        {
+            var attemptId = data;
+            if (SajetTransData(CMD.Signin, ref data))
+            {
+                if (string.IsNullOrEmpty(data) || data.StartsWith("NG"))
+                {
+                    userId = "";
+                    return false;
+                }
+                else
+                {
+                    userId = attemptId;
+                    return true;
+                }
+            }
+            userId = "";
+            return false;
+        }
+
+        private string WorkOrder = "";
+        public bool SajetTransWoCheck(ref string workOrder)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (workOrder == null)
+                workOrder = "";
+            var msg = userId + "," + workOrder + ",";
+
+            if (SajetTransData(CMD.WoCheck, ref msg))
+            {
+                if (string.IsNullOrEmpty(msg) || msg.StartsWith("NG"))
+                {
+                    WorkOrder = "";
+                    return false;
+                }
+                else
+                {
+                    WorkOrder = workOrder;
+                    return true;
+                }
+            }
+            WorkOrder = "";
+            return false;
+        }
+
+        private string SN;
+        public bool SajetTransSnCheck(ref string serialNumber)
+        {
+            var attemptSN = serialNumber;
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (WorkOrder == null)
+                WorkOrder = "";
+            var msg = userId + "," + WorkOrder + "," + serialNumber + ",";
+
+            if (SajetTransData(CMD.SnCheck, ref msg))
+            {
+                if (string.IsNullOrEmpty(msg) || msg.StartsWith("NG"))
+                {
+                    SN = "";
+                    return false;
+                }
+                else
+                {
+                    SN = attemptSN;
+                    return true;
+                }
+            }
+            SN = "";
+            return false;
+        }
+
+        public bool SajetTranFinishSuccess()
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            //if (string.IsNullOrEmpty(WorkOrder))
+            //    return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msg = userId + "," + WorkOrder + "," + SN + ",";
+
+            if (string.IsNullOrEmpty(msg))
+                return false;
+
+            msg += "OK,";
+
+#if DEBUG
+            return true;
+#endif
+
+            return SajetTransData(CMD.Report, ref msg);
+        }
+
+        public bool SajetTranFinishFail(MesErrorCode errorCode)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            //if (string.IsNullOrEmpty(WorkOrder))
+            //    return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msg = userId + "," + WorkOrder + "," + SN + ",";
+
+            if (string.IsNullOrEmpty(msg))
+                return false;
+
+            msg += "NG," + GetMesCodeString(errorCode) + ",";
+
+#if DEBUG
+            return true;
+#endif
+
+            return SajetTransData(CMD.Report, ref msg);
+        }
+
+        public string SajetTransRegisterHeader(string model, string header)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return "";
+            var msg = userId + ",";
+            msg += model + "," + header;
+            if (SajetTransData(CMD.HeaderRegister, ref msg))
+            {
+                if (msg.StartsWith("OK"))
+                {
+                    //get codename
+                    msg = msg.Substring(3);
+                    var spaceIndex = msg.IndexOf(",");
+                    if (spaceIndex > 0)
+                    {
+                        msg = msg.Substring(0, spaceIndex);
+                    }
+                    return msg;
+                }
+                return null;
+            }
+            return null;
+        }
+
+        public bool SajetTransReport(ValueReportDatas reportPairs)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msgHeader = userId + "," + SN;
+            string msg;
+            bool result = true;
+
+            foreach (var report in reportPairs)
+            {
+                msg = string.Format("{0},{1}:{2},", msgHeader, report.Key, report.Val);
+                var cmdResult = SajetTransData(CMD.StringValueReport, ref msg);
+                if (!cmdResult)
+                    result = false;
+            }
+            return result;
+        }
+
+        public bool SajetTransReport(Dictionary<string, int> resultPair, Dictionary<string, string> codePair)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string msg = userId + "," + SN + ",";
+            foreach (var result in resultPair)
+            {
+                if (codePair.Keys.Contains(result.Key))
+                {
+                    msg += string.Format("{0}:{1},", codePair[result.Key], string.Format("{0}.00", result.Value));
+                }
+            }
+            return SajetTransData(CMD.ValueReport, ref msg);
+        }
+
+        public bool SajetTransLog(string data)
+        {
+            if (string.IsNullOrEmpty(userId))
+                return false;
+            if (string.IsNullOrEmpty(SN))
+                return false;
+            string prefix = userId + "," + SN + ",";
+            while (data.Length > 0)
+            {
+                var msg = prefix;
+                int sendLength = Math.Min(250 - msg.Length, data.Length);
+                var sendString = data.Substring(0, sendLength);
+                msg += sendString;
+                if (!SajetTransData(CMD.Log, ref msg))
+                {
+                    break;
+                }
+                data = data.Substring(sendLength);
+            }
+            return data.Length == 0;
+        }
+
+        private bool SajetTransData(CMD command, ref string data)
+        {
+            //return true;
+            if (!data.EndsWith(","))
+            {
+                data = data + ",";
+            }
+            return SajetConnectAdapter.SajetTransData((int)command, ref data);
+        }
+
+        private string GetSendPrefix()
+        {
+            string msg = "";
+            if (string.IsNullOrEmpty(userId))
+            {
+                return null;
+            }
+            msg = userId + ",";
+            if (string.IsNullOrEmpty(WorkOrder))
+            {
+                return null;
+            }
+            msg += WorkOrder + ",";
+            return msg;
+        }
+
+        private string GetMesCodeString(MesErrorCode mesError)
+        {
+            switch (mesError)
+            {
+                case MesErrorCode.ChargerConnectFail:
+                    return "EC001";
+                case MesErrorCode.ModelNameUpadateFail:
+                    return "EC002";
+                case MesErrorCode.SerilaNumberUpadateFail:
+                    return "EC003";
+                case MesErrorCode.UtcDatetimeUpdateFail:
+                    return "EC004";
+                case MesErrorCode.FourthGenModelVersionMismatch:
+                    return "EC005";
+                case MesErrorCode.FourthGenSimInstartionMismatch:
+                    return "EC006";
+                case MesErrorCode.FourthGenSimInfoMismatch:
+                    return "EC007";
+                case MesErrorCode.WifiModeNotClient:
+                    return "EC008";
+                case MesErrorCode.WifiRssiLow:
+                    return "EC009";
+                case MesErrorCode.FirmwareUploadFail:
+                    return "EC010";
+                case MesErrorCode.FirmwareUpdateTimeout:
+                    return "EC011";
+                case MesErrorCode.FirmwareVersionCheckFail:
+                    return "EC012";
+                case MesErrorCode.EmergencyButtonTestFail:
+                    return "EC013";
+                case MesErrorCode.GreenButtonTestFail:
+                    return "EC014";
+                case MesErrorCode.BlueButtonTestFail:
+                    return "EC015";
+                case MesErrorCode.FactoryResetFail:
+                    return "EC016";
+
+                case MesErrorCode.SetOptionsFail:
+                    return "ST001";
+                case MesErrorCode.ProgramFail:
+                    return "ST002";
+                case MesErrorCode.RestFail:
+                    return "ST003";
+                case MesErrorCode.ProgramCheckFail:
+                    return "ST004";
+                case MesErrorCode.GetCheckSumFail:
+                    return "ST005";
+            }
+            return "EC001";
+        }
+    }
+}

+ 74 - 0
MesAdaptor/ValueReportData.cs

@@ -0,0 +1,74 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MesAdaptor
+{
+    public class ValueReportDatas : IEnumerable<ValueReportData>
+    {
+        public ValueReportDatas()
+        {
+            _valueReportDatas = new List<ValueReportData>();
+        }
+
+        public void Add(string key,string val, bool success)
+        {
+            var data = new ValueReportData(key,val,success);
+            var sameKey = _valueReportDatas.FirstOrDefault(x => x.Key == data.Key);
+            _valueReportDatas.Remove(sameKey);
+            _valueReportDatas.Add(data);
+        }
+
+        public void Add(ValueReportData data)
+        {
+            var sameKey = _valueReportDatas.FirstOrDefault(x=>x.Key == data.Key);
+            _valueReportDatas.Remove(sameKey);
+            _valueReportDatas.Add(data);
+        }
+
+        public void Clear()
+        {
+            _valueReportDatas = new List<ValueReportData>();
+        }
+
+        public IEnumerator<ValueReportData> GetEnumerator()
+        {
+            return _valueReportDatas.GetEnumerator();
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return _valueReportDatas.GetEnumerator();
+        }
+
+        public ValueReportData this[string index]
+        {
+            get
+            {
+                return _valueReportDatas.FirstOrDefault(x => x.Key == index);
+            }
+        }
+
+        private List<ValueReportData> _valueReportDatas;
+    }
+
+    public class ValueReportData
+    {
+        public ValueReportData(
+            string key,
+            string val,
+            bool isSuccess)
+        {
+            Key = key;
+            Val = val;
+            IsSuccess = isSuccess;
+        }
+
+        public string Key { get; private set; }
+        public string Val { get; private set; }
+        public bool IsSuccess { get; private set; }
+    }
+}

+ 4 - 0
MesAdaptor/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="PhihongEv.Lib" version="1.0.12" targetFramework="net48" />
+</packages>

+ 31 - 0
ST-LINK_MES.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32510.428
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ST-LINK_MES", "ST-LINK_MES\ST-LINK_MES.csproj", "{2A3E513B-EDF8-4E61-B629-1CE59AB243EC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MesAdaptor", "MesAdaptor\MesAdaptor.csproj", "{6B69CF23-270B-429B-A21D-AD98C2DFF678}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{2A3E513B-EDF8-4E61-B629-1CE59AB243EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{2A3E513B-EDF8-4E61-B629-1CE59AB243EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{2A3E513B-EDF8-4E61-B629-1CE59AB243EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{2A3E513B-EDF8-4E61-B629-1CE59AB243EC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6B69CF23-270B-429B-A21D-AD98C2DFF678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6B69CF23-270B-429B-A21D-AD98C2DFF678}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6B69CF23-270B-429B-A21D-AD98C2DFF678}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6B69CF23-270B-429B-A21D-AD98C2DFF678}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {813B4BD4-56B2-4B0D-8189-B75F3805262A}
+	EndGlobalSection
+EndGlobal

+ 9 - 0
ST-LINK_MES/App.xaml

@@ -0,0 +1,9 @@
+<Application x:Class="ST_LINK_MES.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:ST_LINK_MES"
+             StartupUri="LoginWindow.xaml">
+    <Application.Resources>
+         
+    </Application.Resources>
+</Application>

+ 22 - 0
ST-LINK_MES/App.xaml.cs

@@ -0,0 +1,22 @@
+using MesAdaptor;
+using ST_LINK_MES.Service;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Windows;
+
+namespace ST_LINK_MES
+{
+    /// <summary>
+    /// Interaction logic for App.xaml
+    /// </summary>
+    public partial class App : Application
+    {
+        public App()
+        {
+            AppSettingService.Instance.Load();
+        }
+    }
+}

+ 44 - 0
ST-LINK_MES/LoginWindow.xaml

@@ -0,0 +1,44 @@
+<Window x:Class="ST_LINK_MES.LoginWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:ST_LINK_MES"
+        mc:Ignorable="d"
+        Title="Login" Height="250" Width="400"
+        WindowStartupLocation="CenterScreen"
+        ResizeMode="NoResize"
+        WindowStyle="ToolWindow">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition/>
+            <RowDefinition Height="50"/>
+        </Grid.RowDefinitions>
+        <Grid Background="SkyBlue" Margin="10">
+            <Grid VerticalAlignment="Center" HorizontalAlignment="Center">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="100"/>
+                    <ColumnDefinition/>
+                </Grid.ColumnDefinitions>
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition Height="10"/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <Label Content="員工代號"/>
+                <Label Grid.Row="2" Content="工單號碼"/>
+                <TextBox x:Name="uxIdBox" Grid.Column="1" Width="200" VerticalContentAlignment="Center"/>
+                <TextBox x:Name="uxWorkOrderBox" Grid.Column="1" Grid.Row="2" Width="200" VerticalContentAlignment="Center"/>
+            </Grid>
+            <Label x:Name="uxErrmsg" HorizontalAlignment="Center" VerticalAlignment="Bottom" Content="ErrorMsg" Foreground="Red"/>
+        </Grid>
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition/>
+                <ColumnDefinition/>
+            </Grid.ColumnDefinitions>
+            <Button Click="Connect_Click" Width="100" Height="30" Content="連接" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+            <Button Click="Exit_Click" Grid.Column="1" Width="100" Height="30" Content="離開" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+        </Grid>
+    </Grid>
+</Window>

+ 148 - 0
ST-LINK_MES/LoginWindow.xaml.cs

@@ -0,0 +1,148 @@
+using MesAdaptor;
+using ST_LINK_MES.Service;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace ST_LINK_MES
+{
+    /// <summary>
+    /// Interaction logic for LoginWindow.xaml
+    /// </summary>
+    public partial class LoginWindow : Window
+    {
+        public LoginWindow()
+        {
+            InitializeComponent();
+
+            uxErrmsg.Content = "";
+
+            SajetConnect.SetMes(AppSettingService.Instance.MES, AppSettingService.Instance.MechineCode);
+            SajetConnect.SajetTransStart();
+        }
+
+        public string UserId
+        {
+            get => uxIdBox.Text;
+            set => uxIdBox.Text = value;
+        }
+        public string WorkOrder
+        {
+            get => uxWorkOrderBox.Text;
+            set => uxWorkOrderBox.Text = value;
+        }
+
+        //protected override void OnClosing(CancelEventArgs e)
+        //{
+        //    if (DialogResult == null)
+        //    {
+        //        SajetConnect.SetMes(null);
+        //        Application.Current.Shutdown();
+        //    }
+        //    base.OnClosing(e);
+        //}
+
+        private void Exit_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+
+        private void Connect_Click(object sender, RoutedEventArgs e)
+        {
+            if (!CheckConnect())
+            {
+                return;
+            }
+
+            this.Hide();
+
+            var mainWindow = new MainWindow() {
+                UserId = UserId,
+                WorkOrder = WorkOrder
+            };
+            mainWindow.Closed += MainWindow_Closed;
+            mainWindow.Owner = this;
+            mainWindow.ShowDialog();
+        }
+
+        private void MainWindow_Closed(object sender, EventArgs e)
+        {
+            this.Show();
+            WorkOrder = "";
+        }
+
+        private bool CheckConnect()
+        {
+            uxErrmsg.Content = "";
+
+            if (string.IsNullOrEmpty(uxIdBox.Text))
+            {
+                uxErrmsg.Content = "員工代號不可為空";
+                return false;
+            }
+
+            string id = uxIdBox.Text;
+            string idBackup = id;
+
+            if (CheckIsMesDisableAccount())
+            {
+                //SajetConnect.IsEmsEnabled = false;
+                SajetConnect.SetMes("test");
+                return true;
+            }
+
+            if (!SajetConnect.SajetTransSignIn(ref id))
+            {
+                if (id.StartsWith(idBackup))
+                {
+                    //data not changed
+                    uxErrmsg.Content = "MES 連線失敗";// "ID Error";
+                }
+                else
+                {
+                    uxErrmsg.Content = "員工代號不存在";// "ID Error";
+                }
+                return false;
+            }
+
+            if (string.IsNullOrEmpty(id) || id.StartsWith("NG"))
+            {
+                uxErrmsg.Content = "員工代號不存在";
+                return false;
+            }
+
+            if (!string.IsNullOrEmpty(uxWorkOrderBox.Text))
+            {
+                string workOrder = uxWorkOrderBox.Text;
+                if (!SajetConnect.SajetTransWoCheck(ref workOrder))
+                {
+                    uxErrmsg.Content = "工單號錯誤";
+                    return false;
+                }
+
+                if (string.IsNullOrEmpty(workOrder) || workOrder.StartsWith("NG"))
+                {
+                    uxErrmsg.Content = "工單號錯誤";
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        private bool CheckIsMesDisableAccount()
+        {
+            return uxIdBox.Text == "Admin" && uxWorkOrderBox.Text == "Admin21896826";
+        }
+    }
+}

+ 57 - 0
ST-LINK_MES/MainWindow.xaml

@@ -0,0 +1,57 @@
+<Window x:Class="ST_LINK_MES.MainWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:ST_LINK_MES"
+        mc:Ignorable="d"
+        Title="ST-LINK_MES" Height="450" Width="800"
+        Foreground="White" Background="#FF646464"
+        WindowStartupLocation="CenterScreen"
+        FontSize="12">
+    <Grid Margin="10">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <GroupBox Grid.Row="0" Header="User Setting">
+            <Grid Margin="5">
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition Height="5"/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="70"/>
+                    <ColumnDefinition/>
+                </Grid.ColumnDefinitions>
+                <TextBlock Text="SN" VerticalAlignment="Center"/>
+                <TextBlock Grid.Row="2" Text="Bin File" VerticalAlignment="Center"/>
+                <TextBox  x:Name="uxSN" Grid.Column="1" Height="30" VerticalContentAlignment="Center"/>
+                <Grid Grid.Column="1" Grid.Row="2">
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="29*"/>
+                        <ColumnDefinition Width="287*"/>
+                        <ColumnDefinition Width="50"/>
+                    </Grid.ColumnDefinitions>
+                    <TextBox x:Name="uxBinFilePath" Height="30" Grid.ColumnSpan="2" Margin="0,5" VerticalContentAlignment="Center"/>
+                    <Button x:Name="uxBinFileBtn" Click="uxBinFileBtn_Click" Grid.Column="2" Width="40" Height="40" Margin="5,0" Content="."/>
+                </Grid>
+            </Grid>
+        </GroupBox>
+        <Grid  Grid.Row="1" Height="30" Margin="5">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition/>
+                <ColumnDefinition Width="30"/>
+                <ColumnDefinition Width="100"/>
+            </Grid.ColumnDefinitions>
+            <ProgressBar x:Name="uxProgressBar" VerticalAlignment="Center" Height="10"/>
+            <TextBlock Grid.Column="1" Text="0%" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+            <Button Click="uxRunBtn_Click" Grid.Column="2" Content="Run" Background="LightSkyBlue"/>
+        </Grid>
+        <GroupBox  Grid.Row="2" Header="Terminal">
+            <RichTextBox x:Name="uxTerminal" Background="Black"/>
+        </GroupBox>
+    </Grid>
+</Window>

+ 296 - 0
ST-LINK_MES/MainWindow.xaml.cs

@@ -0,0 +1,296 @@
+using MesAdaptor;
+using Microsoft.Win32;
+using ST_LINK_MES.Model;
+using ST_LINK_MES.Service;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace ST_LINK_MES
+{
+    /// <summary>
+    /// Interaction logic for MainWindow.xaml
+    /// </summary>
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+
+            Title = Title + string.Format(" V{0}", Assembly.GetEntryAssembly().GetName().Version);
+
+            this.stlinkService = new STLinkCliPrograrmService(AppSettingService.Instance.DLinkCliPath);
+            //this.loginWindow = new LoginWindow();
+            this.resultDialog = new ResultDialog();
+
+            Loaded += MainWindow_Loaded;
+        }
+
+        private delegate void GenericDelegate();
+        //private readonly LoginWindow loginWindow;
+        private readonly ResultDialog resultDialog;
+        private readonly STLinkCliPrograrmService stlinkService;
+
+        public string UserId { get; internal set; }
+        public string WorkOrder { get; internal set; }
+
+        protected override void OnClosing(CancelEventArgs e)
+        {
+            base.OnClosing(e);
+
+            var currentSetting = AppSettingService.Instance;
+            var setting = new AppSetting()
+            {
+                LOCK = currentSetting.LOCK,
+                MES = currentSetting.MES,
+                MechineCode = currentSetting.MechineCode,
+                BinPath = uxBinFilePath.Text
+            };
+            currentSetting.Save(setting);
+
+            var stopResult = SajetConnect.SajetTransClose();
+        }
+
+        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
+        {
+            var stopResult = SajetConnect.SajetTransStart();
+
+            //loginWindow.Owner = this;
+            resultDialog.Owner = this;
+
+            //Reset();
+
+            uxBinFilePath.Text = AppSettingService.Instance.BinPath;
+            if (AppSettingService.Instance.LOCK)
+            {
+                uxBinFilePath.IsEnabled = false;
+                uxBinFileBtn.IsEnabled = false;
+            }
+        }
+
+        private void uxBinFileBtn_Click(object sender, RoutedEventArgs e)
+        {
+            OpenFileDialog dlg = new OpenFileDialog();
+            var dlgRsult = dlg.ShowDialog();
+
+            if (dlgRsult != true)
+            {
+                return;
+            }
+
+            uxBinFilePath.Text = dlg.FileName;
+        }
+
+        private void uxRunBtn_Click(object sender, RoutedEventArgs e)
+        {
+            uxTerminal.Document.Blocks.Clear();
+
+            if (string.IsNullOrEmpty(uxSN.Text))
+            {
+                AddTerminalMsg("ERROR: SN Should not be empty");
+                return;
+            }
+
+            if (!ValidateSN())
+            {
+                return;
+            }
+
+            string filePath = uxBinFilePath.Text;
+            if (!File.Exists(filePath))
+            {
+                AddTerminalMsg("ERROR: Program file not found");
+                return;
+            }
+
+            string cliPath = stlinkService.CliPath;
+            if (!File.Exists(filePath))
+            {
+                AddTerminalMsg("ERROR: ST-LINK_CLI not found");
+                return;
+            }
+
+            var task = new Task(() =>
+            {
+                StartProgram(filePath);
+            });
+            task.Start();
+        }
+
+        private void StartProgram(string filePath)
+        {
+            UpdateProgressBar(0, 100);
+
+            stlinkService.OnMsgReceviced += StlinkService_OnMsgReceviced;
+            stlinkService.OnProgressChanged += StlinkService_OnProgressChanged;
+
+            var result = stlinkService.StartProgramProcess(filePath);
+
+            stlinkService.OnMsgReceviced -= StlinkService_OnMsgReceviced;
+            stlinkService.OnProgressChanged -= StlinkService_OnProgressChanged;
+
+            if (result is null)
+            {
+                //report empty error
+                SajetConnect.SajetTranFinishFail(MesErrorCode.ProgramFail);
+                return;
+            }
+
+            if (!string.IsNullOrEmpty(result.ErrorMsg))
+            {
+                AddTerminalMsg(result.ErrorMsg);
+            }
+
+            var reportDatas = new ValueReportDatas();
+            foreach (var logData in result.Data)
+            {
+                reportDatas.Add(logData.Key, logData.Value, true);
+            }
+            SajetConnect.SajetTransReport(reportDatas);
+
+            if (!result.IsSuccess)
+            {
+                var errCode = GetErrorCode(result.Step);
+                //report
+                SajetConnect.SajetTranFinishFail(errCode);
+                resultDialog.MouseDown += ResultDialog_MouseDown;
+                resultDialog.ShowResult(false);
+            }
+
+            if (result.IsSuccess)
+            {
+                //report
+                SajetConnect.SajetTranFinishSuccess();
+                resultDialog.MouseDown += ResultDialog_MouseDown;
+                resultDialog.ShowResult(true);
+            }
+        }
+
+        private MesErrorCode GetErrorCode(int step)
+        {
+            switch(step)
+            {
+                case 0:
+                    return MesErrorCode.None;
+                case 1:
+                    return MesErrorCode.SetOptionsFail;
+                case 2:
+                    return MesErrorCode.ProgramFail;
+                case 3:
+                    return MesErrorCode.RestFail;
+                case 4:
+                    return MesErrorCode.ProgramCheckFail;
+                case 5:
+                    return MesErrorCode.GetCheckSumFail;
+                default:
+                    return MesErrorCode.None;
+            }
+        }
+
+        private void ResultDialog_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            resultDialog.MouseDown -= ResultDialog_MouseDown;
+            this.Close();
+        }
+
+        private void ResultDialog_Closing(object sender, CancelEventArgs e)
+        {
+            resultDialog.Closing -= ResultDialog_Closing;
+            this.Close();
+        }
+
+        private bool ValidateSN()
+        {
+            string tmpSN;
+            bool bResult = false;
+            tmpSN = uxSN.Text;
+
+            var mesSetting = AppSettingService.Instance.MES.ToLower();
+            if (mesSetting == "php" || mesSetting == "shinewave")
+            {
+                bResult = SajetConnect.SajetTransSnCheck(ref tmpSN);
+                if (!bResult)
+                {
+                    MessageBox.Show("SN not found");
+                }
+                return bResult;
+            }
+
+            MessageBox.Show("Not supported MES");
+            return false;
+        }
+
+        private void StlinkService_OnProgressChanged(int currentStep, int maxStep)
+        {
+            UpdateProgressBar(currentStep, maxStep);
+        }
+
+        private void StlinkService_OnMsgReceviced(string msg)
+        {
+            AddTerminalMsg(msg);
+        }
+
+        private void AddTerminalMsg(string msg)
+        {
+            GenericDelegate onMsgReceviced;
+            onMsgReceviced = () =>
+            {
+                var paragraph = new Paragraph();
+                paragraph.Inlines.Add(GetRun(msg));
+                uxTerminal.Document.Blocks.Add(paragraph);
+                uxTerminal.ScrollToEnd();
+            };
+
+            this.Dispatcher.BeginInvoke(onMsgReceviced);
+        }
+
+        private void UpdateProgressBar(int currentStep,int maxStep)
+        {
+            GenericDelegate onUpdateProgressBar;
+            onUpdateProgressBar = () =>
+            {
+                uxProgressBar.Maximum = maxStep;
+                uxProgressBar.Value = currentStep;
+            };
+
+            this.Dispatcher.BeginInvoke(onUpdateProgressBar);
+        }
+
+        private Run GetRun(string msg)
+        {
+            if (msg is null)
+            {
+                msg = "";
+            }
+
+            Color textColor = Colors.White;
+            if (msg.StartsWith("ERROR:") ||
+                msg == "Unable to connect to ST-LINK!" )
+            {
+                textColor = Colors.Red;
+            }
+            if (msg == "Programming Complete." ||
+                msg == "No difference found." ||
+                msg == "MCU Reset." ||
+                msg.StartsWith("checksum:"))
+            {
+                textColor = Colors.LightGreen;
+            }
+            return new Run() { Text = msg, Foreground = new SolidColorBrush(textColor) };
+        }
+    }
+}

+ 15 - 0
ST-LINK_MES/Model/Result.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ST_LINK_MES.Model
+{
+    public class Result
+    {
+        public int Step { get; set; }
+        public bool IsSuccess { get; set; }
+        public Dictionary<string, string> Data { get; set; } = new Dictionary<string, string>();
+        public string ErrorMsg { get; set; }
+    }
+}

+ 55 - 0
ST-LINK_MES/Properties/AssemblyInfo.cs

@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ST-LINK_MES")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ST-LINK_MES")]
+[assembly: AssemblyCopyright("Copyright ©  2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
+//inside a <PropertyGroup>.  For example, if you are using US english
+//in your source files, set the <UICulture> to en-US.  Then uncomment
+//the NeutralResourceLanguage attribute below.  Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+                                     //(used if a resource is not found in the page,
+                                     // or application resource dictionaries)
+    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+                                              //(used if a resource is not found in the page,
+                                              // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.1.0")]
+[assembly: AssemblyFileVersion("1.0.1.0")]

+ 63 - 0
ST-LINK_MES/Properties/Resources.Designer.cs

@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ST_LINK_MES.Properties {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ST_LINK_MES.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
ST-LINK_MES/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?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.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: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" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </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" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 26 - 0
ST-LINK_MES/Properties/Settings.Designer.cs

@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ST_LINK_MES.Properties {
+    
+    
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+        
+        public static Settings Default {
+            get {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
ST-LINK_MES/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 12 - 0
ST-LINK_MES/ResultDialog.xaml

@@ -0,0 +1,12 @@
+<Window x:Class="ST_LINK_MES.ResultDialog"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:ST_LINK_MES"
+        mc:Ignorable="d" ResizeMode="NoResize" WindowStyle="None" WindowStartupLocation="CenterOwner"
+        Title="ResultDialog" Height="250" Width="400">
+    <Grid x:Name="uxBg" Background="Lime">
+        <Label x:Name="uxResultText" Content="PASS" VerticalAlignment="Center" FontSize="72" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center"/>
+    </Grid>
+</Window>

+ 47 - 0
ST-LINK_MES/ResultDialog.xaml.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace ST_LINK_MES
+{
+    /// <summary>
+    /// Interaction logic for ResultDialog.xaml
+    /// </summary>
+    public partial class ResultDialog : Window
+    {
+        public ResultDialog()
+        {
+            InitializeComponent();
+        }
+
+        private delegate void GenericDelegate();
+
+        public void ShowResult(bool isSuccess)
+        {
+            GenericDelegate ShowResultAct = () => {
+                if (isSuccess)
+                {
+                    uxBg.Background = Brushes.Lime;
+                    uxResultText.Content = "PASS";
+                }
+
+                if (!isSuccess)
+                {
+                    uxBg.Background = Brushes.Red;
+                    uxResultText.Content = "FAIL";
+                }
+                this.ShowDialog();
+            };
+            this.Dispatcher.BeginInvoke(ShowResultAct);
+        }
+    }
+}

+ 135 - 0
ST-LINK_MES/ST-LINK_MES.csproj

@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{2A3E513B-EDF8-4E61-B629-1CE59AB243EC}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>ST_LINK_MES</RootNamespace>
+    <AssemblyName>ST-LINK_MES</AssemblyName>
+    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <WarningLevel>4</WarningLevel>
+    <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>true</Prefer32Bit>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Xaml">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="WindowsBase">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="PresentationCore">
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="PresentationFramework">
+      <Private>False</Private>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <ApplicationDefinition Include="App.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </ApplicationDefinition>
+    <Compile Include="LoginWindow.xaml.cs">
+      <DependentUpon>LoginWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Model\Result.cs" />
+    <Compile Include="ResultDialog.xaml.cs">
+      <DependentUpon>ResultDialog.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Service\AppSettingService.cs" />
+    <Compile Include="Service\STLinkCliWrapService.cs" />
+    <Compile Include="Service\STLinkCliPrograrmService.cs" />
+    <Page Include="LoginWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="MainWindow.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Compile Include="App.xaml.cs">
+      <DependentUpon>App.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="MainWindow.xaml.cs">
+      <DependentUpon>MainWindow.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+    <Page Include="ResultDialog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+    <None Include="app.config" />
+    <None Include="packages.config" />
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\MesAdaptor\MesAdaptor.csproj">
+      <Project>{6b69cf23-270b-429b-a21d-ad98c2dff678}</Project>
+      <Name>MesAdaptor</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>GitVersion.exe $(SolutionDir) /updateassemblyinfo</PreBuildEvent>
+  </PropertyGroup>
+</Project>

+ 81 - 0
ST-LINK_MES/Service/AppSettingService.cs

@@ -0,0 +1,81 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows;
+
+namespace ST_LINK_MES.Service
+{
+    public class AppSettingService
+    {
+        private static AppSettingService _Instance;
+        public static AppSettingService Instance
+        {
+            get
+            {
+                if (_Instance == null)
+                {
+                    _Instance = new AppSettingService();
+                }
+                return _Instance;
+            }
+        }
+
+        private AppSettingService()
+        {
+
+        }
+
+        public string MES => appSetting?.MES;
+        public string MechineCode => appSetting?.MechineCode;
+        public bool LOCK => appSetting == null ? false : appSetting.LOCK;
+        public string DLinkCliPath => appSetting?.DLinkCliPath;
+        public string BinPath => appSetting?.BinPath;
+
+        private const string settingFileName = "Settings.ini";
+        private AppSetting appSetting;
+
+        public void Load()
+        {
+            if (!File.Exists(settingFileName))
+            {
+                appSetting = new AppSetting() {
+                    MES = "php",
+                };
+                return;
+            }
+
+            try
+            {
+                appSetting = JsonConvert.DeserializeObject<AppSetting>(File.ReadAllText(settingFileName));
+            }
+            catch
+            {
+                MessageBox.Show($"{settingFileName} format ERROR");
+            }
+        }
+
+        public void Save(AppSetting setting)
+        {
+            if (File.Exists(settingFileName))
+            {
+                File.Delete(settingFileName);
+            }
+
+            File.WriteAllText(settingFileName, JsonConvert.SerializeObject(setting));
+
+            Load();
+        }
+    }
+
+    public class AppSetting
+    {
+        public string MES { get; set; }
+        public string MechineCode { get; set; }
+        public bool LOCK { get; set; }
+        public string DLinkCliPath { get; set; }
+        public string BinPath { get; set; }
+    }
+}

+ 275 - 0
ST-LINK_MES/Service/STLinkCliPrograrmService.cs

@@ -0,0 +1,275 @@
+using ST_LINK_MES.Model;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace ST_LINK_MES.Service
+{
+    public class STLinkCliPrograrmService
+    {
+        public STLinkCliPrograrmService(string stlCliPath = "")
+        {
+            this._cli = new STLinkCliWrapService(stlCliPath);
+        }
+
+        public delegate void OnMsgRecevicedEvent(string msg);
+        public event OnMsgRecevicedEvent OnMsgReceviced;
+
+        public delegate void OnProgressChangedEvent(int currentStep,int maxStep);
+        public event OnProgressChangedEvent OnProgressChanged;
+        public string CliPath => _cli.CliPath;
+
+        private readonly STLinkCliWrapService _cli;
+
+        public Result StartProgramProcess(string filePath)
+        {
+            Result result = new Result() { IsSuccess = false };
+
+            result.Step = 1;
+            var setOptionsResult = SetOptions();
+            if (setOptionsResult != null)
+            {
+                result.ErrorMsg = setOptionsResult.ErrorMsg;
+                foreach (var pair in setOptionsResult.Data)
+                {
+                    result.Data[pair.Key] = pair.Value;
+                }
+            }
+            if (setOptionsResult == null || !setOptionsResult.IsSuccess)
+            {
+                return result;
+            }
+            OnProgressChanged?.Invoke(1, 5);
+
+            result.Step = 2;
+            var startProgramResult = StartProgram(filePath);
+            if (startProgramResult != null)
+            {
+                result.ErrorMsg = startProgramResult.ErrorMsg;
+                foreach (var pair in startProgramResult.Data)
+                {
+                    result.Data[pair.Key] = pair.Value;
+                }
+            }
+            if (startProgramResult == null || !startProgramResult.IsSuccess)
+            {
+                return result;
+            }
+            OnProgressChanged?.Invoke(2, 5);
+
+            result.Step = 3;
+            var restResult = Rest();
+            if (restResult != null)
+            {
+                result.ErrorMsg = restResult.ErrorMsg;
+                foreach (var pair in restResult.Data)
+                {
+                    result.Data[pair.Key] = pair.Value;
+                }
+            }
+            if (restResult == null || !restResult.IsSuccess)
+            {
+                return result;
+            }
+            OnProgressChanged?.Invoke(3, 5);
+
+            result.Step = 4;
+            var checkResult = Check(filePath);
+            if (checkResult != null)
+            {
+                result.ErrorMsg = checkResult.ErrorMsg;
+                foreach (var pair in checkResult.Data)
+                {
+                    result.Data[pair.Key] = pair.Value;
+                }
+            }
+            if (checkResult == null || !checkResult.IsSuccess)
+            {
+                return result;
+            }
+            OnProgressChanged?.Invoke(4, 5);
+
+            result.Step = 5;
+            var getCheckSumResult = GetCheckSum(filePath);
+            if (getCheckSumResult != null)
+            {
+                result.ErrorMsg = getCheckSumResult.ErrorMsg;
+                foreach (var pair in getCheckSumResult.Data)
+                {
+                    result.Data[pair.Key] = pair.Value;
+                }
+            }
+            if (getCheckSumResult == null || !getCheckSumResult.IsSuccess)
+            {
+                return result;
+            }
+            OnProgressChanged?.Invoke(5, 5);
+
+            result.IsSuccess = true;
+            return result;
+        }
+
+        public Result SetOptions()
+        {
+            var result = new Result() { IsSuccess = true };
+
+            _cli.OnMsgReceviced += stlCli_OnMsgReceviced_SetDefaultOptions;
+            var resultInt = _cli.SetDefaultOptions();
+            _cli.OnMsgReceviced -= stlCli_OnMsgReceviced_SetDefaultOptions;
+
+            result.IsSuccess = resultInt == 0;
+            return result;
+
+            void stlCli_OnMsgReceviced_SetDefaultOptions(string msg)
+            {
+                if (msg is null)
+                    return;
+
+                if (msg.Contains("Unable to connect to ST-LINK!"))
+                {
+                    result.ErrorMsg = "ERROR: Unable to connect to ST-LINK!";
+                }
+                OnMsgReceviced?.Invoke(msg);
+            }
+        }
+
+        public Result StartProgram(string filePath)
+        {
+            if (!File.Exists(filePath))
+            {
+                return new Result()
+                {
+                    IsSuccess = false,
+                    ErrorMsg = "ERROR: Program file not found",
+                };
+            }
+
+            var result = new Result() { IsSuccess = true };
+
+            _cli.OnMsgReceviced += stlCli_OnMsgReceviced_StartProgram;
+            var resultInt = _cli.StartProgram(filePath);
+            _cli.OnMsgReceviced -= stlCli_OnMsgReceviced_StartProgram;
+
+            result.IsSuccess = resultInt == 0;
+            return result;
+
+            void stlCli_OnMsgReceviced_StartProgram(string msg)
+            {
+                if (msg is null)
+                    return;
+
+                if (msg.Contains("Unable to connect to ST-LINK!"))
+                {
+                    result.ErrorMsg = "ERROR: Unable to connect to ST-LINK!";
+                }
+                OnMsgReceviced?.Invoke(msg);
+            }
+        }
+
+        public Result Rest()
+        {
+            var result = new Result() { IsSuccess = true };
+
+            _cli.OnMsgReceviced += stlCli_OnMsgReceviced_StartProgram;
+            var resultInt = _cli.Rest();
+            _cli.OnMsgReceviced -= stlCli_OnMsgReceviced_StartProgram;
+
+            result.IsSuccess = resultInt == 0;
+            return result;
+
+            void stlCli_OnMsgReceviced_StartProgram(string msg)
+            {
+                if (msg is null)
+                    return;
+
+                if (msg.Contains("Unable to connect to ST-LINK!"))
+                {
+                    result.ErrorMsg = "ERROR: Unable to connect to ST-LINK!";
+                }
+                OnMsgReceviced?.Invoke(msg);
+            }
+        }
+
+        public Result Check(string filePath)
+        {
+            if (!File.Exists(filePath))
+            {
+                return new Result()
+                {
+                    IsSuccess = false,
+                    ErrorMsg = "ERROR: Check file not found",
+                };
+            }
+
+            var result = new Result() { IsSuccess = true };
+
+            _cli.OnMsgReceviced += stlCli_OnMsgReceviced_StartProgram;
+            var resultInt = _cli.Check(filePath);
+            _cli.OnMsgReceviced -= stlCli_OnMsgReceviced_StartProgram;
+
+            result.IsSuccess = resultInt == 0;
+            return result;
+
+            void stlCli_OnMsgReceviced_StartProgram(string msg)
+            {
+                if (msg is null)
+                    return;
+
+                if (msg.Contains("Unable to connect to ST-LINK!"))
+                {
+                    result.ErrorMsg = "ERROR: Unable to connect to ST-LINK!";
+                }
+                OnMsgReceviced?.Invoke(msg);
+            }
+        }
+
+        public Result GetCheckSum(string filePath)
+        {
+            if (!File.Exists(filePath))
+            {
+                return new Result()
+                {
+                    IsSuccess = false,
+                    ErrorMsg = "ERROR: Check file not found",
+                };
+            }
+
+            var result = new Result() { IsSuccess = true };
+
+            _cli.OnMsgReceviced += stlCli_OnMsgReceviced_StartProgram;
+            var resultInt = _cli.GetCheckSum(filePath);
+            _cli.OnMsgReceviced -= stlCli_OnMsgReceviced_StartProgram;
+
+            result.IsSuccess = resultInt == 0;
+            return result;
+
+            void stlCli_OnMsgReceviced_StartProgram(string msg)
+            {
+                if (msg is null)
+                    return;
+
+                Regex checksumRegex = new Regex("^(.*)file checksum : (.*)$");
+                var match = checksumRegex.Match(msg);
+                if (match.Success &&
+                    match.Groups.Count > 2 &&
+                    match.Groups[2].Value.StartsWith("0x"))
+                {
+                    var checksum = match.Groups[2].Value;
+                    result.Data.Add("checksum", checksum);
+                    result.Data.Add("fileName", Path.GetFileName(filePath));
+
+                    OnMsgReceviced?.Invoke($"checksum: {checksum}");
+                }
+
+                if (msg.Contains("Unable to connect to ST-LINK!"))
+                {
+                    result.ErrorMsg = "ERROR: Unable to connect to ST-LINK!";
+                }
+                OnMsgReceviced?.Invoke(msg);
+            }
+        }
+    }
+}

+ 82 - 0
ST-LINK_MES/Service/STLinkCliWrapService.cs

@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace ST_LINK_MES.Service
+{
+    public class STLinkCliWrapService
+    {
+        public STLinkCliWrapService(string cliPath)
+        {
+            if (string.IsNullOrEmpty(cliPath))
+            {
+                cliPath = "C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility\\ST-LINK_CLI.exe";
+            }
+            this.cliPath = cliPath;
+        }
+
+        public delegate void OnMsgRecevicedEvent(string msg);
+        public event OnMsgRecevicedEvent OnMsgReceviced;
+
+        public string CliPath => cliPath;
+
+        private readonly string cliPath;
+
+        public int SetDefaultOptions()
+        {
+            return RunConsole(cliPath, $"-OB RDP=0 BOR_LEV=3 IWDG_SW=1 nRST_STOP=1 nRST_STDBY=1");
+        }
+
+        public int StartProgram(string filePath)
+        {
+            return RunConsole(cliPath, $"-P \"{filePath}\"");
+        }
+
+        public int Rest()
+        {
+            return RunConsole(cliPath, $"-Rst");
+        }
+
+        public int Check(string filePath)
+        {
+            return RunConsole(cliPath, $"-CmpFile \"{filePath}\"");
+        }
+
+        public int GetCheckSum(string filePath)
+        {
+            return RunConsole(cliPath, $"-Cksum \"{filePath}\"");
+        }
+
+        private int RunConsole(string exePath, string param)
+        {
+            var pInfo = new ProcessStartInfo() {
+                FileName = exePath,
+                Arguments = param,
+                RedirectStandardOutput = true,
+                CreateNoWindow = true,
+                UseShellExecute = false,
+                
+            };
+
+            var p = Process.Start(pInfo);
+            p.OutputDataReceived += P_OutputDataReceived;
+            p.BeginOutputReadLine();
+            p.WaitForExit();
+            p.Exited += P_Exited;
+            return p.ExitCode;
+        }
+
+        private void P_Exited(object sender, EventArgs e)
+        {
+
+        }
+
+        private void P_OutputDataReceived(object sender, DataReceivedEventArgs e)
+        {
+            OnMsgReceviced?.Invoke(e.Data);
+        }
+    }
+}

+ 3 - 0
ST-LINK_MES/app.config

@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>

+ 4 - 0
ST-LINK_MES/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net40" requireReinstallation="true" />
+</packages>