Exemple #1
0
        //static int detansCount = 0;


        /* Расчет допусков для каждого элемента из elements */
        /* Возвращает ассоциативный массив, где ключ - элемент, значение - Result */
        public static Dictionary <PassiveElement[], Result> calculateTolerance_Total(SchemeForTolerance scheme, ref int detansCount)/*, Dictionary<PassiveElement[], Result> elementToToleranceDictionary)/*,
                                                                                                                                     * PassiveElement[] elements, bool forNegative, string error)*/
        {
            Dictionary <PassiveElement[], Result> elementToToleranceDictionary = new Dictionary <PassiveElement[], Result>();

            foreach (PassiveElement element in scheme.getSelectedElements())
            {
                List <PassiveElement> selectedElement = new List <PassiveElement>();
                selectedElement.Add(element);
                SchemeForTolerance tempScheme = new SchemeForTolerance(Scheme.currentScheme,
                                                                       new PassiveElement[] { element }, scheme.error, scheme.useNegativeValues);
                //scheme.setSelectedElements(selectedElement);
                Result result = calculateTolerance(tempScheme);
                detansCount += 4;
                elementToToleranceDictionary.Add(new PassiveElement[] { element }, result);
            }
            return(elementToToleranceDictionary);
        }
Exemple #2
0
        /* Расчет допуска для одного элемента (element) из схемы scheme */
        static Result calculateTolerance(SchemeForTolerance scheme)/*PassiveElement element, SchemeForTolerance scheme, bool forNegative)*/
        {
            PassiveElement element = scheme.getSelectedElements()[0];
            Result         result  = new Result();

            string[] detans = getDetans(element, scheme);
            result.elementNamesToDetansDictionary = new Dictionary <string, DetansPair>();
            result.elementNamesToDetansDictionary.Add("", new DetansPair(detans[1], detans[3]));
            result.elementNamesToDetansDictionary.Add(element.getRightName(), new DetansPair(detans[0], detans[2]));
            string formule = makeToleranceFormule(detans, scheme.error, false);

            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 (!result.valueForPositive.Contains("j"))
                value = (Convert.ToDouble(value) * 100
                         / Convert.ToDouble(element.getFormattedValue())).ToString();
            }
            result.formuleValue.value = value;
            if (scheme.useNegativeValues)
            {
                string negativeValue = calculateFormule(makeToleranceFormule(detans, scheme.error, true), scheme);
                if (!String.IsNullOrEmpty(negativeValue))
                {
                    //if (!result.valueForNegative.Contains("j"))
                    negativeValue = (Convert.ToDouble(negativeValue) * 100
                                     / Convert.ToDouble(element.getFormattedValue())).ToString();
                }
                ((FormuleValueWithNegative)result.formuleValue).negativeValue = negativeValue;
            }
            return(result);
        }
 /*PassiveElement element, SchemeForTolerance scheme, bool forNegative)*/
 /* Расчет допуска для одного элемента (element) из схемы scheme */
 static Result calculateTolerance(SchemeForTolerance scheme)
 {
     PassiveElement element = scheme.getSelectedElements()[0];
     Result result = new Result();
     string[] detans = getDetans(element, scheme);
     result.elementNamesToDetansDictionary = new Dictionary<string, DetansPair>();
     result.elementNamesToDetansDictionary.Add("", new DetansPair(detans[1], detans[3]));
     result.elementNamesToDetansDictionary.Add(element.getRightName(), new DetansPair(detans[0], detans[2]));
     string formule = makeToleranceFormule(detans, scheme.error, false);
     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 (!result.valueForPositive.Contains("j"))
         value = (Convert.ToDouble(value) * 100
             / Convert.ToDouble(element.getFormattedValue())).ToString();
     result.formuleValue.value = value;
     if (scheme.useNegativeValues)
     {
         string negativeValue = calculateFormule(makeToleranceFormule(detans, scheme.error, true), scheme);
         if (!String.IsNullOrEmpty(negativeValue))
             //if (!result.valueForNegative.Contains("j"))
             negativeValue = (Convert.ToDouble(negativeValue) * 100
                 / Convert.ToDouble(element.getFormattedValue())).ToString();
         ((FormuleValueWithNegative)result.formuleValue).negativeValue = negativeValue;
     }
     return result;
 }
 /*, Dictionary<PassiveElement[], Result> elementToToleranceDictionary)/*,
     PassiveElement[] elements, bool forNegative, string error)*/
 //static int detansCount = 0;
 /* Расчет допусков для каждого элемента из elements */
 /* Возвращает ассоциативный массив, где ключ - элемент, значение - Result */
 public static Dictionary<PassiveElement[], Result> calculateTolerance_Total(SchemeForTolerance scheme, ref int detansCount)
 {
     Dictionary<PassiveElement[], Result> elementToToleranceDictionary = new Dictionary<PassiveElement[], Result>();
     foreach (PassiveElement element in scheme.getSelectedElements())
     {
         List<PassiveElement> selectedElement = new List<PassiveElement>();
         selectedElement.Add(element);
         SchemeForTolerance tempScheme = new SchemeForTolerance(Scheme.currentScheme,
             new PassiveElement[] { element }, scheme.error, scheme.useNegativeValues);
         //scheme.setSelectedElements(selectedElement);
         Result result = calculateTolerance(tempScheme);
         detansCount += 4;
         elementToToleranceDictionary.Add(new PassiveElement[] { element }, result);
     }
     return elementToToleranceDictionary;
 }