using System; using System.Collections.Generic; using System.IO; using Aitex.Common.Util; using Aitex.Core.Account; using Aitex.Core.RT.ConfigCenter; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.DataCollection; using Aitex.Core.RT.DBCore; using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.Log; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.RecipeCenter; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Aitex.Core.WCF; using EFEM.RT.Backends; using EFEM.RT.Devices; using EFEM.RT.Modules; using EfemRT.Backends; using MECF.Framework.Common.SCCore; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.Core.Applications; using MECF.Framework.RT.Core.Backend; using MECF.Framework.RT.Core.IoProviders; namespace EFEM.RT.Systems { class ToolLoader : IRtLoader { public void Initialize() { InitCommonModules(); InitBackend(); InitSystemModules(); } private void InitSystemModules() { Singleton.Instance.Initialize(); Singleton.Instance.SetEfemData(); Singleton.Instance.Initialize(); } private void InitCommonModules() { Singleton.Instance.Initialize(); Singleton.Instance.Initialize(); Singleton.Instance.Initialize( System.Configuration.ConfigurationManager.ConnectionStrings["PostgreSQL"].ConnectionString , RtInstance.DatabaseName , PathManager.GetCfgDir() + "DBModel.sql"); Singleton.Instance.Initialize(PathManager.GetCfgDir() + "EventDefine.xml"); Singleton.Instance.Initialize(); Singleton.Instance.Initialize(); Singleton.Instance.Initialize(new Type[] { typeof(AccountService) }); Singleton.Instance.Initialize(PathManager.GetCfgDir() + "Efem.sccfg"); DeviceDefineManager.Instance.Initialize(PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "DeviceDefine.xml"); string ioProviderPathFile = PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "IoProviderConfig.xml"; Dictionary> ioMap; switch (DeviceDefineManager.Instance.GetValue("IoCardQuantity")) { case 1: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard1.xml" } }}, {"System.Super", new Dictionary(){{256, PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "\\_diDefineSuper.xml" }, {512, PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "\\_doDefineSuper.xml" }, { 1001, PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "\\_aiDefineSuper.xml" }, { 2001, PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "\\_aoDefineSuper.xml" } } }, }; break; case 2: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard1.xml" } }}, {"System.dio001", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard2.xml" } }} }; break; case 3: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard1.xml" } }}, {"System.dio001", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard2.xml" } }}, {"System.dio002", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard3.xml" } }} }; break; case 4: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard1.xml" } }}, {"System.dio001", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard2.xml" } }}, {"System.dio002", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard3.xml" } }}, {"System.dio003", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard4.xml" } }} }; break; case 5: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard1.xml" } }}, {"System.dio001", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard2.xml" } }}, {"System.dio002", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard3.xml" } }}, {"System.dio003", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard4.xml" } }}, {"System.dio004", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard5.xml" } }} }; break; case 6: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard1.xml" } }}, {"System.dio001", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard2.xml" } }}, {"System.dio002", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard3.xml" } }}, {"System.dio003", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard4.xml" } }}, {"System.dio004", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard5.xml" } }}, {"System.dio005", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard6.xml" } }}, }; break; case 7: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard1.xml" } }}, {"System.dio001", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard2.xml" } }}, {"System.dio002", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard3.xml" } }}, {"System.dio003", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard4.xml" } }}, {"System.dio004", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard5.xml" } }}, {"System.dio005", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard6.xml" } }}, {"System.dio006", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineCard7.xml" } }}, }; break; default: ioMap = new Dictionary>() { {"System.dio000", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefine.xml" }}} }; break; } if (DeviceDefineManager.Instance.GetValue("MotionAxisInstalled") ?? false) { ioMap.Add("System.MotionAxis", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineMotionAxis.xml" }}); } if (DeviceDefineManager.Instance.GetValue("PLCIoInstalled") ?? false) { ioMap.Add("System.MainPlc", new Dictionary(){{0, PathManager.GetCfgDir()+ $"{SC.GetStringValue("System.DeviceType")}\\" + "_ioDefineMainPlc.xml" }}); } IoProviderManager.Instance.Initialize(ioProviderPathFile, ioMap); WaferManager.Instance.Initialize(); Singleton.Instance.Initialize(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, $"Config\\{SC.GetStringValue("System.DeviceType")}\\", RtInstance.DeviceModelFileName), "EFEM"); //Singleton.Instance.Initialize(); DataCollectionManager.Instance.Initialize("efemdb"); Singleton.Instance.FireEvent += InstanceOnOnEvent; CarrierConfigurationManager.Instance.Initialize(); Singleton.Instance.Initialize(); } private void InstanceOnOnEvent(EventItem obj) { } private void InitBackend() { RtSystemManager.Instance.AddCustomBackend("Connection", new ConnectionView()); RtSystemManager.Instance.AddCustomBackend("IO", new IOView()); RtSystemManager.Instance.AddCustomBackend("SC", new BackendSCConfigView()); } public void Terminate() { Singleton.Instance.Terminate(); Singleton.Instance.Terminate(); Singleton.Instance.Terminate(); Singleton.Instance.Terminate(); IoProviderManager.Instance.Terminate(); Singleton.Instance.Terminate(); DataCollectionManager.Instance.Terminate(); Singleton.Instance.Terminate(); Singleton.Instance.Terminate(); Singleton.Instance.Terminate(); Singleton.Instance.Terminate(); } } }