Ejemplo n.º 1
0
        private void syncSubScope(TemplateSynchronizer <TECSubScope> synchronizer,
                                  TECSubScope template, TECSubScope changed, TECChangedEventArgs args)
        {
            if (changed != template)
            {
                syncItem(changed, template);
            }
            foreach (TECSubScope item in synchronizer.GetFullDictionary()[template].Where(item => item != changed))
            {
                syncItem(changed, item);
            }

            void syncItem(TECSubScope changedItem, TECSubScope subject)
            {
                subject.CopyChildrenFromScope(changedItem);

                subject.Points.ObservablyClear();
                subject.Devices.ObservablyClear();
                subject.Interlocks.ObservablyClear();

                foreach (TECPoint point in changedItem.Points)
                {
                    subject.AddPoint(new TECPoint(point));
                }
                foreach (IEndDevice device in changedItem.Devices)
                {
                    subject.AddDevice(device);
                }
                foreach (TECInterlockConnection connection in changedItem.Interlocks)
                {
                    subject.Interlocks.Add(connection);
                }
            }
        }
Ejemplo n.º 2
0
 //Copy Constructor
 public TECSubScope(TECSubScope sourceSubScope, Dictionary <Guid, Guid> guidDictionary = null,
                    ObservableListDictionary <ITECObject> characteristicReference      = null) : this()
 {
     if (guidDictionary != null)
     {
         guidDictionary[_guid] = sourceSubScope.Guid;
     }
     foreach (IEndDevice device in sourceSubScope.Devices)
     {
         Devices.Add(device);
     }
     foreach (TECPoint point in sourceSubScope.Points)
     {
         var toAdd = new TECPoint(point);
         characteristicReference?.AddItem(point, toAdd);
         Points.Add(toAdd);
     }
     foreach (TECInterlockConnection interlock in sourceSubScope.Interlocks)
     {
         var toAdd = new TECInterlockConnection(interlock);
         characteristicReference?.AddItem(interlock, toAdd);
         Interlocks.Add(toAdd);
     }
     foreach (TECScopeBranch branch in sourceSubScope.ScopeBranches)
     {
         var toAdd = new TECScopeBranch(branch);
         characteristicReference?.AddItem(branch, toAdd);
         ScopeBranches.Add(toAdd);
     }
     this.copyPropertiesFromScope(sourceSubScope);
 }
Ejemplo n.º 3
0
        public void UpdateSubScopeReferenceProperties(TECSubScope subScope)
        {
            var templateSS = SubScopeSynchronizer.GetTemplate(subScope);

            if (templateSS != subScope)
            {
                setProperties(subScope, templateSS);
            }
            SubScopeSynchronizer.ActOnReferences(templateSS, updateSubScope);
            void updateSubScope(TemplateSynchronizer <TECSubScope> synchronizer, TECSubScope template)
            {
                foreach (TECSubScope item in synchronizer.GetFullDictionary()[template])
                {
                    setProperties(template, item);
                }
            }

            void setProperties(TECSubScope tSS, TECSubScope rSS)
            {
                rSS.CopyPropertiesFromScope(tSS);
                rSS.ScopeBranches.ObservablyClear();
                foreach (TECScopeBranch branch in tSS.ScopeBranches)
                {
                    rSS.ScopeBranches.Add(new TECScopeBranch(branch));
                }
            }
        }
Ejemplo n.º 4
0
        protected void handleSubScopeRemoval(TECSubScope removed)
        {
            TECController controller = removed.Connection?.ParentController;

            if (controller != null)
            {
                controller.Disconnect(removed);
            }
        }
Ejemplo n.º 5
0
 //Copy Constructor
 public TECEquipment(TECEquipment equipmentSource, Dictionary <Guid, Guid> guidDictionary = null,
                     ObservableListDictionary <ITECObject> characteristicReference        = null, TemplateSynchronizer <TECSubScope> ssSynchronizer = null) : this()
 {
     if (guidDictionary != null)
     {
         guidDictionary[_guid] = equipmentSource.Guid;
     }
     foreach (TECSubScope subScope in equipmentSource.SubScope)
     {
         var toAdd = new TECSubScope(subScope, guidDictionary, characteristicReference);
         if (ssSynchronizer != null && ssSynchronizer.Contains(subScope))
         {
             ssSynchronizer.LinkNew(ssSynchronizer.GetTemplate(subScope), toAdd);
         }
         characteristicReference?.AddItem(subScope, toAdd);
         SubScope.Add(toAdd);
     }
     copyPropertiesFromScope(equipmentSource);
 }
Ejemplo n.º 6
0
        public object DropData()
        {
            TECSubScope outScope = new TECSubScope(this);

            return(outScope);
        }
Ejemplo n.º 7
0
        private void syncEquipment(TemplateSynchronizer <TECEquipment> synchronizer, TECEquipment template, TECEquipment changed, TECChangedEventArgs args)
        {
            if (!(args.Sender is TECEquipment))
            {
                return;
            }
            TECEquipment        item       = args.Sender as TECEquipment;
            TECSubScope         value      = args.Value as TECSubScope;
            List <TECEquipment> references = synchronizer.GetFullDictionary()[template];

            if (value != null && args.Change == Change.Add)
            {
                TECSubScope newTemplate = value;
                if (item == template)
                {
                    SubScopeSynchronizer.NewGroup(newTemplate);
                }
                else
                {
                    TECSubScope parentTemplate = SubScopeSynchronizer.GetTemplate(newTemplate);
                    if (parentTemplate != null)
                    {
                        SubScopeSynchronizer.RemoveItem(newTemplate);
                        newTemplate = SubScopeSynchronizer.NewItem(parentTemplate);
                    }
                    else
                    {
                        newTemplate = new TECSubScope(value);
                    }
                    template.SubScope.Add(newTemplate);
                    SubScopeSynchronizer.NewGroup(newTemplate);
                    SubScopeSynchronizer.LinkExisting(newTemplate, value);
                }
                foreach (TECEquipment reference in references.Where(obj => obj != item))
                {
                    reference.SubScope.Add(SubScopeSynchronizer.NewItem(newTemplate));
                }
            }
            else if (value != null && args.Change == Change.Remove)
            {
                TECSubScope subScopeTemplate = value;
                if (item != template)
                {
                    subScopeTemplate = SubScopeSynchronizer.GetTemplate(value);
                }
                template.SubScope.Remove(subScopeTemplate);
                List <TECSubScope> subScopeReferences = SubScopeSynchronizer.GetFullDictionary()[subScopeTemplate];
                foreach (TECEquipment reference in references)
                {
                    List <TECSubScope> toRemove = new List <TECSubScope>();
                    foreach (TECSubScope referenceSubScope in reference.SubScope)
                    {
                        if (subScopeReferences.Contains(referenceSubScope))
                        {
                            toRemove.Add(referenceSubScope);
                        }
                    }
                    foreach (TECSubScope thing in toRemove)
                    {
                        reference.SubScope.Remove(thing);
                    }
                }
                SubScopeSynchronizer.RemoveGroup(subScopeTemplate);
                if (SubScopeSynchronizer.GetTemplate(subScopeTemplate) != null)
                {
                    SubScopeSynchronizer.RemoveItem(subScopeTemplate);
                }
            }
            else
            {
                if (item != template)
                {
                    template.CopyChildrenFromScope(item);
                }
                foreach (TECEquipment reference in references.Where(obj => obj != item))
                {
                    reference.CopyChildrenFromScope(item);
                }
            }
        }