예제 #1
0
        static Dictionary <PassiveElement[], Result> calculateTolerances(SchemeForTolerance scheme, ref int detansCount)
        {
            Dictionary <PassiveElement[], Result> elementToToleranceDictionary = new Dictionary <PassiveElement[], Result>();

            //schemeForCalculations = new SchemeForTolerance(Scheme.currentScheme, selectedElements.ToArray(), error);
            elementToToleranceDictionary = Calculations.calculateTolerance_Total(scheme, ref detansCount);
            return(elementToToleranceDictionary);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
        /* Частный случай функции getDetans для одного элемента */
        static string[] getDetans(PassiveElement selectedElement, SchemeForTolerance scheme)
        {
            List <Element> elementsList = new List <Element>();//scheme.passiveElementsList;

            foreach (PassiveElement element in scheme.passiveElementsList)
            {
                elementsList.Add(element);
            }
            elementsList.AddRange((selectedElement).clonnedElements);
            elementsList.Remove((selectedElement).cloneElement);
            elementsList.AddRange(scheme.nullersList);
            List <Element> elementToInfinList = new List <Element>(elementsList);
            List <Element> elementToZeroList  = new List <Element>(elementsList);

            scheme.transformElementToInfin(((PassiveElement)selectedElement).cloneElement, elementToInfinList);
            scheme.transformElementToZero(((PassiveElement)selectedElement).cloneElement, elementToZeroList);
            //scheme.transformElementToInfin(element, elementToInfinList);
            //scheme.transformElementToZero(element, elementToZeroList);
            List <Element> activeElementsForZ     = scheme.getActiveElementsListForZ();
            List <Element> activeElementsForQ     = scheme.getActiveElementsListForQ();
            List <Element> elementsToInfinToZList = new List <Element>(elementToInfinList);

            elementsToInfinToZList.AddRange(activeElementsForZ);
            List <Element> elementsToZeroToZList = new List <Element>(elementToZeroList);

            elementsToZeroToZList.AddRange(activeElementsForZ);
            List <Element> elementsToInfinToQList = new List <Element>(elementToInfinList);

            elementsToInfinToQList.AddRange(activeElementsForQ);
            List <Element> elementsToZeroToQList = new List <Element>(elementToZeroList);

            elementsToZeroToQList.AddRange(activeElementsForQ);
            string[] detans          = new string[4];
            string   elementName     = selectedElement.getRightName();
            string   keyForRemoved   = elementName + "|" + "δ(" + elementName + ")";
            string   keyForSubtended = elementName + "|";

            if (mainForm.elementsStringToDetansMap.ContainsKey(keyForRemoved))
            {
                detans[0] = mainForm.elementsStringToDetansMap[keyForRemoved].itsNumeratorDetan;
                detans[2] = mainForm.elementsStringToDetansMap[keyForRemoved].itsDenominatorDetan;
            }
            else
            {
                detans[0] = getDetan(elementsToInfinToZList);
                correctFormule(ref detans[0]);
                detans[2] = getDetan(elementsToInfinToQList);
                correctFormule(ref detans[2]);
                DetansPair detansPair = new DetansPair(detans[0], detans[2]);
                mainForm.elementsStringToDetansMap.Add(keyForRemoved, detansPair);
                //mainForm.elementsStringToDetansMap[keyForRemoved].itsDenominatorDetan = detans[2];
            }
            if (mainForm.elementsStringToDetansMap.ContainsKey(keyForSubtended))
            {
                detans[1] = mainForm.elementsStringToDetansMap[keyForSubtended].itsNumeratorDetan;
                detans[3] = mainForm.elementsStringToDetansMap[keyForSubtended].itsDenominatorDetan;
            }
            else
            {
                detans[1] = getDetan(elementsToZeroToZList);
                correctFormule(ref detans[1]);
                detans[3] = getDetan(elementsToZeroToQList);
                correctFormule(ref detans[3]);
                DetansPair detansPair = new DetansPair(detans[1], detans[3]);
                mainForm.elementsStringToDetansMap.Add(keyForSubtended, detansPair);
                //mainForm.elementsStringToDetansMap[keyForSubtended].itsNumeratorDetan = detans[1];
                //mainForm.elementsStringToDetansMap[keyForSubtended].itsDenominatorDetan = detans[3];
            }
            for (int i = 0; i < detans.Length; i++)
            {
                correctFormule(ref detans[i]);
            }
            return(detans);
        }
예제 #5
0
        /* Частный случай функции getDetans для одного элемента */
        static string[] getDetans(PassiveElement selectedElement, SchemeForTolerance scheme)
        {
            List<Element> elementsList = new List<Element>();//scheme.passiveElementsList;
            foreach (PassiveElement element in scheme.passiveElementsList)
            {
                elementsList.Add(element);
            }
            elementsList.AddRange((selectedElement).clonnedElements);
            elementsList.Remove((selectedElement).cloneElement);
            elementsList.AddRange(scheme.nullersList);
            List<Element> elementToInfinList = new List<Element>(elementsList);
            List<Element> elementToZeroList = new List<Element>(elementsList);
            scheme.transformElementToInfin(((PassiveElement)selectedElement).cloneElement, elementToInfinList);
            scheme.transformElementToZero(((PassiveElement)selectedElement).cloneElement, elementToZeroList);
            //scheme.transformElementToInfin(element, elementToInfinList);
            //scheme.transformElementToZero(element, elementToZeroList);
            List<Element> activeElementsForZ = scheme.getActiveElementsListForZ();
            List<Element> activeElementsForQ = scheme.getActiveElementsListForQ();
            List<Element> elementsToInfinToZList = new List<Element>(elementToInfinList);
            elementsToInfinToZList.AddRange(activeElementsForZ);
            List<Element> elementsToZeroToZList = new List<Element>(elementToZeroList);
            elementsToZeroToZList.AddRange(activeElementsForZ);
            List<Element> elementsToInfinToQList = new List<Element>(elementToInfinList);
            elementsToInfinToQList.AddRange(activeElementsForQ);
            List<Element> elementsToZeroToQList = new List<Element>(elementToZeroList);
            elementsToZeroToQList.AddRange(activeElementsForQ);
            string[] detans = new string[4];
            string elementName = selectedElement.getRightName();
            string keyForRemoved = elementName + "|" + "δ(" + elementName + ")";
            string keyForSubtended = elementName + "|";
            if (mainForm.elementsStringToDetansMap.ContainsKey(keyForRemoved))
            {
                detans[0] = mainForm.elementsStringToDetansMap[keyForRemoved].itsNumeratorDetan;
                detans[2] = mainForm.elementsStringToDetansMap[keyForRemoved].itsDenominatorDetan;
            }
            else
            {
                detans[0] = getDetan(elementsToInfinToZList);
                correctFormule(ref detans[0]);
                detans[2] = getDetan(elementsToInfinToQList);
                correctFormule(ref detans[2]);
                DetansPair detansPair = new DetansPair(detans[0], detans[2]);
                mainForm.elementsStringToDetansMap.Add(keyForRemoved, detansPair);
                //mainForm.elementsStringToDetansMap[keyForRemoved].itsDenominatorDetan = detans[2];
            }
            if (mainForm.elementsStringToDetansMap.ContainsKey(keyForSubtended))
            {
                detans[1] = mainForm.elementsStringToDetansMap[keyForSubtended].itsNumeratorDetan;
                detans[3] = mainForm.elementsStringToDetansMap[keyForSubtended].itsDenominatorDetan;
            }
            else
            {
                detans[1] = getDetan(elementsToZeroToZList);
                correctFormule(ref detans[1]);
                detans[3] = getDetan(elementsToZeroToQList);
                correctFormule(ref detans[3]);
                DetansPair detansPair = new DetansPair(detans[1], detans[3]);
                mainForm.elementsStringToDetansMap.Add(keyForSubtended, detansPair);
                //mainForm.elementsStringToDetansMap[keyForSubtended].itsNumeratorDetan = detans[1];
                //mainForm.elementsStringToDetansMap[keyForSubtended].itsDenominatorDetan = detans[3];

            }
            for (int i = 0; i < detans.Length; i++)
            {
                correctFormule(ref detans[i]);
            }
            return detans;
        }
예제 #6
0
 /*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;
 }
예제 #7
0
 /*, 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;
 }
예제 #8
0
 static Dictionary<PassiveElement[], Result> calculateTolerances(SchemeForTolerance scheme, ref int detansCount)
 {
     Dictionary<PassiveElement[], Result> elementToToleranceDictionary = new Dictionary<PassiveElement[], Result>();
     //schemeForCalculations = new SchemeForTolerance(Scheme.currentScheme, selectedElements.ToArray(), error);
     elementToToleranceDictionary = Calculations.calculateTolerance_Total(scheme, ref detansCount);
     return elementToToleranceDictionary;
 }