Kaynağa Gözat

Merge branch 'master' of http://192.168.1.123:10080/SDD1/HOZ

HaoShuang 5 yıl önce
ebeveyn
işleme
475e9535df

+ 3 - 3
FileManager/LogManager.cs

@@ -120,11 +120,11 @@ namespace FileManager
             string MethodName = sf.GetMethod().Name;
             //行号
             int LineNumber = sf.GetFileLineNumber();
-            //设置运行状态
-            RunState = true;
+            ////设置运行状态
+            //RunState = true;
             st = null;
 
-            HardwareLogWrite(FileName, MethodName, LineNumber, logContent, RunState);
+            HardwareLogWrite(FileName, MethodName, LineNumber, logContent, logState);
         }
         #endregion
 

+ 0 - 9
SmartSEMControl/HardwareInterface.cs

@@ -193,15 +193,6 @@ namespace SmartSEMControl
         //清除控件
         Boolean Dispose();
 
-
-
-
-        //Pt的控制
-        //PT针插入
-        Boolean InsertPT();
-        //PT针退出
-        Boolean OutputPT();
-
     }
 
     interface FIBControl

+ 225 - 13
SmartSEMControl/SmartSEM.cs

@@ -18,6 +18,94 @@ namespace SmartSEMControl
     //可能遇到的错误提示部分??在log加入之后添加
     class SmartSEM : ISEMControl
     {
+        #region 返回错误代码枚举
+        private enum ZeissErrorCode
+        {
+            // Failed to translate parameter into an id
+            API_E_GET_TRANSLATE_FAIL = 1000,
+            // Failed to get analogue value
+            API_E_GET_AP_FAIL = 1001,
+            // Failed to get digital value
+            API_E_GET_DP_FAIL = 1002,
+            // Parameter supplied is not analogue nor digital
+            API_E_GET_BAD_PARAMETER = 1003,
+            // Failed to translate parameter into an id
+            API_E_SET_TRANSLATE_FAIL = 1004,
+            // Failed to set a digital state 
+            API_E_SET_STATE_FAIL = 1005,
+            // Failed to set a float value
+            API_E_SET_FLOAT_FAIL = 1006,
+            // Value supplied is too low
+            API_E_SET_FLOAT_LIMIT_LOW = 1007,
+            // Value supplied is too high
+            API_E_SET_FLOAT_LIMIT_HIGH = 1008,
+            // Value supplied is is of wrong type
+            API_E_SET_BAD_VALUE = 1009,
+            // Parameter supplied is not analogue nor digital
+            API_E_SET_BAD_PARAMETER = 1010,
+            // Failed to translate command into an id
+            API_E_EXEC_TRANSLATE_FAIL = 1011,
+            // Failed to execute command=
+            API_E_EXEC_CMD_FAIL = 1012,
+            // Failed to execute file macro
+            API_E_EXEC_MCF_FAIL = 1013,
+            // Failed to execute library macro
+            API_E_EXEC_MCL_FAIL = 1014,
+            // Command supplied is not implemented
+            API_E_EXEC_BAD_COMMAND = 1015,
+            // Grab command failed
+            API_E_GRAB_FAIL = 1016,
+            // Get Stage position failed
+            API_E_GET_STAGE_FAIL = 1017,
+            // Move Stage position failed
+            API_E_MOVE_STAGE_FAIL = 1018,
+            // API not initialised
+            API_E_NOT_INITIALISED = 1019,
+            // Failed to translate parameter to an id
+            API_E_NOTIFY_TRANSLATE_FAIL = 1020,
+            // Set notification failed
+            API_E_NOTIFY_SET_FAIL = 1021,
+            // Get limits failed
+            API_E_GET_LIMITS_FAIL = 1022,
+            // Get multiple parameters failed
+            API_E_GET_MULTI_FAIL = 1023,
+            // Set multiple parameters failed
+            API_E_SET_MULTI_FAIL = 1024,
+            // Missing API license
+            API_E_NOT_LICENSED = 1025,
+            // Reserved or not implemented
+            API_E_NOT_IMPLEMENTED = 1026,
+            // Failed to get user name (Remoting Interface only)
+            API_E_GET_USER_NAME_FAIL = 1027,
+            // Failed to get user idle state (Remoting Interface only)
+            API_E_GET_USER_IDLE_FAIL = 1028,
+            // Failed to get the last remoting connection error string (Remoting Interface Only)
+            API_E_GET_LAST_REMOTING_CONNECT_ERROR_FAIL = 1029,
+            // Failed to remotely logon to the EM Server (username and password may be incorrect or EM Server is not running or User is already logged on
+            API_E_EMSERVER_LOGON_FAILED = 1030,
+            // Failed to start the EM Server - this may be because the Server is already running or has an internal error. 
+            API_E_EMSERVER_START_FAILED = 1031,
+            // The command or parameter is currently disabled (you cannot execute or set it).
+            API_E_PARAMETER_IS_DISABLED = 1032,
+            // Remoting incorrectly configured, use RConfigure to correct
+            API_E_REMOTING_NOT_CONFIGURED = 2027,
+            // Remoting did not connect to the server
+            API_E_REMOTING_FAILED_TO_CONNECT = 2028,
+            // Remoting could not start (unknown reason)
+            API_E_REMOTING_COULD_NOT_CREATE_INTERFACE = 2029,
+            // Remoting: Remote server is not running currently.
+            API_E_REMOTING_EMSERVER_NOT_RUNNING = 2030,
+            // Remoting: Remote server has no user logged in
+            API_E_REMOTING_NO_USER_LOGGED_IN = 2031,
+
+            // Internal Defines, although they may be useful in your own program. TRS.
+            API_FIRST_REMOTING_ERROR_CODE = API_E_REMOTING_NOT_CONFIGURED,
+            API_LAST_REMOTING_ERROR_CODE = API_E_REMOTING_NO_USER_LOGGED_IN,
+            API_FIRST_ERROR_CODE = API_E_GET_TRANSLATE_FAIL,
+            API_LAST_ERROR_CODE = API_E_REMOTING_NO_USER_LOGGED_IN
+        }
+        #endregion
+
         #region 固定参数
         private String ELYPATH= @"C:\ProgramData\Carl Zeiss\SmartFIB\API\Drop\";
         private String ELYFILENAME = "ApiLayout.ely";
@@ -179,7 +267,7 @@ namespace SmartSEMControl
             #endif
             if (lrt != 0)
             {
-                LogManager.AddHardwareLog("CZEMApi.Initialise Faild!", false);
+                LogManager.AddHardwareLog("CZEMApi.Initialise Faild - " + ErrorToString(lrt), false);
                 m_bInitialised = false;
                 return false;
             }
@@ -232,7 +320,7 @@ namespace SmartSEMControl
                 long lrt = CZEMApi.ClosingControl();
                 if (lrt != 0)
                 {
-                    LogManager.AddHardwareLog("CZEMApi.ClosingControl Faild!", false);
+                    LogManager.AddHardwareLog("CZEMApi.ClosingControl Faild - " + ErrorToString(lrt), false);
                     return false;
                 }
                 else
@@ -258,6 +346,7 @@ namespace SmartSEMControl
                 long lrt = CZEMApi.Get(str_param, ref varfloat);
                 if (lrt != 0)
                 {
+                    LogManager.AddHardwareLog("Get " + str_param + " Faild - " + ErrorToString(lrt), false);
                     return false;
                 }
                 else
@@ -268,6 +357,7 @@ namespace SmartSEMControl
             }
             else
             {
+                LogManager.AddHardwareLog("ReadParams m_bInitialised = false", false);
                 return false;
             }
         }
