internal LinkAmount(StatusUtil pEnclosingInstance, JDFResourceLink _rl) { enclosingInstance = pEnclosingInstance; JDFNode dump = new JDFDoc("JDF").getJDFRoot(); dump.appendResourceLinkPool().copyElement(_rl, null); dump.appendResourcePool().copyElement(_rl.getTarget(), null); rl = (JDFResourceLink)dump.getResourceLinkPool().getElement(_rl.Name, null, 0); JDFAttributeMap map = (enclosingInstance.m_vPartMap == null || enclosingInstance.m_vPartMap.Count == 0) ? null : enclosingInstance.m_vPartMap[0]; startAmount = rl.getAmount(map); if (startAmount == -1) { map = new JDFAttributeMap(map); map.put(EnumPartIDKey.Condition, "Good"); startAmount = rl.getAmount(map); if (startAmount == -1) { startAmount = 0; } map.put(EnumPartIDKey.Condition, "Waste"); startWaste = rl.getAmount(map); if (startWaste == -1) { startWaste = 0; } } }
/// /// <summary> * sets all relevant parameters of this to the values specified in resourceLink or its linked resource or JDF node /// * </summary> /// * <param name="resourceLink"> the resourceLink to extract the information from </param> /// * <param name="rqp"> parameters </param> /// public virtual void setLink(JDFResourceLink resourceLink, JDFResourceQuParams rqp) { if (resourceLink == null) { return; } JDFAmountPool ap = resourceLink.getAmountPool(); if (ap != null) { copyElement(ap, null); } else { if (resourceLink.hasAttribute(AttributeName.ACTUALAMOUNT)) { setActualAmount(resourceLink.getActualAmount(null)); } if (resourceLink.hasAttribute(AttributeName.AMOUNT)) { setAmount(resourceLink.getAmount(null)); } } setProcessUsage(resourceLink.getEnumProcessUsage()); JDFResource r = resourceLink.getTarget(); if (r == null && rqp != null) { rqp.setExact(false); } bool bExact = rqp == null ? false : rqp.getExact(); if (!bExact || r == null) // if we do not have a resource let's limp // along and provide as much as we have { setResourceName(resourceLink.getLinkedResourceName()); setAttribute(AttributeName.RESOURCEID, resourceLink.getrRef()); EnumUsage usage = resourceLink.getUsage(); if (usage != null) { setAttribute(AttributeName.USAGE, usage.getName()); } if (r != null && r.hasAttribute(AttributeName.PRODUCTID)) { setProductID(r.getProductID()); } } else { // create a copy of the resource in the original jdf JDFResource rr = (JDFResource)r.getParentNode_KElement().copyElement(r, null); rr.inlineRefElements(null, null, true); // move resource copy from the original node into this document moveElement(rr, null); } }
/// /// <summary> * recalculate ncols from parent color intent if it exists </summary> /// private void initAmountsFromParent() { if (theParentProduct == null) { return; } JDFComponent c = (JDFComponent)theParentProduct.getResource(ElementName.COMPONENT, EnumUsage.Output, 0); JDFResourceLink cl = theParentProduct.getLink(c, EnumUsage.Output); if (cl == null) { return; } double amount = cl.getAmount(null); if (amount > 0) { good = (int)amount; waste = (int)(good * 0.1); } }