/// /// <summary> * </summary> /// public virtual void initAuditPool(JDFNode node) { JDFAuditPool auditPool = node.getCreateAuditPool(); JDFAudit a = auditPool.getAudit(-1, EnumAuditType.Created, null, null); if (a == null) { a = auditPool.addAudit(EnumAuditType.Created, null); } }
public void testUsageCounter() { JDFElement.setLongID(false); JDFDoc doc = new JDFDoc("JDF"); JDFNode root = doc.getJDFRoot(); root.setType(EnumType.DigitalPrinting); JDFUsageCounter uc = (JDFUsageCounter)root.appendMatchingResource( ElementName.USAGECOUNTER, EnumProcessUsage.AnyInput, null); Assert.IsTrue(uc.isValid(EnumValidationLevel.Incomplete)); Assert.IsFalse(uc.isValid(EnumValidationLevel.Complete)); uc.setCounterID("c1"); uc.setScope(EnumScope.Job); uc.setCounterTypes(new VString( "NormalSize Black OneSided TwoSided Impressions", " ")); Assert.IsTrue(uc.isValid(EnumValidationLevel.Complete)); Assert.AreEqual(StringUtil.setvString(uc.getEnumCounterTypes()), StringUtil.setvString(uc.getCounterTypes())); JDFResourceLink rl = root.getLink(uc, null); rl.setActualAmount(10, null); JDFAuditPool ap = root.getCreateAuditPool(); JDFResourceAudit ra = (JDFResourceAudit)ap.addAudit( EnumAuditType.ResourceAudit, null); ra.updateLink(rl); JDFUsageCounter uc2 = (JDFUsageCounter)root.appendMatchingResource( ElementName.USAGECOUNTER, EnumProcessUsage.AnyInput, null); uc2.setCounterID("c2"); uc2.setScope(EnumScope.Job); uc2.setCounterTypes(new VString( "NormalSize Color OneSided TwoSided Impressions", " ")); Assert.IsTrue(uc2.isValid(EnumValidationLevel.Complete)); Assert.AreEqual(StringUtil.setvString(uc2.getEnumCounterTypes()), StringUtil.setvString(uc2.getCounterTypes())); rl = root.getLink(uc2, null); rl.setActualAmount(20, null); ra = (JDFResourceAudit)ap.addAudit(EnumAuditType.ResourceAudit, null); ra.updateLink(rl); JDFUsageCounter uc3 = (JDFUsageCounter)root.appendMatchingResource( ElementName.USAGECOUNTER, EnumProcessUsage.AnyInput, null); uc3.setCounterID("c3"); uc3.setScope(EnumScope.Job); uc3.setCounterTypes(new VString( "LargeSize Black OneSided TwoSided Impressions", " ")); Assert.IsTrue(uc3.isValid(EnumValidationLevel.Complete)); Assert.AreEqual(StringUtil.setvString(uc3.getEnumCounterTypes()), StringUtil.setvString(uc3.getCounterTypes())); rl = root.getLink(uc3, null); rl.setActualAmount(30, null); ra = (JDFResourceAudit)ap.addAudit(EnumAuditType.ResourceAudit, null); ra.updateLink(rl); JDFUsageCounter uc4 = (JDFUsageCounter)root.appendMatchingResource( ElementName.USAGECOUNTER, EnumProcessUsage.AnyInput, null); uc4.setCounterID("c4"); uc4.setScope(EnumScope.Job); uc4.setCounterTypes(new VString( "LargeSize Color OneSided TwoSided Impressions", " ")); Assert.IsTrue(uc4.isValid(EnumValidationLevel.Complete)); Assert.AreEqual(StringUtil.setvString(uc4.getEnumCounterTypes()), StringUtil.setvString(uc4.getCounterTypes())); rl = root.getLink(uc4, null); rl.setActualAmount(40, null); ra = (JDFResourceAudit)ap.addAudit(EnumAuditType.ResourceAudit, null); ra.updateLink(rl); Assert.IsTrue(root.isValid(EnumValidationLevel.Incomplete)); doc.write2File(sm_dirTestDataTemp + "UCList.jdf", 2, false); }
/// /// <summary> * Set the Status and StatusDetails of this node update the PhaseTime audit or append a new phasetime as appropriate /// * also prepare a status JMF /// * </summary> /// * <param name="nodeStatus"> the new status of the node </param> /// * <param name="nodeStatusDetails"> the new statusDetails of the node </param> /// * <param name="deviceStatus"> the new status of the device </param> /// * <param name="deviceStatusDetails"> the new statusDetails of the device </param> /// * <param name="vPartMap"> the vector of parts to that should be set </param> /// * <param name="vResLink"> the resourcelinks that are used to fill the various amount attributes in jobphase and phasetime /// * </param> /// public virtual void setPhase(EnumNodeStatus nodeStatus, string nodeStatusDetails, EnumDeviceStatus deviceStatus, string deviceStatusDetails, AmountBag[] amounts) { docJMFPhaseTime = new JDFDoc(ElementName.JMF); JDFJMF jmf = docJMFPhaseTime.getJMFRoot(); docJMFResource = new JDFDoc(ElementName.JMF); JDFJMF jmfRes = docJMFResource.getJMFRoot(); AmountBag ab = getBag(getFirstRefID(), amounts); LinkAmount la = getLinkAmount(getFirstRefID()); AmountBag lastAb = la == null ? null : la.lastBag; JDFAuditPool ap = m_Node.getCreateAuditPool(); // TODO rethink when to send 2 phases JDFPhaseTime pt1 = ap.getLastPhase(m_vPartMap, null); JDFPhaseTime pt2 = pt1; bool bEnd = nodeStatus.Equals(EnumNodeStatus.Completed) || nodeStatus.Equals(EnumNodeStatus.Aborted); pt2 = ap.setPhase(nodeStatus, nodeStatusDetails, m_vPartMap, null); if (bEnd) { JDFProcessRun pr = (JDFProcessRun)ap.addAudit(EnumAuditType.ProcessRun, null); pr.setPartMapVector(m_vPartMap); VElement audits = ap.getAudits(EnumAuditType.PhaseTime, null, m_vPartMap); for (int i = 0; i < audits.Count; i++) { pr.addPhase((JDFPhaseTime)audits[i]); } pr.setEndStatus(nodeStatus); } if (pt1 != null && pt2 != pt1) // we explicitly added a new phasetime // audit, thus we need to add a closing // JMF for the original jobPhase { JDFSignal s = (JDFSignal)jmf.appendMessageElement(JDFMessage.EnumFamily.Signal, JDFMessage.EnumType.Status); JDFDeviceInfo deviceInfo = s.appendDeviceInfo(); JDFJobPhase jp = deviceInfo.createJobPhaseFromPhaseTime(pt1); jp.setJobID(m_Node.getJobID(true)); jp.setJobPartID(m_Node.getJobPartID(false)); setJobPhaseAmounts(lastAb, jp); if (m_deviceID != null) { deviceInfo.setDeviceID(m_deviceID); } } if (pt2 != null) { JDFSignal s = (JDFSignal)jmf.appendMessageElement(JDFMessage.EnumFamily.Signal, JDFMessage.EnumType.Status); JDFDeviceInfo deviceInfo = s.appendDeviceInfo(); if (!bEnd) // don't write a jobphase for an idle device { JDFJobPhase jp = deviceInfo.createJobPhaseFromPhaseTime(pt2); setJobPhaseAmounts(ab, jp); } deviceInfo.setDeviceStatus(deviceStatus); deviceInfo.setStatusDetails(deviceStatusDetails); deviceInfo.setDeviceID(m_deviceID); m_Node.setPartStatus(m_vPartMap, nodeStatus, null); getVResLink(amounts, 2); // update the nodes links generateResourceSignal(amounts, jmfRes); if (bEnd) { pt2.deleteNode(); // zapp the last phasetime } else { pt2.setLinks(getVResLink(amounts, 1)); pt2.eraseEmptyAttributes(true); } } // cleanup! if (vLinkAmount != null) { for (int i = 0; i < vLinkAmount.Length; i++) { string refID = vLinkAmount[i].rl.getrRef(); AmountBag bag = getBag(refID, amounts); vLinkAmount[i].lastBag = new AmountBag(bag); } } jmf.eraseEmptyAttributes(true); }