Beispiel #1
0
        public Unit(UnitSettings settings, IPollManager manager, IJournal journal, UnitGeneralCompleteHandler completion)
        {
            string filePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + settings.FilePath;
            Assembly assembly = Assembly.LoadFile(filePath);

            foreach (Type t in assembly.GetTypes())
            {
                if (t.GetInterfaces().Contains(typeof(IUnit)))
                {
                    Instance = (IUnit)Activator.CreateInstance(t);
                    break;
                }
            }

            this.FullName = settings.FullName;
            this.ShortName = settings.ShortName;
            this.SymbolicName = settings.SymbolicName;
            this.Address = settings.Address;

            Instance.Initialize(MainThread.Dispatcher, settings, manager, journal, completion);

            Instance.UnitParamUpdateEvent += delegate(object sender, Param param)
            {
                if (UnitParamUpdateEvent != null)
                {
                    UnitParamUpdateEvent(this, param);
                }
            };

            Instance.UnitAlarmUpdateEvent += delegate(object sender, IAlarm alarm)
            {
                if (UnitAlarmUpdateEvent != null)
                {
                    UnitAlarmUpdateEvent(this, alarm);
                }
            };

            Instance.UnitStateChangedEvent += delegate(object sender, ParamState state)
            {
                if (UnitStateChangedEvent != null)
                {
                    UnitStateChangedEvent(this, state);
                }
            };
        }
Beispiel #2
0
        public void Initialize(Dispatcher dispatcher, UnitSettings settings, IPollManager manager, IJournal journal, UnitGeneralCompleteHandler complete)
        {
            MainThread.Initialize(dispatcher);

            Settings = settings;
            Journal = journal;
            Manager = manager;

            ThreadPool.QueueUserWorkItem(delegate(object target)
            {
                Processing = new Processing(this);
                Processing.ProcessingAlarmUpdateEvent += AlarmUpdateEvent;
                Processing.ProcessingParamUpdateEvent += ParamUpdateEvent;

                ManualResetEvent ContinueEvent = new ManualResetEvent(false);
                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category0, "Схема подстанции", "Общий контроль состояния", new Prism.Units.Controls.SchematicControl(this, "схема подстанции")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category3, "ЛА №1", "Контроль и управление", new Prism.Units.Controls.LswControl(this, 1, "линейный автомат №1")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category3, "ЛА №2", "Контроль и управление", new Prism.Units.Controls.LswControl(this, 2, "линейный автомат №2")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category3, "ЛА №3", "Контроль и управление", new Prism.Units.Controls.LswControl(this, 3, "линейный автомат №3")));
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category3, "ЛА №4", "Контроль и управление", new Prism.Units.Controls.LswControl(this, 4, "линейный автомат №4")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category3, "ЛА №5", "Контроль и управление", new Prism.Units.Controls.LswControl(this, 5, "линейный автомат №5")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category3, "АЗ", "Контроль и управление", new Prism.Units.Controls.Lsw9Control(this, "запасной автомат")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category2, "ВА №1", "Контроль и управление", new Prism.Units.Controls.RectControl(this, 1, "выпрямительный агрегат №1")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category2, "ВА №2", "Контроль и управление", new Prism.Units.Controls.RectControl(this, 2, "выпрямительный агрегат №2")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category2, "ВА №3", "Контроль и управление", new Prism.Units.Controls.RectControl(this, 3, "выпрямительный агрегат №3")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category1, "Рабочий ввод", "Контроль и управление", new Prism.Units.Controls.LeadinControl(this, 1, "рабочий ввод")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category1, "Резервный ввод", "Контроль и управление", new Prism.Units.Controls.LeadinControl(this, 2, "резервный ввод")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    PresentationControlsInternal.Add(new PresentationControl(PresentationControlCategory.Category1, "Отходящая линия", "Контроль и управление", new Prism.Units.Controls.LeadinControl(this, 3, "отходящая линия")));
                });

                MainThread.EnqueueTask(delegate()
                {
                    ContinueEvent.Set();
                });

                ContinueEvent.WaitOne();
                complete();
            }, null);
        }