예제 #1
0
 /* Расчет погрешности для выбранной комбинации элементов */
 public static Result calculateError(SchemeForError scheme, ref int detansCount)
 {
     //SchemeForError scheme = new SchemeForError(Scheme.currentScheme, elements, elementToToleranceDictionary);
     PassiveElement[] selectedElements = scheme.getSelectedElements().ToArray();
     Dictionary<string, DetansPair> elementsToDetanPairDictionary =
         getDetans(selectedElements, scheme, ref detansCount);
     string formule = makeErrorFormule(elementsToDetanPairDictionary, false);
     Result result = new Result();
     result.elementNamesToDetansDictionary = elementsToDetanPairDictionary;
     if (scheme.useNegativeValues)
         result.formuleValue = new FormuleValueWithNegative();
     else
         result.formuleValue = new FormuleValue();
     result.formuleValue.formule = formule;
     string value = calculateFormule(formule, scheme);
     if (!String.IsNullOrEmpty(value))
     {
         if (!value.Contains("j"))
             //value = value.Replace('.', ',');
             value = (Convert.ToDouble(value) * 100).ToString();
     }
     result.formuleValue.value = value;
     if (scheme.useNegativeValues)
     {
         formule = makeErrorFormule(elementsToDetanPairDictionary, true);
         string resultForNegative = calculateFormule(formule, scheme);
         if (!String.IsNullOrEmpty(resultForNegative))
             if (!resultForNegative.Contains("j"))
                 //resultForNegative = resultForNegative.Replace('.', ',');
                 resultForNegative = (Convert.ToDouble(resultForNegative) * 100).ToString();
         ((FormuleValueWithNegative)result.formuleValue).negativeValue = resultForNegative;
     }
     detansCount += result.elementNamesToDetansDictionary.Count * 2;
     return result;
 }
예제 #2
0
        static Dictionary <PassiveElement[], Result> calculateError(SchemeForError scheme, ref int detansCount)
        {
            Dictionary <PassiveElement[], Result> elementsToErrorDictionary = new Dictionary <PassiveElement[], Result>();

            //Dictionary<PassiveElement, string> elementToToleranceDictionary = getElementToToleranceAssociations();
            //schemeForCalculations = new SchemeForError(Scheme.currentScheme, selectedElements.ToArray(), elementToToleranceDictionary);
            elementsToErrorDictionary.Add(scheme.getSelectedElements().ToArray(), Calculations.calculateError(scheme, ref detansCount));
            // = Calculations.calculateError(selectedElements.ToArray());
            return(elementsToErrorDictionary);
        }
예제 #3
0
        /* Расчет погрешности для выбранной комбинации элементов */
        public static Result calculateError(SchemeForError scheme, ref int detansCount)
        {
            //SchemeForError scheme = new SchemeForError(Scheme.currentScheme, elements, elementToToleranceDictionary);
            PassiveElement[] selectedElements = scheme.getSelectedElements().ToArray();
            Dictionary <string, DetansPair> elementsToDetanPairDictionary =
                getDetans(selectedElements, scheme, ref detansCount);
            string formule = makeErrorFormule(elementsToDetanPairDictionary, false);
            Result result  = new Result();

            result.elementNamesToDetansDictionary = elementsToDetanPairDictionary;
            if (scheme.useNegativeValues)
            {
                result.formuleValue = new FormuleValueWithNegative();
            }
            else
            {
                result.formuleValue = new FormuleValue();
            }
            result.formuleValue.formule = formule;
            string value = calculateFormule(formule, scheme);

            if (!String.IsNullOrEmpty(value))
            {
                if (!value.Contains("j"))
                {
                    //value = value.Replace('.', ',');
                    value = (Convert.ToDouble(value) * 100).ToString();
                }
            }
            result.formuleValue.value = value;
            if (scheme.useNegativeValues)
            {
                formule = makeErrorFormule(elementsToDetanPairDictionary, true);
                string resultForNegative = calculateFormule(formule, scheme);
                if (!String.IsNullOrEmpty(resultForNegative))
                {
                    if (!resultForNegative.Contains("j"))
                    {
                        //resultForNegative = resultForNegative.Replace('.', ',');
                        resultForNegative = (Convert.ToDouble(resultForNegative) * 100).ToString();
                    }
                }
                ((FormuleValueWithNegative)result.formuleValue).negativeValue = resultForNegative;
            }
            detansCount += result.elementNamesToDetansDictionary.Count * 2;
            return(result);
        }
예제 #4
0
        static Dictionary <PassiveElement[], Result> calculateSingleErrors(SchemeForError scheme, ref int detansCount)
        {
            Dictionary <PassiveElement[], Result> elementsToErrorDictionary = new Dictionary <PassiveElement[], Result>();
            //Dictionary<PassiveElement, string> elementToToleranceDictionary = getElementToToleranceAssociations();
            //schemeForCalculations = new SchemeForError(Scheme.currentScheme, selectedElements.ToArray(), elementToToleranceDictionary);
            List <PassiveElement> selectedElements = scheme.getSelectedElements();

            foreach (PassiveElement element in selectedElements)
            {
                List <PassiveElement> selectedElement = new List <PassiveElement>();
                selectedElement.Add(element);
                SchemeForError tempScheme = new SchemeForError(Scheme.currentScheme,
                                                               selectedElement.ToArray(), scheme.elementToToleranceDictionary, scheme.useNegativeValues);
                //scheme.setSelectedElements(selectedElement);
                elementsToErrorDictionary.Add(selectedElement.ToArray(),
                                              Calculations.calculateError(tempScheme, ref detansCount));
            }
            return(elementsToErrorDictionary);
        }
예제 #5
0
 static Dictionary<PassiveElement[], Result> calculateSingleErrors(SchemeForError scheme, ref int detansCount)
 {
     Dictionary<PassiveElement[], Result> elementsToErrorDictionary = new Dictionary<PassiveElement[], Result>();
     //Dictionary<PassiveElement, string> elementToToleranceDictionary = getElementToToleranceAssociations();
     //schemeForCalculations = new SchemeForError(Scheme.currentScheme, selectedElements.ToArray(), elementToToleranceDictionary);
     List<PassiveElement> selectedElements = scheme.getSelectedElements();
     foreach (PassiveElement element in selectedElements)
     {
         List<PassiveElement> selectedElement = new List<PassiveElement>();
         selectedElement.Add(element);
         SchemeForError tempScheme = new SchemeForError(Scheme.currentScheme,
             selectedElement.ToArray(), scheme.elementToToleranceDictionary, scheme.useNegativeValues);
         //scheme.setSelectedElements(selectedElement);
         elementsToErrorDictionary.Add(selectedElement.ToArray(),
             Calculations.calculateError(tempScheme, ref detansCount));
     }
     return elementsToErrorDictionary;
 }
예제 #6
0
 static Dictionary<PassiveElement[], Result> calculateError(SchemeForError scheme, ref int detansCount)
 {
     Dictionary<PassiveElement[], Result> elementsToErrorDictionary = new Dictionary<PassiveElement[], Result>();
     //Dictionary<PassiveElement, string> elementToToleranceDictionary = getElementToToleranceAssociations();
     //schemeForCalculations = new SchemeForError(Scheme.currentScheme, selectedElements.ToArray(), elementToToleranceDictionary);
     elementsToErrorDictionary.Add(scheme.getSelectedElements().ToArray(), Calculations.calculateError(scheme, ref detansCount));
     // = Calculations.calculateError(selectedElements.ToArray());
     return elementsToErrorDictionary;
 }