public SubVariable ApplyOperator(OperatorType operatorType)
    {
        SubVariable res = this;
        dynamic     t1  = source;

        if (operatorType == OperatorType.v_minus)
        {
            res.source = -t1;
        }
        else if (operatorType == OperatorType.v_not)
        {
            res.source = !t1;
        }
        else if (operatorType == OperatorType.v_binairyNot)
        {
            res.source = ~t1;
        }
        else if (operatorType == OperatorType.v_round)
        {
            res.variableType = VariableType.v_int;
            res.source       = Mathf.RoundToInt(t1);
        }

        return(res);
    }
Esempio n. 2
0
        private async Task SetCurrentSubVariableId(string subVariableName)
        {
            var subVariable = await _subVariableRepository.GetSubVariable(subVariableName);

            if (subVariable == null)
            {
                subVariable = new SubVariable {
                    Name = subVariableName
                };
                _subVariableRepository.Add(subVariable);
                await _unitOfWork.CompleteAsync();
            }
            CurrentSubVariableId = subVariable.Id;
        }
Esempio n. 3
0
        private void initMidTermGenerationSubVariables()
        {
            MidTermGenerationSubVariables = new List <SubVariable>();
            var currentSubNarId = StartMidTermSubVarId;

            foreach (var subVar in ElectricityTypes.SubVariables.GetAll())
            {
                var currentSubVar = new SubVariable
                {
                    Id   = currentSubNarId++,
                    Name = subVar
                };
                MidTermGenerationSubVariables.Add(currentSubVar);
            }
        }
        internal async Task <int> GetSubVariableIdAsync(int currentRow)
        {
            var subVariableVal = _currentWorkSheet.Cells[currentRow, _agrigationXlsDescription.SubVariableCol].Value;

            if (subVariableVal == null)
            {
                return(0);
            }
            var subVariableName = subVariableVal.ToString();
            var subVariable     = await _excelImportDataService.SubVariableRepository.GetSubVariable(subVariableName);

            if (subVariable == null)
            {
                subVariable = new SubVariable {
                    Name = subVariableName
                };
                _excelImportDataService.SubVariableRepository.Add(subVariable);
                await _excelImportDataService.UnitOfWork.CompleteAsync();
            }
            return(subVariable.Id);
        }
Esempio n. 5
0
        protected async Task SetCurrentSubVariableId(int currentRow, int subVariableCol, string currentRangePref = "")
        {
            var subVariableVal = CurrentWorkSheet.Cells[currentRow, subVariableCol].Value;

            if (subVariableVal == null)
            {
                CurrentSubVariableId = 0;
            }
            var subVariableName = !string.IsNullOrEmpty(currentRangePref) ? $"{currentRangePref} - {subVariableVal.ToString()}"
                                                                            : subVariableVal.ToString();

            var subVariable = await _subVariableRepository.GetSubVariable(subVariableName);

            if (subVariable == null)
            {
                subVariable = new SubVariable {
                    Name = subVariableName
                };
                _subVariableRepository.Add(subVariable);
                await _unitOfWork.CompleteAsync();
            }
            CurrentSubVariableId = subVariable.Id;
        }
Esempio n. 6
0
 public void Remove(SubVariable subVariable)
 {
     context.Remove(subVariable);
 }
Esempio n. 7
0
 public void Add(SubVariable subVariable)
 {
     context.SubVariables.Add(subVariable);
 }
 public SolveElement(SolveElementType type, SubVariable subVariable)
 {
     this.type        = type;
     this.subVariable = subVariable;
 }
    public SubVariable ApplyOperator(OperatorType operatorType, SubVariable SecondVariable)
    {
        SubVariable res = this;
        dynamic     t1  = source;
        dynamic     t2  = SecondVariable.source;

        if (operatorType == OperatorType.v_plus)
        {
            //float int becomes float
            if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float)
            {
                res.variableType = VariableType.v_float;
            }
            res.source = t1 + t2;
        }
        else if (operatorType == OperatorType.v_minus)
        {
            if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float)
            {
                res.variableType = VariableType.v_float;
            }
            res.source = t1 - t2;
        }
        else if (operatorType == OperatorType.v_multiply)
        {
            if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float)
            {
                res.variableType = VariableType.v_float;
            }
            res.source = t1 * t2;
        }
        else if (operatorType == OperatorType.v_divide)
        {
            if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float)
            {
                res.variableType = VariableType.v_float;
            }
            res.source = t1 / t2;
        }
        else if (operatorType == OperatorType.v_modulo)
        {
            if (this.variableType == VariableType.v_float || SecondVariable.variableType == VariableType.v_float)
            {
                res.variableType = VariableType.v_float;
            }
            res.source = t1 % t2;
        }
        else if (operatorType == OperatorType.v_greater)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 > t2;
        }
        else if (operatorType == OperatorType.v_smaller)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 < t2;
        }
        else if (operatorType == OperatorType.v_greaterEqual)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 >= t2;
        }
        else if (operatorType == OperatorType.v_smallerEqual)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 <= t2;
        }
        else if (operatorType == OperatorType.v_equal)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 == t2;
        }
        else if (operatorType == OperatorType.v_notEqual)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 != t2;
        }
        else if (operatorType == OperatorType.v_binairyAnd)
        {
            res.source = t1 & t2;
        }
        else if (operatorType == OperatorType.v_binairyOr)
        {
            res.source = t1 | t2;
        }
        else if (operatorType == OperatorType.v_binairyNor)
        {
            res.source = t1 ^ t2;
        }
        else if (operatorType == OperatorType.v_and)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 && t2;
        }
        else if (operatorType == OperatorType.v_or)
        {
            res.variableType = VariableType.v_bool;
            res.source       = t1 || t2;
        }
        else if (operatorType == OperatorType.v_binairyLeftShift)
        {
            res.source = t1 << t2;
        }
        else if (operatorType == OperatorType.v_binairyRightShift)
        {
            res.source = t1 >> t2;
        }

        return(res);
    }