Пример #1
0
        public void SetUpFromBaseTechObject(BaseTechObject baseTechObject)
        {
            var baseOperations = baseTechObject.BaseOperations;

            if (baseOperations.Count < 0)
            {
                return;
            }

            var filteredOperations = baseOperations
                                     .Where(x => x.Name != string.Empty &&
                                            x.DefaultPosition > 0)
                                     .OrderBy(x => x.DefaultPosition);

            foreach (var baseOperation in filteredOperations)
            {
                while (modes.Count < baseOperation.DefaultPosition - 1)
                {
                    Insert();
                }

                Mode insertedMode = (Mode)Insert();
                insertedMode.SetUpFromBaseTechObject(baseOperation);
            }
        }
Пример #2
0
            /// <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);
                    }
                }
            }
Пример #3
0
        /// <summary>
        /// Создание технологического объекта.
        /// </summary>
        /// <param name="name">Имя.</param>
        /// <param name="getN">Функция получения порядкового номера.</param>
        /// <param name="technologicalNumber">Технологический номер.</param>
        /// <param name="nameEplan">ОУ объекта в Eplan'е.</param>
        /// <param name="cooperParamNumber">Время совместного перехода шагов (параметр).</param>
        public TechObject(string name, GetN getN, int technologicalNumber,
                          int techType, string nameEplan, int cooperParamNumber,
                          string NameBC, string attachedObjects)
        {
            this.name = name;
            this.getN = getN;

            this.techNumber = new TechObjectN(this, technologicalNumber);
            this.techType   = new Editor.ObjectProperty("Тип", techType);
            this.nameBC     = new Editor.ObjectProperty("Имя объекта Monitor",
                                                        NameBC);
            this.nameEplan         = new NameInEplan(nameEplan, this);
            this.cooperParamNumber = new Editor.ObjectProperty(
                "Время совместного перехода шагов (параметр)",
                cooperParamNumber);

            this.s88Level        = new ObjS88Level(0, this);
            this.attachedObjects = new AttachedToObjects(attachedObjects,
                                                         this);

            // Экземпляр класса базового агрегата
            baseTechObject = new BaseTechObject(this);

            modes             = new ModesManager(this);
            parameters        = new Params();
            parameters.Parent = this;

            equipment = new Equipment(this);

            SetItems();
        }
Пример #4
0
        public BaseTechObject AddBaseObject(string name, string eplanName,
                                            int s88Level, string basicName, string bindingName, bool isPID,
                                            string luaModuleName, string monitorName)
        {
            var obj = new BaseTechObject();

            obj.Name          = name;
            obj.EplanName     = eplanName;
            obj.S88Level      = s88Level;
            obj.BasicName     = basicName;
            obj.BindingName   = bindingName;
            obj.IsPID         = isPID;
            obj.LuaModuleName = luaModuleName;
            obj.MonitorName   = monitorName;

            bool correctName      = name != null && name.Trim() != string.Empty;
            bool correctEplanName = eplanName != null &&
                                    eplanName.Trim() != string.Empty;
            bool noEquals = baseTechObjects.Where(x => x.Name == obj.Name ||
                                                  x.EplanName == obj.EplanName).Count() == 0;

            if (correctName && correctEplanName && noEquals)
            {
                baseTechObjects.Add(obj);
            }

            return(obj);
        }
Пример #5
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);
        }
