Ver código fonte

solve the sync problem while set signal tower light.

sangwq 11 meses atrás
pai
commit
7862a9be38

+ 2 - 1
Venus/Venus_RT/Devices/EFEM/JetEfem.cs

@@ -1003,7 +1003,8 @@ namespace Venus_RT.Devices.EFEM
 
         async void SendBack(string data)
         {
-            await Task.Run(() => _socket.Write(data + '\r'));
+            //await Task.Run(() => _socket.Write(data + '\r'));
+            _socket.Write(data + '\r');
         }
     }
 }

+ 2 - 2
Venus/Venus_RT/Devices/KeplerSignalTower.cs

@@ -94,8 +94,8 @@ namespace Venus_RT.Devices
 
                     break;
             }
-            EfemController?.SetLamp(venusType, venusSetpoint);
-            //_SignalTower?.SetLight(venusType, lightState);
+
+            Singleton<RouteManager>.Instance.EFEM.InvokeSignalTower(venusType, venusSetpoint);
             return true;
         }
 

+ 40 - 3
Venus/Venus_RT/Modules/EFEM/EfemEntity.cs

@@ -85,7 +85,8 @@ namespace Venus_RT.Modules
             Ungrip,
             Flip,
             LiftActionDone,
-            Offline
+            Offline,
+            Light,
         }
 
         public enum EfemType
@@ -141,6 +142,7 @@ namespace Venus_RT.Modules
         private readonly string Name;
         private readonly EfemBase _efem;
         private readonly LoadPortModule[] _lpms = new LoadPortModule[3];
+        private readonly EfemSignalTower _signalTower;
 
         private readonly EfemType _efemType;
         public EfemBase EfemDevice => _efem;
@@ -176,6 +178,7 @@ namespace Venus_RT.Modules
             _efemType = (EfemType)SC.GetValue<int>($"EFEM.EfemType");
 
             _efem = new JetEfem();
+            _signalTower = new EfemSignalTower(_efem);
 
             Name = ModuleName.EFEM.ToString();
 
@@ -272,6 +275,7 @@ namespace Venus_RT.Modules
             AnyStateTransition(MSG.Online,                  fnOnline,           FSM_STATE.SAME);
             AnyStateTransition(MSG.Abort,                   fnAbortRobot,       STATE.Idle);
             AnyStateTransition(MSG.ToInit,                  fnToInit,           STATE.Init);
+            AnyStateTransition(MSG.Light,                   fnSetLight,         FSM_STATE.SAME);
 
 
             AnyStateTransition(MSG.CommReady,          fnCommReady,               STATE.Init);
@@ -413,6 +417,7 @@ namespace Venus_RT.Modules
             }
 
             _efem.Monitor();
+            _signalTower.Monitor();
             return true;
         }
  
@@ -463,12 +468,12 @@ namespace Venus_RT.Modules
             return true;
         }
 
-        private bool fnSetLED(object[] param)
+        private bool fnSetLight(object[] param)
         {
             LightType light = (LightType)param[0];
             LightStatus st = (LightStatus)param[1];
 
-            _efem.SetLamp(light, st);
+            _signalTower.SetLight(light, st);
             return true;
         }
 
@@ -752,6 +757,14 @@ namespace Venus_RT.Modules
             return (int)FSM_MSG.NONE;
         }
 
+        public int InvokeSignalTower(LightType type, LightStatus status)
+        {
+            if(CheckToPostMessage((int)MSG.Light, type, status))
+                return (int)MSG.Light;
+
+            return (int)FSM_MSG.NONE;
+        }
+
         public bool IsPrepareTransferReady(ModuleName module, EnumTransferType type, int slot)
         {
             //if (type == EnumTransferType.Pick)
@@ -987,4 +1000,28 @@ namespace Venus_RT.Modules
             throw new NotImplementedException();
         }
     }
+
+    public class EfemSignalTower
+    {
+        private EfemBase _efem;
+        private Queue<KeyValuePair<LightType, LightStatus>> _pendingCmds = new Queue<KeyValuePair<LightType, LightStatus>>();
+        public EfemSignalTower(EfemBase efem)
+        {
+            _efem = efem;
+        }
+
+        public void Monitor()
+        {
+            if(Singleton<RouteManager>.Instance.EFEM.RobotStatus == RState.End && _pendingCmds.Count > 0)
+            {
+                var lightCommand = _pendingCmds.Dequeue();
+                _efem.SetLamp(lightCommand.Key, lightCommand.Value);
+            }
+        }
+
+        public void SetLight(LightType type, LightStatus status)
+        {
+            _pendingCmds.Enqueue(new KeyValuePair<LightType, LightStatus>(type, status));
+        }
+    }
 }