瀏覽代碼

add robot cycle current step

chenzk 4 天之前
父節點
當前提交
affe7e7265

+ 11 - 0
PunkHPX8_MainPages/ViewModels/RobotCycleViewModel.cs

@@ -47,6 +47,10 @@ namespace PunkHPX8_MainPages.ViewModels
         /// 是否可以输入参数
         /// </summary>
         private bool _isInputParameterEnable;
+        /// <summary>
+        /// 当前正在执行哪一步
+        /// </summary>
+        private string _currentStep;
         #region 系统数据
         /// <summary>
         /// 定时器
@@ -80,6 +84,11 @@ namespace PunkHPX8_MainPages.ViewModels
             get { return _currentCycle; }
             set { SetProperty(ref _currentCycle, value); }
         }
+        public string CurrentStep
+        {
+            get { return _currentStep; }
+            set { SetProperty(ref _currentStep, value); }
+        }
         public bool IsInputParameterEnable
         {
             get { return _isInputParameterEnable; }
@@ -365,6 +374,7 @@ namespace PunkHPX8_MainPages.ViewModels
         {
             _rtDataKeys.Clear();
             _rtDataKeys.Add("EFEM.CurrentRobotCycleTime");
+            _rtDataKeys.Add("EFEM.CurrentRobotCycleStep");
             if (_timer == null)
             {
                 _timer = new DispatcherTimer();
@@ -391,6 +401,7 @@ namespace PunkHPX8_MainPages.ViewModels
                 if (_rtDataValueDic != null)
                 {
                     CurrentCycle = CommonFunction.GetValue<int>(_rtDataValueDic, $"EFEM.CurrentRobotCycleTime");
+                    CurrentStep = CommonFunction.GetValue<string>(_rtDataValueDic, $"EFEM.CurrentRobotCycleStep");
                 }
 
             }

+ 4 - 3
PunkHPX8_MainPages/Views/RobotCycleView.xaml

@@ -105,9 +105,10 @@
                     <TextBox Grid.Column="1" Grid.Row="1" Margin="5,5,5,5" HorizontalAlignment="Center" Width="50" HorizontalContentAlignment="Center"
                          Text="{Binding InPutCycleTimes,Mode=TwoWay}"/>
 
-                    <TextBlock Grid.Column="0" Grid.Row="2" Text="Current cycle:" Margin="5,5,5,5"/>
-                    <TextBlock Grid.Column="1" Grid.Row="2" Margin="5,5,5,5" HorizontalAlignment="Center"
-                           Text="{Binding CurrentCycle}"/>
+                    <TextBlock Grid.Column="0" Grid.Row="2" Text="Achieved cycle:" Margin="5,5,5,5"/>
+                    <TextBlock Grid.Row="2" Grid.Column="1" Width="50" Margin="10,0,10,0" Text="{Binding CurrentCycle}" TextAlignment="Center" VerticalAlignment="Center"  Background="Black" Foreground="Lime" FontSize="16" FontWeight="Bold"/>
+                    <TextBlock Grid.Column="2" Grid.Row="2" Text="Current Step:" Margin="5,5,5,5"/>
+                    <TextBlock Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" Margin="10,0,10,0" Text="{Binding CurrentStep}" TextAlignment="Center" VerticalAlignment="Center"  Background="Black" Foreground="Lime" FontSize="16" FontWeight="Bold"/>
                 </Grid>
             </GroupBox>
 

+ 5 - 1
PunkHPX8_RT/Modules/EFEM/CycleRobotCycleNewRoutine.cs

@@ -42,6 +42,10 @@ namespace PunkHPX8_RT.Modules.EFEM
         /// 当前处于第几次Cycle
         /// </summary>
         private int _currentCycle;
+        /// <summary>
+        /// 当前执行到哪一步
+        /// </summary>
+        private string _currentStep;
         private RobotCycleMoveRoutine _cycleMoveRoutine;
         private List<RobotCycleParameter> _sequences;
         private List<EfemCycleAction> _actions;
@@ -151,7 +155,7 @@ namespace PunkHPX8_RT.Modules.EFEM
                 .LoopRunWithStopStatus(CycleRobotCycleStep.LoopRunRobotCycleWait, () => { return CommonFunction.CheckRoutineEndState(_cycleMoveRoutine); },
                  () => CheckRoutineStopStatus(_cycleMoveRoutine, "CycleRobotCycleRoutine failed"),false, 86400000)//24小时
                 .LoopEnd(CycleRobotCycleStep.LoopEnd, UpdateCycleCount, _delay_1ms)
-                .End(CycleRobotCycleStep.End, AchievedCycleCount, _delay_1ms);
+                .End(CycleRobotCycleStep.End, NullFun, _delay_1ms);
             return Runner.Status;
         }
 

+ 17 - 1
PunkHPX8_RT/Modules/EFEM/EfemEntity.cs

@@ -28,6 +28,7 @@ using MECF.Framework.Common.CommonData;
 using Aitex.Core.RT.Routine;
 using MECF.Framework.Common.IOCore;
 using MECF.Framework.Common.Beckhoff.ModuleIO;
+using System.Windows.Navigation;
 
 namespace PunkHPX8_RT.Modules
 {
@@ -240,6 +241,7 @@ namespace PunkHPX8_RT.Modules
         private STATE _errorPreState;
         private IRoutine _currentRoutine;
         private int _currentCycleTimes;
+        private string _currentCycleStep;
         /// <summary>
         /// 变量是否初始化字典
         /// </summary>
@@ -272,6 +274,14 @@ namespace PunkHPX8_RT.Modules
             _efemSafeOpenRoutine = new EfemSafeOpenRoutine(_efem);
             _efemSafeCloseRoutine = new EfemSafeCloseRoutine(_efem);
         }
+        /// <summary>
+        /// 获取当前robot cycle处于哪一步
+        /// </summary>
+        /// <returns></returns>
+        public void GetCurrentRobotCycleStep(string step)
+        {
+            _currentCycleStep = step;  
+        }
         public LoadPortModule GetLoadportModule(int lpNumber)
         {
             if (lpNumber < 0|| _lpms.Length<=lpNumber)
@@ -370,6 +380,7 @@ namespace PunkHPX8_RT.Modules
             DATA.Subscribe($"{Name}.IsHomed", () => _isHomed,  SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Name}.RobotSpeed",()=>IsIdle?SC.GetValue<int>("EFEM.DefaultMoveSpeedInPercent"):0);
             DATA.Subscribe($"{Name}.CurrentRobotCycleTime",()=>_currentCycleTimes, SubscriptionAttribute.FLAG.IgnoreSaveDB);
+            DATA.Subscribe($"{Name}.CurrentRobotCycleStep",()=>_currentCycleStep, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Name}.VacuumValue",()=>_vacuumValue, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Name}.DoorUnlock", () => _doorUnlock, SubscriptionAttribute.FLAG.IgnoreSaveDB);
             DATA.Subscribe($"{Name}.DoorLocked", () => _doorLocked, SubscriptionAttribute.FLAG.IgnoreSaveDB);
@@ -894,7 +905,12 @@ namespace PunkHPX8_RT.Modules
                 return false;
             }
             _currentCycleTimes = _cycleRobotCycleRoutine.GetCurrentCycle();