@@ -284,6 +374,7 @@ namespace SmartSEMControl
                 long lrt = CZEMApi.GetLimits(str_param, ref varMin, ref varMax);
                 if (lrt != 0)
                 {
+                    LogManager.AddHardwareLog("GetLimits " + str_param + " Faild - " + ErrorToString(lrt), false);
                     return false;
                 }
                 if (value <= Convert.ToSingle(varMax) && value >= Convert.ToSingle(varMin))
@@ -292,17 +383,20 @@ namespace SmartSEMControl
                     lrt = CZEMApi.Set(str_param, ref varFloat);// set value
                     if (lrt != 0)
                     {
+                        LogManager.AddHardwareLog("Set " + str_param + " Faild - " + ErrorToString(lrt), false);
                         return false;
                     }
                     return true;
                 }
                 else
                 {
+                    LogManager.AddHardwareLog("Set " + str_param + " Faild - Out to range", false);
                     return false;
                 }
             }
             else
             {
+                LogManager.AddHardwareLog("ReadParams m_bInitialised = false", false);
                 return false;
             }
         }
@@ -317,12 +411,14 @@ namespace SmartSEMControl
                 long lrt = CZEMApi.Set(str_param, ref varFloat);// set value
                 if (lrt != 0)
                 {
+                    LogManager.AddHardwareLog("Set " + str_param + " Faild - " + ErrorToString(lrt), false);
                     return false;
                 }
                 return true;
             }
             else
             {
+                LogManager.AddHardwareLog("ReadParams m_bInitialised = false", false);
                 return false;
             }
         }
