Ejemplo n.º 1
0
        private bool InitailXML()
        {
            string xmlTarget = "";

            try
            {
                XmlHandler xmlHandler = new XmlHandler();

                xmlTarget = "MainFlow.xml";

                mainFlowConfig = xmlHandler.ReadXml <MainFlowConfig>(Path.Combine(localData.ConfigPath, "MainFlow.xml"));

                localData.MainFlowConfig = mainFlowConfig;
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat("讀取 ", xmlTarget, " 成功"))
                {
                    Scuess = true
                });
                localData.SimulateMode = mainFlowConfig.SimulateMode;

                xmlTarget           = "MapConfig.xml";
                localData.MapConfig = xmlHandler.ReadXml <MapConfig>(Path.Combine(Environment.CurrentDirectory, "MapConfig.xml"));

                xmlTarget = mainFlowConfig.BatteryLogPath;

                try
                {
                    localData.BatteryLogData = xmlHandler.ReadXml <BatteryLog>(Path.Combine(localData.ConfigPath, mainFlowConfig.BatteryLogPath));
                    OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat("讀取 ", xmlTarget, " 成功"))
                    {
                        Scuess = true
                    });
                }
                catch
                {
                    OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat("讀取 ", xmlTarget, " 失敗")));
                    xmlTarget = mainFlowConfig.BatteryBackupLogPath;

                    try
                    {
                        localData.BatteryLogData = xmlHandler.ReadXml <BatteryLog>(Path.Combine(localData.ConfigPath, mainFlowConfig.BatteryBackupLogPath));
                        OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat("讀取 ", xmlTarget, " 成功"))
                        {
                            Scuess = true
                        });
                    }
                    catch
                    {
                        OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat("讀取 ", xmlTarget, " 失敗")));
                        localData.BatteryLogData = new BatteryLog();
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat("讀取 ", xmlTarget, " 失敗"), true));
                return(false);
            }
        }
Ejemplo n.º 2
0
        private bool ControllersInitial()
        {
            string xmlTarget = "";

            try
            {
                UserLoginout = new UserAgent();

                xmlTarget  = "MapHandler";
                MapControl = new MapHandler(normalLogName);
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat(xmlTarget, " 初始化成功"))
                {
                    Scuess = true
                });

                xmlTarget    = "AlarmHandler";
                AlarmHandler = new AlarmHandler();
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat(xmlTarget, " 初始化成功"))
                {
                    Scuess = true
                });

                xmlTarget   = "MIPCControlHandler";
                MipcControl = new MIPCControlHandler(this, AlarmHandler);
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat(xmlTarget, " 初始化成功"))
                {
                    Scuess = true
                });

                xmlTarget   = "MoveControlHandler";
                MoveControl = new MoveControlHandler(MipcControl, AlarmHandler);
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat(xmlTarget, " 初始化成功"))
                {
                    Scuess = true
                });

                xmlTarget         = "LoadUnloadControlHandler";
                LoadUnloadControl = new LoadUnloadControlHandler(MipcControl, AlarmHandler);
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat(xmlTarget, " 初始化成功"))
                {
                    Scuess = true
                });

                return(true);
            }
            catch
            {
                OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs(String.Concat(xmlTarget, " 初始化失敗"), true));
                return(false);
            }
        }
Ejemplo n.º 3
0
        public void InitialMainFlowHander()
        {
            if (!InitailXML())
            {
                return;
            }
            else if (!ControllersInitial())
            {
                return;
            }

            InitialEvent();

            OnComponentIntialDoneEvent?.Invoke(this, new InitialEventArgs("MainFlow初始化成功")
            {
                IsEnd = false, Scuess = true
            });
        }