示例#1
0
        ///
        ///	 <summary> * Get a vector of PartAmounts which are supersets of the filter defined by mPart<br>
        ///	 * i.e. mPart is a submap of all returned elements
        ///	 *  </summary>
        ///	 * <param name="mPart"> filter vector for the part to set the status
        ///	 *  </param>
        ///	 * <returns> VElement - the vector of PartAmount elements that fit, null if nothing matches </returns>
        ///
        public virtual VElement getMatchingPartAmountVector(JDFAttributeMap mPart)
        {
            VElement vPartAmount = getChildElementVector(ElementName.PARTAMOUNT, null, null, true, 0, false);
            int      size        = vPartAmount.Count;

            if (size == 0)
            {
                return(null);
            }
            VElement vPA = new VElement();

            for (int i = 0; i < size; i++)
            {
                JDFPartAmount    ps = (JDFPartAmount)vPartAmount[i];
                VJDFAttributeMap mm = ps.getPartMapVector();
                for (int j = 0; j < mm.Count; j++)
                {
                    JDFAttributeMap m = mm[j];
                    if (m.subMap(mPart))
                    {
                        vPA.Add(ps);
                        break;
                    }
                }
            }
            return(vPA.Count == 0 ? null : vPA);
        }
示例#2
0
        ///
        ///	 <summary> * Get a PartAmount that fits to the filter defined by mPart
        ///	 *  </summary>
        ///	 * <param name="vPart"> filter for the part to set the status </param>
        ///	 * <returns> the PartAmount that fits </returns>
        ///
        public virtual JDFPartAmount getPartAmount(VJDFAttributeMap vPart)
        {
            VElement vPartAmount = getChildElementVector(ElementName.PARTAMOUNT, null, null, true, 0, false);

            for (int i = vPartAmount.Count - 1; i >= 0; i--)
            {
                JDFPartAmount    partAmount = (JDFPartAmount)vPartAmount[i];
                VJDFAttributeMap vMapPart   = partAmount.getPartMapVector();

                if (ContainerUtil.Equals(vMapPart, vPart))
                {
                    return(partAmount); // exact match
                }
            }
            return(null);
        }
示例#3
0
        ///
        ///	 <summary> * Get a PartAmount that fits to the filter defined by mPart
        ///	 *  </summary>
        ///	 * <param name="mPart"> filter for the part to set the status </param>
        ///	 * <param name="iSkip"> the iSkip'th element to get </param>
        ///	 * <returns> the PartAmount that fits </returns>
        ///
        public virtual JDFPartAmount getPartAmount(JDFAttributeMap mPart, int iSkip)
        {
            VElement vPartAmount = getChildElementVector(ElementName.PARTAMOUNT, null, null, true, 0, false);
            int      n           = 0;

            for (int i = vPartAmount.Count - 1; i >= 0; i--)
            {
                JDFPartAmount    partAmount = (JDFPartAmount)vPartAmount[i];
                VJDFAttributeMap vMapPart   = partAmount.getPartMapVector();

                if (vMapPart.subMap(mPart) && ++n > iSkip)
                {
                    return(partAmount); // exact match
                }
            }
            return(null);
        }
示例#4
0
        public virtual void testGetCreatePartAmount()
        {
            JDFAttributeMap  map  = new JDFAttributeMap("Separation", "Black");
            JDFAttributeMap  map2 = new JDFAttributeMap("Separation", "Cyan");
            VJDFAttributeMap vMap = new VJDFAttributeMap();

            vMap.Add(map);
            vMap.Add(map2);

            JDFPartAmount pa1 = ap.getCreatePartAmount(map);

            Assert.AreEqual(map, pa1.getPartMap());
            JDFPartAmount pa3 = ap.getCreatePartAmount(vMap);

            Assert.AreEqual(vMap, pa3.getPartMapVector());
            JDFPartAmount pa4 = ap.getCreatePartAmount(vMap);

            Assert.AreEqual(pa3, pa4);
            JDFPartAmount pa2 = ap.getCreatePartAmount(map2);

            Assert.AreEqual(map2, pa2.getPartMap());
        }
示例#5
0
            ///

            ///
            ///		 <summary> * gets the sum of all matching tags, with the assumpzion that no condition defaults to good
            ///		 *  </summary>
            ///		 * <param name="poolParent">  </param>
            ///		 * <param name="attName">  </param>
            ///		 * <param name="vPart">  </param>
            ///		 * <returns> the sum
            ///		 *  </returns>
            ///
            public static double getAmountPoolSumDouble(IAmountPoolContainer poolParent, string attName, VJDFAttributeMap vPart)
            {
                VJDFAttributeMap vPartLocal = vPart;

                if (vPartLocal == null)
                {
                    vPartLocal = poolParent.getPartMapVector();
                }

                if (poolParent.hasAttribute(attName))
                {
                    return(poolParent.getRealAttribute(attName, null, 0));
                }

                VJDFAttributeMap vm       = vPartLocal == null ? null : new VJDFAttributeMap(vPartLocal);
                JDFResource      linkRoot = poolParent.getLinkRoot();

                if (linkRoot != null && vm != null)
                {
                    SupportClass.SetSupport <string> @set = linkRoot.getPartIDKeys().getSet();
                    @set.Add(AttributeName.CONDITION); // retain good / waste
                    vm.reduceMap(@set);
                }

                if (vm == null)
                {
                    vm = new VJDFAttributeMap();
                    vm.Add((JDFAttributeMap)null);
                }

                double        dd = 0;
                JDFAmountPool ap = poolParent.getAmountPool();

                if (ap == null)
                {
                    return(poolParent.getRealAttribute(attName, null, 0.0));
                }

                VElement vParts = ap.getChildElementVector(ElementName.PARTAMOUNT, null);

                if (vParts.IsEmpty())
                {
                    return(poolParent.getRealAttribute(attName, null, 0.0));
                }

                bool isWaste = vPartLocal != null && vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "Waste"));

                if (!isWaste && (vPartLocal == null || !vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*"))))
                {
                    vPartLocal = new VJDFAttributeMap(vPartLocal);
                    vPartLocal.Add(new JDFAttributeMap(AttributeName.CONDITION, "Good"));
                }

                for (int j = 0; j < vParts.Count; j++)
                {
                    JDFPartAmount    pa            = (JDFPartAmount)vParts[j];
                    VJDFAttributeMap partMapVector = pa.getPartMapVector();
                    if (isWaste)
                    {
                        bool hasCondition = partMapVector.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*"));
                        if (!hasCondition)
                        {
                            continue;
                        }
                    }

                    if (!partMapVector.overlapsMap(vm))
                    {
                        continue;
                    }

                    string ret = null;
                    ret = pa.getAttribute(attName, null, null);
                    if (ret == null)
                    {
                        ret = poolParent.getAttribute(attName, null, null);
                    }

                    dd += StringUtil.parseDouble(ret, 0.0);
                }

                return(dd);
            }