Ejemplo n.º 1
0
        /* Формирование формулы допуска из определителей и значений допусков элементов */
        static string makeErrorFormule(Dictionary <string, DetansPair> elementsToDetanPairDictionary, bool forNegative)
        {
            string minus      = forNegative ? "-" : "";
            string detanZZero = "";
            string detanQZero = "";

            foreach (KeyValuePair <string, DetansPair> elementDetansPair in elementsToDetanPairDictionary)
            {
                if (elementDetansPair.Key.Length == 0)
                {
                    detanZZero = elementDetansPair.Value.itsNumeratorDetan;
                    detanQZero = elementDetansPair.Value.itsDenominatorDetan;
                    break;
                }
            }
            string numerator   = "";
            string denominator = "(" + "(" + detanZZero + ")" + "*" + "(";

            foreach (KeyValuePair <string, DetansPair> elementsToDetanPair in elementsToDetanPairDictionary)
            {
                DetansPair associatedDetanPair = elementsToDetanPair.Value;
                if (elementsToDetanPair.Key.Length > 0)
                {
                    string   detanZ   = associatedDetanPair.itsNumeratorDetan;
                    string   detanQ   = associatedDetanPair.itsDenominatorDetan;
                    string[] elements = elementsToDetanPair.Key.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string elementName in elements)
                    {
                        numerator   += minus + elementName + "*";
                        denominator += minus + elementName + "*";
                    }
                    numerator   += "(" + "(" + detanZ + ")" + "*" + "(" + detanQZero + ")" + "-" + "(" + detanQ + ")" + "*" + "(" + detanZZero + ")" + ")" + "+";
                    denominator += detanQ + "+";
                }
            }
            numerator    = numerator.Remove(numerator.Length - 1, 1);
            denominator += "(" + detanQZero + ")" + ")" + ")";
            string formule = "(" + numerator + ")" + "/" + denominator;

            return(formule);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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;
        }