|
@@ -1,283 +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";
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+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";
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|