public virtual void testMergeLastPhase() { JDFDoc d = new JDFDoc("JDF"); JDFAuditPool ap = d.getJDFRoot().getCreateAuditPool(); JDFPhaseTime pt = ap.setPhase(EnumNodeStatus.InProgress, "dummy", null, null); JDFJobPhase jp = di.createJobPhaseFromPhaseTime(pt); jp.setPhaseAmount(200); jp.setAmount(200); jp.setPhaseWaste(100); JDFDate d1 = jp.getPhaseStartTime(); JDFDoc doc = new JDFDoc(ElementName.DEVICEINFO); JDFDeviceInfo di2 = (JDFDeviceInfo)doc.getRoot(); JDFJobPhase jp2 = (JDFJobPhase)di2.copyElement(jp, null); jp2.setPhaseStartTime(new JDFDate()); StatusCounter.sleep(1000); jp2.setPhaseAmount(300); jp2.setPhaseWaste(30); jp2.setAmount(500); Assert.IsTrue(di2.mergeLastPhase(di)); Assert.AreEqual(d1, jp2.getPhaseStartTime()); Assert.AreEqual(130.0, jp2.getPhaseWaste(), 0.0); Assert.AreEqual(500.0, jp2.getPhaseAmount(), 0.0); Assert.AreEqual(500.0, jp2.getAmount(), 0.0); }
/// /// <summary> * returns true if this is the same phase, i.e. the /// * </summary> /// * <param name="lastphase"> the phase to compare with </param> /// * <param name="bExact"> if true, use startTime as hook, else compare stati /// * @return </param> /// public virtual bool isSamePhase(JDFJobPhase lastphase, bool bExact) { if (lastphase == null) { return(false); } if (bExact) { JDFDate startTime = getPhaseStartTime(); JDFDate lastStartTime = lastphase.getPhaseStartTime(); return(startTime != null && startTime.Equals(lastStartTime)); } if (!ContainerUtil.Equals(getStatus(), lastphase.getStatus())) { return(false); } if (!ContainerUtil.Equals(getStatusDetails(), lastphase.getStatusDetails())) { return(false); } if (!ContainerUtil.Equals(getIdentifier(), lastphase.getIdentifier())) { return(false); } return(true); }
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()); } }
public virtual void testEndTime() { JDFQueueEntry _qe = (JDFQueueEntry) new JDFDoc(ElementName.QUEUEENTRY).getRoot(); JDFDate d = _qe.getEndTime(); Assert.IsNull(d); }
// --------------------------------------------------------------------- // Methods for Attribute PhaseStartTime // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute PhaseStartTime </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setPhaseStartTime(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.PHASESTARTTIME, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute Start // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute Start </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setStart(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.START, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute NewerThan // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute NewerThan </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setNewerThan(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.NEWERTHAN, date.DateTimeISO, null); }
// ************************************************************************ // * Attribute getter / setter // * ************************************************************************ // // --------------------------------------------------------------------- // Methods for Attribute After // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute After </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setAfter(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.AFTER, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute OldTime // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute OldTime </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setOldTime(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.OLDTIME, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute SubmissionTime // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute SubmissionTime </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setSubmissionTime(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.SUBMISSIONTIME, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute PowerOnTime // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute PowerOnTime </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setPowerOnTime(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.POWERONTIME, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute Before // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute Before </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setBefore(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.BEFORE, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute LastEnd // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute LastEnd </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setLastEnd(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.LASTEND, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute TimeStamp // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute TimeStamp </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setTimeStamp(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.TIMESTAMP, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute Required // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute Required </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setRequired(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.REQUIRED, date.DateTimeISO, null); }
// ************************************************************************ // * Attribute getter / setter // * ************************************************************************ // // --------------------------------------------------------------------- // Methods for Attribute Earliest // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute Earliest </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setEarliest(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.EARLIEST, date.DateTimeISO, null); }
// --------------------------------------------------------------------- // Methods for Attribute Until // --------------------------------------------------------------------- /// /// <summary> * (11) set attribute Until </summary> /// * <param name="value">: the value to set the attribute to or null </param> /// public virtual void setUntil(JDFDate @value) { JDFDate date = @value; if (date == null) { date = new JDFDate(); } setAttribute(AttributeName.UNTIL, date.DateTimeISO, null); }
public void testConstructFromDate() { JDFDate start = new JDFDate(); JDFDate end = new JDFDate(start); Assert.AreEqual(new JDFDuration(0), new JDFDuration(start, end)); end.addOffset(20, 0, 0, 0); Assert.AreEqual(new JDFDuration(20), new JDFDuration(start, end)); start.addOffset(120, 0, 0, 0); Assert.AreEqual(new JDFDuration(-100), new JDFDuration(start, end)); }
public virtual void testGetTimes() { JDFQueueEntry qe = q.getQueueEntry(0); qe.setQueueEntryID("qe1"); JDFDate d = qe.getEndTime(); Assert.IsNull(d, "date"); qe.setEndTime(null); d = qe.getEndTime(); Assert.AreEqual(new JDFDate().TimeInMillis, d.TimeInMillis, 30000, "date"); }
private void iterateLast() { iterateRead(4); JDFPhaseTime pt = iterNode.getAuditPool().setPhase(EnumNodeStatus.InProgress, "Final Iteration Ongoing - final output", null, null); pt.setStart(new JDFDate(JDFDate.ToMillisecs(DateTime.Now) + 4000000)); pt.setEnd(new JDFDate(JDFDate.ToMillisecs(DateTime.Now) + 4100000)); pt.appendEmployee().setPersonalID("Employee 1"); pt.appendDevice().setDeviceID("Device 1"); iterNode.setStatus(EnumNodeStatus.Completed); iterDoc.write2File(getIteration(5), 2, false); }
private void iterateSecond() { iterateRead(1); JDFPhaseTime pt = iterNode.getAuditPool().setPhase(EnumNodeStatus.InProgress, "First Approval Ongoing", null, null); pt.setStart(new JDFDate(JDFDate.ToMillisecs(DateTime.Now) + 1000000)); pt.setEnd(new JDFDate(JDFDate.ToMillisecs(DateTime.Now) + 1100000)); pt.appendEmployee().setPersonalID("Employee 2"); pt.appendDevice().setDeviceID("Approval Device 1"); iterRuli.setResStatus(EnumResStatus.Rejected, false); iterNode.setStatus(EnumNodeStatus.Suspended); iterNode.setAttribute("StatusDetails", ITERATION_PAUSED); iterDoc.write2File(getIteration(2), 2, false); }
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); }
private void iterateForth() { iterateRead(3); JDFPhaseTime pt = iterNode.getAuditPool().setPhase(EnumNodeStatus.InProgress, "Second Approval Ongoing", null, null); pt.setStart(new JDFDate(JDFDate.ToMillisecs(DateTime.Now) + 3000000)); pt.setEnd(new JDFDate(JDFDate.ToMillisecs(DateTime.Now) + 3100000)); pt.appendEmployee().setPersonalID("Employee 3"); pt.appendDevice().setDeviceID("Approval Device 1"); iterRuli.setResStatus(EnumResStatus.Available, false); iterNode.setStatus(EnumNodeStatus.Suspended); iterNode.setAttribute("StatusDetails", ITERATION_PAUSED); iterAppSuccess.setResStatus(EnumResStatus.Available, true); iterDoc.write2File(getIteration(4), 2, false); }
// **************************************** Methods // ********************************************* /// /// <summary> * inRange - returns true if the given JDFDate value is in one of the ranges of the range list /// * </summary> /// * <param name="x"> the given JDFDate (duration) value to compare /// * </param> /// * <returns> boolean - true if in range otherwise false </returns> /// public virtual bool inRange(JDFDate x) { int sz = rangeList.Count; for (int i = 0; i < sz; i++) { JDFDateTimeRange r = (JDFDateTimeRange)rangeList[i]; if (r.inRange(x)) { return(true); } } return(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); }
/// /// <summary> * get the implied duration from Start and End /// * </summary> /// * <returns> JDFDuration the duration </returns> /// public virtual JDFDuration getDuration() { JDFDate dStart = getStart(); JDFDate dEnd = getEnd(); if (dStart == null || dEnd == null) { return(null); } int dur = (int)((dEnd.TimeInMillis - dStart.TimeInMillis) / 1000); if (dur < 0) { dur = 0; } return(new JDFDuration(dur)); }
/// /// <summary> * isUniqueOrdered - tests if 'this' is an UniqueOrdered RangeList /// * </summary> /// * <returns> boolean - true if 'this' is an UniqueOrdered RangeList </returns> /// public override bool isUniqueOrdered() { int siz = rangeList.Count; if (siz == 0) { return(false); // attempt to operate on a null element } List <JDFDate> v = new List <JDFDate>(); // vector of ranges for (int i = 0; i < siz; i++) { JDFDateTimeRange r = (JDFDateTimeRange)rangeList[i]; v.Add(r.Left); if (!r.Left.Equals(r.Right)) { v.Add(r.Right); } } int n = v.Count - 1; if (n == 0) { return(true); // single value } JDFDate first = v[0]; JDFDate last = v[n]; if (first.Equals(last)) { return(false); } for (int j = 0; j < n; j++) { JDFDate @value = v[j]; JDFDate nextvalue = v[j + 1]; if (((first.isEarlier(last) && @value.isEarlier(nextvalue)) || (first.isLater(last) && @value.isLater(nextvalue))) == false) { return(false); } } return(true); }
/// /// <summary> * get attribute <code>DefaultValue</code> /// * </summary> /// * <returns> the value of the attribute </returns> /// public virtual JDFDate getDefaultValue() { JDFDate defaultValue = null; string str = getAttribute(AttributeName.DEFAULTVALUE, null, JDFConstants.EMPTYSTRING); if (!JDFConstants.EMPTYSTRING.Equals(str)) { try { defaultValue = new JDFDate(str); } catch (FormatException) { throw new JDFException("not a valid date string. Malformed JDF"); } } return(defaultValue); }
public virtual void testModulesUpdate() { JDFAuditPool ap = n.getCreateAuditPool(); ap.appendXMLComment("JDF 1.3 compatible auditing of module phases with updates", null); JDFPhaseTime pt = ap.addPhaseTime(EnumNodeStatus.Setup, null, null); JDFPhaseTime pt2 = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); JDFPhaseTime pt3 = ap.addPhaseTime(EnumNodeStatus.InProgress, null, null); JDFDate date = new JDFDate(); JDFModulePhase mpRIP = pt.appendModulePhase(); mpRIP.setModuleType("Imaging"); JDFModulePhase mpJob = pt.appendModulePhase(); mpJob.setModuleType("Manual"); mpJob.setStatus(EnumNodeStatus.InProgress); JDFModulePhase mpPrint = pt.appendModulePhase(); mpPrint.setModuleType("Printing"); mpRIP.setStatus(EnumNodeStatus.InProgress); pt.setStart(date); mpRIP.setStart(date); date.addOffset(0, 5, 0, 0); pt.setEnd(date); pt2.copyElement(mpRIP, null); pt2.copyElement(mpJob, null); pt2.copyElement(mpPrint, null); mpPrint.setStatus(EnumNodeStatus.InProgress); pt2.setStart(date); mpPrint.setStart(date); date.addOffset(0, 30, 0, 0); mpRIP.setEnd(date); date.addOffset(0, 70, 0, 0); pt2.setEnd(date); mpPrint.setEnd(date); pt3.copyElement(mpRIP, null); pt3.copyElement(mpJob, null); pt3.copyElement(mpPrint, null); doc.write2File(sm_dirTestDataTemp + "DigiPrintModuleUpdate.jdf", 2, false); }
/// /// <summary> * (12) get JDFDate attribute Start </summary> /// * <returns> JDFDate the value of the attribute </returns> /// public virtual JDFDate getStart() { JDFDate nMyDate = null; string str = JDFConstants.EMPTYSTRING; str = getAttribute(AttributeName.START, null, JDFConstants.EMPTYSTRING); if (!JDFConstants.EMPTYSTRING.Equals(str)) { try { nMyDate = new JDFDate(str); } catch (FormatException) { // throw new JDFException("not a valid date string. Malformed JDF - return null"); } } return(nMyDate); }