public virtual void testVirtualAmounts() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType(EnumType.ConventionalPrinting); JDFComponent comp = (JDFComponent)n.addResource("Component", null, EnumUsage.Output, null, null, null, null); JDFAttributeMap map = new JDFAttributeMap(EnumPartIDKey.SignatureName, "Sig1"); JDFResourceLink rl = n.getLink(comp, null); for (int i = 0; i < 5; i++) { map.put(EnumPartIDKey.SheetName, "Sheet" + i); comp.getCreatePartition(map, new VString("SignatureName SheetName", " ")); rl.setAmount(500 + i, map); JDFAttributeMap map2 = new JDFAttributeMap(map); map2.put("Condition", "Good"); rl.setActualAmount(500 + i, map2); map2.put("Condition", "Waste"); rl.setActualAmount(50 + i, map2); map2.put("Condition", "Good"); Assert.AreEqual(500 + i, rl.getActualAmount(map2), 0.01); map2.put("Condition", "Waste"); Assert.AreEqual(50 + i, rl.getActualAmount(map2), 0.01); } }
public virtual void testGetPartAmountMulti() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType(EnumType.ConventionalPrinting); JDFComponent comp = (JDFComponent)n.addResource("Component", null, EnumUsage.Output, null, null, null, null); JDFAttributeMap map = new JDFAttributeMap(EnumPartIDKey.SignatureName, "Sig1"); JDFAttributeMap mapSig = new JDFAttributeMap(map); JDFAttributeMap map2 = new JDFAttributeMap(EnumPartIDKey.SignatureName, "Sig1"); JDFResourceLink rl = n.getLink(comp, null); map.put(EnumPartIDKey.SheetName, "Sheet"); comp.getCreatePartition(map, new VString("SignatureName SheetName", " ")); map.put(EnumPartIDKey.Side, "Front"); map2.put(EnumPartIDKey.Side, "Back"); VJDFAttributeMap vMap = new VJDFAttributeMap(); vMap.Add(map); vMap.Add(map2); JDFAmountPool aplocal = rl.appendAmountPool(); JDFPartAmount pa = aplocal.appendPartAmount(vMap); Assert.AreEqual(pa.numChildElements_JDFElement(ElementName.PART, null), 2); rl.setActualAmount(42, map); rl.setActualAmount(21, map2); Assert.AreEqual(2, pa.numChildElements_JDFElement(ElementName.PART, null)); Assert.AreEqual(42.0, rl.getActualAmount(map), 0.0); Assert.AreEqual(42.0 + 21.0, rl.getActualAmount(mapSig), 0.0); Assert.AreEqual(aplocal.getPartAmount(vMap), pa); }
public virtual void testAddPhase() { bool bChanged = sc.setPhase(EnumNodeStatus.InProgress, "i", EnumDeviceStatus.Running, "r"); Assert.IsTrue(bChanged); JDFDoc docJMF = sc.getDocJMFPhaseTime(); JDFResponse sig = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0); JDFJobPhase jp = sig.getDeviceInfo(0).getJobPhase(0); Assert.AreEqual(200, jp.getAmount(), 0); sc.addPhase(resID, 0, 100, true); sc.setTrackWaste(resID, true); JDFResourceLink rlXM = n.getLink(xpMedia, null); for (int loop = 1; loop < 4; loop++) { bChanged = sc.setPhase(EnumNodeStatus.InProgress, "i", EnumDeviceStatus.Running, "r"); Assert.IsFalse(bChanged); docJMF = sc.getDocJMFPhaseTime(); sig = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0); jp = sig.getDeviceInfo(0).getJobPhase(0); Assert.AreEqual(200, jp.getAmount(), 0, "multiple setPhase calls do not modify"); Assert.AreEqual(200, rlXM.getActualAmount(new JDFAttributeMap("Condition", "Good")), 0, "multiple setPhase calls do not modify: " + loop); Assert.AreEqual(200.0, jp.getPercentCompleted(), 0, "% " + loop); sc.addPhase(resID, 0, 100, true); Assert.AreEqual(loop * 100, jp.getWaste(), 0, "" + loop); Assert.AreEqual(100 * loop, rlXM.getActualAmount(new JDFAttributeMap("Condition", "Waste")), 0, "multiple setPhase calls do Stack: " + loop); } sc.setWorkType(EnumWorkType.Alteration); bChanged = sc.setPhase(EnumNodeStatus.InProgress, "ii", EnumDeviceStatus.Running, "r"); Assert.IsTrue(bChanged); docJMF = sc.getDocJMFPhaseTime(); sig = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0); jp = sig.getDeviceInfo(0).getJobPhase(0); Assert.AreEqual(200, jp.getAmount(), 0); Assert.AreEqual(400, jp.getWaste(), 0); Assert.IsTrue(jp.hasAttribute(AttributeName.PHASEAMOUNT)); sig = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 1); jp = sig.getDeviceInfo(0).getJobPhase(0); Assert.AreEqual(0.0, jp.getPhaseAmount(), 0.0); Assert.AreEqual(EnumWorkType.Alteration, jp.getMISDetails().getWorkType()); sc.setFirstRefID("dummy"); sc.addPhase(resID, 0, 100, true); sc.setTrackWaste(resID, true); sc.setPhase(EnumNodeStatus.InProgress, "i", EnumDeviceStatus.Running, "r"); docJMF = sc.getDocJMFPhaseTime(); sig = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0); jp = sig.getDeviceInfo(0).getJobPhase(0); Assert.IsFalse(jp.hasAttribute(AttributeName.AMOUNT)); Assert.AreEqual(EnumWorkType.Alteration, jp.getMISDetails().getWorkType()); }
/// /// <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> * apply the parameters in this to all appropriate resources in parentNode or one of parentNode's children /// * </summary> /// * <param name="parentNode"> the node to search in TODO implement resource handling </param> /// public virtual void applyPipeToNode(JDFNode parentNode) { if (parentNode == null) { return; } VElement vNodes = parentNode.getvJDFNode(null, null, false); int size = vNodes.Count; for (int i = 0; i < size; i++) { JDFNode node = (JDFNode)vNodes[i]; if (!matchesNode(node)) { continue; } JDFElement.EnumNodeStatus status = getStatus(); // TODO: set // Status node.setStatus(status); // final boolean isIncremental = (getUpdateMethod () == // EnumUpdateMethod.Incremental); double dAmount = -1.0; JDFResourceLink rl = getResourceLink(); if (rl != null) { JDFResourceLink rlNode = node.getLink(0, rl.Name, new JDFAttributeMap(AttributeName.RREF, rl.getrRef()), null); if (rlNode == null) { throw new JDFException("Applying pipeparams to inconsistent node: missing resourcelink: " + rl.Name); } VJDFAttributeMap vMap = rl.getPartMapVector(); if (vMap == null) { vMap = new VJDFAttributeMap(); vMap.Add(null); } for (int j = 0; j < vMap.Count; j++) { JDFAttributeMap map = vMap[j]; dAmount = rl.getActualAmount(map); rlNode.setActualAmount(dAmount, map); } } } }