Пример #6
0
        /// <summary>
        /// Создание технологического объекта.
        /// </summary>
        /// <param name="name">Имя.</param>
        /// <param name="getN">Функция получения порядкового локального номера.
        /// </param>
        /// <param name="technologicalNumber">Технологический номер.</param>
        /// <param name="nameEplan">ОУ объекта в Eplan'е.</param>
        /// <param name="cooperParamNumber">Время совместного перехода шагов
        /// (параметр).</param>
        /// <param name="attachedObjects">Привязанные объекты</param>
        /// <param name="baseTechObject">Базовый технологический объект</param>
        /// <param name="NameBC">Имя объекта Monitor</param>
        /// <param name="techType">Номер типа</param>
        public TechObject(string name, GetN getLocalNum,
                          int technologicalNumber, int techType, string nameEplan,
                          int cooperParamNumber, string NameBC, string attachedObjects,
                          BaseTechObject baseTechObject)
        {
            this.name        = name;
            this.getLocalNum = getLocalNum;

            this.techNumber = new TechObjectN(this, technologicalNumber);
            this.techType   = new ObjectProperty("Тип", techType);
            this.nameBC     = new ObjectProperty("Имя объекта Monitor",
                                                 NameBC);
            this.nameEplan         = new NameInEplan(nameEplan, this);
            this.cooperParamNumber = new ObjectProperty(
                "Время совместного перехода шагов (параметр)",
                cooperParamNumber);

            this.attachedObjects = new AttachedToObjects(attachedObjects,
                                                         this);

            modes = new ModesManager(this);

            paramsManager        = new ParamsManager();
            paramsManager.Parent = this;

            equipment = new Equipment(this);

            InitBaseTechObject(baseTechObject);
            SetItems();
        }
