public virtual void testAddPhaseTime() { JDFDoc doc = new JDFDoc("JDF"); JDFNode n = doc.getJDFRoot(); JDFAuditPool ap = n.getCreateAuditPool(); JDFProcessRun pr = ap.addProcessRun(EnumNodeStatus.Completed, null, null); JDFPhaseTime pt0 = null; for (int i = 0; i < 10; i++) { JDFPhaseTime pt = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); if (i == 0) { pt0 = pt; } JDFDate start = new JDFDate(); start.TimeInMillis = start.TimeInMillis + i * 1000 * 1000; pt.setStart(start); JDFDate end = new JDFDate(); end.TimeInMillis = end.TimeInMillis + 100 * 1000 + i * 1000 * 1000; pt.setEnd(end); Assert.AreEqual(100, pt.getDuration().Duration, 1.0); pr.addPhase(pt); Assert.AreEqual((i + 1) * 100, pr.getDuration().Duration, 1.0); if (pt0 != null) { Assert.AreEqual(pr.getStart(), pt0.getStart()); } Assert.AreEqual(pr.getEnd(), pt.getEnd()); } }
/// /// <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 override void setUp() { // TODO Auto-generated method stub base.setUp(); jdfDoc = new JDFDoc(ElementName.JDF); jdfRoot = (JDFNode)jdfDoc.getRoot(); jdfRoot.setJobID("jobID"); myAuditPool = jdfRoot.getCreateAuditPool(); }
/// /// <summary> * overwrite this method in case you want to customize the hotfolder for submitqueentry and paramtetrizing /// * the QueueSubmissionParams template is insufficient /// * </summary> /// * <param name="stringURL"> the file url of the hotfolder jdf in the local storage directory (NOT the hf) </param> /// * <param name="newCommand"> the command that was generated from the template </param> /// * <param name="jdfRoot"> the root jdfnode of the dropped file </param> /// protected internal virtual void extractSubmitParams(string stringURL, JDFCommand newCommand, JDFNode jdfRoot) { JDFQueueSubmissionParams sqp = newCommand.getCreateQueueSubmissionParams(0); sqp.setURL(stringURL); JDFAuditPool ap = jdfRoot == null ? null : jdfRoot.getCreateAuditPool(); if (ap != null) { ap.createSubmitProcessRun(null); } }
public virtual void testModuleIDs() { JDFDoc doc = new JDFDoc("JDF"); JDFNode n = doc.getJDFRoot(); JDFAuditPool ap = n.getCreateAuditPool(); JDFPhaseTime pt = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); pt.setModules(new VString("m1 m2", " "), new VString("RIP Press", " ")); Assert.AreEqual(2, pt.numChildElements(ElementName.MODULEPHASE, null)); Assert.AreEqual("m1", pt.getModulePhase(0).getModuleID()); Assert.AreEqual("m2", pt.getModulePhase(1).getModuleID()); Assert.AreEqual("Press", pt.getModulePhase(1).getModuleType()); // Assert.IsTrue(pt.isValid(EnumValidationLevel.Complete)); }
public virtual void testGetDuration() { JDFDoc doc = new JDFDoc("JDF"); JDFNode n = doc.getJDFRoot(); JDFAuditPool ap = n.getCreateAuditPool(); JDFPhaseTime pt = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); pt.setStart(new JDFDate()); JDFDate end = new JDFDate(); end.TimeInMillis = end.TimeInMillis + 100 * 1000; pt.setEnd(end); Assert.AreEqual(100.0, pt.getDuration().Duration, 1.0); }
public virtual void testModules() { JDFAuditPool ap = n.getCreateAuditPool(); ap.appendXMLComment("JDF 1.3 compatible auditing of module phases - note that modulephase start and end times are set outside of the phasetime start and end times", null); JDFPhaseTime pt = ap.addPhaseTime(EnumNodeStatus.Setup, null, null); JDFPhaseTime pt2 = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); JDFDate date = new JDFDate(); JDFModulePhase mpRIP = pt.appendModulePhase(); JDFModulePhase mpRIP2 = pt2.appendModulePhase(); mpRIP.setStatus(EnumNodeStatus.InProgress); mpRIP2.setStatus(EnumNodeStatus.InProgress); mpRIP2.setDescriptiveName("This ModulePhase is actually the same as the initial ModulePhase in the setup PhaseTime"); mpRIP.setModuleType("Imaging"); mpRIP2.setModuleType("Imaging"); pt.setStart(date); mpRIP.setStart(date); mpRIP2.setStart(date); date.addOffset(0, 5, 0, 0); pt.setEnd(date); JDFModulePhase mpPrint = pt2.appendModulePhase(); mpPrint.setStatus(EnumNodeStatus.InProgress); pt2.setStart(date); mpPrint.setStart(date); date.addOffset(0, 30, 0, 0); mpRIP.setEnd(date); mpRIP2.setEnd(date); date.addOffset(0, 70, 0, 0); pt2.setEnd(date); mpPrint.setEnd(date); mpPrint.setModuleType("Printer"); doc.write2File(sm_dirTestDataTemp + "DigiPrintModule1.jdf", 2, false); }
public virtual void testGetDuration() { JDFDoc doc = new JDFDoc("JDF"); JDFNode n = doc.getJDFRoot(); JDFAuditPool ap = n.getCreateAuditPool(); JDFProcessRun pt = ap.addProcessRun(EnumNodeStatus.Completed, null, null); pt.setStart(new JDFDate()); JDFDate end = new JDFDate(); end.TimeInMillis = end.TimeInMillis + 100 * 1000; pt.setEnd(end); Assert.AreEqual(100.0, pt.getDuration().Duration, 1.0); pt.setDurationSeconds(50); Assert.AreEqual(50.0, pt.getDuration().Duration, 1.0); }
public virtual void testGetParentJDFNode() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType("ProcessGroup", true); JDFNode n2 = n.addJDFNode("Scanning"); Assert.AreEqual(n, n2.getParentJDF(), "n2.parent n"); Assert.IsNull(n.getParentJDF(), "n parent"); JDFAuditPool ap = n.getCreateAuditPool(); Assert.AreEqual(n, ap.getParentJDF(), "ap.parent n"); ap = n2.getCreateAuditPool(); Assert.AreEqual(n2, ap.getParentJDF(), "ap.parent n2"); Assert.AreEqual(n2, ap.addCreated("me", n2).getParentJDF(), "a.parent n2"); }
/// /// <summary> * overwrite this method in case you want to customize the hotfolder for returnqueueentryparams and paramtetrizing /// * the ReturnQueueEntryParams template is insufficient /// * </summary> /// * <param name="stringURL"> the file url of the hotfolder jdf in the local storage directory (NOT the hf) </param> /// * <param name="newCommand"> the command that was generated from the template </param> /// * <param name="jdfRoot"> the root jdfnode of the dropped file </param> /// protected internal virtual void extractReturnParams(string stringURL, JDFCommand newCommand, JDFNode jdfRoot) { JDFReturnQueueEntryParams rqp = newCommand.getCreateReturnQueueEntryParams(0); rqp.setURL(stringURL); JDFAuditPool ap = jdfRoot == null ? null : jdfRoot.getCreateAuditPool(); if (ap != null) { JDFProcessRun pr = (JDFProcessRun)ap.getAudit(-1, EnumAuditType.ProcessRun, null, null); string queueEID = pr == null ? null : pr.getAttribute(AttributeName.QUEUEENTRYID); if (!KElement.isWildCard(queueEID)) { rqp.setQueueEntryID(queueEID); } } }
public virtual void testGetLink() { JDFDoc doc = new JDFDoc("JDF"); JDFNode n = doc.getJDFRoot(); JDFResource r = n.addResource("www.foo", EnumResourceClass.Parameter, EnumUsage.Input, null, null, "www.www.com", null); JDFResourceLink rl = n.getLink(r, null); VElement vRL = new VElement(); vRL.Add(rl); JDFAuditPool ap = n.getCreateAuditPool(); JDFPhaseTime pt = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); pt.appendComment().setText("foo"); pt.setLinks(vRL); pt.setStart(new JDFDate()); Assert.AreEqual(rl.ToString(), pt.getLink(0).ToString()); }
public virtual void testInit() { JDFDoc doc = new JDFDoc(ElementName.JDF); JDFNode root = doc.getJDFRoot(); JDFComment cRoot = root.appendComment(); Assert.IsNotNull(cRoot.getAttribute(AttributeName.ID, null, null)); Assert.IsTrue(cRoot.isValid(EnumValidationLevel.Complete)); root.setVersion(JDFElement.EnumVersion.Version_1_2); JDFAuditPool ap = root.getCreateAuditPool(); JDFNotification notif = ap.addNotification(JDFNotification.EnumClass.Information, "Me", null); JDFComment c = notif.appendComment(); c.setText("This element should have no ID attribute"); string id = c.getAttribute(AttributeName.ID, null, null); Assert.IsNull(id); }
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); }
public virtual void testStatusEquals() { // test if the auto classes implement the correct status // compare EnumNodeStatus JDFAuditPool myAuditPool = null; JDFDoc jdfDoc = new JDFDoc(ElementName.JDF); JDFNode jdfRoot = (JDFNode)jdfDoc.getRoot(); Assert.IsTrue(jdfRoot != null, "No Root found"); if (jdfRoot == null) { return; // soothe findbugs ;) } JDFAncestor ancestor = jdfRoot.appendAncestorPool().appendAncestor(); ancestor.setStatus(EnumNodeStatus.Completed); myAuditPool = jdfRoot.getCreateAuditPool(); JDFPhaseTime phaseTime = myAuditPool.addPhaseTime(JDFElement.EnumNodeStatus.Completed, null, null); JDFSpawned spawned = myAuditPool.addSpawned(jdfRoot, null, null, null, null); spawned.setStatus(JDFElement.EnumNodeStatus.Completed); Assert.AreEqual(spawned.getStatus(), phaseTime.getStatus()); Assert.AreEqual(spawned.getStatus(), ancestor.getStatus()); JDFDoc jmfDoc = new JDFDoc(ElementName.JMF); JDFJMF jmfRoot = jmfDoc.getJMFRoot(); Assert.IsTrue(jmfRoot != null, "No Root found"); if (jmfRoot == null) { return; // soothe findbugs ;) } JDFAcknowledge acknowledge = jmfRoot.appendAcknowledge(); acknowledge.setType("PipePush"); // Type is required and its existance // is validated for messages JDFJobPhase jobPhase = acknowledge.appendJobPhase(); jobPhase.setStatus(EnumNodeStatus.Completed); JDFMessage message = jmfRoot.appendMessageElement(EnumFamily.Command, null); message.setType("PipePush"); // Type is required and its existance is // validated for messages JDFPipeParams pipeParams = message.appendPipeParams(); pipeParams.setStatus(EnumNodeStatus.Completed); Assert.AreEqual(jobPhase.getStatus(), pipeParams.getStatus()); Assert.AreEqual(spawned.getStatus(), pipeParams.getStatus()); // compare EnumResStatus JDFDoc responseDoc = new JDFDoc(ElementName.RESPONSE); JDFResponse responseRoot = (JDFResponse)responseDoc.getRoot(); Assert.IsTrue(responseRoot != null, "No Root found"); if (responseRoot == null) { return; // soothe findbugs ;) } responseRoot.setType(ElementName.RESOURCE); JDFResourceInfo resInfo = responseRoot.appendResourceInfo(); resInfo.setResStatus(EnumResStatus.Available); JDFDoc commandDoc = new JDFDoc(ElementName.COMMAND); JDFCommand commandRoot = (JDFCommand)commandDoc.getRoot(); Assert.IsTrue(commandRoot != null, "No Root found"); if (commandRoot == null) { return; // soothe findbugs ;) } commandRoot.setType(ElementName.RESOURCE); JDFResourceCmdParams resCmdParams = commandRoot.appendResourceCmdParams(); resCmdParams.setResStatus(EnumResStatus.Available); Assert.AreEqual(resInfo.getStatus(), resCmdParams.getStatus()); // check EnumQueueStatus JDFDoc queueDoc = new JDFDoc(ElementName.QUEUE); JDFQueue queueRoot = (JDFQueue)queueDoc.getRoot(); Assert.IsTrue(queueRoot != null, "No Root found"); if (queueRoot == null) { return; // soothe findbugs ;) } queueRoot.setQueueStatus(EnumQueueStatus.Running); // check EnumQueueEntryStatus JDFQueueEntry queueEntry = queueRoot.appendQueueEntry(); queueEntry.setQueueEntryStatus(EnumQueueEntryStatus.Running); }
/// /// <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); }