Browse Source

add read delay in IoCylinder && add unknown error codes with VPA driver && add VceEntity

zhouhr 1 year ago
parent
commit
a980a39acf

+ 1 - 1
Venus/Venus_MainPages/RTData.cs

@@ -14,7 +14,7 @@ namespace Venus_MainPages
         static List<string> m_RtDataKeys=new List<string> ();
         public static Dictionary<string, object> RtDataValues=new Dictionary<string, object> ();
         static string ModuleName = "PMA";
-         static RTData()
+        static RTData()
         {
            
         }

+ 1 - 1
Venus/Venus_RT/Devices/IODevices/IoCylinder.cs

@@ -228,7 +228,7 @@ namespace Venus_RT.Devices
             else if (Name == "SlitDoor")
                 _timer.Start(5 * 1000);
             else
-                _timer.Start(2000);
+                _timer.Start(5000);
 
             return true;
         }

+ 5 - 1
Venus/Venus_RT/Devices/PreAligner/HongHuVPA.cs

@@ -99,7 +99,7 @@ namespace Venus_RT.Devices.PreAligner
         //定时器处理新信息为状态
         private bool OnTimer()
         {
-            //锁
+            //线程
             lock (_locker)
             {
                 //采用ascii码模式处理
@@ -148,6 +148,10 @@ namespace Venus_RT.Devices.PreAligner
                             {
                                 LOG.Write(eEvent.ERR_DEVICE_INFO, Module, _ErrorCode2Msg[errorcode]);
                             }
+                            else
+                            {
+                                LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"未知错误码{errorcode}");
+                            }
                         }
                         else
                         {

+ 192 - 0
Venus/Venus_RT/Modules/VCE/VceEntity.cs

@@ -0,0 +1,192 @@
+using Aitex.Core.RT.Fsm;
+using Aitex.Core.Utilities;
+using MECF.Framework.Common.Equipment;
+using MECF.Framework.RT.ModuleLibrary.VceModules;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Venus_RT.Devices.VCE;
+
+namespace Venus_RT.Modules.VCE
+{
+    #region 状态和消息
+    public enum VceSTATE
+    {
+        Init,//初始化
+        Idle,//空闲
+        Error,//错误
+        Homing,//home操作 对应HM
+        DoorOpenning,//开门操作 对应DC
+        DoorClosing,//关门操作 对应DO
+        Loading,//取cassette操作 包括开门关门 对应LOAD,
+        UnLoading,
+        Mapping,//扫片 对应MP 包括三种格式 hex binary 智能(只有智能模式可以判断复杂情况)
+        Goting,//指定槽到达窗口 对应 GC
+        Resetting,//重置
+        Unknown
+    }
+
+    public enum VceMSG
+    {
+        Home,
+        Error,
+        DoorOpen,
+        DoorClose,
+        Map,
+        Load,
+        UnLoad,
+        Reset,
+        Goto,
+        Abort
+    }
+    #endregion
+
+    public class VceEntity : Entity, IEntity
+    {
+        private ModuleName _modulename;
+        private readonly VceModuleBase _vce;
+
+        public VceEntity(ModuleName moduleName)
+        {
+            _modulename = moduleName;
+            _vce = new HongHuVce(25, moduleName);
+            InitFsmMap();
+        }
+
+        /// <summary>
+        /// 定义状态机的迁移表
+        /// </summary>
+        private void InitFsmMap()
+        {
+            fsm = new StateMachine<VceEntity>(_modulename.ToString(), (int)VceSTATE.Unknown, 50);
+            fsm.EnableRepeatedMsg(true);
+
+            AnyStateTransition(VceMSG.Error, fnError, VceSTATE.Error);
+            AnyStateTransition(VceMSG.Abort, fnAbort, VceSTATE.Idle);
+            //HOME init->homing idle->homing
+            Transition(VceSTATE.Init, VceMSG.Home, fnStartHome, VceSTATE.Homing);
+            Transition(VceSTATE.Idle, VceMSG.Home, fnStartHome, VceSTATE.Homing);
+            Transition(VceSTATE.Error, VceMSG.Home, fnStartHome, VceSTATE.Homing);
+            Transition(VceSTATE.Homing, FSM_MSG.TIMER, fnHomeTimeout, VceSTATE.Idle);
+
+            //Open Door 开门
+            Transition(VceSTATE.Idle, VceMSG.DoorOpen, fnStartOpenDoor, VceSTATE.DoorOpenning);
+            Transition(VceSTATE.DoorOpenning, FSM_MSG.TIMER, fnOpenDoorTimeout, VceSTATE.Idle);
+            //Close Door 关门
+            Transition(VceSTATE.Idle, VceMSG.DoorClose, fnStartCloseDoor, VceSTATE.DoorClosing);
+            Transition(VceSTATE.DoorClosing, FSM_MSG.TIMER, fnCloseDoorTimeout, VceSTATE.Idle);
+
+            //Map 扫片
+            Transition(VceSTATE.Idle, VceMSG.Map, fnStartMapping, VceSTATE.Mapping);
+            Transition(VceSTATE.Mapping, FSM_MSG.TIMER, fnMappingTimeout, VceSTATE.Idle);
+
+            //Load 取cassette
+            Transition(VceSTATE.Idle, VceMSG.Load, fnStartLoading, VceSTATE.Loading);
+            Transition(VceSTATE.Loading, FSM_MSG.TIMER, fnLoadingTimeout, VceSTATE.Idle);
+
+            //UnLoad 放cassette
+            Transition(VceSTATE.Idle, VceMSG.UnLoad, fnStartUnLoading, VceSTATE.UnLoading);
+            Transition(VceSTATE.UnLoading, FSM_MSG.TIMER, fnUnLoadingTimeout, VceSTATE.Idle);
+
+            //Goto 指定槽对准窗口
+            Transition(VceSTATE.Idle, VceMSG.Goto, fnStartGoto, VceSTATE.Goting);
+            Transition(VceSTATE.Goting, FSM_MSG.TIMER, fnGotingTimeout, VceSTATE.Idle);
+
+            //
+
+            EnumLoop<VceSTATE>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
+
+            EnumLoop<VceMSG>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
+
+            Running = true;
+        }
+
+        //急停
+        private bool fnAbort(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+        //升降到槽位
+        private bool fnStartGoto(object[] param)
+        {
+            return _vce.Goto(Convert.ToInt32(param[0]));
+        }
+
+        private bool fnGotingTimeout(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        private bool fnError(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        private bool fnStartHome(object[] param)
+        {
+            return _vce.HomeALL();
+        }
+
+        private bool fnHomeTimeout(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        private bool fnStartOpenDoor(object[] param)
+        {
+            return _vce.OpenDoor();
+        }
+
+        private bool fnOpenDoorTimeout(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        private bool fnStartCloseDoor(object[] param)
+        {
+            return _vce.CloseDoor();
+        }
+
+        private bool fnCloseDoorTimeout(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        private bool fnStartMapping(object[] param)
+        {
+            return _vce.Map();
+        }
+
+        private bool fnMappingTimeout(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        private bool fnStartLoading(object[] param)
+        {
+            return _vce.Load();
+        }
+
+        private bool fnLoadingTimeout(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        private bool fnStartUnLoading(object[] param)
+        {
+            return _vce.UnLoad();
+        }
+
+        private bool fnUnLoadingTimeout(object[] param)
+        {
+            throw new NotImplementedException();
+        }
+
+        public bool Check(int msg, out string reason, params object[] args)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 2 - 0
Venus/Venus_RT/Venus_RT.csproj

@@ -162,6 +162,7 @@
     <Compile Include="Devices\TM\JetTM.cs" />
     <Compile Include="Devices\TM\SIASUNRobot.cs" />
     <Compile Include="Devices\VCE\HongHuVce.cs" />
+    <Compile Include="Devices\VCE\HongHuVR.cs" />
     <Compile Include="Devices\VirgoSignalTower.cs" />
     <Compile Include="FAs\FaEvent.cs" />
     <Compile Include="FAs\FaEventItem.cs" />
@@ -254,6 +255,7 @@
     <Compile Include="Modules\TM\MFSwapRoutine.cs" />
     <Compile Include="Modules\TM\MFVentRoutine.cs" />
     <Compile Include="Modules\TM\TMEntity.cs" />
+    <Compile Include="Modules\VCE\VceEntity.cs" />
     <Compile Include="Properties\AssemblyInfo.cs">
       <SubType>Code</SubType>
     </Compile>