Переглянути джерело

EAP Load增加了port的检验

chenkui 3 місяців тому
батько
коміт
f6b8a7c89a

+ 59 - 12
FrameworkLocal/RTModuleLibrary/SystemModules/EquipmentManager.cs

@@ -1444,6 +1444,16 @@ namespace MECF.Framework.RT.ModuleLibrary.SystemModules
                     if(cassteCount=="1")
                     {
                         string strPort=ports[0].ToString();
+                        if (!int.TryParse(strPort, out portID))
+                        {
+                            reason = $"LoadPort {strPort} is not exist";
+                            return false;
+                        }
+                        if (portID > 4)
+                        {
+                            reason = $"LoadPort {strPort} is invalid";
+                            return false;
+                        }
                         bool result=SingleLoadPortLoad(strPort);
                         if(!result)
                         {
@@ -1458,31 +1468,68 @@ namespace MECF.Framework.RT.ModuleLibrary.SystemModules
                         {
                             return true;
                         }
-                        else
+                        else if(ports.Length==2)
                         {
-                            for(int i=0;i<ports.Length;i++)
+                            string str1 = ports[0].ToString();
+                            string str2 = ports[1].ToString();
+                            if(!int.TryParse(str1, out int port1))
+                            {
+                                reason = $"LoadPort {str1} is not exist";
+                                return false;
+                            }
+                            if (!int.TryParse(str2, out int port2))
+                            {
+                                reason = $"LoadPort {str1} is not exist";
+                                return false;
+                            }
+                            if(port1>4)
+                            {
+                                reason = $"LoadPort {str1} is invalid";
+                                return false;
+                            }
+                            if (port2 > 4)
+                            {
+                                reason = $"LoadPort {str2} is invalid";
+                                return false;
+                            }
+                            if (Math.Abs(port1-port2)>=2)
                             {
-                                string str=ports[i].ToString();
-                                bool result = SingleLoadPortLoad(str);
-                                if(result)
-                                {
-                                    return true;
-                                }
+                                reason = $"LP{port1} and LP{port2} is not same VCE";
+                                return false;
                             }
-                            reason = $"LoadPort is not exist";
+                            bool result = SingleLoadPortLoad(str1);
+                            if(result)
+                            {
+                                return true;
+                            }
+                            return false;
+                        }
+                        else
+                        {
+                            reason = "port length is over 2";
                             return false;
                         }
                     }
 
                 case "UNLOAD":
-                    portID = int.Parse(paras[0].ToString());
-                    lp = Modules[ModuleHelper.GetVCEModule(portID)] as VceModuleBase;
+                    string str = paras[0].ToString(); 
+                    if (!int.TryParse(str, out int port))
+                    {
+                        reason = $"LoadPort {str} is not exist";
+                        return false;
+                    }
+                    if (port > 4)
+                    {
+                        reason = $"LoadPort {str} is invalid";
+                        return false;
+                    }
+                    lp = Modules[ModuleHelper.GetVCEModule(port)] as VceModuleBase;
                     if (lp != null)
                     {
                         return lp.CheckToPostMessage(VceMSG.SafeUnload);
                     }
 
-                    reason = $"Not Find LP{portID}";
+                    reason = $"Not Find LP{port}";
                     return false;
 
                 case "MAPCASSETTE":