Пример #7
0
        public void InsertBaseObject(string luaName)
        {
            var            baseObjectManager = BaseTechObjectManager.GetInstance();
            BaseTechObject foundBaseObject   = baseObjectManager
                                               .GetTechObject(luaName);

            if (foundBaseObject != null)
            {
                string baseObjectTypeName = baseObjectManager
                                            .GetS88Name(foundBaseObject.S88Level);
                var treeItem = GetTreeItem(baseObjectTypeName);
                if (treeItem != null)
                {
                    if (treeItem is S88Object s88Obj)
                    {
                        s88Obj.Insert(foundBaseObject.Name);
                    }
                    else
                    {
                        treeItem.Insert();
                    }

                    Editor.Editor.GetInstance().RefreshEditor();
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Добавить опознанный объект при загрузке из LUA
        /// </summary>
        /// <param name="obj">Объект</param>
        private void AddIdentifiedObjectWhenLoadFromLua(TechObject obj)
        {
            BaseTechObject baseTechObject = obj.BaseTechObject;
            var            type           = (BaseTechObjectManager.ObjectType)baseTechObject
                                            .S88Level;
            string name = BaseTechObjectManager.GetInstance()
                          .GetS88Name(baseTechObject.S88Level);

            switch (type)
            {
            case BaseTechObjectManager.ObjectType.ProcessCell:
                AddProcessCellFromLua(obj);
                break;

            case BaseTechObjectManager.ObjectType.Unit:
                AddS88ObjectFromLua(obj, name);
                break;

            case BaseTechObjectManager.ObjectType.Aggregate:
                AddS88ObjectFromLua(obj, name);
                break;

            case BaseTechObjectManager.ObjectType.UserObject:
                AddUserObject(obj);
                break;
            }
        }
Пример #9
0
        /// <summary>
        /// Инициализация базовой операции по имени
        /// </summary>
        /// <param name="baseOperName">Имя операции</param>
        /// <param name="mode">Операция владелец</param>
        public void Init(string baseOperName, Mode mode)
        {
            TechObject     techObject         = owner.Owner.Owner;
            BaseTechObject baseTechObject     = techObject.BaseTechObject;
            string         baseTechObjectName = baseTechObject?.Name ?? string.Empty;

            ResetOperationSteps();

            if (baseTechObjectName != string.Empty)
            {
                BaseOperation operation;
                operation = techObject.BaseTechObject
                            .GetBaseOperationByName(baseOperName);
                if (operation == null)
                {
                    operation = techObject.BaseTechObject
                                .GetBaseOperationByLuaName(baseOperName);
                }

                if (operation != null)
                {
                    Name       = operation.Name;
                    LuaName    = operation.LuaName;
                    Properties = operation.Properties
                                 .Select(x => x.Clone())
                                 .ToList();
                    foreach (var property in Properties)
                    {
                        property.Owner  = this;
                        property.Parent = this;
                    }

                    states = operation.States;
                    foreach (var state in states)
                    {
                        foreach (var step in states[state.Key])
                        {
                            step.Owner = this;
                        }
                    }

                    owner = mode;
                    if (mode.Name == Mode.DefaultModeName)
                    {
                        mode.SetNewValue(operation.Name);
                    }
                }
            }
            else
            {
                Name    = string.Empty;
                LuaName = string.Empty;
                baseOperationProperties = new List <BaseParameter>();
                states = new Dictionary <string, List <BaseStep> >();
            }

            techObject.AttachedObjects.Check();
            SetItems();
        }
Пример #10
0
        /// <summary>
        /// Копия объекта
        /// </summary>
        /// <returns></returns>
        public BaseTechObject Clone()
        {
            var cloned = new BaseTechObject(Owner);

            cloned.Name = Name;

            var aggregateParameters = new List <BaseParameter>();

            foreach (var aggrPar in AggregateParameters)
            {
                aggregateParameters.Add(aggrPar.Clone());
            }
            cloned.AggregateParameters = aggregateParameters;
            if (MainAggregateParameter != null)
            {
                cloned.MainAggregateParameter = MainAggregateParameter.Clone()
                                                as MainAggregateParameter;
            }

            var baseOperations = new List <BaseOperation>();

            foreach (var baseOperation in BaseOperations)
            {
                baseOperations.Add(baseOperation.Clone());
            }
            cloned.BaseOperations = baseOperations;

            cloned.BasicName = BasicName;
            cloned.EplanName = EplanName;

            var equipment = new List <BaseParameter>();

            foreach (var equip in Equipment)
            {
                var newEquip = equip.Clone();
                newEquip.Owner = this;
                equipment.Add(newEquip);
            }
            cloned.Equipment = equipment;

            cloned.S88Level    = S88Level;
            cloned.BindingName = BindingName;
            cloned.IsPID       = IsPID;

            cloned.tankGroups = new List <AttachedObjects>();
            foreach (var tankGroup in tankGroups)
            {
                var clonedStrategy = new AttachedObjectStrategy
                                     .AttachedTanksStrategy(tankGroup.WorkStrategy.Name,
                                                            tankGroup.WorkStrategy.LuaName);
                var clonedGroup = new AttachedObjects(tankGroup.Value,
                                                      tankGroup.Owner, clonedStrategy);
                cloned.tankGroups.Add(clonedGroup);
            }

            return(cloned);
        }
Пример #11
0
        public string SaveObjectInfoToPrgLua(BaseTechObject obj,
                                             string objName, string prefix)
        {
            string res = string.Empty;

            res += SaveTankAdditionalParameters(obj, objName, prefix);
            res += SaveLineAdditionalParameters(obj, objName, prefix);

            return(res);
        }
Пример #12
0
 /// <summary>
 /// Изменить владельца свойств агрегата в аппарате.
 /// </summary>
 /// <param name="oldOwner">Старый базовый объект</param>
 /// <param name="newOwner">Новый базовый объект</param>
 public void ChangePropertiesOwner(BaseTechObject oldOwner,
                                   BaseTechObject newOwner)
 {
     foreach (var property in Properties)
     {
         if (property.Owner == oldOwner)
         {
             property.Owner = newOwner;
         }
     }
 }
Пример #13
0
        /// <summary>
        /// Инициализация базового объекта
        /// </summary>
        /// <param name="baseTechObject">Базовый объект</param>
        public void InitBaseTechObject(BaseTechObject baseTechObject)
        {
            if (baseTechObject != null)
            {
                this.baseTechObject = baseTechObject.Clone(this);

                equipment.AddItems(baseTechObject.Equipment);
                SetItems();
            }

            // Установили новое значение, произошла смена базового объекта
            // Надо сравнить ОУ и изменить его, если требуется
            CompareEplanNames();
        }
        /// <summary>
        /// Добавить базовый объект
        /// </summary>
        /// <param name="name">Имя</param>
        /// <param name="eplanName">Имя в eplan</param>
        /// <param name="s88Level">Уровень по ISA88</param>
        /// <param name="basicName">Базовое имя для функциональности</param>
        /// <param name="bindingName">Имя для привязки к объекту</param>
        /// <param name="isPID">Является ли объект ПИД-регулятором</param>
        /// <returns></returns>
        public BaseTechObject AddBaseObject(string name, string eplanName,
                                            int s88Level, string basicName, string bindingName, bool isPID)
        {
            var obj = BaseTechObject.EmptyBaseTechObject();

            obj.Name        = name;
            obj.EplanName   = eplanName;
            obj.S88Level    = s88Level;
            obj.BasicName   = basicName;
            obj.BindingName = bindingName;
            obj.IsPID       = isPID;

            baseTechObjects.Add(obj);
            return(obj);
        }
Пример #15
0
        /// <summary>
        /// Создание технологического объекта.
        /// </summary>
        /// <param name="name">Имя.</param>
        /// <param name="getN">Функция получения порядкового локального номера.
        /// </param>
        /// <param name="technologicalNumber">Технологический номер.</param>
        /// <param name="nameEplan">ОУ объекта в Eplan'е.</param>
        /// <param name="cooperParamNumber">Время совместного перехода шагов
        /// (параметр).</param>
        /// <param name="attachedObjects">Привязанные объекты</param>
        /// <param name="baseTechObject">Базовый технологический объект</param>
        /// <param name="NameBC">Имя объекта Monitor</param>
        /// <param name="techType">Номер типа</param>
        public TechObject(string name, GetN getLocalNum,
                          int technologicalNumber, int techType, string nameEplan,
                          int cooperParamNumber, string NameBC, string attachedObjects,
                          BaseTechObject baseTechObject)
        {
            this.name        = name;
            this.getLocalNum = getLocalNum;

            this.techNumber = new TechObjectN(this, technologicalNumber);
            this.techType   = new ObjectProperty("Тип", techType);
            this.nameBC     = new ObjectProperty("Имя объекта Monitor",
                                                 NameBC);
            this.nameEplan         = new NameInEplan(nameEplan, this);
            this.cooperParamNumber = new ObjectProperty(
                "Время совместного перехода шагов (параметр)",
                cooperParamNumber, -1);

            var allowedObjects = new List <BaseTechObjectManager.ObjectType>()
            {
                BaseTechObjectManager.ObjectType.Aggregate
            };
            string attachObjectsName    = "Привязанные агрегаты";
            string attachObjectsLuaName = "attached_objects";

            this.attachedObjects = new AttachedObjects(attachedObjects,
                                                       this, new AttachedObjectStrategy.AttachedWithInitStrategy(
                                                           attachObjectsName, attachObjectsLuaName, allowedObjects));

            modes = new ModesManager(this);

            paramsManager        = new ParamsManager();
            paramsManager.Parent = this;

            string sysParName   = "Системные параметры";
            string sysParLuName = "system_parameters";

            systemParams        = new SystemParams(sysParName, sysParLuName);
            systemParams.Parent = this;

            equipment = new Equipment(this);

            InitBaseTechObject(baseTechObject);
            SetItems();
        }
Пример #16
0
        /// <summary>
        /// Добавить базовый объект
        /// </summary>
        /// <param name="name">Имя</param>
        /// <param name="eplanName">Имя в eplan</param>
        /// <param name="s88Level">Уровень по ISA88</param>
        /// <param name="basicName">Базовое имя для функциональности</param>
        /// <param name="bindingName">Имя для привязки к объекту</param>
        /// <param name="isPID">Является ли объект ПИД-регулятором</param>
        /// <returns></returns>
        public BaseTechObject AddBaseObject(string name, string eplanName,
                                            int s88Level, string basicName, string bindingName, bool isPID)
        {
            if (baseTechObjects.Count == 0)
            {
                // Пустой объект, если не должно быть выбрано никаких объектов
                baseTechObjects.Add(BaseTechObject.EmptyBaseTechObject());
            }

            var obj = BaseTechObject.EmptyBaseTechObject();

            obj.Name        = name;
            obj.EplanName   = eplanName;
            obj.S88Level    = s88Level;
            obj.BasicName   = basicName;
            obj.BindingName = bindingName;
            obj.IsPID       = isPID;

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

            if (obj.UseGroups && obj.ObjectGroupsList.Count > 0)
            {
                foreach (var objectGroup in obj.ObjectGroupsList)
                {
                    if (objectGroup.Value == string.Empty)
                    {
                        continue;
                    }

                    string objectNames = objectGroup.GetAttachedObjectsName()
                                         .Select(x => $"{prefix}prg.{x},\n")
                                         .Aggregate((x, y) => x + y);
                    res += $"{objName}.{objectGroup.WorkStrategy.LuaName} =\n";
                    res += $"{prefix}{{\n";
                    res += $"{objectNames}";
                    res += $"{prefix}}}\n";
                }
            }

            bool containsFillOrPumping = obj.BaseOperations
                                         .Any(x => x.LuaName == "FILL" || x.LuaName == "PUMPING");

            if (obj.UseGroups && containsFillOrPumping)
            {
                res += $"{objName}.reset_before_wash =\n" +
                       prefix + "{\n" +
                       prefix + $"{objName}.PAR_FLOAT.PROD_V,\n" +
                       prefix + $"{objName}.PAR_FLOAT.WATER_V,\n" +
                       prefix + "}\n";
            }

            return(res);
        }
Пример #18
0
            /// <summary>
            /// Инициализация данных
            /// </summary>
            /// <param name="objectsNumbrers">Список корректных номеров
            /// привязанных агрегатов</param>
            private void InitAttachedAgregates(List <int> objectsNumbrers)
            {
                foreach (var number in objectsNumbrers)
                {
                    TechObject attachedAggregate = TechObjectManager
                                                   .GetInstance().GetTObject(number);
                    BaseTechObject attachedBaseTechObject = attachedAggregate
                                                            .BaseTechObject;
                    List <BaseParameter> properties = attachedBaseTechObject
                                                      .AggregateParameters;

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

                    if (attachedBaseTechObject.MainAggregateParameter != null)
                    {
                        addingProperties.Add(attachedBaseTechObject
                                             .MainAggregateParameter);
                    }
                    TechObject  thisThechObject = techObject;
                    List <Mode> modes           = thisThechObject.ModesManager.Modes;
                    foreach (var mode in modes)
                    {
                        if (mode.BaseOperation.Name == "")
                        {
                            continue;
                        }

                        mode.BaseOperation.AddProperties(addingProperties,
                                                         attachedBaseTechObject);
                        mode.BaseOperation.Check();
                    }
                }
            }
Пример #19
0
        override public bool SetNewValue(string newValue, bool isExtraValue)
        {
            if (baseTechObject.Name == newValue ||
                baseTechObject.EplanName == newValue)
            {
                return(false);
            }

            if (baseTechObject.Name != "" &&
                (newValue != baseTechObject.Name ||
                 newValue != baseTechObject.EplanName))
            {
                baseTechObject.ResetBaseOperations();
                attachedObjects.Reset();
                equipment.Clear();
            }

            BaseTechObject techObjFromDB = BaseTechObjectManager.GetInstance()
                                           .GetTechObject(newValue);

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

            techObjFromDB.Owner = baseTechObject.Owner;
            baseTechObject      = techObjFromDB;
            S88Level            = baseTechObject.S88Level;
            equipment.AddItems(baseTechObject.Equipment);
            equipment.Check();

            // Т.к установили новое значение, произошла смена базового объекта
            // Надо сравнить ОУ и изменить его, если требуется
            CompareEplanNames();
            return(true);
        }
Пример #20
0
        /// <summary>
        /// Копия объекта
        /// </summary>
        /// <returns></returns>
        public BaseTechObject Clone()
        {
            var cloned = new BaseTechObject(Owner);

            cloned.Name = Name;

            var aggregateParameters = new List <BaseParameter>();

            foreach (var aggrPar in AggregateParameters)
            {
                aggregateParameters.Add(aggrPar.Clone());
            }
            cloned.AggregateParameters = aggregateParameters;
            if (MainAggregateParameter != null)
            {
                cloned.MainAggregateParameter = MainAggregateParameter.Clone()
                                                as MainAggregateParameter;
            }

            var baseOperations = new List <BaseOperation>();

            foreach (var baseOperation in BaseOperations)
            {
                baseOperations.Add(baseOperation.Clone());
            }
            cloned.BaseOperations = baseOperations;

            cloned.BasicName = BasicName;
            cloned.EplanName = EplanName;

            var equipment = new List <BaseParameter>();

            foreach (var equip in Equipment)
            {
                var newEquip = equip.Clone();
                newEquip.Owner = this;
                equipment.Add(newEquip);
            }
            cloned.Equipment = equipment;

            cloned.S88Level    = S88Level;
            cloned.BindingName = BindingName;
            cloned.IsPID       = IsPID;

            cloned.objectGroups = new List <AttachedObjects>();
            foreach (var objectGroup in objectGroups)
            {
                var clonedStrategy = new AttachedObjectStrategy
                                     .AttachedWithoutInitStrategy(
                    objectGroup.WorkStrategy.Name,
                    objectGroup.WorkStrategy.LuaName,
                    objectGroup.WorkStrategy.AllowedObjects);
                var clonedGroup = new AttachedObjects(objectGroup.Value,
                                                      objectGroup.Owner, clonedStrategy);
                cloned.objectGroups.Add(clonedGroup);
            }

            cloned.SystemParams  = SystemParams.Clone();
            cloned.Parameters    = Parameters.Clone();
            cloned.LuaModuleName = LuaModuleName;
            cloned.MonitorName   = MonitorName;

            return(cloned);
        }
Пример #21
0
        /// <summary>
        /// Получение строки для сохранения в зависимости от того, кто
        /// владеет параметром. Сам юнит или это параметр агрегата.
        /// </summary>
        /// <param name="prefix">Отступ</param>
        /// <returns></returns>
        private string GetNumberParameterStringForSave(string prefix)
        {
            BaseTechObject baseTechObject     = null;
            Mode           mainMode           = null;
            var            modes              = new List <Mode>();
            string         mainObjDisplayName = "";

            if (Owner is BaseTechObject aggregateBaseTechObject)
            {
                baseTechObject = aggregateBaseTechObject;
                modes          = baseTechObject.Owner.ModesManager.Modes;

                var baseOperation = Parent as BaseOperation;
                mainMode = baseOperation.Owner;
            }
            else if (Owner is BaseOperation baseOperation)
            {
                baseTechObject = baseOperation.Owner.Owner.Owner.BaseTechObject;
                mainMode       = baseOperation.Owner;
                modes          = mainMode.Owner.Modes;
            }

            mainObjDisplayName = $"{baseTechObject.Owner.DisplayText[0]}";

            Mode modeInParameter = modes
                                   .Where(x => x.GetModeNumber().ToString() == Value)
                                   .FirstOrDefault();
            var res = string.Empty;

            if (modeInParameter != null)
            {
                if (modeInParameter.BaseOperation.Name != string.Empty)
                {
                    string operationLuaName = modeInParameter.BaseOperation
                                              .LuaName.ToUpper();
                    TechObject obj        = baseTechObject.Owner;
                    string     objVarName =
                        $"prg.{obj.NameEplanForFile.ToLower()}" +
                        $"{obj.TechNumber}";
                    res = $"{prefix}{LuaName} = " +
                          $"{objVarName}.operations.{operationLuaName}";
                }
                else
                {
                    string message = $"Ошибка обработки параметра " +
                                     $"\"{Name}\"." +
                                     $" Не задана базовая операция в операции" +
                                     $" \"{modeInParameter.DisplayText[0]}\", объекта " +
                                     $"\"{mainObjDisplayName}\".\n";
                    Logs.AddMessage(message);
                }
            }
            else
            {
                string message = $"Ошибка обработки параметра " +
                                 $"\"{Name}\"." +
                                 $" Указан несуществующий номер операции в операции " +
                                 $"\"{mainMode.DisplayText[0]}\" объекта " +
                                 $"\"{mainObjDisplayName}\".\n";
                Logs.AddMessage(message);
            }

            return(res);
        }
Пример #22
0
        /// <summary>
        /// Получение строки для сохранения в зависимости от того, кто
        /// владеет параметром. Сам юнит или это параметр агрегата.
        /// </summary>
        /// <param name="parameter">Параметр для обработки</param>
        /// <param name="prefix">Отступ</param>
        /// <param name="mainObjMode">Проверяемая операция главного объекта
        /// </param>
        /// <returns></returns>
        public string GetNumberParameterStringForSave(string prefix,
                                                      BaseParameter parameter, Mode mainObjMode)
        {
            BaseTechObject baseTechObject = null;
            List <Mode>    modes          = new List <Mode>();
            string         mainObjName    = "";

            if (parameter.Owner is BaseTechObject)
            {
                baseTechObject = parameter.Owner as BaseTechObject;
                mainObjName    = $"{baseTechObject.Owner.DisplayText[0]}";
                modes          = baseTechObject.Owner.ModesManager.Modes;
            }

            if (parameter.Owner is BaseOperation)
            {
                var operation = parameter.Owner as BaseOperation;
                baseTechObject = operation.Owner.Owner.Owner.BaseTechObject;
                mainObjName    = $"{baseTechObject.Owner.DisplayText[0]}";
                modes          = operation.Owner.Owner.Modes;
            }

            string parameterValue = parameter.Value;
            var    mode           = modes
                                    .Where(x => x.GetModeNumber().ToString() == parameterValue)
                                    .FirstOrDefault();
            var res = "";

            if (mode != null)
            {
                if (mode.BaseOperation.Name != "")
                {
                    parameterValue = mode.BaseOperation.LuaName.ToUpper();
                    TechObject obj     = baseTechObject.Owner;
                    string     objName = "prg." + obj.NameEplanForFile.ToLower() +
                                         obj.TechNumber.ToString();
                    res = $"{prefix}{parameter.LuaName} = " +
                          $"{objName}.operations." + parameterValue + ",\n";
                }
                else
                {
                    string message = $"Ошибка обработки параметра " +
                                     $"\"{parameter.Name}\"." +
                                     $" Не задана базовая операция в операции" +
                                     $" \"{mode.DisplayText[0]}\", объекта " +
                                     $"\"{mainObjName}\".\n";
                    Logs.AddMessage(message);
                }
            }
            else
            {
                string message = $"Ошибка обработки параметра " +
                                 $"\"{parameter.Name}\"." +
                                 $" Указан несуществующий номер операции в операции " +
                                 $"\"{mainObjMode.DisplayText[0]}\" объекта " +
                                 $"\"{mainObjName}\".\n";
                Logs.AddMessage(message);
            }


            return(res);
        }