/// /// * <param name="resLink"> /// * @return </param> /// private VElement getVResLink(AmountBag[] amounts, int n) { if (amounts == null && vLinkAmount == null) { return(null); } if (vLinkAmount == null || amounts == null || vLinkAmount.Length != amounts.Length) { throw new JDFException("incoherent resLink sizes"); } VElement vRet = new VElement(); for (int i = 0; i < vLinkAmount.Length; i++) { LinkAmount la = vLinkAmount[i]; if (n == 1) { vRet.Add(la.getPhaseTimeLink(getBag(la.rl.getrRef(), amounts))); } if (n == 2) { vRet.Add(la.updateNodeLink(getBag(la.rl.getrRef(), amounts))); } if (n == 3) { vRet.Add(la.getResourceInfoLink(getBag(la.rl.getrRef(), amounts))); } } return(vRet); }
/// /// * <param name="amounts"> </param> /// * <param name="jmfRes"> </param> /// private void generateResourceSignal(AmountBag[] amounts, JDFJMF jmfRes) { if (amounts != null) { VElement vResResourceInfo = getVResLink(amounts, 3); JDFSignal sig = jmfRes.appendSignal(EnumType.Resource); JDFResourceQuParams rqp = sig.appendResourceQuParams(); rqp.setJDF(m_Node); rqp.setExact(false); bool bAllExact = true; for (int i = 0; i < vResResourceInfo.Count; i++) { JDFResourceInfo ri = sig.appendResourceInfo(); JDFResourceLink rl = (JDFResourceLink)vResResourceInfo[i]; LinkAmount la = getLinkAmount(rl.getrRef()); bool bExact = la.bCopyResInfo; bAllExact = bAllExact && bExact; rqp.setExact(bExact); ri.setLink(rl, rqp); } rqp.setExact(bAllExact); } }
/// /// <summary> * set copying the resource into resourceInfo on or off for the resourcelink rl /// * </summary> /// * <param name="rl"> the resourcelink to the resource to copy </param> /// * <param name="b"> tracking on or off </param> /// public virtual void setCopyResInResInfo(JDFResourceLink rl, bool b) { LinkAmount la = getLinkAmount(rl.getrRef()); if (la != null) { la.bCopyResInfo = b; } }
/// /// <summary> * set waste tracking on or off for the resourcelink rl /// * </summary> /// * <param name="rl"> the resourcelink to the resource to track </param> /// * <param name="b"> tracking on or off </param> /// public virtual void setTrackWaste(JDFResourceLink rl, bool b) { LinkAmount la = getLinkAmount(rl.getrRef()); if (la != null) { la.bTrackWaste = b; } }
/// /// * <param name="lastAb"> </param> /// * <param name="jp"> </param> /// private void setJobPhaseAmounts(AmountBag lastAb, JDFJobPhase jp) { if (lastAb == null) { return; } LinkAmount la = getLinkAmount(lastAb.refID); if (la == null) { return; } if (la.bTrackWaste) { if (lastAb.phaseAmount != 0) { jp.setPhaseAmount(lastAb.phaseAmount); } if (lastAb.totalAmount != 0) { jp.setAmount(lastAb.totalAmount); } if (lastAb.phaseWaste != 0) { jp.setPhaseWaste(lastAb.phaseWaste); } if (lastAb.totalWaste != 0) { jp.setWaste(lastAb.totalWaste); } } else { if ((lastAb.phaseAmount + lastAb.phaseWaste) != 0) { jp.setPhaseAmount(lastAb.phaseAmount + lastAb.phaseWaste); } if ((lastAb.totalAmount + lastAb.totalWaste) != 0) { jp.setAmount(lastAb.totalAmount + lastAb.totalWaste); } } double total = 0; total = la.startAmount; if (total != 0) { jp.setTotalAmount(total); jp.setPercentCompleted(lastAb.totalAmount / total * 100.0); } }
/// /// * <param name="resLinks"> </param> /// private void setUpResLinks(VElement resLinks) { if (resLinks == null || resLinks.Count == 0) { return; } vLinkAmount = new LinkAmount[resLinks.Count]; for (int i = 0; i < vLinkAmount.Length; i++) { vLinkAmount[i] = new LinkAmount(this, (JDFResourceLink)resLinks[i]); } }
/// /// * <param name="bag"> </param> /// * <returns> JDFResourceAudit the generated audit </returns> /// public virtual JDFResourceAudit setResourceAudit(AmountBag bag, EnumReason reason) { JDFAuditPool ap = m_Node.getCreateAuditPool(); JDFResourceAudit ra = ap.addResourceAudit(null); ra.setContentsModified(false); ra.setReason(reason); LinkAmount la = getLinkAmount(bag.refID); ra.copyElement(la.getResourceAuditLink(bag), null); ra.setPartMapVector(m_vPartMap); return(ra); }
/// /// <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); }