public BaseObject(string baseTechObjectName)
 {
     localObjects   = new List <TechObject>();
     baseTechObject = BaseTechObjectManager.GetInstance()
                      .GetTechObject(baseTechObjectName);
     globalObjectsList = TechObjectManager.GetInstance().TechObjects;
 }
Beispiel #2
0
        public List <string> GetAttachedObjectsName()
        {
            var objectNames = new List <string>();

            if (Value == string.Empty)
            {
                return(objectNames);
            }

            string[] nums = Value.Split(' ');
            foreach (var num in nums)
            {
                bool converted = int.TryParse(num, out int objNum);
                if (converted)
                {
                    var obj = TechObjectManager.GetInstance()
                              .GetTObject(objNum);
                    string objName = obj.NameEplanForFile.ToLower() +
                                     obj.TechNumber;
                    objectNames.Add(objName);
                }
            }

            return(objectNames);
        }
Beispiel #3
0
        /// <summary>
        /// Удаление перекрестных ограничений
        /// </summary>
        protected void ClearCrossRestriction(SortedDictionary <int,
                                                               List <int> > diffDict)
        {
            // Для ограничений на последующие операции
            // не должны проставляться симметричные ограничения.
            if ((luaName != "NextModeRestriction") && (diffDict.Count != 0))
            {
                SortedDictionary <int, List <int> > .KeyCollection keyColl =
                    diffDict.Keys;

                foreach (int key in keyColl)
                {
                    TechObject to = TechObjectManager.GetInstance()
                                    .TechObjects[key - 1];
                    foreach (int val in diffDict[key])
                    {
                        Mode mode = to.GetMode(val - 1);
                        if (mode != null)
                        {
                            mode.DelRestriction(luaName, ownerObjNum,
                                                ownerModeNum);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Изменение словаря ограничений на основании строки ограничений
        /// </summary>
        protected void ChangeRestrictList()
        {
            var res             = new SortedDictionary <int, List <int> >();
            var techObjectsList = TechObjectManager.GetInstance()
                                  .TechObjects;

            for (int i = 0; i < techObjectsList.Count; i++)
            {
                TechObject to = techObjectsList[i];
                for (int j = 0; j < to.ModesManager.Modes.Count; j++)
                {
                    string restrictPair = $"{{ {i+1}, {j + 1} }}";
                    if (restrictStr.Contains(restrictPair))
                    {
                        if (res.ContainsKey(i + 1))
                        {
                            res[i + 1].Add(j + 1);
                        }
                        else
                        {
                            var restrictMode = new List <int>();
                            restrictMode.Add(j + 1);
                            res.Add(i + 1, restrictMode);
                        }
                    }
                }
            }
            restrictList = res;
            ChangeRestrictStr();
        }
        override public ITreeViewItem MoveDown(object child)
        {
            var mode = child as Mode;

            if (mode != null)
            {
                int index = modes.IndexOf(mode);
                if (index <= modes.Count - 2)
                {
                    int tobjNum = TechObjectManager.GetInstance()
                                  .GetTechObjectN(owner);
                    TechObjectManager.GetInstance()
                    .ChangeModeNum(tobjNum, index + 1, index + 2);

                    modes.Remove(mode);
                    modes.Insert(index + 1, mode);

                    foreach (Mode newMode in modes)
                    {
                        ChangeRestrictionModeOwner(newMode);
                    }

                    return(modes[index]);
                }
            }

            return(null);
        }
            /// <summary>
            /// Получить корректные номера технологических объектов из
            /// входной строки
            /// </summary>
            /// <param name="inputString">Входная строка</param>
            /// <returns></returns>
            private List <int> GetValidTechObjNums(string inputString)
            {
                var numbers = new List <int>();

                string[] numbersAsStringArray = inputString.Split(' ')
                                                .ToArray();

                foreach (var numAsString in numbersAsStringArray)
                {
                    int number;
                    int.TryParse(numAsString, out number);
                    if (number == 0)
                    {
                        continue;
                    }

                    TechObject obj = TechObjectManager.GetInstance()
                                     .GetTObject(number);
                    bool correctBaseObject = obj.BaseTechObject != null &&
                                             obj.BaseTechObject.IsAttachable;
                    if (obj != null && correctBaseObject)
                    {
                        numbers.Add(number);
                    }
                }

                numbers = numbers.Distinct().ToList();
                return(numbers);
            }
Beispiel #7
0
        /// <summary>
        /// Сохранить доп. информацию о танке
        /// </summary>
        /// <param name="obj">Сохраняемый базовый объект</param>
        /// <param name="objName">Уникальное имя объекта</param>
        /// <param name="prefix">Отступ</param>
        /// <returns></returns>
        private string SaveTankAdditionalParameters(BaseTechObject obj,
                                                    string objName, string prefix)
        {
            var res = string.Empty;

            if (obj.S88Level == (int)BaseTechObjectManager.ObjectType.Unit)
            {
                var masterObj = TechObjectManager.GetInstance()
                                .ProcessCellObject;
                if (masterObj != null)
                {
                    res += objName + ".master = prg." + masterObj.NameEplan
                           .ToLower() + masterObj.TechNumber + "\n";
                }

                // Параметры сбрасываемые до мойки.
                res += objName + ".reset_before_wash =\n" +
                       prefix + "{\n" +
                       prefix + objName + ".PAR_FLOAT.V_ACCEPTING_CURRENT,\n" +
                       prefix + objName + ".PAR_FLOAT.PRODUCT_TYPE,\n" +
                       prefix + objName + ".PAR_FLOAT.V_ACCEPTING_SET\n" +
                       prefix + "}\n";
            }

            return(res);
        }
Beispiel #8
0
        /// <summary>
        /// Сохранить информацию об объекте в prg.lua
        /// </summary>
        /// <param name="objName">Имя объекта</param>
        /// <param name="prefix">Отступ</param>
        /// <returns></returns>
        public string SaveObjectInfoToPrgLua(string objName, string prefix)
        {
            var res = "";

            if (EplanName.ToLower() != "tank")
            {
                return(res);
            }

            var masterObj = TechObjectManager.GetInstance().ProcessCellObject;

            if (masterObj != null)
            {
                res += objName + ".master = prg." + masterObj.NameEplan
                       .ToLower() + masterObj.TechNumber + "\n";
            }

            // Параметры сбрасываемые до мойки.
            res += objName + ".reset_before_wash =\n" +
                   prefix + "{\n" +
                   prefix + objName + ".PAR_FLOAT.V_ACCEPTING_CURRENT,\n" +
                   prefix + objName + ".PAR_FLOAT.PRODUCT_TYPE,\n" +
                   prefix + objName + ".PAR_FLOAT.V_ACCEPTING_SET\n" +
                   prefix + "}\n";

            return(res);
        }
Beispiel #9
0
        override public Editor.ITreeViewItem MoveDown(object child)
        {
            Mode mode = child as Mode;

            if (mode != null)
            {
                int index = modes.IndexOf(mode);
                if (index <= modes.Count - 2)
                {
                    int tobjNum = TechObjectManager.GetInstance()
                                  .GetTechObjectN(owner);
                    TechObjectManager.GetInstance()
                    .ChangeModeNum(tobjNum, index + 1, index + 2);

                    modes.Remove(mode);
                    modes.Insert(index + 1, mode);

                    foreach (Mode newMode in modes)
                    {
                        ChangeRestrictionModeOwner(newMode);
                    }

                    //TODO: корректировка параметров при перемещении операции

                    return(modes[index]);
                }
            }

            return(null);
        }
            /// <summary>
            /// Удалить привязку агрегатов из аппарата.
            /// </summary>
            /// <param name="aggregatesNumbers">Список агрегатов</param>
            private void RemoveDeletedAgregates(List <int> aggregatesNumbers)
            {
                if (aggregatesNumbers.Count == 0)
                {
                    return;
                }

                foreach (var number in aggregatesNumbers)
                {
                    TechObject removingAgregate = TechObjectManager
                                                  .GetInstance().GetTObject(number);
                    BaseTechObject removingBaseTechObject = removingAgregate
                                                            .BaseTechObject;
                    List <BaseParameter> properties = removingBaseTechObject
                                                      .AggregateParameters;

                    var deletingProperties = new List <BaseParameter>();
                    if (properties.Count != 0)
                    {
                        deletingProperties.AddRange(properties);
                    }

                    if (removingBaseTechObject.MainAggregateParameter != null)
                    {
                        deletingProperties.Add(removingBaseTechObject
                                               .MainAggregateParameter);
                    }
                    TechObject  thisTechObject = techObject;
                    List <Mode> modes          = thisTechObject.ModesManager.Modes;
                    foreach (var mode in modes)
                    {
                        mode.BaseOperation.RemoveProperties(deletingProperties);
                    }
                }
            }
Beispiel #11
0
        override public bool Delete(object child)
        {
            Mode mode = child as Mode;

            if (mode == null)
            {
                return(false);
            }

            int idx = modes.IndexOf(mode) + 1;

            int tobjNum = TechObjectManager.GetInstance()
                          .GetTechObjectN(owner);

            TechObjectManager.GetInstance()
            .ChangeModeNum(tobjNum, idx, -1);

            modes.Remove(mode);

            foreach (Mode newMode in modes)
            {
                ChangeRestrictionModeOwner(newMode);
            }

            //TODO: коррекция параметров при удалении

            return(true);
        }
Beispiel #12
0
        /// <summary>
        /// Сохранить информацию об объекте в prg.lua
        /// </summary>
        /// <param name="objName">Имя объекта</param>
        /// <param name="prefix">Отступ</param>
        /// <returns></returns>
        public string SaveObjectInfoToPrgLua(string objName, string prefix)
        {
            var res = "";

            if (EplanName.ToLower() != "tank")
            {
                return(res);
            }

            var objects   = TechObjectManager.GetInstance();
            var masterObj = objects.Objects
                            .Where(x => x.Name.Contains("Мастер")).FirstOrDefault();

            if (masterObj != null)
            {
                res += objName + ".master = prg." + masterObj.NameEplan
                       .ToLower() + masterObj.TechNumber + "\n";
            }

            // Параметры сбрасываемые до мойки.
            res += objName + ".reset_before_wash =\n" +
                   prefix + "{\n" +
                   prefix + objName + ".PAR_FLOAT.V_ACCEPTING_CURRENT,\n" +
                   prefix + objName + ".PAR_FLOAT.PRODUCT_TYPE,\n" +
                   prefix + objName + ".PAR_FLOAT.V_ACCEPTING_SET\n" +
                   prefix + "}\n";

            return(res);
        }
Beispiel #13
0
        /// <summary>
        /// Изменение словаря ограничений на основании строки ограничений
        /// </summary>
        protected void ChangeRestrictList()
        {
            var res = new SortedDictionary <int, List <int> >();

            for (int i = 0; i < TechObjectManager.GetInstance().Objects.Count;
                 i++)
            {
                TechObject to = TechObjectManager.GetInstance().Objects[i];
                for (int j = 0; j < to.ModesManager.Modes.Count; j++)
                {
                    string restrictPair = "{ " + (i + 1).ToString() + ", " +
                                          (j + 1).ToString() + " }";
                    if (restrictStr.Contains(restrictPair))
                    {
                        if (res.ContainsKey(i + 1))
                        {
                            res[i + 1].Add(j + 1);
                        }
                        else
                        {
                            List <int> restrictMode = new List <int>();
                            restrictMode.Add(j + 1);
                            res.Add(i + 1, restrictMode);
                        }
                    }
                }
            }
            restrictList = res;
        }
Beispiel #14
0
        private string GenerateAttachedObjectsString()
        {
            string value = Value ?? string.Empty;

            if (value == string.Empty)
            {
                return(value);
            }

            var objectNums  = value.Split(' ').Select(int.Parse);
            var objectNames = new List <string>();

            foreach (var objNum in objectNums)
            {
                TechObject findedObject = TechObjectManager.GetInstance()
                                          .GetTObject(objNum);
                if (findedObject != null)
                {
                    string name = $"\"{findedObject.Name} " +
                                  $"{findedObject.TechNumber}\"";
                    objectNames.Add(name);
                }
            }

            return(string.Join(", ", objectNames));
        }
Beispiel #15
0
 public ProcessCell()
 {
     objects        = new List <TechObject>();
     baseTechObject = BaseTechObjectManager.GetInstance()
                      .GetTechObject(Name);
     globalObjectsList = TechObjectManager.GetInstance().TechObjects;
 }
Beispiel #16
0
        public override bool SetNewValue(string newValue)
        {
            string oldValue   = Value;
            var    thisObjNum = TechObjectManager.GetInstance()
                                .GetTechObjectN(Owner);
            List <int> newNumbers = strategy.GetValidTechObjNums(newValue,
                                                                 thisObjNum);

            newValue = string.Join(" ", newNumbers);
            base.SetNewValue(newValue);

            if (strategy.UseInitialization)
            {
                var replacedObjects = new Dictionary <TechObject, TechObject>();

                List <TechObject> newObjects = newNumbers
                                               .Select(x => TechObjectManager.GetInstance().GetTObject(x))
                                               .ToList();
                List <TechObject> oldObjects = strategy
                                               .GetValidTechObjNums(oldValue, thisObjNum)
                                               .Select(x => TechObjectManager.GetInstance().GetTObject(x))
                                               .ToList();
                replacedObjects = FindReplacedObjects(oldObjects,
                                                      newObjects);
                ChangeOwnerInReplacedObjectsProperties(replacedObjects);

                List <int> deletedAgregatesNumbers = FindDeletedObjects(
                    oldValue, newValue, replacedObjects);
                RemoveDeletedObjects(deletedAgregatesNumbers);

                InitAttachedObjects(newNumbers);
            }

            return(true);
        }
 public void ChangeCrossRestriction(ModesManager oldModesMngr = null)
 {
     for (int i = 0; i < modes.Count; i++)
     {
         if ((oldModesMngr != null) &&
             (i < oldModesMngr.Modes.Count))
         {
             modes[i].ChangeCrossRestriction(oldModesMngr.Modes[i]);
         }
         else
         {
             modes[i].ChangeCrossRestriction();
         }
     }
     if (oldModesMngr != null)
     {
         if (oldModesMngr.Modes.Count > modes.Count)
         {
             for (int i = modes.Count; i < oldModesMngr.Modes.Count;
                  i++)
             {
                 int tobjNum = TechObjectManager.GetInstance()
                               .GetTechObjectN(owner);
                 TechObjectManager.GetInstance()
                 .ChangeModeNum(tobjNum, i + 1, -1);
             }
         }
     }
 }
        private void ChangeRestrictionModeOwner(Mode newMode)
        {
            int objParentNum = TechObjectManager.GetInstance()
                               .GetTechObjectN(owner);
            int modeParentNum = GetModeN(newMode);

            newMode.SetRestrictionOwner(objParentNum, modeParentNum);
        }
 public UserObject()
 {
     objects        = new List <TechObject>();
     baseTechObject = BaseTechObjectManager.GetInstance()
                      .GetTechObject(Name);
     techObjectManager = TechObjectManager.GetInstance();
     globalObjectsList = techObjectManager.TechObjects;
 }
Beispiel #20
0
        /// <summary>
        /// Изменить номер операции
        /// </summary>
        /// <param name="objNum">Номер объекта</param>
        /// <param name="prev">Старый номер операции</param>
        /// <param name="curr">Новый номер операции</param>
        public void ChangeModeNum(int objNum, int prev, int curr)
        {
            const int markAsDelete = -1;

            if (curr != markAsDelete)
            {
                // Замена нового на старый
                if (restrictStr.Contains($"{{ {objNum}, {curr} }}"))
                {
                    restrictStr = restrictStr
                                  .Replace($"{{ {objNum}, {curr} }}",
                                           $"{{ {objNum}, {prev} N}}");
                }

                //Замена старого на новый
                if (restrictStr.Contains($"{{ {objNum}, {prev} }}"))
                {
                    restrictStr = restrictStr
                                  .Replace($"{{ {objNum}, {prev} }}",
                                           $"{{ {objNum}, {curr} }}");
                }

                // Убираем букву-заглушку, которая закрывала уже измененный
                // текст от изменений
                if (restrictStr.Contains("N"))
                {
                    restrictStr = restrictStr.Replace("N", "");
                }
            }
            // Удаление объекта (индекс -1)
            else
            {
                if (restrictStr.Contains($"{{ {objNum}, {prev} }}"))
                {
                    restrictStr += " ";
                    restrictStr  = restrictStr
                                   .Replace($"{{ {objNum}, {prev} }} ", "");
                    restrictStr.Trim();
                    ChangeModeNum(objNum, prev, markAsDelete);
                }
                else
                {
                    var modesCount = TechObjectManager.GetInstance()
                                     .TechObjects[objNum - 1].ModesManager.Modes.Count;
                    for (int i = prev + 1; i <= modesCount; i++)
                    {
                        if (restrictStr.Contains($"{{ {objNum}, {i} }}"))
                        {
                            restrictStr = restrictStr
                                          .Replace($"{{ {objNum}, {i} }}",
                                                   $"{{ {objNum}, {i - 1} }}");
                        }
                    }
                }
            }
            ChangeRestrictList();
        }
Beispiel #21
0
        /// <summary>
        /// Изменить номер объекта.
        /// </summary>
        /// <param name="oldNum">Предыдущий номер объекта</param>
        /// <param name="newNum">Текущий номер объекта</param>
        public void ChangeObjNum(int oldNum, int newNum)
        {
            const int markForDelete = -1;

            if (newNum != markForDelete)
            {
                // Замена нового на старый
                if (restrictStr.Contains($"{{ {newNum},"))
                {
                    restrictStr = restrictStr
                                  .Replace($"{{ {newNum},", $"{{N {oldNum},");
                }

                //Замена старого на новый
                if (restrictStr.Contains($"{{ {oldNum},"))
                {
                    restrictStr = restrictStr
                                  .Replace($"{{ {oldNum},", $"{{ {newNum},");
                }

                // Убираем букву-заглушку, которая закрывала уже измененный
                // текст от изменений
                if (restrictStr.Contains("N"))
                {
                    restrictStr = restrictStr.Replace("N", "");
                }
            }
            else
            {
                // Удаление объекта (индекс -1)
                if (restrictStr.Contains($"{{ {oldNum},"))
                {
                    restrictStr += " ";
                    int idx     = restrictStr.IndexOf($"{{ {oldNum},");
                    int idx_end = restrictStr.IndexOf("}", idx);
                    // 2й символ для пробела
                    restrictStr = restrictStr.Remove(idx, idx_end - idx + 2);
                    restrictStr.Trim();
                    ChangeObjNum(oldNum, markForDelete);
                }
                else
                {
                    var techObjectsList = TechObjectManager.GetInstance()
                                          .TechObjects;
                    for (int i = oldNum + 1; i <= techObjectsList.Count; i++)
                    {
                        if (restrictStr.Contains($"{{ {i},"))
                        {
                            restrictStr = restrictStr
                                          .Replace($"{{ {i},", $"{{ {i - 1},");
                        }
                    }
                }
            }

            ChangeRestrictList();
        }
Beispiel #22
0
        override public ITreeViewItem Replace(object child, object copyObject)
        {
            var  selectedState = child as State;
            var  copiedState   = copyObject as State;
            bool statesNotNull = selectedState != null && copiedState != null;

            if (statesNotNull)
            {
                State newState = copiedState.Clone();
                if (newState.Name != selectedState.Name)
                {
                    newState.Name = selectedState.Name;
                }
                int index = stepsMngr.IndexOf(selectedState);
                stepsMngr.Remove(selectedState);
                stepsMngr.Insert(index, newState);
                SetItems();

                newState.AddParent(this);
                return(newState);
            }

            var  selectesRestrMan   = child as RestrictionManager;
            var  copiedRestrMan     = copyObject as RestrictionManager;
            bool restrictionNotNull =
                selectesRestrMan != null && copiedRestrMan != null;

            if (restrictionNotNull)
            {
                for (int i = 0; i < selectesRestrMan.Restrictions.Count; i++)
                {
                    selectesRestrMan.Replace(selectesRestrMan.Items[i],
                                             copiedRestrMan.Items[i]);
                }

                int objNum = TechObjectManager.GetInstance()
                             .GetTechObjectN(owner.Owner);
                int modeNum = getN(this);

                foreach (var restrict in selectesRestrMan.Restrictions)
                {
                    restrict.SetRestrictionOwner(objNum, modeNum);
                }

                selectesRestrMan.AddParent(this);
                return(selectesRestrMan);
            }

            return(null);
        }
Beispiel #23
0
        override public ITreeViewItem Replace(object child,
                                              object copyObject)
        {
            var  mode           = child as Mode;
            var  copyMode       = copyObject as Mode;
            bool objectsNotNull = mode != null && copyMode != null;

            if (objectsNotNull)
            {
                Mode newMode = copyMode.Clone(GetModeN, this, copyMode.Name);
                if (!mode.BaseObjectsList.Contains(copyMode.BaseOperation.Name))
                {
                    bool editBaseOperation = true;
                    newMode.SetNewValue(string.Empty, editBaseOperation);
                }

                int index = modes.IndexOf(mode);
                modes.Remove(mode);
                modes.Insert(index, newMode);

                string modeTechObjName      = Owner.NameEplan;
                int    modeTechObjNumber    = Owner.TechNumber;
                string copyObjTechObjName   = copyMode.Owner.Owner.NameEplan;
                int    copyObjTechObjNumber = copyMode.Owner.Owner.TechNumber;
                if (modeTechObjName == copyObjTechObjName)
                {
                    newMode.ModifyDevNames(owner.TechNumber, -1,
                                           owner.NameEplan);
                }
                else
                {
                    newMode.ModifyDevNames(modeTechObjName, modeTechObjNumber,
                                           copyObjTechObjName, copyObjTechObjNumber);
                }

                ChangeRestrictionModeOwner(newMode);
                int newN = TechObjectManager.GetInstance()
                           .GetTechObjectN(Owner);
                int oldN = TechObjectManager.GetInstance()
                           .GetTechObjectN(copyMode.Owner.Owner);
                newMode.ModifyRestrictObj(oldN, newN);

                newMode.ChangeCrossRestriction(mode);

                newMode.AddParent(this);
                return(newMode);
            }

            return(null);
        }
Beispiel #24
0
        override public Editor.ITreeViewItem Replace(object child,
                                                     object copyObject)
        {
            if (child is State && copyObject is State)
            {
                var selectedState = child as State;
                var copyingObject = copyObject as State;

                if (selectedState != null)
                {
                    State newState = copyingObject.Clone();
                    if (newState.Name != selectedState.Name)
                    {
                        newState.Name = selectedState.Name;
                    }
                    int index = stepsMngr.IndexOf(selectedState);
                    stepsMngr.Remove(selectedState);
                    stepsMngr.Insert(index, newState);
                    SetItems();

                    return(newState);
                }
            }

            if (child is RestrictionManager && copyObject is RestrictionManager)
            {
                var restrictMan = child as RestrictionManager;
                if (restrictMan != null)
                {
                    var copyMan = copyObject as RestrictionManager;
                    for (int i = 0; i < restrictMan.Restrictions.Count; i++)
                    {
                        restrictMan.Replace(restrictMan.Items[i],
                                            copyMan.Items[i]);
                    }

                    int objNum = TechObjectManager.GetInstance()
                                 .GetTechObjectN(owner.Owner);
                    int modeNum = getN(this);

                    foreach (var restrict in restrictMan.Restrictions)
                    {
                        restrict.SetRestrictionOwner(objNum, modeNum);
                    }
                    return(restrictMan);
                }
            }

            return(null);
        }
Beispiel #25
0
        /// <summary>
        /// Удалить этот объект из привязки объектов
        /// </summary>
        /// <param name="techObject">Агрегат</param>
        private void RemoveAttachingToUnits(TechObject techObject)
        {
            int objNum = TechObjectManager.GetInstance()
                         .GetTechObjectN(techObject);

            foreach (var obj in globalObjectsList)
            {
                RemoveAttachingToUnit(obj.AttachedObjects, objNum);

                foreach (var tankGroup in obj.BaseTechObject?.TankGroupsList)
                {
                    RemoveAttachingToUnit(tankGroup, objNum);
                }
            }
        }
Beispiel #26
0
        public void RemoveAttachingToUnits(TechObject techObject)
        {
            int objNum = TechObjectManager.GetInstance()
                         .GetTechObjectN(techObject);

            foreach (var obj in TechObjects)
            {
                RemoveAttachingToUnit(obj.AttachedObjects, objNum);

                if (obj.BaseTechObject?.ObjectGroupsList != null)
                {
                    foreach (var group in obj.BaseTechObject.ObjectGroupsList)
                    {
                        RemoveAttachingToUnit(group, objNum);
                    }
                }
            }
        }
Beispiel #27
0
        /// <summary>
        /// Установка перекрестных ограничений
        /// </summary>
        protected void SetCrossRestriction()
        {
            if (LuaName != "NextModeRestriction")
            {
                SortedDictionary <int, List <int> > .KeyCollection keyColl =
                    restrictList.Keys;

                foreach (int key in keyColl)
                {
                    TechObject to = TechObjectManager.GetInstance()
                                    .TechObjects[key - 1];
                    foreach (int val in restrictList[key])
                    {
                        Mode mode = to.GetMode(val - 1);
                        mode.AddRestriction(luaName, ownerObjNum, ownerModeNum);
                    }
                }
            }
        }
            /// <summary>
            /// Проверить привязанные объекты на инициализацию и
            /// инициализировать, если не инициализировано.
            /// </summary>
            public string Check()
            {
                var        res          = "";
                List <int> numbers      = GetValidTechObjNums(this.Value);
                string     checkedValue = string.Join(" ", numbers);

                if (checkedValue != this.Value)
                {
                    int objGlobalNumber = TechObjectManager.GetInstance()
                                          .GetTechObjectN(techObject);
                    res += $"Проверьте привязанные агрегаты в объекте: " +
                           $"{objGlobalNumber}." +
                           $"{techObject.Name + techObject.TechNumber}. " +
                           $"В поле присутствуют агрегаты, которые нельзя " +
                           $"привязывать.\n";
                }

                InitAttachedAgregates(numbers);
                return(res);
            }
Beispiel #29
0
        /// <summary>
        /// Проверить привязанные объекты на инициализацию и
        /// инициализировать, если не инициализировано.
        /// </summary>
        public string Check()
        {
            var        res          = "";
            var        objNum       = TechObjectManager.GetInstance().GetTechObjectN(Owner);
            List <int> numbers      = strategy.GetValidTechObjNums(Value, objNum);
            string     checkedValue = string.Join(" ", numbers);

            if (checkedValue != Value)
            {
                int objGlobalNumber = TechObjectManager.GetInstance()
                                      .GetTechObjectN(owner);
                res += $"Проверьте {Name.ToLower()} в объекте: " +
                       $"{objGlobalNumber}." +
                       $"{owner.Name + owner.TechNumber}. " +
                       $"В поле присутствуют агрегаты, которые нельзя " +
                       $"привязывать.\n";
            }

            InitAttachedObjects(numbers);
            return(res);
        }
        override public bool Delete(object child)
        {
            var mode = child as Mode;

            if (mode != null)
            {
                int idx     = modes.IndexOf(mode) + 1;
                int tobjNum = TechObjectManager.GetInstance()
                              .GetTechObjectN(owner);
                TechObjectManager.GetInstance().ChangeModeNum(tobjNum, idx, -1);
                modes.Remove(mode);

                foreach (Mode newMode in modes)
                {
                    ChangeRestrictionModeOwner(newMode);
                }

                return(true);
            }
            return(false);
        }