Browse Source

同步TIN02 recipe lock功能

jiangjy 3 weeks ago
parent
commit
3e63f1aa3d

+ 1 - 1
Furnace/FurnaceRT/Equipments/Systems/EquipmentManager_FA.cs

@@ -664,7 +664,7 @@ namespace FurnaceRT.Equipments.Systems
         }
         public string GetRecipeBody(string recipename)
         {
-            var test = RecipeFileManager.Instance.LoadRecipeByFullPathForFA(recipename);
+            
 
             return RecipeFileManager.Instance.LoadRecipeByFullPathForFA(recipename);
         }

+ 65 - 0
Furnace/FurnaceRT/Extraction/RecipeLockManager.cs

@@ -0,0 +1,65 @@
+using Aitex.Core.RT.DataCenter;
+using Aitex.Core.RT.OperationCenter;
+using Aitex.Core.Util;
+using DocumentFormat.OpenXml.Vml.Office;
+using MECF.Framework.Common.OperationCenter;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+public class RecipeLockManager : Singleton<RecipeLockManager>
+{
+
+    private bool _isLocked;
+
+    private bool IsLocked
+    {
+        get { return _isLocked; }
+        set
+        {
+            locktimer?.Dispose();
+            _isLocked = value;
+            if (!value)
+                return;
+            locktimer = new Timer(LockCallBack, null, 12000, 10000);
+        }
+    }
+    private Timer locktimer;
+    private bool _isInit = false;
+
+    void LockCallBack(object state)
+    {
+        this.IsLocked = false;
+    }
+
+    public void Initialize()
+    {
+        if (this._isInit)
+            return;
+        try
+        {
+            DATA.Subscribe("RecipeEditLock", () => this.IsLocked, SubscriptionAttribute.FLAG.IgnoreSaveDB);
+            OP.Subscribe($"RecipeEditLock", LockCallBack);
+            this._isInit = true;
+        }
+        catch
+        {
+
+        }
+    }
+
+    private bool LockCallBack(out string reason, int time, object[] param)
+    {
+        reason = string.Empty;
+
+        if (param.Length >= 1 && param[0] is bool isLocked)
+            this.IsLocked = isLocked;
+
+        return true;
+    }
+
+
+}

+ 1 - 0
Furnace/FurnaceRT/FurnaceRT.csproj

@@ -259,6 +259,7 @@
     <Compile Include="Equipments\WaferRobots\WaferRobotPlace.cs" />
     <Compile Include="Extraction\ExtractionMethods.cs" />
     <Compile Include="Extraction\MinicsManager.cs" />
+    <Compile Include="Extraction\RecipeLockManager.cs" />
     <Compile Include="FAs\VIDMap.cs" />
     <Compile Include="Properties\Annotations.cs" />
     <Compile Include="Equipments\PMs\RecipeExecutions\FurnaceRecipeFileContext.cs" />

+ 1 - 0
Furnace/FurnaceRT/Instances/ToolLoader.cs

@@ -119,6 +119,7 @@ namespace FurnaceRT.Instances
             UpgradeDataTable();
             if (SC.ContainsItem("Minics.EnableMinics") && SC.GetValue<bool>("Minics.EnableMinics"))
                 Singleton<MinicsManager>.Instance.Initialize(SC.GetStringValue("Minics.ip"), int.Parse(SC.GetStringValue("Minics.port")));
+            Singleton<RecipeLockManager>.Instance.Initialize();
 
             Singleton<EventManager>.Instance.FireEvent += InstanceOnEvent;
 

+ 35 - 7
Furnace/FurnaceUI/Views/Recipes/RecipeViewModel.cs

@@ -8,6 +8,7 @@ using FurnaceUI.Models;
 using FurnaceUI.Views.Editors;
 using MECF.Framework.Common.CommonData;
 using MECF.Framework.Common.DataCenter;
+using MECF.Framework.Common.OperationCenter;
 using MECF.Framework.Common.Utilities;
 using MECF.Framework.UI.Client.CenterViews.Editors;
 using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
@@ -22,6 +23,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Linq;
+using System.Threading;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
@@ -2219,11 +2221,26 @@ namespace FurnaceUI.Views.Recipes
         private string oldName { get; set; }
 
         private string oldStepName { get; set; }
-
+        private Timer locktimer;
+        public void RequestRecipeEditLock()
+        {
+            locktimer?.Dispose();
+            locktimer = new Timer(LockCallBack, null, 0, 5000);
+        }
+        void LockCallBack(object state)
+        {
+            InvokeClient.Instance.Service.DoOperation("RecipeEditLock", true);
+        }
         private bool PopupPage()
         {
+            if (QueryDataClient.Instance.Service.GetData("RecipeEditLock") is bool locked && locked)
+            {
+                DialogBox.ShowInfo($"Others is editing recipe{Environment.NewLine}Please wait...");
+                return false;
+            }
             if (CurrentFileNode == null || !CurrentFileNode.IsFile)
                 return false;
+
             var windowManager = IoC.Get<IWindowManager>();
             RecipeProcessEditViewModel recipeEditViewModel = new RecipeProcessEditViewModel(CurrentFileNode.PrefixPath, CurrentFileNode.FullPath, CurrentFileNode.Permission);
             recipeEditViewModel.SetParent(Window.GetWindow((UIElement)GetView()));
@@ -2234,15 +2251,26 @@ namespace FurnaceUI.Views.Recipes
             {
                 recipeEditViewModel.SelectedStepName = oldStepName;
             }
-            bool? bret = (windowManager as WindowManager)?.ShowDialogWithTitle(recipeEditViewModel, this, null, $"Recipe Edit");
-            if (recipeEditViewModel.CurrentRecipe != null && recipeEditViewModel.selectStep != null)
+            RequestRecipeEditLock();
+            try
+            {
+                bool? bret = (windowManager as WindowManager)?.ShowDialogWithTitle(recipeEditViewModel, this, null, $"Recipe Edit");
+                if (recipeEditViewModel.CurrentRecipe != null && recipeEditViewModel.selectStep != null)
+                {
+                    oldPrefix = recipeEditViewModel.CurrentRecipe.PrefixPath;
+                    oldName = recipeEditViewModel.CurrentRecipe.Name;
+                    oldStepName = recipeEditViewModel.SelectedRecipeStep.Name;
+                }
+                return bret == true;
+
+            }
+            finally
             {
-                oldPrefix = recipeEditViewModel.CurrentRecipe.PrefixPath;
-                oldName = recipeEditViewModel.CurrentRecipe.Name;
-                oldStepName = recipeEditViewModel.SelectedRecipeStep.Name;
+                this.locktimer?.Dispose();
+                InvokeClient.Instance.Service.DoOperation("RecipeEditLock", false);
             }
 
-            return bret == true;
+
         }
 
     }