@@ -336,6 +432,7 @@ namespace SmartSEMControl
                 long lrt = CZEMApi.Execute(cmd);// execute command
                 if (lrt != 0)
                 {
+                    LogManager.AddHardwareLog("ExecuteCmd " + cmd + " Faild - " + ErrorToString(lrt), false);
                     return false;
                 }
                 else
@@ -1757,17 +1854,132 @@ namespace SmartSEMControl
         }
         #endregion
 
-        //PT针插入
-        public Boolean InsertPT()
-        {
-            //插入动作
-            //已经插入完成
-            return false;
-        }
-        //PT针退出
-        public Boolean OutputPT()
-        {
-            return false;
+        #region 错误代码转义
+        private String ErrorToString(long lError)
+        {
+            string strError;
+            switch ((ZeissErrorCode)lError)
+            {
+                case 0:
+                    strError = "OK";
+                    break;
+                case ZeissErrorCode.API_E_GET_TRANSLATE_FAIL:
+                    strError = "Failed to translate parameter into an ID";
+                    break;
+                case ZeissErrorCode.API_E_GET_AP_FAIL:
+                    strError = "Failed to get analogue value";
+                    break;
+                case ZeissErrorCode.API_E_GET_DP_FAIL:
+                    strError = "Failed to get digital value";
+                    break;
+                case ZeissErrorCode.API_E_GET_BAD_PARAMETER:
+                    strError = "Parameter supplied is neither analogue nor digital";
+                    break;
+                case ZeissErrorCode.API_E_SET_TRANSLATE_FAIL:
+                    strError = "Failed to translate parameter into an ID";
+                    break;
+                case ZeissErrorCode.API_E_SET_STATE_FAIL:
+                    strError = "Failed to set a digital state";
+                    break;
+                case ZeissErrorCode.API_E_SET_FLOAT_FAIL:
+                    strError = "Failed to set a float value";
+                    break;
+                case ZeissErrorCode.API_E_SET_FLOAT_LIMIT_LOW:
+                    strError = "Value supplied is too low";
+                    break;
+                case ZeissErrorCode.API_E_SET_FLOAT_LIMIT_HIGH:
+                    strError = "Value supplied is too high";
+                    break;
+                case ZeissErrorCode.API_E_SET_BAD_VALUE:
+                    strError = "Value supplied is of wrong type";
+                    break;
+                case ZeissErrorCode.API_E_SET_BAD_PARAMETER:
+                    strError = "Parameter supplied is not analogue nor digital";
+                    break;
+                case ZeissErrorCode.API_E_EXEC_TRANSLATE_FAIL:
+                    strError = "Failed to translate command into an ID";
+                    break;
+                case ZeissErrorCode.API_E_EXEC_CMD_FAIL:
+                    strError = "Failed to execute command";
+                    break;
+                case ZeissErrorCode.API_E_EXEC_MCF_FAIL:
+                    strError = "Failed to execute file macro";
+                    break;
+                case ZeissErrorCode.API_E_EXEC_MCL_FAIL:
+                    strError = "Failed to execute library macro";
+                    break;
+                case ZeissErrorCode.API_E_EXEC_BAD_COMMAND:
+                    strError = "Command supplied is not implemented";
+                    break;
+                case ZeissErrorCode.API_E_GRAB_FAIL:
+                    strError = "Grab command failed";
+                    break;
+                case ZeissErrorCode.API_E_GET_STAGE_FAIL:
+                    strError = "Get Stage position failed";
+                    break;
+                case ZeissErrorCode.API_E_MOVE_STAGE_FAIL:
+                    strError = "Move Stage position failed";
+                    break;
+                case ZeissErrorCode.API_E_NOT_INITIALISED:
+                    strError = "API not initialised";
+                    break;
+                case ZeissErrorCode.API_E_NOTIFY_TRANSLATE_FAIL: // 1020L
+                    strError = "Failed to translate parameter to an ID";
+                    break;
+                case ZeissErrorCode.API_E_NOTIFY_SET_FAIL:
+                    strError = "Set notification failed";
+                    break;
+                case ZeissErrorCode.API_E_GET_LIMITS_FAIL:
+                    strError = "Get limits failed";
+                    break;
+                case ZeissErrorCode.API_E_GET_MULTI_FAIL:
+                    strError = "Get multiple parameters failed";
+                    break;
+                case ZeissErrorCode.API_E_SET_MULTI_FAIL:
+                    strError = "Set multiple parameters failed";
+                    break;
+                case ZeissErrorCode.API_E_NOT_LICENSED:
+                    strError = "Missing API license";
+                    break;
+                case ZeissErrorCode.API_E_NOT_IMPLEMENTED:
+                    strError = "Reserved or not implemented";
+                    break;
+                case ZeissErrorCode.API_E_GET_USER_NAME_FAIL:
+                    strError = "Failed to get user name";
+                    break;
+                case ZeissErrorCode.API_E_GET_USER_IDLE_FAIL:
+                    strError = "Failed to get user idle state";
+                    break;
+                case ZeissErrorCode.API_E_GET_LAST_REMOTING_CONNECT_ERROR_FAIL:
+                    strError = "Failed to get the last remoting connection error string";
+                    break;
+                case ZeissErrorCode.API_E_EMSERVER_LOGON_FAILED:
+                    strError = "Failed to remotely logon to the EM Server. Username and password may be incorrect or EM Server is not running or User is already logged on";
+                    break;
+                case ZeissErrorCode.API_E_EMSERVER_START_FAILED:
+                    strError = "Failed to start the EM Server. This may be because the Server is already running or has an internal error.";
+                    break;
+                case ZeissErrorCode.API_E_REMOTING_NOT_CONFIGURED:
+                    strError = "Remoting incorrectly configured, use RConfigure to correct";
+                    break;
+                case ZeissErrorCode.API_E_REMOTING_FAILED_TO_CONNECT:
+                    strError = "Remoting did not connect to the server";
+                    break;
+                case ZeissErrorCode.API_E_REMOTING_COULD_NOT_CREATE_INTERFACE:
+                    strError = "Remoting could not start (unknown reason)";
+                    break;
+                case ZeissErrorCode.API_E_REMOTING_EMSERVER_NOT_RUNNING:
+                    strError = "EMServer is not running on the remote machine";
+                    break;
+                case ZeissErrorCode.API_E_REMOTING_NO_USER_LOGGED_IN:
+                    strError = "No user is logged into EM Server on the remote machine";
+                    break;
+                default:
+                    strError = string.Format("Unknown error code {0}", lError);
+                    break;
+            }
+            return strError;
         }
+        #endregion
     }
 }