-            return ret == RState.End;
+            bool result = ret == RState.End;
+            if (result)
+            {
+                _currentCycleStep = "";
+            }
+            return result;
         }
 
         private bool FnErrorPickTimeout(object[] param)

+ 25 - 4
PunkHPX8_RT/Modules/EFEM/RobotCycleMoveRoutine.cs

@@ -1,11 +1,12 @@
 using Aitex.Core.RT.Routine;
 using Aitex.Core.RT.SCCore;
-using PunkHPX8_Core;
-using PunkHPX8_RT.Devices.EFEM;
+using Aitex.Core.Util;
 using MECF.Framework.Common.Equipment;
 using MECF.Framework.Common.Routine;
 using MECF.Framework.Common.Schedulers;
 using MECF.Framework.Common.Utilities;
+using PunkHPX8_Core;
+using PunkHPX8_RT.Devices.EFEM;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -65,7 +66,11 @@ namespace PunkHPX8_RT.Modules.EFEM
         private bool RunAction()
         {
             EfemCycleAction action = _moveActionQueue[Runner.LoopCounter];
-            switch(action.Action)
+            if(Runner.LoopCounter + 1 <= _moveActionQueue.Count - 1)
+            {
+                UpdateCurrentStep(action, _moveActionQueue[Runner.LoopCounter + 1]);
+            }
+            switch (action.Action)
             {
                 case "Pick":
                     Queue<MoveItem> moveItems = new Queue<MoveItem>();
@@ -85,11 +90,27 @@ namespace PunkHPX8_RT.Modules.EFEM
                     alignerParamater[2] = action.Parameter;
                     alignerParamater[3] = SC.GetValue<int>("EFEM.Aligner1.AlignerPlatType");
                     return _efemAlignRoutine.Start(alignerParamater) ==RState.Running;
-
             }
             return false;
         }
         /// <summary>
+        /// 更新当前执行到哪一步
+        /// </summary>
+        private void UpdateCurrentStep(EfemCycleAction action, EfemCycleAction nextAction)
+        {
+            EfemEntity efemEntity = Singleton<RouteManager>.Instance.GetModule<EfemEntity>("EFEM");
+            string step = "";
+            switch (action.Action)
+            {
+                case "Pick":
+                    MoveItem moveItem1 = (MoveItem)action.Parameter;
+                    MoveItem moveItem2 = (MoveItem)nextAction.Parameter;
+                    step = $"{moveItem1.SourceModule} -> {moveItem2.DestinationModule}";
+                    efemEntity.GetCurrentRobotCycleStep(step);
+                    break;
+            } 
+        }
+        /// <summary>
         /// 启动
         /// </summary>
         /// <param name="objs"></param>