Esempio n. 1
0
        /// <summary>
        /// Копирование доп. свойств базовой операции
        /// </summary>
        /// <param name="newOwner">Новая базовая операция-владелец</param>
        /// <returns></returns>
        private List <BaseParameter> CloneProperties(BaseOperation newOwner)
        {
            var properties = new List <BaseParameter>();

            for (int i = 0; i < baseOperationProperties.Count; i++)
            {
                BaseParameter oldProperty = baseOperationProperties[i];
                BaseParameter newProperty = oldProperty.Clone();
                if (oldProperty.Owner is BaseTechObject)
                {
                    var obj = oldProperty.Owner as BaseTechObject;
                    if (obj.IsAttachable)
                    {
                        newProperty.Owner = oldProperty.Owner;
                    }
                }
                else
                {
                    newProperty.Owner = newOwner;
                }
                properties.Add(newProperty);
            }

            return(properties);
        }
Esempio n. 2
0
        /// <summary>
        /// Создание новой операции.
        /// </summary>
        /// <param name="name">Имя операции.</param>
        /// <param name="getN">Функция получения номера операции.</param>
        /// <param name="newOwner">Владелец операции (Менеджер операций)
        /// </param>
        public Mode(string name, GetN getN, ModesManager newOwner)
        {
            this.name  = name;
            this.getN  = getN;
            this.owner = newOwner;

            restrictionMngr = new RestrictionManager();

            stepsMngr = new List <State>();

            var lastState   = State.StateType.STATES_CNT;
            var secondState = State.StateType.PAUSE;

            stepsMngr.Add(new State(State.StateType.RUN, this, true));
            for (var state = secondState; state < lastState; state++)
            {
                stepsMngr.Add(new State(state, this));
            }

            operPar = new OperationParams();

            // Экземпляр класса базовой операции
            baseOperation = new BaseOperation(this);

            SetItems();
        }
Esempio n. 3
0
        /// <summary>
        /// Проверка состояний состоящих из шагов
        /// </summary>
        /// <returns>Строка с ошибками</returns>
        public string Check()
        {
            var          errors       = string.Empty;
            List <State> stepsManager = stepsMngr;

            foreach (State state in stepsManager)
            {
                errors += state.Check();
            }

            errors += BaseOperation.Check();

            return(errors);
        }
Esempio n. 4
0
        /// <summary>
        /// Добавить базовую операцию
        /// </summary>
        /// <param name="luaName">Lua-имя</param>
        /// <param name="name">Имя</param>
        /// <returns></returns>
        public BaseOperation AddBaseOperation(string luaName, string name)
        {
            if (BaseOperations.Count == 0)
            {
                // Пустой объект, если не должно быть выбрано никаких объектов
                BaseOperations.Add(BaseOperation.EmptyOperation());
            }

            var operation = BaseOperation.EmptyOperation();

            operation.LuaName = luaName;
            operation.Name    = name;
            BaseOperations.Add(operation);

            return(operation);
        }
Esempio n. 5
0
        /// <summary>
        /// Копирование состояний и базовых шагов
        /// </summary>
        /// <param name="newOwner">Новая операция-владелец</param>
        /// <returns></returns>
        private Dictionary <string, List <BaseStep> > CloneStates(
            BaseOperation newOwner)
        {
            var clonedStates = new Dictionary <string, List <BaseStep> >();

            foreach (var state in States)
            {
                var             clonedSteps = new List <BaseStep>();
                List <BaseStep> steps       = state.Value;
                foreach (var step in steps)
                {
                    BaseStep clonedStep = step.Clone();
                    clonedStep.Owner = newOwner;
                    clonedSteps.Add(clonedStep);
                }

                clonedStates.Add(state.Key, clonedSteps);
            }

            return(clonedStates);
        }
Esempio n. 6
0
        public void SetUpFromBaseTechObject(BaseOperation baseOperation)
        {
            bool setBaseOperation = true;

            SetNewValue(baseOperation.Name, setBaseOperation);

            var filteredSteps = baseOperation.Steps
                                .Where(x => x.Name != string.Empty && x.DefaultPosition > 0)
                                .OrderBy(x => x.DefaultPosition);
            const int mainStepsIndex = 0;
            State     mainState      = stepsMngr[mainStepsIndex];

            foreach (var baseStep in filteredSteps)
            {
                while (mainState.Steps.Count < baseStep.DefaultPosition)
                {
                    mainState.Insert();
                }

                Step newStep = (Step)mainState.Insert();
                newStep.SetUpFromBaseTechObject(baseStep);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Создание новой операции.
        /// </summary>
        /// <param name="name">Имя операции.</param>
        /// <param name="getN">Функция получения номера операции.</param>
        /// <param name="newOwner">Владелец операции (Менеджер операций)
        /// </param>
        public Mode(string name, GetN getN, ModesManager newOwner)
        {
            this.name  = name;
            this.getN  = getN;
            this.owner = newOwner;

            restrictionMngr = new RestrictionManager();

            stepsMngr = new List <State>();

            stepsMngr.Add(new State(StateStr[(int)StateName.RUN], true, this,
                                    true));
            for (StateName i = StateName.PAUSE; i < StateName.STATES_CNT; i++)
            {
                stepsMngr.Add(new State(StateStr[(int)i], true, this));
            }

            operPar = new OperationParams();

            // Экземпляр класса базовой операции
            baseOperation = new BaseOperation(this);

            SetItems();
        }
Esempio n. 8
0
        public void SetUpFromBaseTechObject(BaseOperation baseOperation)
        {
            bool setBaseOperation = true;

            SetNewValue(baseOperation.Name, setBaseOperation);

            foreach (var state in States)
            {
                var stateSteps = baseOperation
                                 .GetStateBaseSteps(state.Type)
                                 .Where(x => x.DefaultPosition > 0)
                                 .OrderBy(x => x.DefaultPosition);
                foreach (var baseStep in stateSteps)
                {
                    while (state.Steps.Count < baseStep.DefaultPosition)
                    {
                        state.Insert();
                    }

                    var newStep = (Step)state.Insert();
                    newStep.SetUpFromBaseTechObject(baseStep);
                }
            }
        }